gdi32: Avoid making a copy of the device clipping region in the DIB driver.

This commit is contained in:
Alexandre Julliard 2011-12-27 15:48:05 +01:00
parent 56373bc491
commit 8b3271c3b0
3 changed files with 10 additions and 41 deletions

View File

@ -929,7 +929,7 @@ DWORD dibdrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO *info
struct clipped_rects clipped_rects;
DWORD ret;
dib_info src_dib;
HRGN saved_clip = NULL;
HRGN tmp_rgn = 0;
dibdrv_physdev *pdev = NULL;
TRACE( "%p %p %p\n", dev, hbitmap, info );
@ -972,8 +972,13 @@ DWORD dibdrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO *info
if (!hbitmap)
{
if (clip) saved_clip = add_extra_clipping_region( pdev, clip );
clip = pdev->clip;
if (clip && pdev->clip)
{
tmp_rgn = CreateRectRgn( 0, 0, 0, 0 );
CombineRgn( tmp_rgn, clip, pdev->clip, RGN_AND );
clip = tmp_rgn;
}
else if (!clip) clip = pdev->clip;
}
if (!get_clipped_rects( dib, &dst->visrect, clip, &clipped_rects ))
@ -1000,7 +1005,7 @@ update_format:
ret = ERROR_BAD_FORMAT;
done:
if (saved_clip) restore_clipping_region( pdev, saved_clip );
if (tmp_rgn) DeleteObject( tmp_rgn );
if (hbitmap) GDI_ReleaseObj( hbitmap );
return ret;
}

View File

@ -298,33 +298,6 @@ int get_clipped_rects( const dib_info *dib, const RECT *rc, HRGN clip, struct cl
return clip_rects->count;
}
/***********************************************************************
* add_extra_clipping_region
*
* Temporarily add a region to the current clipping region.
* The returned region must be restored with restore_clipping_region.
*/
HRGN add_extra_clipping_region( dibdrv_physdev *pdev, HRGN rgn )
{
HRGN ret, clip;
if (!(clip = CreateRectRgn( 0, 0, 0, 0 ))) return 0;
CombineRgn( clip, pdev->clip, rgn, RGN_AND );
ret = pdev->clip;
pdev->clip = clip;
return ret;
}
/***********************************************************************
* restore_clipping_region
*/
void restore_clipping_region( dibdrv_physdev *pdev, HRGN rgn )
{
if (!rgn) return;
DeleteObject( pdev->clip );
pdev->clip = rgn;
}
/**********************************************************************
* dibdrv_CreateDC
*/
@ -334,11 +307,6 @@ static BOOL dibdrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
dibdrv_physdev *pdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pdev) );
if (!pdev) return FALSE;
if (!(pdev->clip = CreateRectRgn(0, 0, 0, 0)))
{
HeapFree( GetProcessHeap(), 0, pdev );
return FALSE;
}
clear_dib_info(&pdev->dib);
clear_dib_info(&pdev->brush_dib);
push_dc_driver( dev, &pdev->dev, &dib_driver );
@ -352,7 +320,6 @@ static BOOL dibdrv_DeleteDC( PHYSDEV dev )
{
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
TRACE("(%p)\n", dev);
DeleteObject(pdev->clip);
free_pattern_brush(pdev);
HeapFree( GetProcessHeap(), 0, pdev );
return TRUE;
@ -409,8 +376,7 @@ static void dibdrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
TRACE("(%p, %p)\n", dev, rgn);
SetRectRgn( pdev->clip, 0, 0, pdev->dib.width, pdev->dib.height );
if (rgn) CombineRgn( pdev->clip, pdev->clip, rgn, RGN_AND );
pdev->clip = rgn;
return next->funcs->pSetDeviceClipping( next, rgn );
}

View File

@ -232,8 +232,6 @@ extern COLORREF make_rgb_colorref( HDC hdc, dib_info *dib, COLORREF color, BOOL
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 ) DECLSPEC_HIDDEN;
extern int get_clipped_rects( const dib_info *dib, const RECT *rc, HRGN clip, struct clipped_rects *clip_rects ) DECLSPEC_HIDDEN;
extern HRGN add_extra_clipping_region( dibdrv_physdev *pdev, HRGN rgn ) DECLSPEC_HIDDEN;
extern void restore_clipping_region( dibdrv_physdev *pdev, HRGN rgn ) 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;