Eliminated D3DXLoadSurfaceFromSurface from Image::copy.

TRAC #21621 Issue=311 Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@1311 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent dabf0027
...@@ -870,19 +870,6 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, ...@@ -870,19 +870,6 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
RECT sourceRect = {x, y, x + width, y + height}; RECT sourceRect = {x, y, x + width, y + height};
RECT destRect = {xoffset, yoffset, xoffset + width, yoffset + height}; RECT destRect = {xoffset, yoffset, xoffset + width, yoffset + height};
if (isRenderableFormat())
{
result = D3DXLoadSurfaceFromSurface(getSurface(), NULL, &destRect, renderTargetData, NULL, &sourceRect, D3DX_FILTER_BOX, 0);
if (FAILED(result))
{
ERR("Copying surfaces unexpectedly failed.");
renderTargetData->Release();
return error(GL_OUT_OF_MEMORY);
}
}
else
{
D3DLOCKED_RECT sourceLock = {0}; D3DLOCKED_RECT sourceLock = {0};
result = renderTargetData->LockRect(&sourceLock, &sourceRect, 0); result = renderTargetData->LockRect(&sourceLock, &sourceRect, 0);
...@@ -915,6 +902,16 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, ...@@ -915,6 +902,16 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
case D3DFMT_A8R8G8B8: case D3DFMT_A8R8G8B8:
switch(getD3DFormat()) switch(getD3DFormat())
{ {
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
for(int y = 0; y < height; y++)
{
memcpy(dest, source, 4 * width);
source += sourceLock.Pitch;
dest += destLock.Pitch;
}
break;
case D3DFMT_L8: case D3DFMT_L8:
for(int y = 0; y < height; y++) for(int y = 0; y < height; y++)
{ {
...@@ -947,6 +944,25 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, ...@@ -947,6 +944,25 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
case D3DFMT_R5G6B5: case D3DFMT_R5G6B5:
switch(getD3DFormat()) switch(getD3DFormat())
{ {
case D3DFMT_X8R8G8B8:
for(int y = 0; y < height; y++)
{
for(int x = 0; x < width; x++)
{
unsigned short rgb = ((unsigned short*)source)[x];
unsigned char red = (rgb & 0xF800) >> 8;
unsigned char green = (rgb & 0x07E0) >> 3;
unsigned char blue = (rgb & 0x001F) << 3;
dest[x + 0] = blue | (blue >> 5);
dest[x + 1] = green | (green >> 6);
dest[x + 2] = red | (red >> 5);
dest[x + 3] = 0xFF;
}
source += sourceLock.Pitch;
dest += destLock.Pitch;
}
break;
case D3DFMT_L8: case D3DFMT_L8:
for(int y = 0; y < height; y++) for(int y = 0; y < height; y++)
{ {
...@@ -967,6 +983,45 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, ...@@ -967,6 +983,45 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
case D3DFMT_A1R5G5B5: case D3DFMT_A1R5G5B5:
switch(getD3DFormat()) switch(getD3DFormat())
{ {
case D3DFMT_X8R8G8B8:
for(int y = 0; y < height; y++)
{
for(int x = 0; x < width; x++)
{
unsigned short argb = ((unsigned short*)source)[x];
unsigned char red = (argb & 0x7C00) >> 7;
unsigned char green = (argb & 0x03E0) >> 2;
unsigned char blue = (argb & 0x001F) << 3;
dest[x + 0] = blue | (blue >> 5);
dest[x + 1] = green | (green >> 5);
dest[x + 2] = red | (red >> 5);
dest[x + 3] = 0xFF;
}
source += sourceLock.Pitch;
dest += destLock.Pitch;
}
break;
case D3DFMT_A8R8G8B8:
for(int y = 0; y < height; y++)
{
for(int x = 0; x < width; x++)
{
unsigned short argb = ((unsigned short*)source)[x];
unsigned char red = (argb & 0x7C00) >> 7;
unsigned char green = (argb & 0x03E0) >> 2;
unsigned char blue = (argb & 0x001F) << 3;
unsigned char alpha = (signed short)argb >> 15;
dest[x + 0] = blue | (blue >> 5);
dest[x + 1] = green | (green >> 5);
dest[x + 2] = red | (red >> 5);
dest[x + 3] = alpha;
}
source += sourceLock.Pitch;
dest += destLock.Pitch;
}
break;
case D3DFMT_L8: case D3DFMT_L8:
for(int y = 0; y < height; y++) for(int y = 0; y < height; y++)
{ {
...@@ -1005,7 +1060,6 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, ...@@ -1005,7 +1060,6 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
unlock(); unlock();
renderTargetData->UnlockRect(); renderTargetData->UnlockRect();
}
renderTargetData->Release(); renderTargetData->Release();
......
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