From 7223883aaa136bf0a078081796d3bdf45706a8a7 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 4 Apr 2011 16:40:00 -0500 Subject: [PATCH 2/4] gdiplus: Add a software implementation of GdipDrawDriverString. --- dlls/gdiplus/graphics.c | 188 ++++++++++++++++++++++++++++++++++++++++- dlls/gdiplus/tests/graphics.c | 2 - 2 files changed, 187 insertions(+), 3 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index f26561a..d7cc644 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5650,6 +5650,191 @@ static GpStatus GDI32_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT1 return Ok; } +static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT16 *text, INT length, + GDIPCONST GpFont *font, GDIPCONST GpBrush *brush, + GDIPCONST PointF *positions, INT flags, + GDIPCONST GpMatrix *matrix ) +{ + static const INT unsupported_flags = ~(DriverStringOptionsCmapLookup); + GpStatus stat; + PointF *real_positions; + POINT *pti; + HFONT hfont; + HDC hdc; + int min_x=INT_MAX, min_y=INT_MAX, max_x=INT_MIN, max_y=INT_MIN, i, x, y; + DWORD max_glyphsize=0; + GLYPHMETRICS glyphmetrics; + static const MAT2 identity = {{0,1}, {0,0}, {0,0}, {0,1}}; + BYTE *glyph_mask; + BYTE *text_mask; + int text_mask_stride; + BYTE *pixel_data; + int pixel_data_stride; + GpRect pixel_area; + UINT ggo_flags = GGO_GRAY8_BITMAP; + + if (length <= 0) + return Ok; + + if (flags & DriverStringOptionsRealizedAdvance) + { + FIXME("Not implemented for DriverStringOptionsRealizedAdvance\n"); + return NotImplemented; + } + + if (!(flags & DriverStringOptionsCmapLookup)) + ggo_flags |= GGO_GLYPH_INDEX; + + if (flags & unsupported_flags) + FIXME("Ignoring flags %x\n", flags & unsupported_flags); + + if (matrix) + FIXME("Ignoring matrix\n"); + + real_positions = GdipAlloc(sizeof(PointF) * length); + if (!real_positions) + return OutOfMemory; + + pti = GdipAlloc(sizeof(POINT) * length); + if (!pti) + { + GdipFree(real_positions); + return OutOfMemory; + } + + memcpy(real_positions, positions, sizeof(PointF) * length); + + transform_and_round_points(graphics, pti, real_positions, length); + + GdipFree(real_positions); + + get_font_hfont(graphics, font, &hfont); + + hdc = CreateCompatibleDC(0); + SelectObject(hdc, hfont); + + /* Get the boundaries of the text to be drawn */ + for (i=0; i max_glyphsize) + max_glyphsize = glyphsize; + + left = pti[i].x - glyphmetrics.gmptGlyphOrigin.x; + top = pti[i].y - glyphmetrics.gmptGlyphOrigin.y; + right = pti[i].x - glyphmetrics.gmptGlyphOrigin.x + glyphmetrics.gmBlackBoxX; + bottom = pti[i].y - glyphmetrics.gmptGlyphOrigin.y + glyphmetrics.gmBlackBoxY; + + if (left < min_x) min_x = left; + if (top < min_y) min_y = top; + if (right > max_x) max_x = right; + if (bottom > max_y) max_y = bottom; + } + + glyph_mask = GdipAlloc(max_glyphsize); + text_mask = GdipAlloc((max_x - min_x) * (max_y - min_y)); + text_mask_stride = max_x - min_x; + + if (!(glyph_mask && text_mask)) + { + GdipFree(glyph_mask); + GdipFree(text_mask); + GdipFree(pti); + DeleteDC(hdc); + DeleteObject(hfont); + return OutOfMemory; + } + + /* Generate a mask for the text */ + for (i=0; i