Alexandre Julliard : gdi32: Add a helper function to retrieve the DIB rectangle.

Alexandre Julliard julliard at winehq.org
Wed Apr 4 15:08:01 CDT 2018


Module: wine
Branch: master
Commit: 737a113c10b9db17b729df001a90b2deb98d21c5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=737a113c10b9db17b729df001a90b2deb98d21c5

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Apr  4 15:20:57 2018 +0200

gdi32: Add a helper function to retrieve the DIB rectangle.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/dibdrv/dc.c     | 22 +++++++++++-----------
 dlls/gdi32/dibdrv/dibdrv.h |  1 +
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c
index 78f4b7a..1aa67f3 100644
--- a/dlls/gdi32/dibdrv/dc.c
+++ b/dlls/gdi32/dibdrv/dc.c
@@ -240,16 +240,20 @@ DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
     return ERROR_SUCCESS;
 }
 
+int get_dib_rect( const dib_info *dib, RECT *rc )
+{
+    rc->left   = max( 0, -dib->rect.left );
+    rc->top    = max( 0, -dib->rect.top );
+    rc->right  = min( dib->rect.right, dib->width ) - dib->rect.left;
+    rc->bottom = min( dib->rect.bottom, dib->height ) - dib->rect.top;
+    return !is_rect_empty( rc );
+}
+
 int clip_rect_to_dib( const dib_info *dib, RECT *rc )
 {
     RECT rect;
 
-    rect.left   = max( 0, -dib->rect.left );
-    rect.top    = max( 0, -dib->rect.top );
-    rect.right  = min( dib->rect.right, dib->width ) - dib->rect.left;
-    rect.bottom = min( dib->rect.bottom, dib->height ) - dib->rect.top;
-    if (is_rect_empty( &rect )) return 0;
-    return intersect_rect( rc, &rect, rc );
+    return get_dib_rect( dib, &rect ) && intersect_rect( rc, &rect, rc );
 }
 
 int get_clipped_rects( const dib_info *dib, const RECT *rc, HRGN clip, struct clipped_rects *clip_rects )
@@ -260,11 +264,7 @@ int get_clipped_rects( const dib_info *dib, const RECT *rc, HRGN clip, struct cl
 
     init_clipped_rects( clip_rects );
 
-    rect.left   = max( 0, -dib->rect.left );
-    rect.top    = max( 0, -dib->rect.top );
-    rect.right  = min( dib->rect.right, dib->width ) - dib->rect.left;
-    rect.bottom = min( dib->rect.bottom, dib->height ) - dib->rect.top;
-    if (is_rect_empty( &rect )) return 0;
+    if (!get_dib_rect( dib, &rect )) return 0;
     if (rc && !intersect_rect( &rect, &rect, rc )) return 0;
 
     if (!clip)
diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h
index ce34c0d..f79f5b0 100644
--- a/dlls/gdi32/dibdrv/dibdrv.h
+++ b/dlls/gdi32/dibdrv/dibdrv.h
@@ -251,6 +251,7 @@ extern void free_pattern_brush(dib_brush *brush) DECLSPEC_HIDDEN;
 extern void copy_dib_color_info(dib_info *dst, const dib_info *src) DECLSPEC_HIDDEN;
 extern BOOL convert_dib(dib_info *dst, const dib_info *src) DECLSPEC_HIDDEN;
 extern DWORD get_pixel_color( DC *dc, const dib_info *dib, COLORREF color, BOOL mono_fixup ) DECLSPEC_HIDDEN;
+extern int get_dib_rect( const dib_info *dib, RECT *rc ) DECLSPEC_HIDDEN;
 extern int clip_rect_to_dib( const dib_info *dib, RECT *rc ) DECLSPEC_HIDDEN;
 extern int get_clipped_rects( const dib_info *dib, const RECT *rc, HRGN clip, struct clipped_rects *clip_rects ) DECLSPEC_HIDDEN;
 extern void add_clipped_bounds( dibdrv_physdev *dev, const RECT *rect, HRGN clip ) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list