mirror of
https://github.com/RGBCube/serenity
synced 2025-06-14 15:22:07 +00:00
LibGL: Add context lifetime debug output
Also, make `::create_context` return a `NonnullOwnPtr`.
This commit is contained in:
parent
a0086c033d
commit
a4d98c4622
2 changed files with 11 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "GLContext.h"
|
#include "GLContext.h"
|
||||||
#include "SoftwareGLContext.h"
|
#include "SoftwareGLContext.h"
|
||||||
|
#include <AK/Debug.h>
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
|
|
||||||
__attribute__((visibility("hidden"))) GL::GLContext* g_gl_context;
|
__attribute__((visibility("hidden"))) GL::GLContext* g_gl_context;
|
||||||
|
@ -15,22 +16,28 @@ namespace GL {
|
||||||
|
|
||||||
GLContext::~GLContext()
|
GLContext::~GLContext()
|
||||||
{
|
{
|
||||||
|
dbgln_if(GL_DEBUG, "GLContext::~GLContext() {:p}", this);
|
||||||
if (g_gl_context == this)
|
if (g_gl_context == this)
|
||||||
make_context_current(nullptr);
|
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)
|
if (!g_gl_context)
|
||||||
g_gl_context = context;
|
make_context_current(context);
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
void make_context_current(GLContext* 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;
|
g_gl_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ public:
|
||||||
virtual void present() = 0;
|
virtual void present() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
OwnPtr<GLContext> create_context(Gfx::Bitmap&);
|
NonnullOwnPtr<GLContext> create_context(Gfx::Bitmap&);
|
||||||
void make_context_current(GLContext*);
|
void make_context_current(GLContext*);
|
||||||
void present_context(GLContext*);
|
void present_context(GLContext*);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue