Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1663)

Unified Diff: Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 251023004: WebGL: Free temporary GPU resources held by inactive or hidden WebGL. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use ASSERT instead of 'if' in prepareMailbox() Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/graphics/gpu/DrawingBuffer.cpp
diff --git a/Source/platform/graphics/gpu/DrawingBuffer.cpp b/Source/platform/graphics/gpu/DrawingBuffer.cpp
index bcf1a10ae65da690d43f1828cf206946252c421a..3e70a4319fdb995d717a73289dea85a188cd3286 100644
--- a/Source/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -148,6 +148,7 @@ DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context,
, m_sampleCount(0)
, m_packAlignment(4)
, m_destructionInProgress(false)
+ , m_isHidden(false)
, m_contextEvictionManager(contextEvictionManager)
{
// Used by browser tests to detect the use of a DrawingBuffer.
@@ -185,6 +186,26 @@ void DrawingBuffer::markLayerComposited()
m_layerComposited = true;
}
+
+void DrawingBuffer::setIsHidden(bool hidden)
+{
+ ASSERT(!m_destructionInProgress);
Ken Russell (switch to Gerrit) 2014/07/09 20:57:57 This assert seems a little aggressive, but I do ag
+ if (m_isHidden == hidden)
+ return;
+ m_isHidden = hidden;
dshwang 2014/07/09 17:40:54 I changes m_isHidden meaning. It doesn't include m
+ if (m_isHidden)
+ freeRecycledMailboxes();
+}
+
+void DrawingBuffer::freeRecycledMailboxes()
+{
+ if (m_recycledMailboxQueue.isEmpty())
+ return;
+ m_context->makeContextCurrent();
+ while (!m_recycledMailboxQueue.isEmpty())
+ deleteMailbox(m_recycledMailboxQueue.takeLast());
+}
+
blink::WebGraphicsContext3D* DrawingBuffer::context()
{
return m_context.get();
@@ -192,6 +213,7 @@ blink::WebGraphicsContext3D* DrawingBuffer::context()
bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox, blink::WebExternalBitmap* bitmap)
{
+ ASSERT(!m_isHidden);
dshwang 2014/07/09 17:40:54 As danakj@ mentioned, 'm_isHidden == true' never h
if (!m_contentsChanged)
return false;
@@ -278,8 +300,8 @@ bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox,
void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mailbox)
{
- if (m_destructionInProgress) {
- mailboxReleasedWhileDestructionInProgress(mailbox);
+ if (m_destructionInProgress || m_isHidden) {
+ mailboxReleasedWithoutRecycling(mailbox);
return;
}
@@ -296,7 +318,7 @@ void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail
ASSERT_NOT_REACHED();
}
-void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const blink::WebExternalTextureMailbox& mailbox)
+void DrawingBuffer::mailboxReleasedWithoutRecycling(const blink::WebExternalTextureMailbox& mailbox)
{
ASSERT(m_textureMailboxes.size());
m_context->makeContextCurrent();

Powered by Google App Engine
This is Rietveld 408576698