diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-01-12 16:39:59 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-14 21:38:09 +0100 |
commit | a4d98c462294664baad8689fe0defd4e5490bf1c (patch) | |
tree | d62ddd877e2ddfb30a09e1ea1308850fdc469047 /Userland/Libraries/LibGL | |
parent | a0086c033ddfe2d18aa5d0704fe09c63a2a18a01 (diff) | |
download | serenity-a4d98c462294664baad8689fe0defd4e5490bf1c.zip |
LibGL: Add context lifetime debug output
Also, make `::create_context` return a `NonnullOwnPtr`.
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r-- | Userland/Libraries/LibGL/GLContext.cpp | 13 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLContext.h | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGL/GLContext.cpp b/Userland/Libraries/LibGL/GLContext.cpp index 4c8f7dc977..f49d90e4b7 100644 --- a/Userland/Libraries/LibGL/GLContext.cpp +++ b/Userland/Libraries/LibGL/GLContext.cpp @@ -7,6 +7,7 @@ #include "GLContext.h" #include "SoftwareGLContext.h" +#include <AK/Debug.h> #include <LibGfx/Bitmap.h> __attribute__((visibility("hidden"))) GL::GLContext* g_gl_context; @@ -15,22 +16,28 @@ namespace GL { GLContext::~GLContext() { + dbgln_if(GL_DEBUG, "GLContext::~GLContext() {:p}", this); if (g_gl_context == this) make_context_current(nullptr); } -OwnPtr<GLContext> create_context(Gfx::Bitmap& bitmap) +NonnullOwnPtr<GLContext> create_context(Gfx::Bitmap& bitmap) { - auto context = adopt_own(*new SoftwareGLContext(bitmap)); + auto context = make<SoftwareGLContext>(bitmap); + dbgln_if(GL_DEBUG, "GL::create_context({}) -> {:p}", bitmap.size(), context.ptr()); if (!g_gl_context) - g_gl_context = context; + make_context_current(context); return context; } void make_context_current(GLContext* context) { + if (g_gl_context == context) + return; + + dbgln_if(GL_DEBUG, "GL::make_context_current({:p})", context); g_gl_context = context; } diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index 896b005e7a..bf189197d9 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -120,7 +120,7 @@ public: virtual void present() = 0; }; -OwnPtr<GLContext> create_context(Gfx::Bitmap&); +NonnullOwnPtr<GLContext> create_context(Gfx::Bitmap&); void make_context_current(GLContext*); void present_context(GLContext*); |