]> git.cworth.org Git - apitrace/blobdiff - retrace/glretrace_ws.cpp
Replace dynamic_cast with virtual functions.
[apitrace] / retrace / glretrace_ws.cpp
index 5ae908fc6c75a3cfffee7fb1d33077f65b090c95..d1e85f824d08815d4a511c06197725051e85062d 100644 (file)
@@ -122,7 +122,16 @@ createContext(Context *shareContext) {
 }
 
 
-static thread_specific Context *
+Context::~Context()
+{
+    //assert(this != getCurrentContext());
+    if (this != getCurrentContext()) {
+        delete wsContext;
+    }
+}
+
+
+static OS_THREAD_SPECIFIC_PTR(Context)
 currentContextPtr;
 
 
@@ -153,9 +162,6 @@ makeCurrent(trace::Call &call, glws::Drawable *drawable, Context *context)
         return false;
     }
 
-    if (currentContext) {
-        currentContext->drawable = NULL;
-    }
     currentContextPtr = context;
 
     if (drawable && context) {
@@ -208,6 +214,9 @@ updateDrawable(int width, int height) {
         return;
     }
 
+    width  = std::max(width,  currentDrawable->width);
+    height = std::max(height, currentDrawable->height);
+
     // Check for bound framebuffer last, as this may have a performance impact.
     GLint draw_framebuffer = 0;
     glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer);
@@ -224,7 +233,7 @@ updateDrawable(int width, int height) {
 
 int
 parseAttrib(const trace::Value *attribs, int param, int default_ = 0) {
-    const trace::Array *attribs_ = dynamic_cast<const trace::Array *>(attribs);
+    const trace::Array *attribs_ = attribs ? attribs->toArray() : NULL;
 
     if (attribs_) {
         for (size_t i = 0; i + 1 < attribs_->values.size(); i += 2) {