Alexandre Julliard : gdi32: Add helpers to paint a region with the brush or pen.

Alexandre Julliard julliard at winehq.org
Thu Dec 29 12:15:44 CST 2011


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Dec 29 10:10:35 2011 +0100

gdi32: Add helpers to paint a region with the brush or pen.

---

 dlls/gdi32/dibdrv/dibdrv.h   |    3 ++-
 dlls/gdi32/dibdrv/graphics.c |   23 ++++++-----------------
 dlls/gdi32/dibdrv/objects.c  |   31 +++++++++++++++----------------
 3 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h
index 1f158db..a5fd968 100644
--- a/dlls/gdi32/dibdrv/dibdrv.h
+++ b/dlls/gdi32/dibdrv/dibdrv.h
@@ -233,7 +233,8 @@ extern BOOL convert_dib(dib_info *dst, const dib_info *src) DECLSPEC_HIDDEN;
 extern COLORREF make_rgb_colorref( HDC hdc, dib_info *dib, COLORREF color, BOOL *got_pixel, DWORD *pixel ) DECLSPEC_HIDDEN;
 extern DWORD get_pixel_color(dibdrv_physdev *pdev, COLORREF color, BOOL mono_fixup) DECLSPEC_HIDDEN;
 extern BOOL brush_rect( dibdrv_physdev *pdev, const RECT *rect, HRGN clip, INT rop ) DECLSPEC_HIDDEN;
-extern BOOL pen_rect(dibdrv_physdev *pdev, const RECT *rect, HRGN clip, INT rop) DECLSPEC_HIDDEN;
+extern BOOL brush_region( dibdrv_physdev *pdev, HRGN region ) DECLSPEC_HIDDEN;
+extern BOOL pen_region( dibdrv_physdev *pdev, HRGN region ) DECLSPEC_HIDDEN;
 extern int get_clipped_rects( const dib_info *dib, const RECT *rc, HRGN clip, struct clipped_rects *clip_rects ) DECLSPEC_HIDDEN;
 extern int clip_line(const POINT *start, const POINT *end, const RECT *clip,
                      const bres_params *params, POINT *pt1, POINT *pt2) DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c
index 81d1d1b..ad52273 100644
--- a/dlls/gdi32/dibdrv/graphics.c
+++ b/dlls/gdi32/dibdrv/graphics.c
@@ -464,7 +464,7 @@ BOOL dibdrv_LineTo( PHYSDEV dev, INT x, INT y )
     if (region)
     {
         if (pdev->clip) CombineRgn( region, region, pdev->clip, RGN_AND );
-        ret = pen_rect( pdev, NULL, region, GetROP2(dev->hdc) );
+        ret = pen_region( pdev, region );
         DeleteObject( region );
     }
     return ret;
@@ -529,7 +529,6 @@ BOOL dibdrv_PolyPolygon( PHYSDEV dev, const POINT *pt, const INT *counts, DWORD
     DWORD total, i, pos;
     BOOL ret = FALSE;
     POINT *points;
-    INT rop = GetROP2( dev->hdc );
     HRGN outline = 0, interior;
 
     if (defer_pen( pdev )) return next->funcs->pPolyPolygon( next, pt, counts, polygons );
@@ -551,11 +550,9 @@ BOOL dibdrv_PolyPolygon( PHYSDEV dev, const POINT *pt, const INT *counts, DWORD
         return FALSE;
     }
 
-    if (pdev->clip) CombineRgn( interior, interior, pdev->clip, RGN_AND );
-
     /* if not using a region, paint the interior first so the outline can overlap it */
     if (!pdev->pen_uses_region || !(outline = CreateRectRgn( 0, 0, 0, 0 )))
-        ret = brush_rect( pdev, NULL, interior, rop );
+        ret = brush_region( pdev, interior );
 
     for (i = pos = 0; i < polygons; i++)
     {
@@ -566,9 +563,8 @@ BOOL dibdrv_PolyPolygon( PHYSDEV dev, const POINT *pt, const INT *counts, DWORD
 
     if (outline)
     {
-        if (pdev->clip) CombineRgn( outline, outline, pdev->clip, RGN_AND );
         CombineRgn( interior, interior, outline, RGN_DIFF );
-        ret = pen_rect( pdev, NULL, outline, rop ) && brush_rect( pdev, NULL, interior, rop );
+        ret = pen_region( pdev, outline ) && brush_region( pdev, interior );
         DeleteObject( outline );
     }
 
@@ -587,7 +583,6 @@ BOOL dibdrv_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* counts, DWO
     DWORD max_points = 0, i;
     POINT *points;
     BOOL ret = TRUE;
-    INT rop = GetROP2( dev->hdc );
     HRGN outline = 0;
 
     if (defer_pen( pdev )) return next->funcs->pPolyPolyline( next, pt, counts, polylines );
@@ -620,7 +615,7 @@ BOOL dibdrv_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* counts, DWO
     if (outline)
     {
         if (pdev->clip) CombineRgn( outline, outline, pdev->clip, RGN_AND );
-        ret = pen_rect( pdev, NULL, outline, rop );
+        ret = pen_region( pdev, outline );
         DeleteObject( outline );
     }
 
@@ -659,7 +654,6 @@ BOOL dibdrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
     RECT rect = get_device_rect( dev->hdc, left, top, right, bottom, TRUE );
     POINT pts[4];
     BOOL ret;
-    INT rop = GetROP2( dev->hdc );
     HRGN outline = 0;
 
     TRACE("(%p, %d, %d, %d, %d)\n", dev, left, top, right, bottom);
@@ -696,12 +690,7 @@ BOOL dibdrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
         HRGN interior = CreateRectRgnIndirect( &rect );
 
         CombineRgn( interior, interior, outline, RGN_DIFF );
-        if (pdev->clip)
-        {
-            CombineRgn( outline, outline, pdev->clip, RGN_AND );
-            CombineRgn( interior, interior, pdev->clip, RGN_AND );
-        }
-        ret = pen_rect( pdev, NULL, outline, rop ) && brush_rect( pdev, NULL, interior, rop );
+        ret = pen_region( pdev, outline ) && brush_region( pdev, interior );
         DeleteObject( outline );
         DeleteObject( interior );
     }
@@ -711,7 +700,7 @@ BOOL dibdrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
         rect.top    += (pdev->pen_width + 1) / 2;
         rect.right  -= pdev->pen_width / 2;
         rect.bottom -= pdev->pen_width / 2;
-        ret = brush_rect( pdev, &rect, pdev->clip, rop );
+        ret = brush_rect( pdev, &rect, pdev->clip, GetROP2(dev->hdc) );
     }
     return ret;
 }
diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c
index 197b220..c7f2ae9 100644
--- a/dlls/gdi32/dibdrv/objects.c
+++ b/dlls/gdi32/dibdrv/objects.c
@@ -1329,11 +1329,12 @@ static void add_join( dibdrv_physdev *pdev, HRGN region, const POINT *pt,
     return;
 }
 
-static BOOL get_wide_lines_region( dibdrv_physdev *pdev, int num, POINT *pts, BOOL close, HRGN total )
+static BOOL wide_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts, BOOL close, HRGN total)
 {
     int i;
     HRGN segment;
 
+    assert( total != 0 );  /* wide pens should always be drawn through a region */
     assert( num >= 2 );
 
     if (!close) num--;
@@ -1481,18 +1482,6 @@ static BOOL get_wide_lines_region( dibdrv_physdev *pdev, int num, POINT *pts, BO
     return TRUE;
 }
 
-static BOOL wide_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts, BOOL close, HRGN region)
-{
-    if (region) return get_wide_lines_region( pdev, num, pts, close, region );
-
-    if (!(region = CreateRectRgn( 0, 0, 0, 0 ))) return FALSE;
-    get_wide_lines_region( pdev, num, pts, close, region );
-    if (pdev->clip) CombineRgn( region, region, pdev->clip, RGN_AND );
-    pen_rect( pdev, NULL, region, GetROP2( pdev->dev.hdc ) );
-    DeleteObject( region );
-    return TRUE;
-}
-
 static const dash_pattern dash_patterns_cosmetic[4] =
 {
     {2, {18, 6}, 24},             /* PS_DASH */
@@ -2022,15 +2011,25 @@ BOOL brush_rect(dibdrv_physdev *pdev, const RECT *rect, HRGN clip, INT rop)
     return ret;
 }
 
-BOOL pen_rect(dibdrv_physdev *pdev, const RECT *rect, HRGN clip, INT rop)
+/* paint a region with the brush (note: the region can be modified) */
+BOOL brush_region( dibdrv_physdev *pdev, HRGN region )
+{
+    if (pdev->clip) CombineRgn( region, region, pdev->clip, RGN_AND );
+    return brush_rect( pdev, NULL, region, GetROP2( pdev->dev.hdc ));
+}
+
+/* paint a region with the pen (note: the region can be modified) */
+BOOL pen_region( dibdrv_physdev *pdev, HRGN region )
 {
     struct clipped_rects clipped_rects;
     rop_mask color;
     DWORD pen_color = get_pixel_color( pdev, pdev->pen_colorref, TRUE );
 
-    if (!get_clipped_rects( &pdev->dib, rect, clip, &clipped_rects )) return TRUE;
+    if (pdev->clip) CombineRgn( region, region, pdev->clip, RGN_AND );
+
+    if (!get_clipped_rects( &pdev->dib, NULL, region, &clipped_rects )) return TRUE;
 
-    calc_rop_masks( rop, pen_color, &color );
+    calc_rop_masks( GetROP2( pdev->dev.hdc ), pen_color, &color );
     pdev->dib.funcs->solid_rects( &pdev->dib, clipped_rects.count, clipped_rects.rects,
                                   color.and, color.xor );
     free_clipped_rects( &clipped_rects );




More information about the wine-cvs mailing list