Commit 64e2ad57 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Make get_glyph_bitmap return a dib_info structure in order to avoid code duplication.

parent b5691b5e
...@@ -441,24 +441,13 @@ static inline void get_text_bkgnd_masks( dibdrv_physdev *pdev, rop_mask *mask ) ...@@ -441,24 +441,13 @@ static inline void get_text_bkgnd_masks( dibdrv_physdev *pdev, rop_mask *mask )
} }
static void draw_glyph( dibdrv_physdev *pdev, const POINT *origin, const GLYPHMETRICS *metrics, static void draw_glyph( dibdrv_physdev *pdev, const POINT *origin, const GLYPHMETRICS *metrics,
const struct gdi_image_bits *image, DWORD text_color, const dib_info *glyph_dib, DWORD text_color,
const struct intensity_range *ranges, const struct clipped_rects *clipped_rects, const struct intensity_range *ranges, const struct clipped_rects *clipped_rects,
RECT *bounds ) RECT *bounds )
{ {
int i; int i;
RECT rect, clipped_rect; RECT rect, clipped_rect;
POINT src_origin; POINT src_origin;
dib_info glyph_dib;
glyph_dib.bit_count = 8;
glyph_dib.width = metrics->gmBlackBoxX;
glyph_dib.height = metrics->gmBlackBoxY;
glyph_dib.rect.left = 0;
glyph_dib.rect.top = 0;
glyph_dib.rect.right = metrics->gmBlackBoxX;
glyph_dib.rect.bottom = metrics->gmBlackBoxY;
glyph_dib.stride = get_dib_stride( metrics->gmBlackBoxX, 8 );
glyph_dib.bits = *image;
rect.left = origin->x + metrics->gmptGlyphOrigin.x; rect.left = origin->x + metrics->gmptGlyphOrigin.x;
rect.top = origin->y - metrics->gmptGlyphOrigin.y; rect.top = origin->y - metrics->gmptGlyphOrigin.y;
...@@ -473,7 +462,7 @@ static void draw_glyph( dibdrv_physdev *pdev, const POINT *origin, const GLYPHME ...@@ -473,7 +462,7 @@ static void draw_glyph( dibdrv_physdev *pdev, const POINT *origin, const GLYPHME
src_origin.x = clipped_rect.left - rect.left; src_origin.x = clipped_rect.left - rect.left;
src_origin.y = clipped_rect.top - rect.top; src_origin.y = clipped_rect.top - rect.top;
pdev->dib.funcs->draw_glyph( &pdev->dib, &clipped_rect, &glyph_dib, &src_origin, pdev->dib.funcs->draw_glyph( &pdev->dib, &clipped_rect, glyph_dib, &src_origin,
text_color, ranges ); text_color, ranges );
} }
} }
...@@ -491,7 +480,7 @@ static const int padding[4] = {0, 3, 2, 1}; ...@@ -491,7 +480,7 @@ static const int padding[4] = {0, 3, 2, 1};
* using only values 0 or 16. * using only values 0 or 16.
*/ */
static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS *metrics, static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS *metrics,
struct gdi_image_bits *image ) dib_info *glyph_dib )
{ {
UINT ggo_flags = aa_flags | GGO_GLYPH_INDEX; UINT ggo_flags = aa_flags | GGO_GLYPH_INDEX;
static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} }; static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} };
...@@ -499,12 +488,12 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS ...@@ -499,12 +488,12 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS
int i, x, y; int i, x, y;
DWORD ret, size; DWORD ret, size;
BYTE *buf, *dst, *src; BYTE *buf, *dst, *src;
int pad, stride; int pad;
image->ptr = NULL; glyph_dib->bits.ptr = NULL;
image->is_copy = FALSE; glyph_dib->bits.is_copy = FALSE;
image->free = free_heap_bits; glyph_dib->bits.free = free_heap_bits;
image->param = NULL; glyph_dib->bits.param = NULL;
indices[0] = index; indices[0] = index;
...@@ -519,9 +508,17 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS ...@@ -519,9 +508,17 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS
if (!ret) return ERROR_SUCCESS; /* empty glyph */ if (!ret) return ERROR_SUCCESS; /* empty glyph */
/* We'll convert non-antialiased 1-bpp bitmaps to 8-bpp, so these sizes relate to 8-bpp */ /* We'll convert non-antialiased 1-bpp bitmaps to 8-bpp, so these sizes relate to 8-bpp */
glyph_dib->bit_count = 8;
glyph_dib->width = metrics->gmBlackBoxX;
glyph_dib->height = metrics->gmBlackBoxY;
glyph_dib->rect.left = 0;
glyph_dib->rect.top = 0;
glyph_dib->rect.right = metrics->gmBlackBoxX;
glyph_dib->rect.bottom = metrics->gmBlackBoxY;
glyph_dib->stride = get_dib_stride( metrics->gmBlackBoxX, glyph_dib->bit_count );
pad = padding[ metrics->gmBlackBoxX % 4 ]; pad = padding[ metrics->gmBlackBoxX % 4 ];
stride = get_dib_stride( metrics->gmBlackBoxX, 8 ); size = metrics->gmBlackBoxY * glyph_dib->stride;
size = metrics->gmBlackBoxY * stride;
buf = HeapAlloc( GetProcessHeap(), 0, size ); buf = HeapAlloc( GetProcessHeap(), 0, size );
if (!buf) return ERROR_OUTOFMEMORY; if (!buf) return ERROR_OUTOFMEMORY;
...@@ -538,7 +535,7 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS ...@@ -538,7 +535,7 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS
for (y = metrics->gmBlackBoxY - 1; y >= 0; y--) for (y = metrics->gmBlackBoxY - 1; y >= 0; y--)
{ {
src = buf + y * get_dib_stride( metrics->gmBlackBoxX, 1 ); src = buf + y * get_dib_stride( metrics->gmBlackBoxX, 1 );
dst = buf + y * stride; dst = buf + y * glyph_dib->stride;
if (pad) memset( dst + metrics->gmBlackBoxX, 0, pad ); if (pad) memset( dst + metrics->gmBlackBoxX, 0, pad );
...@@ -548,11 +545,11 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS ...@@ -548,11 +545,11 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT aa_flags, GLYPHMETRICS
} }
else if (pad) else if (pad)
{ {
for (y = 0, dst = buf; y < metrics->gmBlackBoxY; y++, dst += stride) for (y = 0, dst = buf; y < metrics->gmBlackBoxY; y++, dst += glyph_dib->stride)
memset( dst + metrics->gmBlackBoxX, 0, pad ); memset( dst + metrics->gmBlackBoxX, 0, pad );
} }
image->ptr = buf; glyph_dib->bits.ptr = buf;
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
...@@ -592,26 +589,15 @@ BOOL render_aa_text_bitmapinfo( HDC hdc, BITMAPINFO *info, struct gdi_image_bits ...@@ -592,26 +589,15 @@ BOOL render_aa_text_bitmapinfo( HDC hdc, BITMAPINFO *info, struct gdi_image_bits
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
GLYPHMETRICS metrics; GLYPHMETRICS metrics;
struct gdi_image_bits image; dib_info glyph_dib;
err = get_glyph_bitmap( hdc, (UINT)str[i], aa_flags, &metrics, &image ); err = get_glyph_bitmap( hdc, (UINT)str[i], aa_flags, &metrics, &glyph_dib );
if (err) continue; if (err) continue;
if (image.ptr) if (glyph_dib.bits.ptr)
{ {
RECT rect, clipped_rect; RECT rect, clipped_rect;
POINT src_origin; POINT src_origin;
dib_info glyph_dib;
glyph_dib.bit_count = 8;
glyph_dib.width = metrics.gmBlackBoxX;
glyph_dib.height = metrics.gmBlackBoxY;
glyph_dib.rect.left = 0;
glyph_dib.rect.top = 0;
glyph_dib.rect.right = metrics.gmBlackBoxX;
glyph_dib.rect.bottom = metrics.gmBlackBoxY;
glyph_dib.stride = get_dib_stride( metrics.gmBlackBoxX, 8 );
glyph_dib.bits = image;
rect.left = x + metrics.gmptGlyphOrigin.x; rect.left = x + metrics.gmptGlyphOrigin.x;
rect.top = y - metrics.gmptGlyphOrigin.y; rect.top = y - metrics.gmptGlyphOrigin.y;
...@@ -627,7 +613,7 @@ BOOL render_aa_text_bitmapinfo( HDC hdc, BITMAPINFO *info, struct gdi_image_bits ...@@ -627,7 +613,7 @@ BOOL render_aa_text_bitmapinfo( HDC hdc, BITMAPINFO *info, struct gdi_image_bits
fg_pixel, glyph_intensities ); fg_pixel, glyph_intensities );
} }
} }
if (image.free) image.free( &image ); free_dib_info( &glyph_dib );
if (dx) if (dx)
{ {
...@@ -698,15 +684,15 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, ...@@ -698,15 +684,15 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
GLYPHMETRICS metrics; GLYPHMETRICS metrics;
struct gdi_image_bits image; dib_info glyph_dib;
err = get_glyph_bitmap( dev->hdc, (UINT)str[i], aa_flags, &metrics, &image ); err = get_glyph_bitmap( dev->hdc, (UINT)str[i], aa_flags, &metrics, &glyph_dib );
if (err) continue; if (err) continue;
if (image.ptr) if (glyph_dib.bits.ptr)
draw_glyph( pdev, &origin, &metrics, &image, text_color, ranges, &clipped_rects, &bounds ); draw_glyph( pdev, &origin, &metrics, &glyph_dib, text_color, ranges, &clipped_rects, &bounds );
if (image.free) image.free( &image ); free_dib_info( &glyph_dib );
if (dx) if (dx)
{ {
......
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