Module: wine Branch: master Commit: 0c5e7a6d4dcf07855742bb339a17e7f7ee0a196c URL: http://source.winehq.org/git/wine.git/?a=commit;h=0c5e7a6d4dcf07855742bb339a...
Author: Huw Davies huw@codeweavers.com Date: Tue Apr 5 13:23:20 2011 +0100
gdi32: Add a dib primitive function table.
---
dlls/gdi32/Makefile.in | 1 + dlls/gdi32/dibdrv/dc.c | 20 +++++++++++++++++++ dlls/gdi32/dibdrv/dibdrv.h | 8 +++++++ dlls/gdi32/dibdrv/primitives.c | 42 ++++++++++++++++++++++++++++++++++++++++ dlls/gdi32/gdi_private.h | 2 + 5 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/dlls/gdi32/Makefile.in b/dlls/gdi32/Makefile.in index 13b1a72..9753ef4 100644 --- a/dlls/gdi32/Makefile.in +++ b/dlls/gdi32/Makefile.in @@ -15,6 +15,7 @@ C_SRCS = \ dc.c \ dib.c \ dibdrv/dc.c \ + dibdrv/primitives.c \ driver.c \ enhmetafile.c \ enhmfdrv/bitblt.c \ diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index d105f60..a230fbf 100644 --- a/dlls/gdi32/dibdrv/dc.c +++ b/dlls/gdi32/dibdrv/dc.c @@ -36,6 +36,13 @@ static BOOL CDECL dibdrv_DeleteDC( PHYSDEV dev ) return 0; }
+static void init_bit_fields(dib_info *dib, const DWORD *bit_fields) +{ + dib->red_mask = bit_fields[0]; + dib->green_mask = bit_fields[1]; + dib->blue_mask = bit_fields[2]; +} + static BOOL init_dib(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD *bit_fields, void *bits) { dib->bit_count = bi->biBitCount; @@ -55,8 +62,21 @@ static BOOL init_dib(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD *bit dib->stride = -dib->stride; }
+ dib->funcs = &funcs_null; + switch(dib->bit_count) { + case 32: + init_bit_fields(dib, bit_fields); + if(dib->red_mask == 0xff0000 && dib->green_mask == 0x00ff00 && dib->blue_mask == 0x0000ff) + dib->funcs = &funcs_8888; + else + { + TRACE("32 bpp bitmasks not supported, will forward to graphics driver.\n"); + return FALSE; + } + break; + default: TRACE("bpp %d not supported, will forward to graphics driver.\n", dib->bit_count); return FALSE; diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h index 9dca50f..da41f21 100644 --- a/dlls/gdi32/dibdrv/dibdrv.h +++ b/dlls/gdi32/dibdrv/dibdrv.h @@ -22,3 +22,11 @@ static inline dibdrv_physdev *get_dibdrv_pdev( PHYSDEV dev ) { return (dibdrv_physdev *)dev; } + +typedef struct primitive_funcs +{ + DWORD (* colorref_to_pixel)(const dib_info *dib, COLORREF color); +} primitive_funcs; + +extern const primitive_funcs funcs_8888 DECLSPEC_HIDDEN; +extern const primitive_funcs funcs_null DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/dibdrv/primitives.c b/dlls/gdi32/dibdrv/primitives.c new file mode 100644 index 0000000..8bbfc4d --- /dev/null +++ b/dlls/gdi32/dibdrv/primitives.c @@ -0,0 +1,42 @@ +/* + * DIB driver primitives. + * + * Copyright 2011 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "gdi_private.h" +#include "dibdrv.h" + +static DWORD colorref_to_pixel_888(const dib_info *dib, COLORREF color) +{ + return ( ((color >> 16) & 0xff) | (color & 0xff00) | ((color << 16) & 0xff0000) ); +} + +static DWORD colorref_to_pixel_null(const dib_info *dib, COLORREF color) +{ + return 0; +} + +const primitive_funcs funcs_8888 = +{ + colorref_to_pixel_888 +}; + +const primitive_funcs funcs_null = +{ + colorref_to_pixel_null +}; diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 5849d88..8aa23bd 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -86,6 +86,8 @@ typedef struct void *bits; /* points to the top-left corner of the dib. */
DWORD red_mask, green_mask, blue_mask; + + const struct primitive_funcs *funcs; } dib_info;
typedef struct dibdrv_physdev