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"
|
|
|
|
|
2011-08-23 12:49:53 +02:00
|
|
|
#include "wine/exception.h"
|
2011-04-01 16:27:48 +02:00
|
|
|
#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-12-06 17:38:14 +01:00
|
|
|
static BOOL init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD *bit_fields,
|
2011-12-12 15:58:05 +01:00
|
|
|
const RGBQUAD *color_table, void *bits, enum dib_info_flags flags)
|
2011-04-01 16:27:48 +02:00
|
|
|
{
|
2011-08-19 17:26:17 +02:00
|
|
|
dib->bit_count = bi->biBitCount;
|
|
|
|
dib->width = bi->biWidth;
|
|
|
|
dib->height = bi->biHeight;
|
2011-11-29 15:12:00 +01:00
|
|
|
dib->compression = bi->biCompression;
|
2011-08-19 17:26:17 +02:00
|
|
|
dib->stride = get_dib_stride( dib->width, dib->bit_count );
|
|
|
|
dib->bits.ptr = bits;
|
|
|
|
dib->bits.is_copy = FALSE;
|
|
|
|
dib->bits.free = NULL;
|
|
|
|
dib->bits.param = NULL;
|
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 */
|
2011-08-19 17:26:17 +02:00
|
|
|
dib->bits.ptr = (BYTE*)dib->bits.ptr + (dib->height - 1) * dib->stride;
|
2011-04-01 16:27:48 +02:00
|
|
|
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-12-10 12:48:33 +01:00
|
|
|
if (color_table && bi->biClrUsed)
|
2011-05-27 15:17:20 +02:00
|
|
|
{
|
2011-12-12 15:58:05 +01:00
|
|
|
dib->color_table = color_table;
|
2011-12-10 12:48:33 +01:00
|
|
|
dib->color_table_size = bi->biClrUsed;
|
2011-05-27 15:17:20 +02:00
|
|
|
}
|
2011-12-12 11:44:11 +01:00
|
|
|
else if (flags & default_color_table)
|
|
|
|
{
|
2011-12-12 15:58:05 +01:00
|
|
|
dib->color_table = get_default_color_table( dib->bit_count );
|
2011-12-12 11:44:11 +01:00
|
|
|
dib->color_table_size = dib->color_table ? (1 << dib->bit_count) : 0;
|
|
|
|
}
|
2011-05-27 15:17:20 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
dib->color_table = NULL;
|
|
|
|
dib->color_table_size = 0;
|
|
|
|
}
|
|
|
|
|
2011-04-01 16:27:48 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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-12-10 12:48:33 +01:00
|
|
|
return init_dib_info( dib, &info->bmiHeader, (const DWORD *)info->bmiColors,
|
2011-12-12 15:58:05 +01:00
|
|
|
info->bmiColors, bits, flags );
|
2011-07-18 16:27:43 +02:00
|
|
|
}
|
|
|
|
|
2011-08-29 15:26:50 +02:00
|
|
|
BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_flags flags)
|
|
|
|
{
|
2011-08-29 15:55:35 +02:00
|
|
|
if (!bmp->dib)
|
|
|
|
{
|
2011-12-12 11:44:11 +01:00
|
|
|
BITMAPINFO info;
|
2011-08-29 15:55:35 +02:00
|
|
|
|
2011-12-12 11:44:11 +01:00
|
|
|
get_ddb_bitmapinfo( bmp, &info );
|
2011-10-31 20:06:37 +01:00
|
|
|
if (!bmp->bitmap.bmBits)
|
|
|
|
{
|
|
|
|
int width_bytes = get_dib_stride( bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel );
|
|
|
|
bmp->bitmap.bmBits = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
bmp->bitmap.bmHeight * width_bytes );
|
|
|
|
if (!bmp->bitmap.bmBits) return FALSE;
|
|
|
|
}
|
2011-12-12 11:44:11 +01:00
|
|
|
return init_dib_info_from_bitmapinfo( dib, &info, bmp->bitmap.bmBits, flags );
|
2011-08-29 15:55:35 +02:00
|
|
|
}
|
2011-08-29 15:26:50 +02:00
|
|
|
return init_dib_info( dib, &bmp->dib->dsBmih, bmp->dib->dsBitfields,
|
2011-12-10 12:48:33 +01:00
|
|
|
bmp->color_table, bmp->dib->dsBm.bmBits, flags );
|
2011-08-29 15:26:50 +02:00
|
|
|
}
|
|
|
|
|
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-08-19 17:26:17 +02:00
|
|
|
dib->bits.ptr = NULL;
|
|
|
|
dib->bits.free = NULL;
|
|
|
|
dib->bits.param = 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-08-19 17:26:17 +02:00
|
|
|
if (dib->bits.free) dib->bits.free( &dib->bits );
|
|
|
|
clear_dib_info( dib );
|
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;
|
2011-12-12 15:58:05 +01:00
|
|
|
dst->color_table = src->color_table;
|
2011-05-12 13:05:37 +02:00
|
|
|
}
|
|
|
|
|
2011-08-03 20:26:44 +02:00
|
|
|
DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bitblt_coords *src,
|
2011-10-12 17:57:02 +02:00
|
|
|
const BITMAPINFO *dst_info, void *dst_bits, BOOL add_alpha )
|
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-12-12 11:44:11 +01:00
|
|
|
if ( !init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, default_color_table ) )
|
2011-07-18 16:27:43 +02:00
|
|
|
return ERROR_BAD_FORMAT;
|
2011-12-12 11:44:11 +01:00
|
|
|
if ( !init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, default_color_table ) )
|
2011-07-18 16:27:43 +02:00
|
|
|
return ERROR_BAD_FORMAT;
|
2011-05-12 13:05:37 +02:00
|
|
|
|
2011-08-23 12:49:53 +02:00
|
|
|
__TRY
|
|
|
|
{
|
2011-10-13 00:15:29 +02:00
|
|
|
dst_dib.funcs->convert_to( &dst_dib, &src_dib, &src->visrect );
|
|
|
|
ret = TRUE;
|
2011-08-23 12:49:53 +02:00
|
|
|
}
|
|
|
|
__EXCEPT_PAGE_FAULT
|
|
|
|
{
|
|
|
|
WARN( "invalid bits pointer %p\n", src_bits );
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
__ENDTRY
|
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 */
|
|
|
|
if(!ret) return ERROR_BAD_FORMAT;
|
2011-08-03 20:26:44 +02:00
|
|
|
|
|
|
|
/* update coordinates, the destination rectangle is always stored at 0,0 */
|
|
|
|
src->x -= src->visrect.left;
|
|
|
|
src->y -= src->visrect.top;
|
|
|
|
offset_rect( &src->visrect, -src->visrect.left, -src->visrect.top );
|
2011-10-12 17:57:02 +02:00
|
|
|
|
|
|
|
if (add_alpha && dst_dib.funcs == &funcs_8888 && src_dib.funcs != &funcs_8888)
|
|
|
|
{
|
|
|
|
DWORD *pixel = dst_dib.bits.ptr;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = src->visrect.top; y < src->visrect.bottom; y++, pixel += dst_dib.stride / 4)
|
|
|
|
for (x = src->visrect.left; x < src->visrect.right; x++)
|
|
|
|
pixel[x] |= 0xff000000;
|
|
|
|
}
|
|
|
|
|
2011-07-18 16:27:43 +02:00
|
|
|
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 )
|
|
|
|
{
|
2011-10-19 13:41:51 +02:00
|
|
|
pdev->pen_color = get_pixel_color( pdev, pdev->pen_colorref, TRUE );
|
|
|
|
pdev->brush_color = get_pixel_color( pdev, pdev->brush_colorref, TRUE );
|
2011-11-14 13:49:02 +01:00
|
|
|
pdev->text_color = get_pixel_color( pdev, GetTextColor( pdev->dev.hdc ), TRUE );
|
2011-06-15 14:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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-08-02 15:11:10 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* add_extra_clipping_region
|
|
|
|
*
|
|
|
|
* Temporarily add a region to the current clipping region.
|
|
|
|
* The returned region must be restored with restore_clipping_region.
|
|
|
|
*/
|
2011-08-23 12:16:30 +02:00
|
|
|
HRGN add_extra_clipping_region( dibdrv_physdev *pdev, HRGN rgn )
|
2011-08-02 15:11:10 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
*/
|
2011-08-23 12:16:30 +02:00
|
|
|
void restore_clipping_region( dibdrv_physdev *pdev, HRGN rgn )
|
2011-08-02 15:11:10 +02:00
|
|
|
{
|
|
|
|
if (!rgn) return;
|
|
|
|
DeleteObject( pdev->clip );
|
|
|
|
pdev->clip = rgn;
|
|
|
|
}
|
|
|
|
|
2011-09-07 23:47:31 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* dibdrv_CreateDC
|
|
|
|
*/
|
|
|
|
static BOOL dibdrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
|
|
|
|
LPCWSTR output, const DEVMODEW *data )
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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-09-07 23:47:31 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, pdev );
|
|
|
|
return TRUE;
|
2011-05-12 12:27:35 +02:00
|
|
|
}
|
|
|
|
|
2011-11-07 22:14:50 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_CopyBitmap
|
|
|
|
*/
|
|
|
|
static BOOL dibdrv_CopyBitmap( HBITMAP src, HBITMAP dst )
|
|
|
|
{
|
|
|
|
return nulldrv_CopyBitmap( src, dst );
|
|
|
|
}
|
|
|
|
|
2011-10-31 20:21:15 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_DeleteBitmap
|
|
|
|
*/
|
|
|
|
static BOOL dibdrv_DeleteBitmap( HBITMAP bitmap )
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2011-09-07 23:47:31 +02:00
|
|
|
free_dib_info(&pdev->dib);
|
2011-04-07 14:47:18 +02:00
|
|
|
pdev->defer = 0;
|
2011-12-12 11:44:11 +01:00
|
|
|
if(!init_dib_info_from_bitmapobj(&pdev->dib, bmp, default_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);
|
|
|
|
|
2011-10-19 13:41:51 +02:00
|
|
|
pdev->bkgnd_color = get_pixel_color( pdev, color, FALSE );
|
2011-05-06 12:21:13 +02:00
|
|
|
|
|
|
|
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-12-06 13:15:35 +01:00
|
|
|
static void dibdrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
|
2011-04-13 15:57:44 +02:00
|
|
|
{
|
|
|
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetDeviceClipping );
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
2011-12-06 13:15:35 +01:00
|
|
|
TRACE("(%p, %p)\n", dev, rgn);
|
2011-04-13 15:57:44 +02:00
|
|
|
|
2011-12-06 13:15:35 +01:00
|
|
|
SetRectRgn( pdev->clip, 0, 0, pdev->dib.width, pdev->dib.height );
|
|
|
|
if (rgn) CombineRgn( pdev->clip, pdev->clip, rgn, RGN_AND );
|
|
|
|
return next->funcs->pSetDeviceClipping( next, rgn );
|
2011-04-13 15:57:44 +02:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2011-12-08 17:04:14 +01:00
|
|
|
if (pdev->dib.color_table)
|
2011-06-02 13:22:02 +02:00
|
|
|
{
|
2011-10-19 13:41:51 +02:00
|
|
|
pdev->bkgnd_color = get_pixel_color( pdev, GetBkColor( dev->hdc ), FALSE );
|
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-11-14 13:49:02 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* dibdrv_SetTextColor
|
|
|
|
*/
|
|
|
|
static COLORREF dibdrv_SetTextColor( PHYSDEV dev, COLORREF color )
|
|
|
|
{
|
|
|
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetTextColor );
|
|
|
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
|
|
|
|
|
|
|
pdev->text_color = get_pixel_color( pdev, color, TRUE );
|
2011-11-14 13:49:05 +01:00
|
|
|
update_aa_ranges( pdev );
|
2011-11-14 13:49:02 +01:00
|
|
|
|
|
|
|
return next->funcs->pSetTextColor( next, color );
|
|
|
|
}
|
|
|
|
|
2011-10-17 20:39:54 +02:00
|
|
|
const struct gdi_dc_funcs dib_driver =
|
2011-04-01 16:27:48 +02:00
|
|
|
{
|
|
|
|
NULL, /* pAbortDoc */
|
|
|
|
NULL, /* pAbortPath */
|
2011-10-11 15:23:04 +02:00
|
|
|
dibdrv_AlphaBlend, /* pAlphaBlend */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pAngleArc */
|
|
|
|
NULL, /* pArc */
|
|
|
|
NULL, /* pArcTo */
|
|
|
|
NULL, /* pBeginPath */
|
2011-10-14 12:30:28 +02:00
|
|
|
dibdrv_BlendImage, /* pBlendImage */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pChoosePixelFormat */
|
|
|
|
NULL, /* pChord */
|
|
|
|
NULL, /* pCloseFigure */
|
2011-11-07 22:14:50 +01:00
|
|
|
dibdrv_CopyBitmap, /* pCopyBitmap */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pCreateBitmap */
|
2011-09-07 15:36:58 +02:00
|
|
|
NULL, /* pCreateCompatibleDC */
|
2011-09-07 23:47:31 +02:00
|
|
|
dibdrv_CreateDC, /* pCreateDC */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pCreateDIBSection */
|
2011-10-31 20:21:15 +01:00
|
|
|
dibdrv_DeleteBitmap, /* pDeleteBitmap */
|
2011-04-01 16:27:48 +02:00
|
|
|
dibdrv_DeleteDC, /* pDeleteDC */
|
|
|
|
NULL, /* pDeleteObject */
|
|
|
|
NULL, /* pDescribePixelFormat */
|
|
|
|
NULL, /* pDeviceCapabilities */
|
|
|
|
NULL, /* pEllipse */
|
|
|
|
NULL, /* pEndDoc */
|
|
|
|
NULL, /* pEndPage */
|
|
|
|
NULL, /* pEndPath */
|
2011-10-19 15:37:10 +02:00
|
|
|
NULL, /* pEnumFonts */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pEnumICMProfiles */
|
|
|
|
NULL, /* pExcludeClipRect */
|
|
|
|
NULL, /* pExtDeviceMode */
|
|
|
|
NULL, /* pExtEscape */
|
|
|
|
NULL, /* pExtFloodFill */
|
|
|
|
NULL, /* pExtSelectClipRgn */
|
2011-11-14 13:49:04 +01:00
|
|
|
dibdrv_ExtTextOut, /* pExtTextOut */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pFillPath */
|
|
|
|
NULL, /* pFillRgn */
|
|
|
|
NULL, /* pFlattenPath */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pFontIsLinked */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pFrameRgn */
|
|
|
|
NULL, /* pGdiComment */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGdiRealizationInfo */
|
|
|
|
NULL, /* pGetCharABCWidths */
|
|
|
|
NULL, /* pGetCharABCWidthsI */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pGetCharWidth */
|
|
|
|
NULL, /* pGetDeviceCaps */
|
|
|
|
NULL, /* pGetDeviceGammaRamp */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetFontData */
|
|
|
|
NULL, /* pGetFontUnicodeRanges */
|
|
|
|
NULL, /* pGetGlyphIndices */
|
|
|
|
NULL, /* pGetGlyphOutline */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pGetICMProfile */
|
2011-07-25 15:30:33 +02:00
|
|
|
dibdrv_GetImage, /* pGetImage */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetKerningPairs */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pGetNearestColor */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetOutlineTextMetrics */
|
2011-10-19 13:41:58 +02:00
|
|
|
dibdrv_GetPixel, /* pGetPixel */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pGetPixelFormat */
|
|
|
|
NULL, /* pGetSystemPaletteEntries */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetTextCharsetInfo */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pGetTextExtentExPoint */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetTextExtentExPointI */
|
|
|
|
NULL, /* pGetTextFace */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pGetTextMetrics */
|
2011-11-28 13:21:52 +01:00
|
|
|
dibdrv_GradientFill, /* pGradientFill */
|
2011-04-01 16:27:48 +02:00
|
|
|
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 */
|
2011-08-19 17:26:19 +02:00
|
|
|
dibdrv_PolyPolyline, /* pPolyPolyline */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pPolygon */
|
2011-08-19 17:26:19 +02:00
|
|
|
dibdrv_Polyline, /* pPolyline */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pPolylineTo */
|
2011-08-02 15:11:10 +02:00
|
|
|
dibdrv_PutImage, /* 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 */
|
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 */
|
2011-10-19 13:41:55 +02:00
|
|
|
dibdrv_SetPixel, /* pSetPixel */
|
2011-04-01 16:27:48 +02:00
|
|
|
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 */
|
2011-11-14 13:49:02 +01:00
|
|
|
dibdrv_SetTextColor, /* pSetTextColor */
|
2011-04-01 16:27:48 +02:00
|
|
|
NULL, /* pSetTextJustification */
|
|
|
|
NULL, /* pSetViewportExt */
|
|
|
|
NULL, /* pSetViewportOrg */
|
|
|
|
NULL, /* pSetWindowExt */
|
|
|
|
NULL, /* pSetWindowOrg */
|
|
|
|
NULL, /* pSetWorldTransform */
|
|
|
|
NULL, /* pStartDoc */
|
|
|
|
NULL, /* pStartPage */
|
2011-09-27 17:13:39 +02:00
|
|
|
dibdrv_StretchBlt, /* pStretchBlt */
|
2011-04-01 16:27:48 +02:00
|
|
|
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 */
|
|
|
|
};
|