From 36a0bb0f5296fa5412e40fc3e1e4a854550e448b Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Wed, 27 Jul 2016 09:59:26 +0100 Subject: [PATCH] gdi32: Avoid unnecessary calls to get_dc_ptr(). Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/gdi32/dibdrv/bitblt.c | 19 ++++--------------- dlls/gdi32/gdi_private.h | 7 +++++++ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/dlls/gdi32/dibdrv/bitblt.c b/dlls/gdi32/dibdrv/bitblt.c index 71ef2723f23..12e4cd830b9 100644 --- a/dlls/gdi32/dibdrv/bitblt.c +++ b/dlls/gdi32/dibdrv/bitblt.c @@ -1390,18 +1390,12 @@ COLORREF get_pixel_bitmapinfo( const BITMAPINFO *info, void *bits, struct bitblt BOOL dibdrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst, PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop ) { - BOOL ret; - DC *dc_dst = get_dc_ptr( dst_dev->hdc ); - - if (!dc_dst) return FALSE; + DC *dc_dst = get_physdev_dc( dst_dev ); if (dst->width == 1 && src->width > 1) src->width--; if (dst->height == 1 && src->height > 1) src->height--; - ret = dc_dst->nulldrv.funcs->pStretchBlt( &dc_dst->nulldrv, dst, - src_dev, src, rop ); - release_dc_ptr( dc_dst ); - return ret; + return dc_dst->nulldrv.funcs->pStretchBlt( &dc_dst->nulldrv, dst, src_dev, src, rop ); } /*********************************************************************** @@ -1410,14 +1404,9 @@ BOOL dibdrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst, BOOL dibdrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords *dst, PHYSDEV src_dev, struct bitblt_coords *src, BLENDFUNCTION blend ) { - BOOL ret; - DC *dc_dst = get_dc_ptr( dst_dev->hdc ); + DC *dc_dst = get_physdev_dc( dst_dev ); - if (!dc_dst) return FALSE; - - ret = dc_dst->nulldrv.funcs->pAlphaBlend( &dc_dst->nulldrv, dst, src_dev, src, blend ); - release_dc_ptr( dc_dst ); - return ret; + return dc_dst->nulldrv.funcs->pAlphaBlend( &dc_dst->nulldrv, dst, src_dev, src, blend ); } /*********************************************************************** diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 47cdf6698d7..a837215d7af 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -469,6 +469,13 @@ static inline DC *get_nulldrv_dc( PHYSDEV dev ) return CONTAINING_RECORD( dev, DC, nulldrv ); } +static inline DC *get_physdev_dc( PHYSDEV dev ) +{ + while (dev->funcs != &null_driver) + dev = dev->next; + return get_nulldrv_dc( dev ); +} + /* Undocumented value for DIB's iUsage: Indicates a mono DIB w/o pal entries */ #define DIB_PAL_MONO 2