Commit 0c5e7a6d authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Add a dib primitive function table.

parent ea8b32ce
......@@ -15,6 +15,7 @@ C_SRCS = \
dc.c \
dib.c \
dibdrv/dc.c \
dibdrv/primitives.c \
driver.c \
enhmetafile.c \
enhmfdrv/bitblt.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;
......
......@@ -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;
/*
* 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
};
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment