summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-01-27 14:10:17 +0000
committerJose Fonseca <jfonseca@vmware.com>2016-01-28 14:28:34 +0000
commit10ab22a9e883a525cef4d5a7b89f705b6afcec53 (patch)
tree90ea1645a89dc5c76429106e5964edc0eda9e267
parenteb2587964121b538d97c42f22de10fe2ce02ee3e (diff)
wgltrace: Emit fake glBitmap on wglUseFontBitmapsA.
Basic implementation.
-rw-r--r--wrappers/trace.py2
-rw-r--r--wrappers/wgltrace.py57
2 files changed, 59 insertions, 0 deletions
diff --git a/wrappers/trace.py b/wrappers/trace.py
index a43841fc..c1504cd7 100644
--- a/wrappers/trace.py
+++ b/wrappers/trace.py
@@ -965,6 +965,7 @@ class Tracer:
print ' trace::fakeMemcpy(%s, %s);' % (ptr, size)
def fake_call(self, function, args):
+ print ' {'
print ' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,)
for arg, instance in zip(function.args, args):
assert not arg.output
@@ -974,4 +975,5 @@ class Tracer:
print ' trace::localWriter.endEnter();'
print ' trace::localWriter.beginLeave(_fake_call);'
print ' trace::localWriter.endLeave();'
+ print ' }'
diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py
index bc79d774..3d958b7c 100644
--- a/wrappers/wgltrace.py
+++ b/wrappers/wgltrace.py
@@ -97,6 +97,63 @@ class WglTracer(GlTracer):
print ' gltrace::clearContext();'
print ' }'
+ # Emit fake glBitmap calls in the trace on wglUseFontBitmapsA.
+ # This enables to capture the real bitmaps and replay them outside Windows.
+ #
+ # XXX: In spite what
+ # https://msdn.microsoft.com/en-us/library/windows/desktop/dd374392.aspx
+ # implies, GetGlyphOutline(GGO_BITMAP) does not seem to work with
+ # certain fonts. The only solution is to draw the font charactors with
+ # a HBITMAP like the old Mesa fxwgl.c code used to do. That too, seems
+ # to be the way that opengl32.dll implements wglUseFontBitmaps.
+ #
+ if function.name == 'wglUseFontBitmapsA':
+ glNewList = glapi.getFunctionByName('glNewList')
+ glBitmap = glapi.getFunctionByName('glBitmap')
+ glEndList = glapi.getFunctionByName('glEndList')
+
+ print r' bool warned = false;'
+ print r' for (DWORD i = 0; i < count; ++i) {'
+ self.fake_call(glNewList, ['listBase + i', 'GL_COMPILE'])
+
+ print r' UINT uChar = first + i;'
+ print r' GLYPHMETRICS gm;'
+ print r' ZeroMemory(&gm, sizeof gm);'
+ print r' static const MAT2 mat2 = {{0, 1}, {0, 0}, {0, 0}, {0, -1}};'
+ print r' DWORD cbBuffer = GetGlyphOutlineA(hdc, uChar, GGO_BITMAP, &gm, 0, NULL, &mat2);'
+ print r' if (cbBuffer == GDI_ERROR) {'
+ print r' if (!warned) {'
+ print r' os::log("apitrace: warning: wglUseFontBitmapsA: GetGlyphOutlineA failed\n");'
+ print r' warned = true;'
+ print r' }'
+ print r' } else {'
+ print r' LPVOID lpvBuffer = NULL;'
+ print r' if (cbBuffer) {'
+ print r' lpvBuffer = malloc(cbBuffer);'
+ print r' DWORD dwRet;'
+ print r' dwRet = GetGlyphOutlineA(hdc, uChar, GGO_BITMAP, &gm, cbBuffer, lpvBuffer, &mat2);'
+ print r' assert(dwRet != GDI_ERROR);'
+ print r' assert(dwRet > 0);'
+ print r' }'
+ print r' GLsizei width = gm.gmBlackBoxX;'
+ print r' GLfloat height = gm.gmBlackBoxY;'
+ print r' GLfloat xorig = -gm.gmptGlyphOrigin.x;'
+ print r' GLfloat yorig = gm.gmptGlyphOrigin.y;'
+ print r' GLfloat xmove = gm.gmCellIncX;'
+ print r' GLfloat ymove = gm.gmCellIncY;'
+ print r' if (cbBuffer == 0) {'
+ print r' // We still need to emit an empty glBitmap for empty characters like spaces;'
+ print r' width = height = xorig = yorig = 0;'
+ print r' }'
+ print r' const GLubyte *bitmap = (const GLubyte *)lpvBuffer;'
+
+ self.fake_call(glBitmap, ['width', 'height', 'xorig', 'yorig', 'xmove', 'ymove', 'bitmap'])
+
+ print r' free(lpvBuffer);'
+ print r' }'
+ self.fake_call(glEndList, [])
+ print r' }'
+
if __name__ == '__main__':
print