Roderick Colenbrander : wined3d: Optimize d3dfmt_convert_surface.

Alexandre Julliard julliard at wine.codeweavers.com
Sat Jul 29 05:22:12 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: dc743d82fff84743e09a1c86d5e803ca8a7c375d
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=dc743d82fff84743e09a1c86d5e803ca8a7c375d

Author: Roderick Colenbrander <thunderbird2k at gmx.net>
Date:   Fri Jul 28 13:57:49 2006 +0200

wined3d: Optimize d3dfmt_convert_surface.

---

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

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index a763537..fffcc82 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -936,7 +936,7 @@ static void flush_to_framebuffer_drawpix
         case WINED3DFMT_P8:
         {
             UINT pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *) This);    /* target is argb, 4 byte */
-            int row;
+            int height = This->glRect.bottom - This->glRect.top;
             type = GL_UNSIGNED_BYTE;
             fmt = GL_RGBA;
 
@@ -945,12 +945,11 @@ static void flush_to_framebuffer_drawpix
                 ERR("Out of memory\n");
                 return;
             }
-            for(row = This->dirtyRect.top; row < This->dirtyRect.bottom; row++) {
-                d3dfmt_convert_surface(This->resource.allocatedMemory + row * pitch + This->lockedRect.left,
-                                       (BYTE *) mem + row * pitch * 4 + This->lockedRect.left * 4,
-                                       This->lockedRect.right - This->lockedRect.left,
-                                       CONVERT_PALETTED, This);
-            }
+            d3dfmt_convert_surface(This->resource.allocatedMemory,
+                                   mem,
+                                   pitch*height,
+                                   CONVERT_PALETTED,
+                                   This);
         }
         break;
 
@@ -1813,11 +1812,10 @@ static HRESULT WINAPI IWineD3DSurfaceImp
         else This->Flags &= ~SFLAG_GLCKEY;
         d3dfmt_get_conv(This, TRUE /* We need color keying */, &format, &internal, &type, &convert, &bpp);
 
-        if((convert != NO_CONVERSION) &&
-	   This->resource.allocatedMemory) {
+        if((convert != NO_CONVERSION) && This->resource.allocatedMemory) {
             int width = This->glRect.right - This->glRect.left;
             int height = This->glRect.bottom - This->glRect.top;
-            int row;
+            int pitch = IWineD3DSurface_GetPitch(iface);
 
             mem = HeapAlloc(GetProcessHeap(), 0, width * height * bpp);
             if(!mem) {
@@ -1825,14 +1823,14 @@ static HRESULT WINAPI IWineD3DSurfaceImp
                 return WINED3DERR_OUTOFVIDEOMEMORY;
             }
 
-            for(row = This->glRect.top; row < This->glRect.bottom; row++) {
-                BYTE *cur = This->resource.allocatedMemory + row * This->pow2Width * This->bytesPerPixel;
-                d3dfmt_convert_surface(cur + This->glRect.left * This->bytesPerPixel,
-                                       mem + row * width * bpp,
-                                       width,
-                                       convert,
-                                       This);
-            }
+            d3dfmt_convert_surface(This->resource.allocatedMemory,
+                                    mem,
+                                    pitch*height,
+                                    convert,
+                                    This);
+            /* Make sure the correct pitch is used */
+            glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch);
+
             This->Flags |= SFLAG_CONVERTED;
         } else {
             This->Flags &= ~SFLAG_CONVERTED;




More information about the wine-cvs mailing list