summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp')
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp51
1 files changed, 36 insertions, 15 deletions
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index 0c9fddc83..dffcfc637 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -111,6 +111,18 @@ public:
GraphicsSurface::Flags m_surfaceFlags;
RefPtr<GraphicsSurface> m_graphicsSurface;
#endif
+
+ // Register as a child of a Qt context to make the necessary when it may be destroyed before the GraphicsContext3D instance
+ class QtContextWatcher : public QObject
+ {
+ public:
+ QtContextWatcher(QObject* ctx, GraphicsContext3DPrivate* watcher): QObject(ctx), m_watcher(watcher) { }
+ ~QtContextWatcher() { m_watcher->m_platformContext = 0; m_watcher->m_platformContextWatcher = 0; }
+
+ private:
+ GraphicsContext3DPrivate* m_watcher;
+ };
+ QtContextWatcher* m_platformContextWatcher;
};
bool GraphicsContext3DPrivate::isOpenGLES() const
@@ -149,11 +161,16 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H
, m_surface(0)
, m_platformContext(0)
, m_surfaceOwner(0)
+ , m_platformContextWatcher(0)
{
if (renderStyle == GraphicsContext3D::RenderToCurrentGLContext) {
m_platformContext = QOpenGLContext::currentContext();
if (m_platformContext)
m_surface = m_platformContext->surface();
+
+ // Watcher needed to invalidate the GL context if destroyed before this instance
+ m_platformContextWatcher = new QtContextWatcher(m_platformContext, this);
+
initializeOpenGLFunctions();
return;
}
@@ -260,6 +277,9 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
#endif
delete m_surfaceOwner;
m_surfaceOwner = 0;
+
+ delete m_platformContextWatcher;
+ m_platformContextWatcher = 0;
}
#if USE(ACCELERATED_COMPOSITING)
@@ -441,22 +461,23 @@ GraphicsContext3D::~GraphicsContext3D()
if (!m_private)
return;
- makeContextCurrent();
- m_functions->glDeleteTextures(1, &m_texture);
- m_functions->glDeleteFramebuffers(1, &m_fbo);
- if (m_attrs.antialias) {
- m_functions->glDeleteRenderbuffers(1, &m_multisampleColorBuffer);
- m_functions->glDeleteFramebuffers(1, &m_multisampleFBO);
- if (m_attrs.stencil || m_attrs.depth)
- m_functions->glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
- } else if (m_attrs.stencil || m_attrs.depth) {
- if (isGLES2Compliant()) {
- if (m_attrs.depth)
- m_functions->glDeleteRenderbuffers(1, &m_depthBuffer);
- if (m_attrs.stencil)
- m_functions->glDeleteRenderbuffers(1, &m_stencilBuffer);
+ if (makeContextCurrent()) {
+ m_functions->glDeleteTextures(1, &m_texture);
+ m_functions->glDeleteFramebuffers(1, &m_fbo);
+ if (m_attrs.antialias) {
+ m_functions->glDeleteRenderbuffers(1, &m_multisampleColorBuffer);
+ m_functions->glDeleteFramebuffers(1, &m_multisampleFBO);
+ if (m_attrs.stencil || m_attrs.depth)
+ m_functions->glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
+ } else if (m_attrs.stencil || m_attrs.depth) {
+ if (isGLES2Compliant()) {
+ if (m_attrs.depth)
+ m_functions->glDeleteRenderbuffers(1, &m_depthBuffer);
+ if (m_attrs.stencil)
+ m_functions->glDeleteRenderbuffers(1, &m_stencilBuffer);
+ }
+ m_functions->glDeleteRenderbuffers(1, &m_depthStencilBuffer);
}
- m_functions->glDeleteRenderbuffers(1, &m_depthStencilBuffer);
}
m_functions = 0;