Huw Davies : gdi32: Actually use the dib driver's Get/ PutImage if the bitmap is a dib.

Alexandre Julliard julliard at winehq.org
Tue Aug 2 14:18:28 CDT 2011


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Aug  2 14:11:11 2011 +0100

gdi32: Actually use the dib driver's Get/PutImage if the bitmap is a dib.

---

 dlls/gdi32/dib.c          |   17 +++++++++++++----
 dlls/gdi32/tests/bitmap.c |    3 +--
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 5adafcb..4fc3f3a 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -509,6 +509,7 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
     struct bitblt_coords src, dst;
     INT src_to_dst_offset;
     HRGN clip = 0;
+    const struct gdi_dc_funcs *funcs;
 
     src_bits.ptr = (void *)bits;
     src_bits.is_copy = FALSE;
@@ -578,9 +579,14 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
         if (lines < src.visrect.bottom) src.visrect.bottom = lines;
     }
 
-    physdev = GET_DC_PHYSDEV( dc, pPutImage );
+    /* Hack to ensure we don't get the nulldrv if the bmp hasn't been selected
+       into a dc yet */
+    physdev = GET_DC_PHYSDEV( dc, pCreateBitmap );
     if (!BITMAP_SetOwnerDC( hbitmap, physdev )) goto done;
 
+    funcs = bitmap->funcs;
+    if (bitmap->dib) funcs = dc->dibdrv.dev.funcs;
+
     result = lines;
 
     offset_rect( &src.visrect, 0, src_to_dst_offset );
@@ -600,7 +606,7 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
 
     memcpy( dst_info, src_info, FIELD_OFFSET( BITMAPINFO, bmiColors[256] ));
 
-    err = physdev->funcs->pPutImage( physdev, hbitmap, clip, dst_info, &src_bits, &src, &dst, 0 );
+    err = funcs->pPutImage( NULL, hbitmap, clip, dst_info, &src_bits, &src, &dst, 0 );
     if (err == ERROR_BAD_FORMAT)
     {
         void *ptr;
@@ -616,7 +622,7 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
                 src_bits.is_copy = TRUE;
                 src_bits.free = free_heap_bits;
                 if (!err)
-                    err = physdev->funcs->pPutImage( physdev, hbitmap, clip, dst_info, &src_bits, &src, &dst, 0 );
+                    err = funcs->pPutImage( NULL, hbitmap, clip, dst_info, &src_bits, &src, &dst, 0 );
             }
         }
         else err = ERROR_OUTOFMEMORY;
@@ -915,6 +921,7 @@ INT WINAPI GetDIBits(
     char dst_bmibuf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
     BITMAPINFO *dst_info = (BITMAPINFO *)dst_bmibuf;
     unsigned int colors = 0;
+    const struct gdi_dc_funcs *funcs;
 
     if (!info) return 0;
 
@@ -936,6 +943,8 @@ INT WINAPI GetDIBits(
 	return 0;
     }
 
+    funcs = bmp->funcs;
+    if (bmp->dib) funcs = dc->dibdrv.dev.funcs;
 
     if (bpp == 0) /* query bitmap info only */
     {
@@ -1104,7 +1113,7 @@ INT WINAPI GetDIBits(
 
         lines = src.height;
 
-        err = bmp->funcs->pGetImage( NULL, hbitmap, src_info, &src_bits, &src );
+        err = funcs->pGetImage( NULL, hbitmap, src_info, &src_bits, &src );
 
         if(err)
         {
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index bf51b4a..f12a40e 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -437,8 +437,7 @@ static void test_dib_bits_access( HBITMAP hdib, void *bits )
     ok(info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect);
     ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
     ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
-    /* it has been protected now */
-    todo_wine ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
+    ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
 
     /* try writing protected bits to a file */
 




More information about the wine-cvs mailing list