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

Unified Diff: Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 369043003: Let canvas decide how to handle the case of resource lost reported by client: 2D part (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: release mailbox immediately if resource is lost 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
« no previous file with comments | « Source/platform/graphics/Canvas2DLayerBridge.h ('k') | Source/platform/graphics/gpu/DrawingBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/Canvas2DLayerBridge.cpp
diff --git a/Source/platform/graphics/Canvas2DLayerBridge.cpp b/Source/platform/graphics/Canvas2DLayerBridge.cpp
index 5e2f83c293a99350ea6c8b818abf25026147f5bf..da82069880413b505264ebe98146d68e8766c8c6 100644
--- a/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -489,28 +489,38 @@ Canvas2DLayerBridge::MailboxInfo* Canvas2DLayerBridge::createMailboxInfo() {
return mailboxInfo;
}
-void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox& mailbox)
+void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox& mailbox, bool lostResource)
{
freeReleasedMailbox(); // Never have more than one mailbox in the released state.
+ bool contextLost = m_contextProvider->context3d()->isContextLost() || !m_isSurfaceValid;
Vector<MailboxInfo>::iterator mailboxInfo;
for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++mailboxInfo) {
if (nameEquals(mailboxInfo->m_mailbox, mailbox)) {
mailboxInfo->m_mailbox.syncPoint = mailbox.syncPoint;
ASSERT(mailboxInfo->m_status == MailboxInUse);
- mailboxInfo->m_status = MailboxReleased;
// Trigger Canvas2DLayerBridge self-destruction if this is the
// last live mailbox and the layer bridge is not externally
// referenced.
- m_releasedMailboxInfoIndex = mailboxInfo - m_mailboxes.begin();
- m_framesSinceMailboxRelease = 0;
- if (isHidden()) {
- freeReleasedMailbox();
- } else {
- ASSERT(!m_destructionInProgress);
- Canvas2DLayerManager::get().layerTransientResourceAllocationChanged(this);
- }
ASSERT(mailboxInfo->m_parentLayerBridge.get() == this);
mailboxInfo->m_parentLayerBridge.clear();
+
+ if (contextLost) {
+ // No need to clean up the mailbox resource, but make sure the
+ // mailbox can also be reusable once the context is restored.
+ mailboxInfo->m_status = MailboxAvailable;
+ m_releasedMailboxInfoIndex = InvalidMailboxIndex;
+ Canvas2DLayerManager::get().layerTransientResourceAllocationChanged(this);
dshwang 2014/07/09 08:14:50 Do we need to remove the given mailboxInfo from m_
Justin Novosad 2014/07/11 17:22:38 That is a good question. A generated mailbox is no
danakj 2014/07/11 17:31:07 To be sure we're on the same page the |lostResourc
+ } else {
+ mailboxInfo->m_status = MailboxReleased;
+ m_releasedMailboxInfoIndex = mailboxInfo - m_mailboxes.begin();
+ m_framesSinceMailboxRelease = 0;
+ if (isHidden() || lostResource) {
Justin Novosad 2014/07/11 18:05:05 According to Dana's most recent comment, we probab
Hongbo Min 2014/07/15 13:51:13 To make code much clean, I reset the syncPoint to
+ freeReleasedMailbox();
+ } else {
+ ASSERT(!m_destructionInProgress);
+ Canvas2DLayerManager::get().layerTransientResourceAllocationChanged(this);
+ }
+ }
return;
}
}
« no previous file with comments | « Source/platform/graphics/Canvas2DLayerBridge.h ('k') | Source/platform/graphics/gpu/DrawingBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698