X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fglretrace_egl.cpp;h=c03d04c2d4fc16743e6b71665c42de5f4d518bcd;hb=d38b370ca8d332ca54a6f5cdea3373199991f65d;hp=3f83f55b41c734a44cd34f747209f85696584fa0;hpb=9115776479fc67fe12cc3f7ccb8da2fd684d2232;p=apitrace diff --git a/retrace/glretrace_egl.cpp b/retrace/glretrace_egl.cpp index 3f83f55..c03d04c 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,13 +138,14 @@ 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) { unsigned long long orig_context = call.ret->toUIntPtr(); unsigned long long orig_config = call.arg(1).toUIntPtr(); Context *share_context = getContext(call.arg(2).toUIntPtr()); - trace::Array *attrib_array = dynamic_cast(&call.arg(3)); + trace::Array *attrib_array = call.arg(3).toArray(); glws::Profile profile; switch (current_api) { @@ -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(); }