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

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

Issue 2057283002: Fix canvas-related crash caused by bad object teardown sequence (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test crash Created 4 years, 6 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 | « third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
index 8a4c4e7d4d85691c7079a5003403eedf80462b1c..811210c09a2e02a6ee4bc11b3248d25bb034eb7d 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -117,7 +117,7 @@ Canvas2DLayerBridge::Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider
, m_opacityMode(opacityMode)
, m_size(size)
{
- ASSERT(m_contextProvider);
+ DCHECK(m_contextProvider);
// Used by browser tests to detect the use of a Canvas2DLayerBridge.
TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation", TRACE_EVENT_SCOPE_GLOBAL);
startRecording();
@@ -125,18 +125,18 @@ Canvas2DLayerBridge::Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider
Canvas2DLayerBridge::~Canvas2DLayerBridge()
{
- ASSERT(m_destructionInProgress);
+ DCHECK(m_destructionInProgress);
#if USE_IOSURFACE_FOR_2D_CANVAS
clearCHROMIUMImageCache();
#endif // USE_IOSURFACE_FOR_2D_CANVAS
m_layer.reset();
- ASSERT(m_mailboxes.size() == 0);
+ DCHECK_EQ(0u, m_mailboxes.size());
}
void Canvas2DLayerBridge::startRecording()
{
- ASSERT(m_isDeferralEnabled);
+ DCHECK(m_isDeferralEnabled);
m_recorder = adoptPtr(new SkPictureRecorder);
m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr);
if (m_imageBuffer) {
@@ -345,7 +345,7 @@ bool Canvas2DLayerBridge::prepareMailboxFromImage(PassRefPtr<SkImage> image, Web
// Re-use the texture's existing mailbox, if there is one.
if (mailboxInfo.m_image->getTexture()->getCustomData()) {
- ASSERT(mailboxInfo.m_image->getTexture()->getCustomData()->size() == sizeof(mailboxInfo.m_mailbox.name));
+ DCHECK(mailboxInfo.m_image->getTexture()->getCustomData()->size() == sizeof(mailboxInfo.m_mailbox.name));
memcpy(&mailboxInfo.m_mailbox.name[0], mailboxInfo.m_image->getTexture()->getCustomData()->data(), sizeof(mailboxInfo.m_mailbox.name));
} else {
gl->GenMailboxCHROMIUM(mailboxInfo.m_mailbox.name);
@@ -394,8 +394,8 @@ static void hibernateWrapper(WeakPtr<Canvas2DLayerBridge> bridge, double /*idleD
void Canvas2DLayerBridge::hibernate()
{
- ASSERT(!isHibernating());
- ASSERT(m_hibernationScheduled);
+ DCHECK(!isHibernating());
+ DCHECK(m_hibernationScheduled);
m_hibernationScheduled = false;
@@ -438,7 +438,7 @@ void Canvas2DLayerBridge::hibernate()
// case because flushRecordingOnly should only fail it it fails to allocate
// a surface, and we have an early exit at the top of this function for when
// 'this' does not already have a surface.
- ASSERT(!m_haveRecordedDrawCommands);
+ DCHECK(!m_haveRecordedDrawCommands);
SkPaint copyPaint;
copyPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
m_surface->draw(tempHibernationSurface->getCanvas(), 0, 0, &copyPaint); // GPU readback
@@ -587,7 +587,7 @@ void Canvas2DLayerBridge::beginDestruction()
m_layer->layer()->removeFromParent();
}
- ASSERT(!m_bytesAllocated);
+ DCHECK(!m_bytesAllocated);
}
void Canvas2DLayerBridge::unregisterTaskObserver()
@@ -600,7 +600,7 @@ void Canvas2DLayerBridge::unregisterTaskObserver()
void Canvas2DLayerBridge::setFilterQuality(SkFilterQuality filterQuality)
{
- ASSERT(!m_destructionInProgress);
+ DCHECK(!m_destructionInProgress);
m_filterQuality = filterQuality;
if (m_layer)
m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality);
@@ -649,7 +649,7 @@ bool Canvas2DLayerBridge::writePixels(const SkImageInfo& origInfo, const void* p
} else {
flush();
}
- ASSERT(!m_haveRecordedDrawCommands);
+ DCHECK(!m_haveRecordedDrawCommands);
// call write pixels on the surface, not the recording canvas.
// No need to call beginDirectSurfaceAccessModeIfNeeded() because writePixels
// ignores the matrix and clip state.
@@ -673,7 +673,7 @@ void Canvas2DLayerBridge::skipQueuedDrawCommands()
void Canvas2DLayerBridge::flushRecordingOnly()
{
- ASSERT(!m_destructionInProgress);
+ DCHECK(!m_destructionInProgress);
if (m_haveRecordedDrawCommands && getOrCreateSurface()) {
TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushRecordingOnly");
@@ -717,7 +717,7 @@ gpu::gles2::GLES2Interface* Canvas2DLayerBridge::contextGL()
bool Canvas2DLayerBridge::checkSurfaceValid()
{
- ASSERT(!m_destructionInProgress);
+ DCHECK(!m_destructionInProgress);
if (m_destructionInProgress)
return false;
if (isHibernating())
@@ -741,10 +741,10 @@ bool Canvas2DLayerBridge::checkSurfaceValid()
bool Canvas2DLayerBridge::restoreSurface()
{
- ASSERT(!m_destructionInProgress);
+ DCHECK(!m_destructionInProgress);
if (m_destructionInProgress)
return false;
- ASSERT(isAccelerated() && !m_surface);
+ DCHECK(isAccelerated() && !m_surface);
gpu::gles2::GLES2Interface* sharedGL = nullptr;
m_layer->clearTexture();
@@ -784,7 +784,7 @@ bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox,
// 4. Here.
return false;
}
- ASSERT(isAccelerated() || isHibernating() || m_softwareRenderingWhileHidden);
+ DCHECK(isAccelerated() || isHibernating() || m_softwareRenderingWhileHidden);
// if hibernating but not hidden, we want to wake up from
// hibernation
@@ -817,9 +817,9 @@ bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox,
void Canvas2DLayerBridge::mailboxReleased(const WebExternalTextureMailbox& mailbox, bool lostResource)
{
- ASSERT(isAccelerated() || isHibernating());
+ DCHECK(isAccelerated() || isHibernating());
bool contextLost = !isHibernating() && (!m_surface || m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR);
- ASSERT(m_mailboxes.last().m_parentLayerBridge.get() == this);
+ DCHECK(m_mailboxes.last().m_parentLayerBridge.get() == this);
// Mailboxes are typically released in FIFO order, so we iterate
// from the end of m_mailboxes.
@@ -831,14 +831,14 @@ void Canvas2DLayerBridge::mailboxReleased(const WebExternalTextureMailbox& mailb
if (nameEquals(releasedMailboxInfo->m_mailbox, mailbox)) {
break;
}
- ASSERT(releasedMailboxInfo != firstMailbox);
+ DCHECK(releasedMailboxInfo != firstMailbox);
}
if (!contextLost) {
// Invalidate texture state in case the compositor altered it since the copy-on-write.
if (releasedMailboxInfo->m_image) {
#if USE_IOSURFACE_FOR_2D_CANVAS
- ASSERT(releasedMailboxInfo->m_imageInfo.empty());
+ DCHECK(releasedMailboxInfo->m_imageInfo.empty());
#endif // USE_IOSURFACE_FOR_2D_CANVAS
if (mailbox.validSyncToken) {
contextGL()->WaitSyncTokenCHROMIUM(mailbox.syncToken);
@@ -877,8 +877,8 @@ void Canvas2DLayerBridge::mailboxReleased(const WebExternalTextureMailbox& mailb
WebLayer* Canvas2DLayerBridge::layer() const
{
- ASSERT(!m_destructionInProgress);
- ASSERT(m_layer);
+ DCHECK(!m_destructionInProgress);
+ DCHECK(m_layer);
return m_layer->layer();
}
@@ -905,7 +905,7 @@ void Canvas2DLayerBridge::prepareSurfaceForPaintingIfNeeded()
void Canvas2DLayerBridge::finalizeFrame(const FloatRect &dirtyRect)
{
- ASSERT(!m_destructionInProgress);
+ DCHECK(!m_destructionInProgress);
if (m_layer)
m_layer->layer()->invalidateRect(enclosingIntRect(dirtyRect));
if (m_rateLimiter)
@@ -916,7 +916,7 @@ void Canvas2DLayerBridge::finalizeFrame(const FloatRect &dirtyRect)
void Canvas2DLayerBridge::didProcessTask()
{
TRACE_EVENT0("cc", "Canvas2DLayerBridge::didProcessTask");
- ASSERT(m_isRegisteredTaskObserver);
+ DCHECK(m_isRegisteredTaskObserver);
// If m_renderTaskProcessedForCurrentFrame is already set to true,
// it means that rendering tasks are not synchronized with the compositor
// (i.e. not using requestAnimationFrame), so we are at risk of posting
@@ -942,7 +942,7 @@ void Canvas2DLayerBridge::didProcessTask()
void Canvas2DLayerBridge::willProcessTask()
{
- ASSERT_NOT_REACHED();
+ NOTREACHED();
}
PassRefPtr<SkImage> Canvas2DLayerBridge::newImageSnapshot(AccelerationHint hint, SnapshotReason)
@@ -973,8 +973,8 @@ Canvas2DLayerBridge::ImageInfo::ImageInfo(GLuint imageId, GLuint textureId, GLin
, m_textureId(textureId)
, m_gpuMemoryBufferId(gpuMemoryBufferId)
{
- ASSERT(imageId);
- ASSERT(textureId);
+ DCHECK(imageId);
+ DCHECK(textureId);
DCHECK_NE(-1, gpuMemoryBufferId);
}
« no previous file with comments | « third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698