X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;ds=sidebyside;f=retrace%2Fglretrace_egl.cpp;h=27c5bb8e39531a8534f63542e76a2cfaa392e400;hb=712cc1db47e56a1032dc72d4209ffc9054ec54e4;hp=3f83f55b41c734a44cd34f747209f85696584fa0;hpb=e7cb2b98575d5ff3801bd3527a648e0dbfdebdad;p=apitrace diff --git a/retrace/glretrace_egl.cpp b/retrace/glretrace_egl.cpp index 3f83f55..27c5bb8 100644 --- a/retrace/glretrace_egl.cpp +++ b/retrace/glretrace_egl.cpp @@ -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; } @@ -137,6 +138,7 @@ static void retrace_eglDestroySurface(trace::Call &call) { static void retrace_eglBindAPI(trace::Call &call) { current_api = call.arg(0).toUInt(); + eglBindAPI(current_api); } static void retrace_eglCreateContext(trace::Call &call) { @@ -187,7 +189,7 @@ static void retrace_eglCreateContext(trace::Call &call) { } retrace::warning(call) << "Failed to create " << name << " context.\n"; - os::abort(); + exit(1); } context_map[orig_context] = context; @@ -202,7 +204,11 @@ 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); } } @@ -216,10 +222,14 @@ static void retrace_eglMakeCurrent(trace::Call &call) { 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(); }