X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fglretrace_egl.cpp;h=45855643f5b55272e494be1bcef8a799e26c928f;hb=7a9fb5103e052150232b64cb5d99374cda3f1234;hp=1f8020a45ffe5c6694d012d31aba90aa6a69297e;hpb=06555614b7385c49964d27aaeec68dec6ff31744;p=apitrace diff --git a/retrace/glretrace_egl.cpp b/retrace/glretrace_egl.cpp index 1f8020a..4585564 100644 --- a/retrace/glretrace_egl.cpp +++ b/retrace/glretrace_egl.cpp @@ -32,6 +32,7 @@ #include "retrace.hpp" #include "glretrace.hpp" #include "os.hpp" +#include "eglsize.hpp" #ifndef EGL_OPENGL_ES_API #define EGL_OPENGL_ES_API 0x30A0 @@ -45,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; @@ -76,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; @@ -102,9 +103,7 @@ static void createDrawable(unsigned long long orig_config, unsigned long long or profile = last_profile; } - glws::Visual *visual = glretrace::visual[profile]; - - glws::Drawable *drawable = glws::createDrawable(visual); + glws::Drawable *drawable = glretrace::createDrawable(profile); drawable_map[orig_surface] = drawable; } @@ -128,7 +127,8 @@ static void retrace_eglDestroySurface(trace::Call &call) { it = drawable_map.find(orig_surface); if (it != drawable_map.end()) { - if (it->second != drawable) { + glretrace::Context *currentContext = glretrace::getCurrentContext(); + if (!currentContext || it->second != currentContext->drawable) { // TODO: reference count delete it->second; } @@ -143,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; @@ -169,7 +169,7 @@ static void retrace_eglCreateContext(trace::Call &call) { } - glws::Context *context = glws::createContext(glretrace::visual[profile], share_context, profile, retrace::debug); + Context *context = glretrace::createContext(share_context, profile); if (!context) { const char *name; switch (profile) { @@ -203,43 +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()); - if (new_drawable == drawable && new_context == context) { - return; - } - - if (drawable && context) { - glFlush(); - if (!retrace::doubleBuffer) { - frame_complete(call); - } - } - - bool result = glws::makeCurrent(new_drawable, new_context); - - if (new_drawable && new_context && result) { - drawable = new_drawable; - context = new_context; - } else { - drawable = NULL; - context = NULL; - } + 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 && drawable) { - drawable->swapBuffers(); + if (retrace::doubleBuffer) { + if (drawable) { + drawable->swapBuffers(); + } } else { glFlush(); } @@ -280,5 +269,8 @@ const retrace::Entry glretrace::egl_callbacks[] = { {"eglSwapBuffers", &retrace_eglSwapBuffers}, //{"eglCopyBuffers", &retrace::ignore}, {"eglGetProcAddress", &retrace::ignore}, + {"eglCreateImageKHR", &retrace::ignore}, + {"eglDestroyImageKHR", &retrace::ignore}, + {"glEGLImageTargetTexture2DOES", &retrace::ignore}, {NULL, NULL}, };