summaryrefslogtreecommitdiff
path: root/wrappers
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-01-27 23:18:52 +0000
committerJose Fonseca <jfonseca@vmware.com>2016-01-28 14:52:23 +0000
commit6ef9b3c9f85aba3a4e57786ac202733882778b44 (patch)
treea7671ecdd24602ecf7a0f47bc4bd0635a34d9fdf /wrappers
parent225a67a4168338ba070283ee13e17b1f815dbfb5 (diff)
wgltrace: Don't emit wglUseFontBitmapsA call.
Just emit a fake string marker for reference.
Diffstat (limited to 'wrappers')
-rw-r--r--wrappers/gltrace.py16
-rw-r--r--wrappers/wgltrace.py209
2 files changed, 136 insertions, 89 deletions
diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py
index 769f2e34..3695e977 100644
--- a/wrappers/gltrace.py
+++ b/wrappers/gltrace.py
@@ -209,7 +209,15 @@ class GlTracer(Tracer):
print '}'
print
- print 'static void _trace_user_arrays(GLuint count);'
+ print r'static void _trace_user_arrays(GLuint count);'
+ print
+
+ print r'static void _fakeStringMarker(GLsizei len, const GLvoid * string);'
+ print
+ print r'static inline void'
+ print r'_fakeStringMarker(const std::string &s) {'
+ print r' _fakeStringMarker(s.length(), s.data());'
+ print r'}'
print
print '// whether glLockArraysEXT() has ever been called'
@@ -1108,6 +1116,12 @@ class GlTracer(Tracer):
print '}'
print
+ # Fake glStringMarkerGREMEDY
+ print r'static void _fakeStringMarker(GLsizei len, const GLvoid * string) {'
+ glStringMarkerGREMEDY = api.getFunctionByName('glStringMarkerGREMEDY')
+ self.fake_call(glStringMarkerGREMEDY, ['len', 'string'])
+ print r'}'
+
#
# Hooks for glTexCoordPointer, which is identical to the other array
# pointers except the fact that it is indexed by glClientActiveTexture.
diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py
index 9ba54991..29081bde 100644
--- a/wrappers/wgltrace.py
+++ b/wrappers/wgltrace.py
@@ -83,20 +83,6 @@ class WglTracer(GlTracer):
print ' }'
print ' gltrace::releaseContext((uintptr_t)hglrc);'
- GlTracer.traceFunctionImplBody(self, function)
-
- if function.name in self.createContextFunctionNames:
- print ' if (_result)'
- print ' gltrace::createContext((uintptr_t)_result);'
-
- if function.name in self.makeCurrentFunctionNames:
- print ' if (_result) {'
- print ' if (hglrc != NULL)'
- print ' gltrace::setContext((uintptr_t)hglrc);'
- print ' else'
- 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.
#
@@ -108,106 +94,151 @@ class WglTracer(GlTracer):
# to be the way that opengl32.dll implements wglUseFontBitmaps.
#
if function.name == 'wglUseFontBitmapsA':
+
+ self.invokeFunction(function)
+
+ # Emit a fake string marker with the original call
+ print r' {'
+ print r' std::ostringstream ss;'
+ print r' ss << __FUNCTION__ << "(hdc = " << hdc << ", first = " << first << ", count = " << count << ", listBase = " << listBase << ") = " << (_result ? "TRUE" : "FALSE");'
+ print r' _fakeStringMarker(ss.str());'
+ print r' }'
+ print
+
glNewList = glapi.getFunctionByName('glNewList')
glBitmap = glapi.getFunctionByName('glBitmap')
glEndList = glapi.getFunctionByName('glEndList')
- print r' BOOL bRet;'
- print r' TEXTMETRIC tm;'
- print r' bRet = GetTextMetricsA(hdc, &tm);'
- print r' assert(bRet);'
- print
- print r' HDC memDC = CreateCompatibleDC(hdc);'
- print
- print r' SetMapMode(memDC, MM_TEXT);'
- print r' SetTextAlign(memDC, TA_BASELINE);'
- print r' SetBkColor(memDC, RGB(0, 0, 0));'
- print r' SetBkMode(memDC, OPAQUE);'
- print r' SetTextColor(memDC, RGB(255,255,255));'
- print
- print r' BITMAPINFO * bmi = (BITMAPINFO *)malloc(offsetof(BITMAPINFO, bmiColors[2]));'
- print r' ZeroMemory(&bmi->bmiHeader, sizeof bmi->bmiHeader);'
- print r' bmi->bmiHeader.biSize = sizeof bmi->bmiHeader;'
- print r' bmi->bmiHeader.biPlanes = 1;'
- print r' bmi->bmiHeader.biBitCount = 1;'
- print r' bmi->bmiHeader.biCompression = BI_RGB;'
- print r' bmi->bmiColors[0].rgbBlue = 0;'
- print r' bmi->bmiColors[0].rgbGreen = 0;'
- print r' bmi->bmiColors[0].rgbRed = 0;'
- print r' bmi->bmiColors[0].rgbReserved = 0;'
- print r' bmi->bmiColors[1].rgbBlue = 255;'
- print r' bmi->bmiColors[1].rgbGreen = 255;'
- print r' bmi->bmiColors[1].rgbRed = 255;'
- print r' bmi->bmiColors[1].rgbReserved = 0;'
- print
- print r' for (DWORD i = 0; i < count; ++i) {'
+ print r' if (_result) {'
+
+ print r' HFONT hFont = (HFONT)GetCurrentObject(hdc, OBJ_FONT);'
+ print r' assert (hFont != nullptr);'
+ print r' LOGFONT lf;'
+ print r' if (GetObject(hFont, sizeof lf, &lf) != 0) {'
+ print r' std::ostringstream ss;'
+ print r' ss << "lfFaceName = " << lf.lfFaceName'
+ print r' << ", lfHeight = " << lf.lfHeight'
+ print r' << ", lfWeight = " << lf.lfWeight;'
+ print r' if (lf.lfItalic) ss << ", lfItalic = 1";'
+ print r' if (lf.lfUnderline) ss << ", lfUnderline = 1";'
+ print r' if (lf.lfStrikeOut) ss << ", lfStrikeOut = 1";'
+ print r' _fakeStringMarker(ss.str());'
+ print r' }'
+ print
+
+ print r' BOOL bRet;'
+ print r' TEXTMETRIC tm;'
+ print r' bRet = GetTextMetricsA(hdc, &tm);'
+ print r' assert(bRet);'
+ print
+ print r' HDC memDC = CreateCompatibleDC(hdc);'
+ print
+ print r' SetMapMode(memDC, MM_TEXT);'
+ print r' SetTextAlign(memDC, TA_BASELINE);'
+ print r' SetBkColor(memDC, RGB(0, 0, 0));'
+ print r' SetBkMode(memDC, OPAQUE);'
+ print r' SetTextColor(memDC, RGB(255,255,255));'
+ print
+ print r' BITMAPINFO * bmi = (BITMAPINFO *)malloc(offsetof(BITMAPINFO, bmiColors[2]));'
+ print r' ZeroMemory(&bmi->bmiHeader, sizeof bmi->bmiHeader);'
+ print r' bmi->bmiHeader.biSize = sizeof bmi->bmiHeader;'
+ print r' bmi->bmiHeader.biPlanes = 1;'
+ print r' bmi->bmiHeader.biBitCount = 1;'
+ print r' bmi->bmiHeader.biCompression = BI_RGB;'
+ print r' bmi->bmiColors[0].rgbBlue = 0;'
+ print r' bmi->bmiColors[0].rgbGreen = 0;'
+ print r' bmi->bmiColors[0].rgbRed = 0;'
+ print r' bmi->bmiColors[0].rgbReserved = 0;'
+ print r' bmi->bmiColors[1].rgbBlue = 255;'
+ print r' bmi->bmiColors[1].rgbGreen = 255;'
+ print r' bmi->bmiColors[1].rgbRed = 255;'
+ print r' bmi->bmiColors[1].rgbReserved = 0;'
+ print
+ print r' for (DWORD i = 0; i < count; ++i) {'
self.fake_call(glNewList, ['listBase + i', 'GL_COMPILE'])
- print r' char cChar = first + i;'
+ print r' char cChar = first + i;'
- print r' // TODO: Use GetCharABSWidths'
- print r' // http://www.codeproject.com/Articles/14915/Width-of-text-in-italic-font'
- print r' // https://support.microsoft.com/en-us/kb/94646'
- print r' SIZE size;'
- print r' bRet = GetTextExtentPoint32A(hdc, &cChar, 1, &size);'
- print r' if (bRet) {'
- print r' assert(size.cx >= 0);'
- print r' assert(size.cy >= 0);'
+ print r' // TODO: Use GetCharABSWidths'
+ print r' // http://www.codeproject.com/Articles/14915/Width-of-text-in-italic-font'
+ print r' // https://support.microsoft.com/en-us/kb/94646'
+ print r' SIZE size;'
+ print r' bRet = GetTextExtentPoint32A(hdc, &cChar, 1, &size);'
+ print r' if (bRet) {'
+ print r' assert(size.cx >= 0);'
+ print r' assert(size.cy >= 0);'
print
- print r' // Round width to 32 pixels'
- print r' int nWidth = (size.cx + 0x1f) & ~0x1f;'
- print r' int nHeight = size.cy;'
+ print r' // Round width to 32 pixels'
+ print r' int nWidth = (size.cx + 0x1f) & ~0x1f;'
+ print r' int nHeight = size.cy;'
print
- print r' DWORD dwBytes = nWidth / 8 * nHeight;'
- print r' LPVOID lpvBits = NULL;'
- print r' if (dwBytes) {'
- print r' lpvBits = malloc(dwBytes);'
+ print r' DWORD dwBytes = nWidth / 8 * nHeight;'
+ print r' LPVOID lpvBits = NULL;'
+ print r' if (dwBytes) {'
+ print r' lpvBits = malloc(dwBytes);'
print
- print r' HBITMAP memBM = CreateCompatibleBitmap(memDC, nWidth, nHeight);'
+ print r' HBITMAP memBM = CreateCompatibleBitmap(memDC, nWidth, nHeight);'
print
- print r' HGDIOBJ origBM = SelectObject(memDC, memBM);'
+ print r' HGDIOBJ origBM = SelectObject(memDC, memBM);'
print
- print r' PatBlt(memDC, 0, 0, nWidth, nHeight, BLACKNESS);'
- print r' SelectObject(memDC, GetCurrentObject(hdc, OBJ_FONT));'
+ print r' PatBlt(memDC, 0, 0, nWidth, nHeight, BLACKNESS);'
+ print r' SelectObject(memDC, hFont);'
print
- print r' bmi->bmiHeader.biWidth = nWidth;'
- print r' bmi->bmiHeader.biHeight = nHeight;'
+ print r' bmi->bmiHeader.biWidth = nWidth;'
+ print r' bmi->bmiHeader.biHeight = nHeight;'
print
- print r' bRet = TextOutA(memDC, 0, tm.tmAscent, &cChar, 1);'
- print r' assert(bRet);'
+ print r' bRet = TextOutA(memDC, 0, tm.tmAscent, &cChar, 1);'
+ print r' assert(bRet);'
print
- print r' SelectObject(memDC, origBM);'
+ print r' SelectObject(memDC, origBM);'
print
- print r' int nScanLines = GetDIBits(memDC, memBM, 0, nHeight, lpvBits, bmi, DIB_RGB_COLORS);'
- print r' assert(nScanLines == nHeight);'
+ print r' int nScanLines = GetDIBits(memDC, memBM, 0, nHeight, lpvBits, bmi, DIB_RGB_COLORS);'
+ print r' assert(nScanLines == nHeight);'
print
- print r' DeleteObject(memBM);'
- print r' }'
+ print r' DeleteObject(memBM);'
+ print r' }'
print
- print r' GLsizei width = nWidth;'
- print r' GLfloat height = nHeight;'
- print r' GLfloat xorig = 0;'
- print r' GLfloat yorig = tm.tmDescent;'
- print r' GLfloat xmove = size.cx;'
- print r' GLfloat ymove = 0;'
- print r' const GLubyte *bitmap = (const GLubyte *)lpvBits;'
- print r' if (bitmap == NULL) {'
- 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' GLsizei width = nWidth;'
+ print r' GLfloat height = nHeight;'
+ print r' GLfloat xorig = 0;'
+ print r' GLfloat yorig = tm.tmDescent;'
+ print r' GLfloat xmove = size.cx;'
+ print r' GLfloat ymove = 0;'
+ print r' const GLubyte *bitmap = (const GLubyte *)lpvBits;'
+ print r' if (bitmap == NULL) {'
+ print r' // We still need to emit an empty glBitmap for empty characters like spaces;'
+ print r' width = height = xorig = yorig = 0;'
+ print r' }'
# FIXME: glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
# FIXME: glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
self.fake_call(glBitmap, ['width', 'height', 'xorig', 'yorig', 'xmove', 'ymove', 'bitmap'])
- print r' free(lpvBits);'
- print r' }'
+ print r' free(lpvBits);'
+ print r' }'
self.fake_call(glEndList, [])
- print r' }'
+ print r' }'
print
- print r' DeleteDC(memDC);'
- print r' free(bmi);'
+ print r' DeleteDC(memDC);'
+ print r' free(bmi);'
+
+ print r' } // _result'
+ return
+
+ GlTracer.traceFunctionImplBody(self, function)
+
+ if function.name in self.createContextFunctionNames:
+ print ' if (_result)'
+ print ' gltrace::createContext((uintptr_t)_result);'
+
+ if function.name in self.makeCurrentFunctionNames:
+ print ' if (_result) {'
+ print ' if (hglrc != NULL)'
+ print ' gltrace::setContext((uintptr_t)hglrc);'
+ print ' else'
+ print ' gltrace::clearContext();'
+ print ' }'
if __name__ == '__main__':
@@ -217,6 +248,8 @@ if __name__ == '__main__':
print '#include <string.h>'
print '#include <windows.h>'
print
+ print '#include <sstream>'
+ print
print '#include "trace_writer_local.hpp"'
print '#include "os.hpp"'
print