Commit 10b295cd by Nicolas Capens

Implement support for RGBA blitting.

Change-Id: I1ad9fed9aea34cd20f8d78f4d4469c61aeb00ea6 Reviewed-on: https://swiftshader-review.googlesource.com/2753Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 0c42ee1a
......@@ -39,15 +39,15 @@ namespace sw
bool flipX = destRect.x0 > destRect.x1;
bool flipY = destRect.y0 > destRect.y1;
if(flipX)
{
swap(dRect.x0, dRect.x1);
swap(sRect.x0, sRect.x1);
}
if(flipY)
{
swap(dRect.y0, dRect.y1);
swap(sRect.y0, sRect.y1);
if(flipX)
{
swap(dRect.x0, dRect.x1);
swap(sRect.x0, sRect.x1);
}
if(flipY)
{
swap(dRect.y0, dRect.y1);
swap(sRect.y0, sRect.y1);
}
source->lockInternal(sRect.x0, sRect.y0, sRect.slice, sw::LOCK_READONLY, sw::PUBLIC);
......@@ -104,10 +104,17 @@ namespace sw
case FORMAT_A8R8G8B8:
c = Float4(*Pointer<Byte4>(element)).zyxw;
break;
case FORMAT_A8B8G8R8:
c = Float4(*Pointer<Byte4>(element));
break;
case FORMAT_X8R8G8B8:
c = Float4(*Pointer<Byte4>(element)).zyxw;
c.w = 1.0f;
break;
case FORMAT_X8B8G8R8:
c = Float4(*Pointer<Byte4>(element));
c.w = 1.0f;
break;
case FORMAT_A16B16G16R16:
c = Float4(*Pointer<UShort4>(element));
break;
......@@ -137,15 +144,15 @@ namespace sw
{
Rect dRect = destRect;
Rect sRect = sourceRect;
if(destRect.x0 > destRect.x1)
{
swap(dRect.x0, dRect.x1);
swap(sRect.x0, sRect.x1);
}
if(destRect.y0 > destRect.y1)
{
swap(dRect.y0, dRect.y1);
swap(sRect.y0, sRect.y1);
if(destRect.x0 > destRect.x1)
{
swap(dRect.x0, dRect.x1);
swap(sRect.x0, sRect.x1);
}
if(destRect.y0 > destRect.y1)
{
swap(dRect.y0, dRect.y1);
swap(sRect.y0, sRect.y1);
}
BlitState state;
......@@ -240,7 +247,9 @@ namespace sw
case FORMAT_L8:
case FORMAT_A8:
case FORMAT_A8R8G8B8:
case FORMAT_A8B8G8R8:
case FORMAT_X8R8G8B8:
case FORMAT_X8B8G8R8:
unscale = vector(255, 255, 255, 255);
break;
case FORMAT_A16B16G16R16:
......@@ -263,7 +272,9 @@ namespace sw
case FORMAT_L8:
case FORMAT_A8:
case FORMAT_A8R8G8B8:
case FORMAT_A8B8G8R8:
case FORMAT_X8R8G8B8:
case FORMAT_X8B8G8R8:
scale = vector(255, 255, 255, 255);
break;
case FORMAT_A16B16G16R16:
......@@ -311,6 +322,13 @@ namespace sw
*Pointer<UInt>(d) = UInt(As<Long>(c1));
}
break;
case FORMAT_A8B8G8R8:
{
UShort4 c0 = As<UShort4>(RoundShort4(color));
Byte8 c1 = Pack(c0, c0);
*Pointer<UInt>(d) = UInt(As<Long>(c1));
}
break;
case FORMAT_X8R8G8B8:
{
UShort4 c0 = As<UShort4>(RoundShort4(color.zyxw));
......@@ -318,6 +336,13 @@ namespace sw
*Pointer<UInt>(d) = UInt(As<Long>(c1)) | 0xFF000000;
}
break;
case FORMAT_X8B8G8R8:
{
UShort4 c0 = As<UShort4>(RoundShort4(color));
Byte8 c1 = Pack(c0, c0);
*Pointer<UInt>(d) = UInt(As<Long>(c1)) | 0xFF000000;
}
break;
case FORMAT_A16B16G16R16:
*Pointer<UShort4>(d) = UShort4(RoundInt(color));
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment