From: Olivier Lauffenburger Date: Thu, 6 Jul 2017 15:27:00 +0000 (-0600) Subject: st/wgl: Implement wglUseFontBitmaps. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=43dea65ad2e8259330849aa7a3e1ed86db5a5d0f;p=mesa.git st/wgl: Implement wglUseFontBitmaps. wglUseFontBitmaps is currently a noop. This patch implements this function for Windows. Misc code clean-ups by Brian. Signed-off-by: Olivier Lauffenburger Reviewed-by: Brian Paul --- diff --git a/src/gallium/state_trackers/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/stw_wgl.c index de4b4f6f3b0..532a5adb955 100644 --- a/src/gallium/state_trackers/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/stw_wgl.c @@ -214,14 +214,7 @@ wglUseFontBitmapsA( DWORD count, DWORD listBase ) { - (void) hdc; - (void) first; - (void) count; - (void) listBase; - - assert( 0 ); - - return FALSE; + return wglUseFontBitmapsW(hdc, first, count, listBase); } WINGDIAPI BOOL APIENTRY @@ -240,14 +233,54 @@ wglUseFontBitmapsW( DWORD count, DWORD listBase ) { - (void) hdc; - (void) first; - (void) count; - (void) listBase; - - assert( 0 ); - - return FALSE; + GLYPHMETRICS gm; + MAT2 tra; + FIXED one, minus_one, zero; + void *buffer = NULL; + BOOL result = TRUE; + + one.value = 1; + one.fract = 0; + minus_one.value = -1; + minus_one.fract = 0; + zero.value = 0; + zero.fract = 0; + + tra.eM11 = one; + tra.eM22 = minus_one; + tra.eM12 = tra.eM21 = zero; + + for (int i = 0; i < count; i++) { + DWORD size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, &gm, 0, + NULL, &tra); + + glNewList(listBase + i, GL_COMPILE); + + if (size != GDI_ERROR) { + if (size == 0) { + glBitmap(0, 0, -gm.gmptGlyphOrigin.x, gm.gmptGlyphOrigin.y, + gm.gmCellIncX, gm.gmCellIncY, NULL); + } + else { + buffer = realloc(buffer, size); + size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, &gm, + size, buffer, &tra); + + glBitmap(gm.gmBlackBoxX, gm.gmBlackBoxY, + -gm.gmptGlyphOrigin.x, gm.gmptGlyphOrigin.y, + gm.gmCellIncX, gm.gmCellIncY, buffer); + } + } + else { + result = FALSE; + } + + glEndList(); + } + + free(buffer); + + return result; } WINGDIAPI BOOL APIENTRY