2011-04-01 16:27:48 +02:00
|
|
|
/*
|
|
|
|
* DIB driver initialization and DC functions.
|
|
|
|
*
|
|
|
|
* 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 <assert.h>
|
|
|
|
|
|
|
|
#include "gdi_private.h"
|
|
|
|
#include "dibdrv.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dib);
|
|
|
|
|
2011-07-25 15:30:33 +02:00
|
|
|
static const DWORD bit_fields_888[3] = {0xff0000, 0x00ff00, 0x0000ff};
|
|
|
|
static const DWORD bit_fields_555[3] = {0x7c00, 0x03e0, 0x001f};
|
|
|
|
|
2011-04-05 14:26:08 +02:00
|
|
|
static void calc_shift_and_len(DWORD mask, int *shift, int *len)
|
|
|
|
{
|
|
|
|
int s, l;
|
|
|
|
|
2011-04-12 13:49:08 +02:00
|
|
|
if(!mask)
|
|
|
|
{
|
|
|
|
*shift = *len = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-05 14:26:08 +02:00
|
|
|
s = 0;
|
|
|
|
while ((mask & 1) == 0)
|
|
|
|
{
|
|
|
|
mask >>= 1;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
l = 0;
|
|
|
|
while ((mask & 1) == 1)
|
|
|
|
{
|
|
|
|
mask >>= 1;
|
|
|
|
l++;
|
|
|
|
}
|
|
|
|
*shift = s;
|
|
|
|
*len = l;
|
|
|
|
}
|
|
|
|
|
2011-04-05 14:23:20 +02:00
|
|
|
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];
|
2011-04-05 14:26:08 +02:00
|
|
|
calc_shift_and_len(dib->red_mask, &dib->red_shift, &dib->red_len);
|
|
|
|
calc_shift_and_len(dib->green_mask, &dib->green_shift, &dib->green_len);
|
|
|
|
calc_shift_and_len(dib->blue_mask, &dib->blue_shift, &dib->blue_len);
|
2011-04-05 14:23:20 +02:00
|
|
|
}
|
|
|
|
|
2011-05-27 15:17:20 +02:00
|
|
|
static BOOL init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD *bit_fields,
|
2011-07-12 17:12:05 +02:00
|
|
|
RGBQUAD *color_table, int color_table_size, void *bits, enum dib_info_flags flags)
|
2011-04-01 16:27:48 +02:00
|
|
|
{
|
|
|
|
dib->bit_count = bi->biBitCount;
|
|
|
|
dib->width = bi->biWidth;
|
|
|
|
dib->height = bi->biHeight;
|
2011-07-19 14:09:03 +02:00
|
|
|
dib->stride = get_dib_stride( dib->width, dib->bit_count );
|
2011-04-01 16:27:48 +02:00
|
|
|
dib->bits = bits;
|
2011-07-12 17:12:04 +02:00
|
|
|
dib->ptr_to_free = NULL;
|
2011-07-12 17:12:05 +02:00
|
|
|
dib->flags = flags;
|
2011-04-01 16:27:48 +02:00
|
|
|
|
|
|
|
if(dib->height < 0) /* top-down */
|
|
|
|
{
|
|
|
|
dib->height = -dib->height;
|
|
|
|
}
|
|
|
|
else /* bottom-up */
|
|
|
|
{
|
|
|
|
/* bits always points to the top-left corner and the stride is -ve */
|
|
|
|
dib->bits = (BYTE*)dib->bits + (dib->height - 1) * dib->stride;
|
|
|
|
dib->stride = -dib->stride;
|
|
|
|
}
|
|
|
|
|
2011-04-05 14:23:20 +02:00
|
|
|
dib->funcs = &funcs_null;
|
|
|
|
|
2011-04-01 16:27:48 +02:00
|
|
|
switch(dib->bit_count)
|
|
|
|
{
|
2011-04-05 14:23:20 +02:00
|
|
|
case 32:
|
2011-04-12 13:49:08 +02:00
|
|
|
if(bi->biCompression == BI_RGB)
|
2011-05-11 16:13:40 +02:00
|
|
|
bit_fields = bit_fields_888;
|
|
|
|
|
|
|
|
init_bit_fields(dib, bit_fields);
|
|
|
|
|
|
|
|
if(dib->red_mask == 0xff0000 && dib->green_mask == 0x00ff00 && dib->blue_mask == 0x0000ff)
|
2011-04-07 14:47:18 +02:00
|
|
|
dib->funcs = &funcs_8888;
|
|
|
|
else
|
2011-05-11 16:13:40 +02:00
|
|
|
dib->funcs = &funcs_32;
|
2011-04-07 14:47:18 +02:00
|
|
|
break;
|
2011-04-05 14:23:20 +02:00
|
|
|
|
2011-06-01 10:41:39 +02:00
|
|
|
case 24:
|
|
|
|
dib->funcs = &funcs_24;
|
|
|
|
break;
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
case 16:
|
|
|
|
if(bi->biCompression == BI_RGB)
|
|
|
|
bit_fields = bit_fields_555;
|
|
|
|
|
|
|
|
init_bit_fields(dib, bit_fields);
|
|
|
|
|
|
|
|
if(dib->red_mask == 0x7c00 && dib->green_mask == 0x03e0 && dib->blue_mask == 0x001f)
|
|
|
|
dib->funcs = &funcs_555;
|
|
|
|
else
|
|
|
|
dib->funcs = &funcs_16;
|
|
|
|
break;
|
|
|
|
|
2011-05-27 15:26:02 +02:00
|
|
|
case 8:
|
|
|
|
dib->funcs = &funcs_8;
|
|
|
|
break;
|
|
|
|
|
2011-05-31 11:02:03 +02:00
|
|
|
case 4:
|
|
|
|
dib->funcs = &funcs_4;
|
|
|
|
break;
|
|
|
|
|
2011-06-15 14:43:49 +02:00
|
|
|
case 1:
|
|
|
|
dib->funcs = &funcs_1;
|
|
|
|
break;
|
|
|
|
|
2011-04-01 16:27:48 +02:00
|
|
|
default:
|
|
|
|
TRACE("bpp %d not supported, will forward to graphics driver.\n", dib->bit_count);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:17:20 +02:00
|
|
|
if(color_table)
|
|
|
|
{
|
2011-07-12 17:12:05 +02:00
|
|
|
if (flags & private_color_table)
|
|
|
|
{
|
|
|
|
dib->color_table = HeapAlloc(GetProcessHeap(), 0, color_table_size * sizeof(dib->color_table[0]));
|
|
|
|
if(!dib->color_table) return FALSE;
|
|
|
|
memcpy(dib->color_table, color_table, color_table_size * sizeof(color_table[0]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dib->color_table = color_table;
|
2011-05-27 15:17:20 +02:00
|
|
|
dib->color_table_size = color_table_size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dib->color_table = NULL;
|
|
|
|
dib->color_table_size = 0;
|
|
|
|
}
|
|
|
|
|
2011-04-01 16:27:48 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:17:20 +02:00
|
|
|
BOOL init_dib_info_from_packed(dib_info *dib, const BITMAPINFOHEADER *bi, WORD usage, HPALETTE palette)
|
2011-05-12 13:05:37 +02:00
|
|
|
{
|
|
|
|
DWORD *masks = NULL;
|
2011-05-27 15:17:20 +02:00
|
|
|
RGBQUAD *color_table = NULL, pal_table[256];
|
2011-05-12 13:05:37 +02:00
|
|
|
BYTE *ptr = (BYTE*)bi + bi->biSize;
|
2011-07-28 16:34:14 +02:00
|
|
|
int num_colors = get_dib_num_of_colors( (const BITMAPINFO *)bi );
|
2011-05-12 13:05:37 +02:00
|
|
|
|
|
|
|
if(bi->biCompression == BI_BITFIELDS)
|
|
|
|
{
|
|
|
|
masks = (DWORD *)ptr;
|
|
|
|
ptr += 3 * sizeof(DWORD);
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:17:20 +02:00
|
|
|
if(num_colors)
|
|
|
|
{
|
|
|
|
if(usage == DIB_PAL_COLORS)
|
|
|
|
{
|
|
|
|
PALETTEENTRY entries[256];
|
|
|
|
const WORD *index = (const WORD*) ptr;
|
|
|
|
UINT i, count = GetPaletteEntries( palette, 0, num_colors, entries );
|
|
|
|
for (i = 0; i < num_colors; i++, index++)
|
|
|
|
{
|
|
|
|
PALETTEENTRY *entry = &entries[*index % count];
|
|
|
|
pal_table[i].rgbRed = entry->peRed;
|
|
|
|
pal_table[i].rgbGreen = entry->peGreen;
|
|
|
|
pal_table[i].rgbBlue = entry->peBlue;
|
|
|
|
pal_table[i].rgbReserved = 0;
|
|
|
|
}
|
|
|
|
color_table = pal_table;
|
|
|
|
ptr += num_colors * sizeof(WORD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
color_table = (RGBQUAD*)ptr;
|
|
|
|
ptr += num_colors * sizeof(*color_table);
|
|
|
|
}
|
|
|
|
}
|
2011-05-12 13:05:37 +02:00
|
|
|
|
2011-07-12 17:12:05 +02:00
|
|
|
return init_dib_info(dib, bi, masks, color_table, num_colors, ptr, private_color_table);
|
2011-05-12 13:05:37 +02:00
|
|
|
}
|
|
|
|
|
2011-07-18 16:27:43 +02:00
|
|
|
BOOL init_dib_info_from_bitmapinfo(dib_info *dib, const BITMAPINFO *info, void *bits, enum dib_info_flags flags)
|
|
|
|
{
|
2011-07-28 16:34:14 +02:00
|
|
|
unsigned int colors = get_dib_num_of_colors( info );
|
2011-07-18 16:27:43 +02:00
|
|
|
void *colorptr = (char *)&info->bmiHeader + info->bmiHeader.biSize;
|
|
|
|
const DWORD *bitfields = (info->bmiHeader.biCompression == BI_BITFIELDS) ? (DWORD *)colorptr : NULL;
|
|
|
|
|
|
|
|
return init_dib_info( dib, &info->bmiHeader, bitfields, colors ? colorptr : NULL, colors, bits, flags );
|
|
|
|
}
|
|
|
|
|
2011-05-12 12:27:35 +02:00
|
|
|
static void clear_dib_info(dib_info *dib)
|
|
|
|
{
|
2011-05-27 15:17:20 +02:00
|
|
|
dib->color_table = NULL;
|
2011-05-12 12:27:35 +02:00
|
|
|
dib->bits = NULL;
|
2011-07-12 17:12:04 +02:00
|
|
|
dib->ptr_to_free = NULL;
|
2011-05-12 12:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* free_dib_info
|
|
|
|
*
|
|
|
|
* Free the resources associated with a dib and optionally the bits
|
|
|
|
*/
|
2011-07-12 17:12:04 +02:00
|
|
|
void free_dib_info(dib_info *dib)
|
2011-05-12 12:27:35 +02:00
|
|
|
{
|
2011-07-12 17:12:05 +02:00
|
|
|
if (dib->flags & private_color_table)
|
|
|
|
HeapFree(GetProcessHeap(), 0, dib->color_table);
|
2011-05-27 15:17:20 +02:00
|
|
|
dib->color_table = NULL;
|
2011-07-12 17:12:04 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, dib->ptr_to_free);
|
|
|
|
dib->ptr_to_free = NULL;
|
|
|
|
dib->bits = NULL;
|
2011-05-12 12:27:35 +02:00
|
|
|
}
|
|
|
|
|
2011-05-12 13:05:37 +02:00
|
|
|
void copy_dib_color_info(dib_info *dst, const dib_info *src)
|
|
|
|
{
|
|
|
|
dst->bit_count = src->bit_count;
|
|
|
|
dst->red_mask = src->red_mask;
|
|
|
|
dst->green_mask = src->green_mask;
|
|
|
|
dst->blue_mask = src->blue_mask;
|
|
|
|
dst->red_len = src->red_len;
|
|
|
|
dst->green_len = src->green_len;
|
|
|
|
dst->blue_len = src->blue_len;
|
|
|
|
dst->red_shift = src->red_shift;
|
|
|
|
dst->green_shift = src->green_shift;
|
|
|
|
dst->blue_shift = src->blue_shift;
|
|
|
|
dst->funcs = src->funcs;
|
2011-05-27 15:17:20 +02:00
|
|
|
dst->color_table_size = src->color_table_size;
|
|
|
|
dst->color_table = NULL;
|
2011-07-12 17:12:05 +02:00
|
|
|
dst->flags = src->flags;
|
2011-05-27 15:17:20 +02:00
|
|
|
if(dst->color_table_size)
|
|
|
|
{
|
|
|
|
int size = dst->color_table_size * sizeof(dst->color_table[0]);
|
2011-07-12 17:12:05 +02:00
|
|
|
if (dst->flags & private_color_table)
|
|
|
|
{
|
|
|
|
dst->color_table = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
memcpy(dst->color_table, src->color_table, size);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dst->color_table = src->color_table;
|
2011-05-27 15:17:20 +02:00
|
|
|
}
|
2011-05-12 13:05:37 +02:00
|
|
|
}
|
|
|
|
|
2011-07-18 16:27:43 +02:00
|
|
|
DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, const RECT *src_rect,
|
|
|
|
const BITMAPINFO *dst_info, void *dst_bits )
|
2011-05-12 13:05:37 +02:00
|
|
|
{
|
2011-07-18 16:27:43 +02:00
|
|
|
dib_info src_dib, dst_dib;
|
|
|
|
DWORD ret;
|
2011-05-12 13:05:37 +02:00
|
|
|
|
2011-07-18 16:27:43 +02:00
|
|
|
if ( !init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, 0 ) )
|
|
|
|
return ERROR_BAD_FORMAT;
|
|
|
|
if ( !init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, 0 ) )
|
|
|
|
return ERROR_BAD_FORMAT;
|
2011-05-12 13:05:37 +02:00
|
|
|
|
2011-07-18 16:27:43 +02:00
|
|
|
ret = dst_dib.funcs->convert_to( &dst_dib, &src_dib, src_rect );
|
2011-05-12 13:05:37 +02:00
|
|
|
|
2011-07-18 16:27:43 +02:00
|
|
|
/* We shared the color tables, so there's no need to free the dib_infos here */
|
2011-05-27 14:41:32 +02:00
|
|
|
|
2011-07-18 16:27:43 +02:00
|
|
|
if(!ret) return ERROR_BAD_FORMAT;
|
|
|
|
return ERROR_SUCCESS;
|
2011-05-12 13:05:37 +02:00
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:48 +02:00
|
|
|
static void update_fg_colors( dibdrv_physdev *pdev )
|
|
|
|
{
|
|
|
|
pdev->pen_color = get_fg_color( pdev, pdev->pen_colorref );
|
|
|
|
pdev->brush_color = get_fg_color( pdev, pdev->brush_colorref );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_masks( dibdrv_physdev *pdev, INT rop )
|
|
|
|
{
|
|
|
|
calc_and_xor_masks( rop, pdev->pen_color, &pdev->pen_and, &pdev->pen_xor );
|
|
|
|
update_brush_rop( pdev, rop );
|
|
|
|
if( GetBkMode( pdev->dev.hdc ) == OPAQUE )
|
|
|
|
calc_and_xor_masks( rop, pdev->bkgnd_color, &pdev->bkgnd_and, &pdev->bkgnd_xor );
|
|
|
|
}
|
|
|
|
|
2011-05-12 12:27:35 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_DeleteDC
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
static BOOL dibdrv_DeleteDC( PHYSDEV dev )
|
2011-05-12 12:27:35 +02:00
|
|
|
{
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
|
|
|
TRACE("(%p)\n", dev);
|
|
|
|
DeleteObject(pdev->clip);
|
2011-05-12 13:05:37 +02:00
|
|
|
free_pattern_brush(pdev);
|
2011-07-12 17:12:04 +02:00
|
|
|
free_dib_info(&pdev->dib);
|
2011-05-12 12:27:35 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-25 15:30:33 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_GetImage
|
|
|
|
*/
|
|
|
|
static DWORD dibdrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
|
|
|
|
struct gdi_image_bits *bits, struct bitblt_coords *src )
|
|
|
|
{
|
|
|
|
TRACE( "%p %p %p\n", dev, hbitmap, info );
|
|
|
|
|
|
|
|
info->bmiHeader.biSize = sizeof(info->bmiHeader);
|
|
|
|
info->bmiHeader.biPlanes = 1;
|
|
|
|
info->bmiHeader.biCompression = BI_RGB;
|
|
|
|
info->bmiHeader.biXPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biYPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biClrUsed = 0;
|
|
|
|
info->bmiHeader.biClrImportant = 0;
|
|
|
|
|
|
|
|
if (hbitmap)
|
|
|
|
{
|
|
|
|
BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP );
|
|
|
|
|
|
|
|
if (!bmp) return ERROR_INVALID_HANDLE;
|
|
|
|
assert(bmp->dib);
|
|
|
|
|
|
|
|
info->bmiHeader.biWidth = bmp->dib->dsBmih.biWidth;
|
|
|
|
info->bmiHeader.biHeight = bmp->dib->dsBmih.biHeight;
|
|
|
|
info->bmiHeader.biBitCount = bmp->dib->dsBmih.biBitCount;
|
|
|
|
info->bmiHeader.biSizeImage = get_dib_image_size( (BITMAPINFO *)&bmp->dib->dsBmih );
|
|
|
|
|
|
|
|
switch (info->bmiHeader.biBitCount)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
if (bmp->color_table)
|
|
|
|
{
|
|
|
|
info->bmiHeader.biClrUsed = min( bmp->nb_colors, 1 << info->bmiHeader.biBitCount );
|
|
|
|
memcpy( info->bmiColors, bmp->color_table, info->bmiHeader.biClrUsed * sizeof(RGBQUAD) );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
if (bmp->dib->dsBmih.biCompression == BI_BITFIELDS &&
|
|
|
|
memcmp( bmp->dib->dsBitfields, bit_fields_555, sizeof(bmp->dib->dsBitfields) ))
|
|
|
|
{
|
|
|
|
info->bmiHeader.biCompression = BI_BITFIELDS;
|
|
|
|
memcpy( info->bmiColors, bmp->dib->dsBitfields, sizeof(bmp->dib->dsBitfields) );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
if (bmp->dib->dsBmih.biCompression == BI_BITFIELDS &&
|
|
|
|
memcmp( bmp->dib->dsBitfields, bit_fields_888, sizeof(bmp->dib->dsBitfields) ))
|
|
|
|
{
|
|
|
|
info->bmiHeader.biCompression = BI_BITFIELDS;
|
|
|
|
memcpy( info->bmiColors, bmp->dib->dsBitfields, sizeof(bmp->dib->dsBitfields) );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (bits)
|
|
|
|
{
|
|
|
|
bits->ptr = bmp->dib->dsBm.bmBits;
|
|
|
|
bits->is_copy = FALSE;
|
|
|
|
bits->free = NULL;
|
|
|
|
}
|
|
|
|
GDI_ReleaseObj( hbitmap );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
|
|
|
|
|
|
|
info->bmiHeader.biWidth = pdev->dib.width;
|
|
|
|
info->bmiHeader.biHeight = pdev->dib.stride > 0 ? -pdev->dib.height : pdev->dib.height;
|
|
|
|
info->bmiHeader.biBitCount = pdev->dib.bit_count;
|
|
|
|
info->bmiHeader.biSizeImage = pdev->dib.height * abs(pdev->dib.stride);
|
|
|
|
|
|
|
|
switch (info->bmiHeader.biBitCount)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
if (pdev->dib.color_table)
|
|
|
|
{
|
|
|
|
info->bmiHeader.biClrUsed = min( pdev->dib.color_table_size, 1 << pdev->dib.bit_count );
|
|
|
|
memcpy( info->bmiColors, pdev->dib.color_table,
|
|
|
|
info->bmiHeader.biClrUsed * sizeof(RGBQUAD) );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
if (pdev->dib.funcs != &funcs_555)
|
|
|
|
{
|
|
|
|
DWORD *masks = (DWORD *)info->bmiColors;
|
|
|
|
masks[0] = pdev->dib.red_mask;
|
|
|
|
masks[1] = pdev->dib.green_mask;
|
|
|
|
masks[2] = pdev->dib.blue_mask;
|
|
|
|
info->bmiHeader.biCompression = BI_BITFIELDS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
if (pdev->dib.funcs != &funcs_8888)
|
|
|
|
{
|
|
|
|
DWORD *masks = (DWORD *)info->bmiColors;
|
|
|
|
masks[0] = pdev->dib.red_mask;
|
|
|
|
masks[1] = pdev->dib.green_mask;
|
|
|
|
masks[2] = pdev->dib.blue_mask;
|
|
|
|
info->bmiHeader.biCompression = BI_BITFIELDS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (bits)
|
|
|
|
{
|
|
|
|
bits->ptr = pdev->dib.bits;
|
|
|
|
if (pdev->dib.stride < 0)
|
|
|
|
bits->ptr = (char *)bits->ptr + (pdev->dib.height - 1) * pdev->dib.stride;
|
|
|
|
bits->is_copy = FALSE;
|
|
|
|
bits->free = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-04-01 16:27:48 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_SelectBitmap
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
static HBITMAP dibdrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
|
2011-04-01 16:27:48 +02:00
|
|
|
{
|
|
|
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectBitmap );
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
|
|
|
BITMAPOBJ *bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
|
|
|
|
TRACE("(%p, %p)\n", dev, bitmap);
|
|
|
|
|
|
|
|
if (!bmp) return 0;
|
|
|
|
assert(bmp->dib);
|
|
|
|
|
2011-04-13 15:57:44 +02:00
|
|
|
pdev->clip = CreateRectRgn(0, 0, 0, 0);
|
2011-04-07 14:47:18 +02:00
|
|
|
pdev->defer = 0;
|
|
|
|
|
2011-05-12 12:27:35 +02:00
|
|
|
clear_dib_info(&pdev->dib);
|
2011-05-12 13:05:37 +02:00
|
|
|
clear_dib_info(&pdev->brush_dib);
|
|
|
|
pdev->brush_and_bits = pdev->brush_xor_bits = NULL;
|
2011-05-12 12:27:35 +02:00
|
|
|
|
2011-05-27 15:17:20 +02:00
|
|
|
if(!init_dib_info(&pdev->dib, &bmp->dib->dsBmih, bmp->dib->dsBitfields,
|
2011-07-12 17:12:05 +02:00
|
|
|
bmp->color_table, bmp->nb_colors, bmp->dib->dsBm.bmBits, private_color_table))
|
2011-04-07 14:47:18 +02:00
|
|
|
pdev->defer |= DEFER_FORMAT;
|
2011-04-01 16:27:48 +02:00
|
|
|
|
|
|
|
GDI_ReleaseObj( bitmap );
|
|
|
|
|
|
|
|
return next->funcs->pSelectBitmap( next, bitmap );
|
|
|
|
}
|
|
|
|
|
2011-05-06 12:21:13 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_SetBkColor
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
static COLORREF dibdrv_SetBkColor( PHYSDEV dev, COLORREF color )
|
2011-05-06 12:21:13 +02:00
|
|
|
{
|
|
|
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetBkColor );
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
|
|
|
|
|
|
|
pdev->bkgnd_color = pdev->dib.funcs->colorref_to_pixel( &pdev->dib, color );
|
|
|
|
|
|
|
|
if( GetBkMode(dev->hdc) == OPAQUE )
|
|
|
|
calc_and_xor_masks( GetROP2(dev->hdc), pdev->bkgnd_color, &pdev->bkgnd_and, &pdev->bkgnd_xor );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pdev->bkgnd_and = ~0u;
|
|
|
|
pdev->bkgnd_xor = 0;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:49 +02:00
|
|
|
update_fg_colors( pdev ); /* Only needed in the 1 bpp case */
|
|
|
|
|
2011-05-06 12:21:13 +02:00
|
|
|
return next->funcs->pSetBkColor( next, color );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_SetBkMode
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
static INT dibdrv_SetBkMode( PHYSDEV dev, INT mode )
|
2011-05-06 12:21:13 +02:00
|
|
|
{
|
|
|
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetBkMode );
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
|
|
|
|
|
|
|
if( mode == OPAQUE )
|
|
|
|
calc_and_xor_masks( GetROP2(dev->hdc), pdev->bkgnd_color, &pdev->bkgnd_and, &pdev->bkgnd_xor );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pdev->bkgnd_and = ~0u;
|
|
|
|
pdev->bkgnd_xor = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return next->funcs->pSetBkMode( next, mode );
|
|
|
|
}
|
|
|
|
|
2011-04-13 15:57:44 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_SetDeviceClipping
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
static void dibdrv_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn )
|
2011-04-13 15:57:44 +02:00
|
|
|
{
|
|
|
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetDeviceClipping );
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
|
|
|
TRACE("(%p, %p, %p)\n", dev, vis_rgn, clip_rgn);
|
|
|
|
|
|
|
|
CombineRgn( pdev->clip, vis_rgn, clip_rgn, clip_rgn ? RGN_AND : RGN_COPY );
|
|
|
|
return next->funcs->pSetDeviceClipping( next, vis_rgn, clip_rgn);
|
|
|
|
}
|
|
|
|
|
2011-06-02 13:22:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_SetDIBColorTable
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
static UINT dibdrv_SetDIBColorTable( PHYSDEV dev, UINT pos, UINT count, const RGBQUAD *colors )
|
2011-06-02 13:22:02 +02:00
|
|
|
{
|
|
|
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetDIBColorTable );
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
|
|
|
TRACE("(%p, %d, %d, %p)\n", dev, pos, count, colors);
|
|
|
|
|
|
|
|
if( pdev->dib.color_table && pos < pdev->dib.color_table_size )
|
|
|
|
{
|
|
|
|
if( pos + count > pdev->dib.color_table_size ) count = pdev->dib.color_table_size - pos;
|
|
|
|
memcpy( pdev->dib.color_table + pos, colors, count * sizeof(RGBQUAD) );
|
|
|
|
|
|
|
|
pdev->bkgnd_color = pdev->dib.funcs->colorref_to_pixel( &pdev->dib, GetBkColor( dev->hdc ) );
|
2011-06-15 14:43:48 +02:00
|
|
|
update_fg_colors( pdev );
|
2011-06-02 13:22:02 +02:00
|
|
|
|
|
|
|
update_masks( pdev, GetROP2( dev->hdc ) );
|
|
|
|
}
|
|
|
|
return next->funcs->pSetDIBColorTable( next, pos, count, colors );
|
|
|
|
}
|
|
|
|
|
2011-04-07 14:48:39 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_SetROP2
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
static INT dibdrv_SetROP2( PHYSDEV dev, INT rop )
|
2011-04-07 14:48:39 +02:00
|
|
|
{
|
|
|
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetROP2 );
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
|
|
|
|
2011-06-02 13:22:02 +02:00
|
|
|
update_masks( pdev, rop );
|
2011-04-07 14:48:39 +02:00
|
|
|
|
|
|
|
return next->funcs->pSetROP2( next, rop );
|
|
|
|
}
|
|
|
|
|
2011-04-01 16:27:48 +02:00
|
|
|
const DC_FUNCTIONS dib_driver =
|
|
|
|
{
|
|
|
|
NULL, /* pAbortDoc */
|
|
|
|
NULL, /* pAbortPath */
|
|
|
|
NULL, /* pAlphaBlend */
|
|
|
|
NULL, /* pAngleArc */
|
|
|
|
NULL, /* pArc */
|
|
|
|
NULL, /* pArcTo */
|
|
|
|
NULL, /* pBeginPath */
|
|
|
|
NULL, /* pChoosePixelFormat */
|
|
|
|
NULL, /* pChord */
|
|
|
|
NULL, /* pCloseFigure */
|
|
|
|
NULL, /* pCreateBitmap */
|
|
|
|
NULL, /* pCreateDC */
|
|
|
|
NULL, /* pCreateDIBSection */
|
|
|
|
NULL, /* pDeleteBitmap */
|
|
|
|
dibdrv_DeleteDC, /* pDeleteDC */
|
|
|
|
NULL, /* pDeleteObject */
|
|
|
|
NULL, /* pDescribePixelFormat */
|
|
|
|
NULL, /* pDeviceCapabilities */
|
|
|
|
NULL, /* pEllipse */
|
|
|
|
NULL, /* pEndDoc */
|
|
|
|
NULL, /* pEndPage */
|
|
|
|
NULL, /* pEndPath */
|
|
|
|
NULL, /* pEnumDeviceFonts */
|
|
|
|
NULL, /* pEnumICMProfiles */
|
|
|
|
NULL, /* pExcludeClipRect */
|
|
|
|
NULL, /* pExtDeviceMode */
|
|
|
|
NULL, /* pExtEscape */
|
|
|
|
NULL, /* pExtFloodFill */
|
|
|
|
NULL, /* pExtSelectClipRgn */
|
|
|
|
NULL, /* pExtTextOut */
|
|
|
|
NULL, /* pFillPath */
|
|
|
|
NULL, /* pFillRgn */
|
|
|
|
NULL, /* pFlattenPath */
|
|
|
|
NULL, /* pFrameRgn */
|
|
|
|
NULL, /* pGdiComment */
|
|
|
|
NULL, /* pGetCharWidth */
|
|
|
|
NULL, /* pGetDeviceCaps */
|
|
|
|
NULL, /* pGetDeviceGammaRamp */
|
|
|
|
NULL, /* pGetICMProfile */
|
2011-07-25 15:30:33 +02:00
|
|
|
dibdrv_GetImage, /* pGetImage */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pGetNearestColor */
|
|
|
|
NULL, /* pGetPixel */
|
|
|
|
NULL, /* pGetPixelFormat */
|
|
|
|
NULL, /* pGetSystemPaletteEntries */
|
|
|
|
NULL, /* pGetTextExtentExPoint */
|
|
|
|
NULL, /* pGetTextMetrics */
|
|
|
|
NULL, /* pIntersectClipRect */
|
|
|
|
NULL, /* pInvertRgn */
|
2011-04-07 14:49:33 +02:00
|
|
|
dibdrv_LineTo, /* pLineTo */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pModifyWorldTransform */
|
|
|
|
NULL, /* pMoveTo */
|
|
|
|
NULL, /* pOffsetClipRgn */
|
|
|
|
NULL, /* pOffsetViewportOrg */
|
|
|
|
NULL, /* pOffsetWindowOrg */
|
2011-05-16 12:29:04 +02:00
|
|
|
dibdrv_PaintRgn, /* pPaintRgn */
|
2011-04-11 11:07:12 +02:00
|
|
|
dibdrv_PatBlt, /* pPatBlt */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pPie */
|
|
|
|
NULL, /* pPolyBezier */
|
|
|
|
NULL, /* pPolyBezierTo */
|
|
|
|
NULL, /* pPolyDraw */
|
|
|
|
NULL, /* pPolyPolygon */
|
|
|
|
NULL, /* pPolyPolyline */
|
|
|
|
NULL, /* pPolygon */
|
|
|
|
NULL, /* pPolyline */
|
|
|
|
NULL, /* pPolylineTo */
|
2011-07-14 11:30:58 +02:00
|
|
|
NULL, /* pPutImage */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pRealizeDefaultPalette */
|
|
|
|
NULL, /* pRealizePalette */
|
2011-05-13 14:28:15 +02:00
|
|
|
dibdrv_Rectangle, /* pRectangle */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pResetDC */
|
|
|
|
NULL, /* pRestoreDC */
|
|
|
|
NULL, /* pRoundRect */
|
|
|
|
NULL, /* pSaveDC */
|
|
|
|
NULL, /* pScaleViewportExt */
|
|
|
|
NULL, /* pScaleWindowExt */
|
|
|
|
dibdrv_SelectBitmap, /* pSelectBitmap */
|
2011-04-11 11:00:28 +02:00
|
|
|
dibdrv_SelectBrush, /* pSelectBrush */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pSelectClipPath */
|
|
|
|
NULL, /* pSelectFont */
|
|
|
|
NULL, /* pSelectPalette */
|
2011-04-07 14:46:33 +02:00
|
|
|
dibdrv_SelectPen, /* pSelectPen */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pSetArcDirection */
|
|
|
|
NULL, /* pSetBitmapBits */
|
2011-05-06 12:21:13 +02:00
|
|
|
dibdrv_SetBkColor, /* pSetBkColor */
|
|
|
|
dibdrv_SetBkMode, /* pSetBkMode */
|
2011-04-11 11:00:28 +02:00
|
|
|
dibdrv_SetDCBrushColor, /* pSetDCBrushColor */
|
2011-04-07 14:47:59 +02:00
|
|
|
dibdrv_SetDCPenColor, /* pSetDCPenColor */
|
2011-06-02 13:22:02 +02:00
|
|
|
dibdrv_SetDIBColorTable, /* pSetDIBColorTable */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pSetDIBitsToDevice */
|
2011-04-13 15:57:44 +02:00
|
|
|
dibdrv_SetDeviceClipping, /* pSetDeviceClipping */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pSetDeviceGammaRamp */
|
|
|
|
NULL, /* pSetLayout */
|
|
|
|
NULL, /* pSetMapMode */
|
|
|
|
NULL, /* pSetMapperFlags */
|
|
|
|
NULL, /* pSetPixel */
|
|
|
|
NULL, /* pSetPixelFormat */
|
|
|
|
NULL, /* pSetPolyFillMode */
|
2011-04-07 14:48:39 +02:00
|
|
|
dibdrv_SetROP2, /* pSetROP2 */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pSetRelAbs */
|
|
|
|
NULL, /* pSetStretchBltMode */
|
|
|
|
NULL, /* pSetTextAlign */
|
|
|
|
NULL, /* pSetTextCharacterExtra */
|
|
|
|
NULL, /* pSetTextColor */
|
|
|
|
NULL, /* pSetTextJustification */
|
|
|
|
NULL, /* pSetViewportExt */
|
|
|
|
NULL, /* pSetViewportOrg */
|
|
|
|
NULL, /* pSetWindowExt */
|
|
|
|
NULL, /* pSetWindowOrg */
|
|
|
|
NULL, /* pSetWorldTransform */
|
|
|
|
NULL, /* pStartDoc */
|
|
|
|
NULL, /* pStartPage */
|
|
|
|
NULL, /* pStretchBlt */
|
|
|
|
NULL, /* pStretchDIBits */
|
|
|
|
NULL, /* pStrokeAndFillPath */
|
|
|
|
NULL, /* pStrokePath */
|
|
|
|
NULL, /* pSwapBuffers */
|
|
|
|
NULL, /* pUnrealizePalette */
|
|
|
|
NULL, /* pWidenPath */
|
|
|
|
NULL, /* pwglCopyContext */
|
|
|
|
NULL, /* pwglCreateContext */
|
|
|
|
NULL, /* pwglCreateContextAttribsARB */
|
|
|
|
NULL, /* pwglDeleteContext */
|
|
|
|
NULL, /* pwglGetPbufferDCARB */
|
2011-07-13 14:22:59 +02:00
|
|
|
NULL, /* pwglGetProcAddress */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pwglMakeContextCurrentARB */
|
2011-07-13 14:22:59 +02:00
|
|
|
NULL, /* pwglMakeCurrent */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pwglSetPixelFormatWINE */
|
|
|
|
NULL, /* pwglShareLists */
|
|
|
|
NULL, /* pwglUseFontBitmapsA */
|
|
|
|
NULL /* pwglUseFontBitmapsW */
|
|
|
|
};
|