Huw Davies : gdi32: Move the intersection of vis rects into a separate function.
Alexandre Julliard
julliard at winehq.org
Mon Oct 17 13:08:55 CDT 2011
Module: wine
Branch: master
Commit: 64f6e9bc583f9ad54f2912b75847c1eb68f34de8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=64f6e9bc583f9ad54f2912b75847c1eb68f34de8
Author: Huw Davies <huw at codeweavers.com>
Date: Mon Oct 17 15:46:05 2011 +0100
gdi32: Move the intersection of vis rects into a separate function.
---
dlls/gdi32/bitblt.c | 103 ++++++++++++++++++++++++---------------------
dlls/gdi32/gdi_private.h | 3 +
2 files changed, 58 insertions(+), 48 deletions(-)
diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c
index 28b1a73..ea5ad41 100644
--- a/dlls/gdi32/bitblt.c
+++ b/dlls/gdi32/bitblt.c
@@ -47,6 +47,60 @@ static inline void swap_ints( int *i, int *j )
*j = tmp;
}
+BOOL intersect_vis_rectangles( struct bitblt_coords *dst, struct bitblt_coords *src )
+{
+ RECT rect;
+
+ /* intersect the rectangles */
+
+ if ((src->width == dst->width) && (src->height == dst->height)) /* no stretching */
+ {
+ offset_rect( &src->visrect, dst->x - src->x, dst->y - src->y );
+ intersect_rect( &rect, &src->visrect, &dst->visrect );
+ src->visrect = dst->visrect = rect;
+ offset_rect( &src->visrect, src->x - dst->x, src->y - dst->y );
+ }
+ else /* stretching */
+ {
+ /* map source rectangle into destination coordinates */
+ rect = src->visrect;
+ offset_rect( &rect, -min( src->x, src->x + src->width + 1),
+ -min( src->y, src->y + src->height + 1) );
+ rect.left = dst->x + rect.left * dst->width / abs(src->width);
+ rect.top = dst->y + rect.top * dst->height / abs(src->height);
+ rect.right = dst->x + rect.right * dst->width / abs(src->width);
+ rect.bottom = dst->y + rect.bottom * dst->height / abs(src->height);
+ if (rect.left > rect.right) swap_ints( &rect.left, &rect.right );
+ if (rect.top > rect.bottom) swap_ints( &rect.top, &rect.bottom );
+
+ /* avoid rounding errors */
+ rect.left--;
+ rect.top--;
+ rect.right++;
+ rect.bottom++;
+ if (!intersect_rect( &dst->visrect, &rect, &dst->visrect )) return FALSE;
+
+ /* map destination rectangle back to source coordinates */
+ rect = dst->visrect;
+ offset_rect( &rect, -min( dst->x, dst->x + dst->width + 1),
+ -min( dst->y, dst->y + dst->height + 1) );
+ rect.left = src->x + rect.left * src->width / abs(dst->width);
+ rect.top = src->y + rect.top * src->height / abs(dst->height);
+ rect.right = src->x + rect.right * src->width / abs(dst->width);
+ rect.bottom = src->y + rect.bottom * src->height / abs(dst->height);
+ if (rect.left > rect.right) swap_ints( &rect.left, &rect.right );
+ if (rect.top > rect.bottom) swap_ints( &rect.top, &rect.bottom );
+
+ /* avoid rounding errors */
+ rect.left--;
+ rect.top--;
+ rect.right++;
+ rect.bottom++;
+ if (!intersect_rect( &src->visrect, &rect, &src->visrect )) return FALSE;
+ }
+ return TRUE;
+}
+
static BOOL get_vis_rectangles( DC *dc_dst, struct bitblt_coords *dst,
DC *dc_src, struct bitblt_coords *src )
{
@@ -104,54 +158,7 @@ static BOOL get_vis_rectangles( DC *dc_dst, struct bitblt_coords *dst,
if (is_rect_empty( &src->visrect )) return FALSE;
if (is_rect_empty( &dst->visrect )) return FALSE;
- /* intersect the rectangles */
-
- if ((src->width == dst->width) && (src->height == dst->height)) /* no stretching */
- {
- offset_rect( &src->visrect, dst->x - src->x, dst->y - src->y );
- intersect_rect( &rect, &src->visrect, &dst->visrect );
- src->visrect = dst->visrect = rect;
- offset_rect( &src->visrect, src->x - dst->x, src->y - dst->y );
- }
- else /* stretching */
- {
- /* map source rectangle into destination coordinates */
- rect = src->visrect;
- offset_rect( &rect, -min( src->x, src->x + src->width + 1),
- -min( src->y, src->y + src->height + 1) );
- rect.left = dst->x + rect.left * dst->width / abs(src->width);
- rect.top = dst->y + rect.top * dst->height / abs(src->height);
- rect.right = dst->x + rect.right * dst->width / abs(src->width);
- rect.bottom = dst->y + rect.bottom * dst->height / abs(src->height);
- if (rect.left > rect.right) swap_ints( &rect.left, &rect.right );
- if (rect.top > rect.bottom) swap_ints( &rect.top, &rect.bottom );
-
- /* avoid rounding errors */
- rect.left--;
- rect.top--;
- rect.right++;
- rect.bottom++;
- if (!intersect_rect( &dst->visrect, &rect, &dst->visrect )) return FALSE;
-
- /* map destination rectangle back to source coordinates */
- rect = dst->visrect;
- offset_rect( &rect, -min( dst->x, dst->x + dst->width + 1),
- -min( dst->y, dst->y + dst->height + 1) );
- rect.left = src->x + rect.left * src->width / abs(dst->width);
- rect.top = src->y + rect.top * src->height / abs(dst->height);
- rect.right = src->x + rect.right * src->width / abs(dst->width);
- rect.bottom = src->y + rect.bottom * src->height / abs(dst->height);
- if (rect.left > rect.right) swap_ints( &rect.left, &rect.right );
- if (rect.top > rect.bottom) swap_ints( &rect.top, &rect.bottom );
-
- /* avoid rounding errors */
- rect.left--;
- rect.top--;
- rect.right++;
- rect.bottom++;
- if (!intersect_rect( &src->visrect, &rect, &src->visrect )) return FALSE;
- }
- return TRUE;
+ return intersect_vis_rectangles( dst, src );
}
void free_heap_bits( struct gdi_image_bits *bits )
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index d8648ef..bf1bc18 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -222,6 +222,9 @@ typedef struct tagBITMAPOBJ
extern BOOL BIDI_Reorder( HDC hDC, LPCWSTR lpString, INT uCount, DWORD dwFlags, DWORD dwWineGCP_Flags,
LPWSTR lpOutString, INT uCountOut, UINT *lpOrder, WORD **lpGlyphs, INT* cGlyphs ) DECLSPEC_HIDDEN;
+/* bitblt.c */
+extern BOOL intersect_vis_rectangles( struct bitblt_coords *dst, struct bitblt_coords *src ) DECLSPEC_HIDDEN;
+
/* bitmap.c */
extern void get_ddb_bitmapinfo( BITMAPOBJ *bmp, BITMAPINFO *info ) DECLSPEC_HIDDEN;
extern BOOL get_bitmap_image( HBITMAP hbitmap, BITMAPINFO *info, struct gdi_image_bits *bits ) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list