gdi32: The clip region should stop the flooding.

This commit is contained in:
Huw Davies 2012-01-19 10:11:44 +00:00 committed by Alexandre Julliard
parent 32c23cbc80
commit 3dc4f259e9
2 changed files with 35 additions and 25 deletions

View file

@ -678,17 +678,20 @@ BOOL dibdrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
return dibdrv_RoundRect( dev, left, top, right, bottom, right - left, bottom - top );
}
static inline BOOL is_interior( dib_info *dib, int x, int y, DWORD pixel, UINT type)
static inline BOOL is_interior( dib_info *dib, HRGN clip, int x, int y, DWORD pixel, UINT type)
{
/* the clip rgn stops the flooding */
if (!PtInRegion( clip, x, y )) return FALSE;
if (type == FLOODFILLBORDER)
return dib->funcs->get_pixel( dib, x, y ) != pixel;
else
return dib->funcs->get_pixel( dib, x, y ) == pixel;
}
static void fill_row( dib_info *dib, RECT *row, DWORD pixel, UINT type, HRGN rgn );
static void fill_row( dib_info *dib, HRGN clip, RECT *row, DWORD pixel, UINT type, HRGN rgn );
static inline void do_next_row( dib_info *dib, const RECT *row, int offset, DWORD pixel, UINT type, HRGN rgn )
static inline void do_next_row( dib_info *dib, HRGN clip, const RECT *row, int offset, DWORD pixel, UINT type, HRGN rgn )
{
RECT next;
@ -697,26 +700,26 @@ static inline void do_next_row( dib_info *dib, const RECT *row, int offset, DWOR
next.left = next.right = row->left;
while (next.right < row->right)
{
if (is_interior( dib, next.right, next.top, pixel, type)) next.right++;
if (is_interior( dib, clip, next.right, next.top, pixel, type)) next.right++;
else
{
if (next.left != next.right && !PtInRegion( rgn, next.left, next.top ))
fill_row( dib, &next, pixel, type, rgn );
fill_row( dib, clip, &next, pixel, type, rgn );
next.left = ++next.right;
}
}
if (next.left != next.right && !PtInRegion( rgn, next.left, next.top ))
fill_row( dib, &next, pixel, type, rgn );
fill_row( dib, clip, &next, pixel, type, rgn );
}
static void fill_row( dib_info *dib, RECT *row, DWORD pixel, UINT type, HRGN rgn )
static void fill_row( dib_info *dib, HRGN clip, RECT *row, DWORD pixel, UINT type, HRGN rgn )
{
while (row->left > 0 && is_interior( dib, row->left - 1, row->top, pixel, type)) row->left--;
while (row->right < dib->width && is_interior( dib, row->right, row->top, pixel, type)) row->right++;
while (row->left > 0 && is_interior( dib, clip, row->left - 1, row->top, pixel, type)) row->left--;
while (row->right < dib->width && is_interior( dib, clip, row->right, row->top, pixel, type)) row->right++;
add_rect_to_region( rgn, row );
if (row->top > 0) do_next_row( dib, row, -1, pixel, type, rgn );
if (row->top < dib->height - 1) do_next_row( dib, row, 1, pixel, type, rgn );
if (row->top > 0) do_next_row( dib, clip, row, -1, pixel, type, rgn );
if (row->top < dib->height - 1) do_next_row( dib, clip, row, 1, pixel, type, rgn );
return;
}
@ -733,7 +736,7 @@ BOOL dibdrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
TRACE( "(%p, %d, %d, %08x, %d\n", pdev, x, y, color, type );
if (!is_interior( &pdev->dib, x, y, pixel, type )) return FALSE;
if (!is_interior( &pdev->dib, pdev->clip, x, y, pixel, type )) return FALSE;
rgn = CreateRectRgn( 0, 0, 0, 0 );
row.left = x;
@ -741,7 +744,7 @@ BOOL dibdrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
row.top = y;
row.bottom = y + 1;
fill_row( &pdev->dib, &row, pixel, type, rgn );
fill_row( &pdev->dib, pdev->clip, &row, pixel, type, rgn );
brush_region( pdev, rgn );

View file

@ -145,7 +145,7 @@ static const char *sha1_graphics_a8r8g8b8[] =
"f451a05f699ac3bbe155d059e7871a2636887b5f",
"5dca709c60e0cd50fa85274a2836aec9eb6168e3",
"dccaef62738ff90da4554a85d8cb846d6436799e",
"57b3c6ece2c4f322d5cb5e5dde596714607d5502",
"cc4e1372ddf6e303a7fd159090c9d3a1f8ec2a89",
NULL
};
@ -217,7 +217,7 @@ static const char *sha1_graphics_a8r8g8b8_bitfields[] =
"f451a05f699ac3bbe155d059e7871a2636887b5f",
"5dca709c60e0cd50fa85274a2836aec9eb6168e3",
"dccaef62738ff90da4554a85d8cb846d6436799e",
"57b3c6ece2c4f322d5cb5e5dde596714607d5502",
"cc4e1372ddf6e303a7fd159090c9d3a1f8ec2a89",
NULL
};
@ -289,7 +289,7 @@ static const char *sha1_graphics_a8b8g8r8[] =
"707bc44fc9fed68ff1f537f0473e0cd825dd660f",
"f19f5d8e2c96328f06f3985d02ff474fa37b1ea8",
"175a7bcb73c74eceecc000657a0100bccf158ff4",
"71085fe7617b710a27a3ee4478d94e4d9209804e",
"d26eeb6b2d345b587d4305a1234ec0842a96d4b6",
NULL
};
@ -361,7 +361,7 @@ static const char *sha1_graphics_r10g10b10[] =
"88cfa7b7c1487f8eda05fce92b622942c9fb7ca4",
"64cf929548bc5324fb14b053077bf5bc4be3e15c",
"ad91dde8566dceaadc3523cdc8149cd7415a1b70",
"a56731d5c808a8a37ce057818d8c61d563ae4432",
"1936661eee8073068506131c9e89265b2f8403e8",
NULL
};
@ -433,7 +433,7 @@ static const char *sha1_graphics_r6g6b6[] =
"8e32ea3614c3b20899d748db48258761c7158d2b",
"5da35bad12e3e9b26a0444d30820099481281e45",
"94f004e98ae8035af948611770a4a2dd6643f510",
"130b503745311a795cd565f667c76870326b82d4",
"045ddaf752e7ffc7ded792f36af3c7c0cfeeae42",
NULL
};
@ -505,7 +505,7 @@ static const char *sha1_graphics_24[] =
"09cb4ab070083144bed4271c0a2a34ccb6ed13c0",
"cc5ed4c9e925f0a457a7437fbb8054528cdd9469",
"c95afd0a020e68a76982fe8663b5d64113987233",
"64d9e7cf03118d096a9a5bc5b5ee8c48df8bc0f6",
"48658ff76c137185c56a53f3ccf0e958d0296742",
NULL
};
@ -581,7 +581,7 @@ static const char *sha1_graphics_r5g5b5[] =
"7de23c68ca224818fdf127c5e96729dcd0de2b8b",
"a848b1b0293b05b3f9358a3ffcb21a2e5fdecf05",
"1a0fd0df17fa4c455a4a91cad30b5242f77fd233",
"1511523f4c6fd76a10867c44cc87a95446387425",
"af45bf81d119be5cf6845ad41191ba52637e65e9",
NULL
};
@ -652,7 +652,7 @@ static const char *sha1_graphics_r4g4b4[] =
"6fd751b7328c02954bce98bed94b3ce3c73db118",
"91d50b5a604d6c38aa0d08b9af995490f8ec246b",
"8585783d0373e9696b508776b6e6b18a80b09888",
"2e8fc36b1e534314c153375b9d3f6d217ccc08f1",
"b53cde47b0e28063770d3b1328c3cc2f774a6300",
NULL
};
@ -729,7 +729,7 @@ static const char *sha1_graphics_8_color[] =
"d7ffa3893c6fa937569791cf49986518a4a4d96e",
"26bc25a011e2b60961ee9d6c6141d928ae24389b",
"8771d5ff7b93b9dd9d077e672b342235dfb28472",
"6591276cda7784d91c79ed66ad4558b3f17426bc",
"6a1f6e1d494bf6b0ece7af5fa164ebaadb3a19bd",
NULL
};
@ -886,7 +886,7 @@ static const char *sha1_graphics_8[] =
"a6311d74fc058079a327abb536e69353be719925",
"fbaa8848a1d3896469c37fd43ab44233f5b875a3",
"0000000000000000000000000000000000000000",
"f3e856449b0ad00297cae027f51e3586746f9918",
"c2ac98ef716fd8a5ac8f08ce66293d9a96344337",
NULL
};
@ -957,7 +957,7 @@ static const char *sha1_graphics_4[] =
"6fe7d0d17b892032cfd171c3d7c365f030b5be38",
"7ae780dcc7cf04dda50648bfc07cc6a7a2f2189e",
"0000000000000000000000000000000000000000",
"3b6e78e568ed3e60e77f45fdf38cdfed4c341bb9",
"9ab46e0c42f82dc73df8a55cbf881abd72397cec",
NULL
};
@ -1840,6 +1840,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh
pSetLayout(hdc, LAYOUT_LTR);
}
DeleteObject( hrgn );
for(i = 0, y = 10; i < 256; i++)
{
@ -2554,6 +2555,11 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh
solid_patblt( hdc, 100, 160, 50, 50, RGB( 0, 0, 0xff ) );
solid_patblt( hdc, 90, 160, 70, 10, RGB( 0, 0, 0xff ) );
/* add a vertical 'bar' to show that the clip rgn stops the flooding */
hrgn = CreateRectRgn( 180, 10, 190, 210 );
ExtSelectClipRgn( hdc, hrgn, RGN_DIFF );
DeleteObject( hrgn );
solid_brush = CreateSolidBrush( RGB( 0xff, 0, 0 ) );
SelectObject( hdc, solid_brush );
@ -2562,9 +2568,10 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh
compare_hash(bmi, bits, sha1, "flood fill" );
memset(bits, 0xcc, dib_size);
ExtSelectClipRgn( hdc, NULL, RGN_COPY );
SelectObject(hdc, orig_brush);
SelectObject(hdc, orig_pen);
DeleteObject(hrgn);
DeleteObject(dib_brush);
DeleteObject(solid_brush);
DeleteObject(wide_pen);