Chromium Code Reviews| Index: Source/platform/graphics/Canvas2DLayerBridge.cpp |
| diff --git a/Source/platform/graphics/Canvas2DLayerBridge.cpp b/Source/platform/graphics/Canvas2DLayerBridge.cpp |
| index 5e2f83c293a99350ea6c8b818abf25026147f5bf..dce52df4a7abc11bf5baaa9da0e62b53a43b7493 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) |
|
danakj
2014/07/08 15:19:41
I don't see this method using lostResource still?
Hongbo Min
2014/07/09 01:43:09
Yes, lostResource is not needed here in my opinion
dshwang
2014/07/09 07:14:36
So freeReleasedMailbox() must be called when lostR
Hongbo Min
2014/07/09 07:36:56
freeReleasedMailbox would return early if context
|
| { |
| 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); |
| + } else { |
| + mailboxInfo->m_status = MailboxReleased; |
| + m_releasedMailboxInfoIndex = mailboxInfo - m_mailboxes.begin(); |
| + m_framesSinceMailboxRelease = 0; |
| + if (isHidden()) { |
| + freeReleasedMailbox(); |
| + } else { |
| + ASSERT(!m_destructionInProgress); |
| + Canvas2DLayerManager::get().layerTransientResourceAllocationChanged(this); |
| + } |
| + } |
| return; |
| } |
| } |