X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glretrace_cgl.cpp;h=8cb5786d4fc9053caa02c7183cb743cb10535727;hb=ac4dd9a23fe0e08496368a0e013ad538675106f3;hp=892dc0d1c67e0ffd2d3fb96bfc048a55834195d5;hpb=31c9f62616e2c59973ca00fd074e8c288f6488b3;p=apitrace diff --git a/glretrace_cgl.cpp b/glretrace_cgl.cpp index 892dc0d..8cb5786 100644 --- a/glretrace_cgl.cpp +++ b/glretrace_cgl.cpp @@ -38,6 +38,7 @@ typedef std::map DrawableMap; typedef std::map ContextMap; static DrawableMap drawable_map; static ContextMap context_map; +static glws::Context *sharedContext = NULL; static glws::Drawable * @@ -46,6 +47,9 @@ getDrawable(unsigned long drawable_id) { return NULL; } + /* XXX: Support multiple drawables. */ + drawable_id = 1; + DrawableMap::const_iterator it; it = drawable_map.find(drawable_id); if (it == drawable_map.end()) { @@ -65,29 +69,21 @@ getContext(unsigned long long ctx) { ContextMap::const_iterator it; it = context_map.find(ctx); if (it == context_map.end()) { - return (context_map[ctx] = ws->createContext(visual)); + glws::Context *context; + context_map[ctx] = context = ws->createContext(visual, sharedContext); + if (!sharedContext) { + sharedContext = context; + } + return context; } return it->second; } + static void retrace_CGLSetCurrentContext(Trace::Call &call) { unsigned long long ctx = call.arg(0).toUIntPtr(); - /* - * XXX: Frame termination is mostly a guess, because we don't trace enough - * of the CGL API to know that. - */ - if (drawable && context) { - if (double_buffer) { - drawable->swapBuffers(); - } else { - glFlush(); - } - - frame_complete(call.no); - } - glws::Drawable *new_drawable = getDrawable(ctx); glws::Context *new_context = getContext(ctx); @@ -103,18 +99,32 @@ static void retrace_CGLSetCurrentContext(Trace::Call &call) { } +static void retrace_CGLFlushDrawable(Trace::Call &call) { + if (drawable && context) { + if (double_buffer) { + drawable->swapBuffers(); + } else { + glFlush(); + } + + frame_complete(call.no); + } +} + + void glretrace::retrace_call_cgl(Trace::Call &call) { - const char *name = call.name().c_str(); + const char *name = call.name(); if (strcmp(name, "CGLSetCurrentContext") == 0) { retrace_CGLSetCurrentContext(call); return; } - if (strcmp(name, "CGLGetCurrentContext") == 0) { + if (strcmp(name, "CGLFlushDrawable") == 0) { + retrace_CGLFlushDrawable(call); return; } - retrace::retrace_unknown(call); + return; }