Commit 1e83fd00 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Use the gdi_image_bits structure to maintain the dib driver's bits.

parent 2e908e06
......@@ -73,8 +73,10 @@ static BOOL init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD
dib->width = bi->biWidth;
dib->height = bi->biHeight;
dib->stride = get_dib_stride( dib->width, dib->bit_count );
dib->bits = bits;
dib->ptr_to_free = NULL;
dib->bits.ptr = bits;
dib->bits.is_copy = FALSE;
dib->bits.free = NULL;
dib->bits.param = NULL;
dib->flags = flags;
if(dib->height < 0) /* top-down */
......@@ -84,7 +86,7 @@ static BOOL init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD
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->bits.ptr = (BYTE*)dib->bits.ptr + (dib->height - 1) * dib->stride;
dib->stride = -dib->stride;
}
......@@ -211,8 +213,9 @@ BOOL init_dib_info_from_bitmapinfo(dib_info *dib, const BITMAPINFO *info, void *
static void clear_dib_info(dib_info *dib)
{
dib->color_table = NULL;
dib->bits = NULL;
dib->ptr_to_free = NULL;
dib->bits.ptr = NULL;
dib->bits.free = NULL;
dib->bits.param = NULL;
}
/**********************************************************************
......@@ -224,11 +227,9 @@ void free_dib_info(dib_info *dib)
{
if (dib->flags & private_color_table)
HeapFree(GetProcessHeap(), 0, dib->color_table);
dib->color_table = NULL;
HeapFree(GetProcessHeap(), 0, dib->ptr_to_free);
dib->ptr_to_free = NULL;
dib->bits = NULL;
if (dib->bits.free) dib->bits.free( &dib->bits );
clear_dib_info( dib );
}
void copy_dib_color_info(dib_info *dst, const dib_info *src)
......@@ -423,7 +424,7 @@ static DWORD dibdrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
if (bits)
{
bits->ptr = dib->bits;
bits->ptr = dib->bits.ptr;
if (dib->stride < 0)
bits->ptr = (char *)bits->ptr + (dib->height - 1) * dib->stride;
bits->is_copy = FALSE;
......@@ -479,6 +480,7 @@ static inline BOOL rop_uses_pat(DWORD rop)
return ((rop >> 4) & 0x0f0000) != (rop & 0x0f0000);
}
/***********************************************************************
* dibdrv_PutImage
*/
......@@ -541,6 +543,7 @@ static DWORD dibdrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINF
}
init_dib_info_from_bitmapinfo( &src_dib, info, bits->ptr, 0 );
src_dib.bits.is_copy = bits->is_copy;
origin.x = src->visrect.left;
origin.y = src->visrect.top;
......
......@@ -1089,7 +1089,7 @@ void free_pattern_brush( dibdrv_physdev *pdev )
static BOOL create_pattern_brush_bits(dibdrv_physdev *pdev)
{
DWORD size = pdev->brush_dib.height * abs(pdev->brush_dib.stride);
DWORD *brush_bits = pdev->brush_dib.bits;
DWORD *brush_bits = pdev->brush_dib.bits.ptr;
DWORD *and_bits, *xor_bits;
assert(pdev->brush_and_bits == NULL);
......@@ -1161,7 +1161,9 @@ static BOOL create_hatch_brush_bits(dibdrv_physdev *pdev)
hatch.bit_count = 1;
hatch.height = hatch.width = 8;
hatch.stride = 4;
hatch.bits = (void *) hatches[pdev->brush_hatch];
hatch.bits.ptr = (void *) hatches[pdev->brush_hatch];
hatch.bits.free = hatch.bits.param = NULL;
hatch.bits.is_copy = FALSE;
fg_mask.and = pdev->brush_and;
fg_mask.xor = pdev->brush_xor;
......@@ -1306,8 +1308,12 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush )
pdev->brush_dib.height = orig_dib.height;
pdev->brush_dib.width = orig_dib.width;
pdev->brush_dib.stride = get_dib_stride( pdev->brush_dib.width, pdev->brush_dib.bit_count );
pdev->brush_dib.ptr_to_free = HeapAlloc( GetProcessHeap(), 0, pdev->brush_dib.height * pdev->brush_dib.stride );
pdev->brush_dib.bits = pdev->brush_dib.ptr_to_free;
pdev->brush_dib.bits.param = NULL;
pdev->brush_dib.bits.ptr = HeapAlloc( GetProcessHeap(), 0,
pdev->brush_dib.height * pdev->brush_dib.stride );
pdev->brush_dib.bits.is_copy = TRUE;
pdev->brush_dib.bits.free = free_heap_bits;
rect.left = rect.top = 0;
rect.right = orig_dib.width;
......
......@@ -29,37 +29,37 @@ WINE_DEFAULT_DEBUG_CHANNEL(dib);
static inline DWORD *get_pixel_ptr_32(const dib_info *dib, int x, int y)
{
return (DWORD *)((BYTE*)dib->bits + y * dib->stride + x * 4);
return (DWORD *)((BYTE*)dib->bits.ptr + y * dib->stride + x * 4);
}
static inline DWORD *get_pixel_ptr_24_dword(const dib_info *dib, int x, int y)
{
return (DWORD *)((BYTE*)dib->bits + y * dib->stride) + x * 3 / 4;
return (DWORD *)((BYTE*)dib->bits.ptr + y * dib->stride) + x * 3 / 4;
}
static inline BYTE *get_pixel_ptr_24(const dib_info *dib, int x, int y)
{
return (BYTE*)dib->bits + y * dib->stride + x * 3;
return (BYTE*)dib->bits.ptr + y * dib->stride + x * 3;
}
static inline WORD *get_pixel_ptr_16(const dib_info *dib, int x, int y)
{
return (WORD *)((BYTE*)dib->bits + y * dib->stride + x * 2);
return (WORD *)((BYTE*)dib->bits.ptr + y * dib->stride + x * 2);
}
static inline BYTE *get_pixel_ptr_8(const dib_info *dib, int x, int y)
{
return (BYTE*)dib->bits + y * dib->stride + x;
return (BYTE*)dib->bits.ptr + y * dib->stride + x;
}
static inline BYTE *get_pixel_ptr_4(const dib_info *dib, int x, int y)
{
return (BYTE*)dib->bits + y * dib->stride + x / 2;
return (BYTE*)dib->bits.ptr + y * dib->stride + x / 2;
}
static inline BYTE *get_pixel_ptr_1(const dib_info *dib, int x, int y)
{
return (BYTE*)dib->bits + y * dib->stride + x / 8;
return (BYTE*)dib->bits.ptr + y * dib->stride + x / 8;
}
static const BYTE pixel_masks_1[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
......
......@@ -83,8 +83,7 @@ typedef struct
{
int bit_count, width, height;
int stride; /* stride in bytes. Will be -ve for bottom-up dibs (see bits). */
void *bits; /* points to the top-left corner of the dib. */
void *ptr_to_free;
struct gdi_image_bits bits; /* bits.ptr points to the top-left corner of the dib. */
DWORD red_mask, green_mask, blue_mask;
int red_shift, green_shift, blue_shift;
......
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