X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fglretrace_egl.cpp;h=45855643f5b55272e494be1bcef8a799e26c928f;hb=aa135d6ca5642fb2e5c807a1d4df96f5d6b07c98;hp=43e8169836b257c73c08a75fc61f5a77b813b92f;hpb=122c9879c2d4361ee4c46e95f348b6032efeb8f6;p=apitrace diff --git a/retrace/glretrace_egl.cpp b/retrace/glretrace_egl.cpp index 43e8169..4585564 100644 --- a/retrace/glretrace_egl.cpp +++ b/retrace/glretrace_egl.cpp @@ -46,7 +46,7 @@ using namespace glretrace; typedef std::map DrawableMap; -typedef std::map ContextMap; +typedef std::map ContextMap; typedef std::map ProfileMap; static DrawableMap drawable_map; static ContextMap context_map; @@ -77,7 +77,7 @@ getDrawable(unsigned long long surface_ptr) { return (it != drawable_map.end()) ? it->second : NULL; } -static glws::Context * +static Context * getContext(unsigned long long context_ptr) { if (context_ptr == 0) { return NULL; @@ -127,7 +127,8 @@ static void retrace_eglDestroySurface(trace::Call &call) { it = drawable_map.find(orig_surface); if (it != drawable_map.end()) { - if (it->second != currentDrawable) { + glretrace::Context *currentContext = glretrace::getCurrentContext(); + if (!currentContext || it->second != currentContext->drawable) { // TODO: reference count delete it->second; } @@ -142,7 +143,7 @@ static void retrace_eglBindAPI(trace::Call &call) { static void retrace_eglCreateContext(trace::Call &call) { unsigned long long orig_context = call.ret->toUIntPtr(); unsigned long long orig_config = call.arg(1).toUIntPtr(); - glws::Context *share_context = getContext(call.arg(2).toUIntPtr()); + Context *share_context = getContext(call.arg(2).toUIntPtr()); trace::Array *attrib_array = dynamic_cast(&call.arg(3)); glws::Profile profile; @@ -168,7 +169,7 @@ static void retrace_eglCreateContext(trace::Call &call) { } - glws::Context *context = glretrace::createContext(share_context, profile); + Context *context = glretrace::createContext(share_context, profile); if (!context) { const char *name; switch (profile) { @@ -202,24 +203,32 @@ static void retrace_eglDestroyContext(trace::Call &call) { it = context_map.find(orig_context); if (it != context_map.end()) { - delete it->second; + glretrace::Context *currentContext = glretrace::getCurrentContext(); + if (it->second != currentContext) { + // TODO: reference count + delete it->second; + } context_map.erase(it); } } static void retrace_eglMakeCurrent(trace::Call &call) { glws::Drawable *new_drawable = getDrawable(call.arg(1).toUIntPtr()); - glws::Context *new_context = getContext(call.arg(3).toUIntPtr()); + Context *new_context = getContext(call.arg(3).toUIntPtr()); glretrace::makeCurrent(call, new_drawable, new_context); } static void retrace_eglSwapBuffers(trace::Call &call) { + glws::Drawable *drawable = getDrawable(call.arg(1).toUIntPtr()); + frame_complete(call); - if (retrace::doubleBuffer && currentDrawable) { - currentDrawable->swapBuffers(); + if (retrace::doubleBuffer) { + if (drawable) { + drawable->swapBuffers(); + } } else { glFlush(); }