]> git.cworth.org Git - apitrace/blobdiff - retrace/glretrace_ws.cpp
stash: Trace and replay of glx-tfp works
[apitrace] / retrace / glretrace_ws.cpp
index 319a2cbe80e65cfbb6b701c8c0d1b3f23c5dcd9c..03e1fc1db7655ecf4b66e170d6d6caf539b1966a 100644 (file)
@@ -122,14 +122,23 @@ createContext(Context *shareContext) {
 }
 
 
-static os::thread_specific_ptr<Context>
+Context::~Context()
+{
+    //assert(this != getCurrentContext());
+    if (this != getCurrentContext()) {
+        delete wsContext;
+    }
+}
+
+
+static thread_specific Context *
 currentContextPtr;
 
 
 bool
 makeCurrent(trace::Call &call, glws::Drawable *drawable, Context *context)
 {
-    Context *currentContext = currentContextPtr.release();
+    Context *currentContext = currentContextPtr;
     glws::Drawable *currentDrawable = currentContext ? currentContext->drawable : NULL;
 
     if (drawable == currentDrawable && context == currentContext) {
@@ -153,13 +162,10 @@ makeCurrent(trace::Call &call, glws::Drawable *drawable, Context *context)
         return false;
     }
 
-    if (currentContext) {
-        currentContext->drawable = NULL;
-    }
+    currentContextPtr = context;
 
     if (drawable && context) {
         context->drawable = drawable;
-        currentContextPtr.reset(context);
         
         if (!context->used) {
             initContext();
@@ -173,7 +179,7 @@ makeCurrent(trace::Call &call, glws::Drawable *drawable, Context *context)
 
 Context *
 getCurrentContext(void) {
-    return currentContextPtr.get();
+    return currentContextPtr;
 }
 
 
@@ -243,5 +249,65 @@ parseAttrib(const trace::Value *attribs, int param, int default_ = 0) {
     return default_;
 }
 
+void
+createWindow(glws::Drawable *window)
+{
+    glws::Visual *visual = getVisual(getDefaultProfile());
+
+    glws::createWindow(window, visual);
+}
+
+void
+destroyWindow(glws::Drawable *window)
+{
+    glws::destroyWindow(window);
+}
+
+glws::Drawable *
+createPixmap(unsigned width, unsigned height, unsigned depth)
+{
+    return glws::createPixmap(width, height, depth);
+}
+
+glws::Drawable *
+createGLPixmap(GLXFBConfig fbconfig, glws::Drawable *pixmap,
+               unsigned width, unsigned height, int *attrib_list)
+{
+    return glws::createGLPixmap(fbconfig, pixmap, width, height, attrib_list);
+}
+
+void
+bindTexImage(glws::Drawable *pixmap, int buffer)
+{
+    glws::bindTexImage(pixmap, buffer);
+}
+
+void
+releaseTexImage(glws::Drawable *pixmap, int buffer)
+{
+    glws::releaseTexImage(pixmap, buffer);
+}
+
+void
+copySubBuffer(glws::Drawable *drawable, int x, int y, int width, int height)
+{
+    glws::copySubBuffer(drawable, x, y, width, height);
+}
+
+void
+putImageData(glws::Drawable *drawable, char *data,
+             int width, int height, int depth,
+             int bits_per_pixel, int bytes_per_line, int byte_order)
+{
+    glws::putImageData(drawable, data, width, height, depth,
+                       bits_per_pixel, bytes_per_line, byte_order);
+}
+
+GLXFBConfig
+chooseConfig(int *attrib_list)
+{
+    return glws::chooseConfig(attrib_list);
+}
+
 
 } /* namespace glretrace */