[Mesa-dev] [PATCH 2/2] gallium: Implement wglUseFontBitmaps.

Olivier Lauffenburger o.lauffenburger at topsolid.com
Thu Jul 6 15:27:09 UTC 2017


wglUseFontBitmaps is currently a noop.
This patch implements this function for Windows.

Signed-off-by: Olivier Lauffenburger <o.lauffenburger at topsolid.com>
---
 src/gallium/state_trackers/wgl/stw_wgl.c | 50 ++++++++++++++++++++++++++++----
 1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/stw_wgl.c
index de4b4f6f3b..12c94b30a7 100644
--- a/src/gallium/state_trackers/wgl/stw_wgl.c
+++ b/src/gallium/state_trackers/wgl/stw_wgl.c
@@ -219,9 +219,7 @@ wglUseFontBitmapsA(
    (void) count;
    (void) listBase;
 
-   assert( 0 );
-
-   return FALSE;
+   return wglUseFontBitmapsW(hdc, first, count, listBase);
 }
 
 WINGDIAPI BOOL APIENTRY
@@ -245,9 +243,49 @@ wglUseFontBitmapsW(
    (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
-- 
2.13.2.windows.1



More information about the mesa-dev mailing list