]> git.cworth.org Git - apitrace/blobdiff - glretrace_cgl.cpp
Ignore assertion failure on Mac OS X.
[apitrace] / glretrace_cgl.cpp
index 892dc0d1c67e0ffd2d3fb96bfc048a55834195d5..c42dd813edf65cc0506fa0d1ad89fd928ea1d20a 100644 (file)
@@ -38,6 +38,7 @@ typedef std::map<unsigned long long, glws::Drawable *> DrawableMap;
 typedef std::map<unsigned long long, glws::Context *> 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,6 +99,19 @@ 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();
 
@@ -111,10 +120,11 @@ void glretrace::retrace_call_cgl(Trace::Call &call) {
        return;
     }
 
-    if (strcmp(name, "CGLGetCurrentContext") == 0) {
+    if (strcmp(name, "CGLFlushDrawable") == 0) {
+       retrace_CGLFlushDrawable(call);
        return;
     }
 
-    retrace::retrace_unknown(call);
+    return;
 }