Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 m_canvas->setNotificationClient(this); | 113 m_canvas->setNotificationClient(this); |
| 114 #ifndef NDEBUG | 114 #ifndef NDEBUG |
| 115 canvas2DLayerBridgeInstanceCounter.increment(); | 115 canvas2DLayerBridgeInstanceCounter.increment(); |
| 116 #endif | 116 #endif |
| 117 } | 117 } |
| 118 | 118 |
| 119 Canvas2DLayerBridge::~Canvas2DLayerBridge() | 119 Canvas2DLayerBridge::~Canvas2DLayerBridge() |
| 120 { | 120 { |
| 121 ASSERT(m_destructionInProgress); | 121 ASSERT(m_destructionInProgress); |
| 122 ASSERT(!Canvas2DLayerManager::get().isInList(this)); | 122 ASSERT(!Canvas2DLayerManager::get().isInList(this)); |
| 123 if (m_canvas) | |
| 124 m_canvas->setNotificationClient(nullptr); | |
| 123 m_layer.clear(); | 125 m_layer.clear(); |
| 124 ASSERT(m_mailboxes.size() == 0); | 126 ASSERT(m_mailboxes.size() == 0); |
| 125 #ifndef NDEBUG | 127 #ifndef NDEBUG |
| 126 canvas2DLayerBridgeInstanceCounter.decrement(); | 128 canvas2DLayerBridgeInstanceCounter.decrement(); |
| 127 #endif | 129 #endif |
| 128 } | 130 } |
| 129 | 131 |
| 130 void Canvas2DLayerBridge::beginDestruction() | 132 void Canvas2DLayerBridge::beginDestruction() |
| 131 { | 133 { |
| 132 ASSERT(!m_destructionInProgress); | 134 ASSERT(!m_destructionInProgress); |
| 133 setRateLimitingEnabled(false); | 135 setRateLimitingEnabled(false); |
| 134 m_canvas->silentFlush(); | 136 m_canvas->silentFlush(); |
| 135 m_imageBuffer = 0; | 137 m_imageBuffer = 0; |
| 136 freeTransientResources(); | 138 freeTransientResources(); |
| 137 setIsHidden(true); | 139 setIsHidden(true); |
| 138 m_destructionInProgress = true; | 140 m_destructionInProgress = true; |
| 139 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 141 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
| 140 m_canvas->setNotificationClient(0); | 142 m_canvas->setNotificationClient(0); |
|
dshwang
2015/02/04 13:32:06
The patch demonstrates that the destructor is call
| |
| 141 m_surface.clear(); | 143 m_surface.clear(); |
| 142 m_canvas.clear(); | 144 m_canvas.clear(); |
| 143 m_layer->clearTexture(); | 145 m_layer->clearTexture(); |
| 144 // Orphaning the layer is required to trigger the recration of a new layer | 146 // Orphaning the layer is required to trigger the recration of a new layer |
| 145 // in the case where destruction is caused by a canvas resize. Test: | 147 // in the case where destruction is caused by a canvas resize. Test: |
| 146 // virtual/gpu/fast/canvas/canvas-resize-after-paint-without-layout.html | 148 // virtual/gpu/fast/canvas/canvas-resize-after-paint-without-layout.html |
| 147 m_layer->layer()->removeFromParent(); | 149 m_layer->layer()->removeFromParent(); |
| 148 // To anyone who ever hits this assert: Please update crbug.com/344666 | 150 // To anyone who ever hits this assert: Please update crbug.com/344666 |
| 149 // with repro steps. | 151 // with repro steps. |
| 150 ASSERT(!m_bytesAllocated); | 152 ASSERT(!m_bytesAllocated); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { | 533 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { |
| 532 // This copy constructor should only be used for Deque::prepend | 534 // This copy constructor should only be used for Deque::prepend |
| 533 // Assuming 'other' is to be destroyed, we transfer m_image and | 535 // Assuming 'other' is to be destroyed, we transfer m_image and |
| 534 // m_parentLayerBridge ownership rather than do a refcount dance. | 536 // m_parentLayerBridge ownership rather than do a refcount dance. |
| 535 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 537 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
| 536 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); | 538 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); |
| 537 m_parentLayerBridge = const_cast<MailboxInfo*>(&other)->m_parentLayerBridge. release(); | 539 m_parentLayerBridge = const_cast<MailboxInfo*>(&other)->m_parentLayerBridge. release(); |
| 538 } | 540 } |
| 539 | 541 |
| 540 } // namespace blink | 542 } // namespace blink |
| OLD | NEW |