diff options
author | Pierre-Antoine LaFayette <plafayet@codeaurora.org> | 2012-10-10 13:43:45 -0400 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2013-01-20 18:38:31 -0800 |
commit | c018655c37a1da5d7e1f9dc94d0467130cf630f1 (patch) | |
tree | 1fdea05f45d91439905ed7904b194e4747342364 /Source/WebCore/platform/graphics/android/GraphicsContext3DProxy.cpp | |
parent | 77ab7f788fa2de43390a0ddb447c94a191284e88 (diff) | |
download | external_webkit-c018655c37a1da5d7e1f9dc94d0467130cf630f1.zip external_webkit-c018655c37a1da5d7e1f9dc94d0467130cf630f1.tar.gz external_webkit-c018655c37a1da5d7e1f9dc94d0467130cf630f1.tar.bz2 |
Fix for memory leak in WebGL
CRs-fixed: 407009
(cherry-picked from commit 796a2a4cc637a3b04ee845e595b081e826207924)
Change-Id: I584fe07dd5887ed52b74bc84044d510f8a2e2ba8
Diffstat (limited to 'Source/WebCore/platform/graphics/android/GraphicsContext3DProxy.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/android/GraphicsContext3DProxy.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsContext3DProxy.cpp b/Source/WebCore/platform/graphics/android/GraphicsContext3DProxy.cpp index 0d273bb..e2ab6f9 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsContext3DProxy.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsContext3DProxy.cpp @@ -34,6 +34,7 @@ namespace WebCore { GraphicsContext3DProxy::GraphicsContext3DProxy() + : m_texture(0) { LOGWEBGL("GraphicsContext3DProxy::GraphicsContext3DProxy(), this = %p", this); } @@ -49,22 +50,6 @@ void GraphicsContext3DProxy::setGraphicsContext(GraphicsContext3DInternal* conte m_context = context; } -void GraphicsContext3DProxy::incr() -{ - MutexLocker lock(m_mutex); - m_refcount++; -} - -void GraphicsContext3DProxy::decr() -{ - MutexLocker lock(m_mutex); - m_refcount--; - if (m_refcount == 0) { - glDeleteTextures(1, &m_texture); - m_texture = 0; - } -} - bool GraphicsContext3DProxy::lockFrontBuffer(GLuint& texture, SkRect& rect) { MutexLocker lock(m_mutex); @@ -79,6 +64,7 @@ bool GraphicsContext3DProxy::lockFrontBuffer(GLuint& texture, SkRect& rect) glBindTexture(GL_TEXTURE_EXTERNAL_OES, m_texture); glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, image); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0); texture = m_texture; } @@ -88,10 +74,13 @@ bool GraphicsContext3DProxy::lockFrontBuffer(GLuint& texture, SkRect& rect) void GraphicsContext3DProxy::releaseFrontBuffer() { MutexLocker lock(m_mutex); + if (m_texture) { + glDeleteTextures(1, &m_texture); + m_texture = 0; + } if (!m_context) { return; } - glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0); m_context->releaseFrontBuffer(); } } |