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

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

Issue 1520123002: Fix state restoration logic in canvas 2d wakeup from hibernation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp » ('j') | 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 c1f26965e024218c2ab6a3a9bc4a3ef8d3b7f5f8..cd865932e8558591c2630d3e71c1adfb49fc483a 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -170,7 +170,7 @@ bool Canvas2DLayerBridge::shouldAccelerate(AccelerationHint hint) const
else if (m_accelerationMode == DisableAcceleration)
accelerate = false;
else
- accelerate = hint == PreferAcceleration;
+ accelerate = hint == PreferAcceleration || hint == PreferAccelerationAfterVisibilityChange;
if (accelerate && (!m_contextProvider || m_contextProvider->context3d()->isContextLost()))
accelerate = false;
@@ -251,8 +251,9 @@ SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint)
if (m_surface)
return m_surface.get();
- if (m_layer && !isHibernating())
+ if (m_layer && !isHibernating() && hint == PreferAcceleration) {
return nullptr; // re-creation will happen through restore()
+ }
bool wantAcceleration = shouldAccelerate(hint);
bool surfaceIsAccelerated;
@@ -289,6 +290,9 @@ SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint)
if (m_imageBuffer)
m_imageBuffer->updateGPUMemoryUsage();
+
+ if (m_imageBuffer && !m_isDeferralEnabled)
+ m_imageBuffer->resetCanvas(m_surface->getCanvas());
}
return m_surface.get();
}
@@ -394,9 +398,12 @@ void Canvas2DLayerBridge::setIsHidden(bool hidden)
copyPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
RefPtr<SkSurface> oldSurface = m_surface.release();
m_softwareRenderingWhileHidden = false;
- SkSurface* newSurface = getOrCreateSurface();
+ SkSurface* newSurface = getOrCreateSurface(PreferAccelerationAfterVisibilityChange);
if (newSurface) {
oldSurface->draw(newSurface->getCanvas(), 0, 0, &copyPaint);
+ if (m_imageBuffer && !m_isDeferralEnabled) {
+ m_imageBuffer->resetCanvas(m_surface->getCanvas());
+ }
}
}
if (!isHidden() && isHibernating()) {
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698