Markus Amsler : wined3d: Use width while converting surfaces.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Nov 7 10:16:35 CST 2006


Module: wine
Branch: master
Commit: 5ec0ce5b38bd6cd16f3f62e8286c8dfae1568a3d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5ec0ce5b38bd6cd16f3f62e8286c8dfae1568a3d

Author: Markus Amsler <markus.amsler at oribi.org>
Date:   Mon Nov  6 19:45:10 2006 +0100

wined3d: Use width while converting surfaces.

This fixes also a heap corruption with 1x1 and 2x2 surfaces.

---

 dlls/wined3d/surface.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 7fd300f..7aa72d4 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -47,7 +47,7 @@ typedef enum {
     CONVERT_RGB32_888
 } CONVERT_TYPES;
 
-HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *surf);
+HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *surf);
 
 static void surface_download_data(IWineD3DSurfaceImpl *This) {
     if (This->resource.format == WINED3DFMT_DXT1 ||
@@ -991,6 +991,7 @@ static void flush_to_framebuffer_drawpix
             d3dfmt_convert_surface(This->resource.allocatedMemory,
                                    mem,
                                    pitch,
+                                   pitch,
                                    height,
                                    pitch * 4,
                                    CONVERT_PALETTED,
@@ -1572,8 +1573,8 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceI
     return WINED3D_OK;
 }
 
-HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *surf) {
-    BYTE *dest;
+HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *surf) {
+    BYTE *source, *dest;
     TRACE("(%p)->(%p),(%d,%d,%d,%d,%p)\n", src, dst, pitch, height, outpitch, convert, surf);
 
     switch (convert) {
@@ -1636,10 +1637,11 @@ HRESULT d3dfmt_convert_surface(BYTE *src
 
             for (y = 0; y < height; y++)
             {
+                source = src + pitch * y;
                 dest = dst + outpitch * y;
-                /* This is an 1 bpp format, using the pitch here is fine */
-                for (x = 0; x < pitch; x++) {
-                    BYTE color = *src++;
+                /* This is an 1 bpp format, using the width here is fine */
+                for (x = 0; x < width; x++) {
+                    BYTE color = *source++;
                     *dest++ = table[color][0];
                     *dest++ = table[color][1];
                     *dest++ = table[color][2];
@@ -1670,7 +1672,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src
             for (y = 0; y < height; y++) {
                 Source = (WORD *) (src + y * pitch);
                 Dest = (WORD *) (dst + y * outpitch);
-                for (x = 0; x < pitch / 2; x++ ) {
+                for (x = 0; x < width / 2; x++ ) {
                     WORD color = *Source++;
                     *Dest = ((color & 0xFFC0) | ((color & 0x1F) << 1));
                     if ((color < surf->SrcBltCKey.dwColorSpaceLowValue) ||
@@ -1849,7 +1851,7 @@ static HRESULT WINAPI IWineD3DSurfaceImp
             ERR("Out of memory %d, %d!\n", outpitch, height);
             return WINED3DERR_OUTOFVIDEOMEMORY;
         }
-        d3dfmt_convert_surface(This->resource.allocatedMemory, mem, pitch, height, outpitch, convert, This);
+        d3dfmt_convert_surface(This->resource.allocatedMemory, mem, pitch, width, height, outpitch, convert, This);
 
         This->Flags |= SFLAG_CONVERTED;
     } else if (This->resource.format == WINED3DFMT_P8 && GL_SUPPORT(EXT_PALETTED_TEXTURE)) {




More information about the wine-cvs mailing list