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

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

Issue 2391373002: Refactor CRC2D::reset() to avoid non-additive SkCanvas state operations (Closed)
Patch Set: review Created 4 years, 2 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
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 ede0f8a397c742de87325c34aa8df2594013d884..724208bd954bec602346ec3b68b45e85eb157156 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -167,9 +167,14 @@ Canvas2DLayerBridge::~Canvas2DLayerBridge() {
void Canvas2DLayerBridge::startRecording() {
DCHECK(m_isDeferralEnabled);
m_recorder = wrapUnique(new SkPictureRecorder);
- m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr);
+ SkCanvas* canvas =
+ m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr);
+ // Always save an initial frame, to support resetting the top level matrix
+ // and clip.
+ canvas->save();
+
if (m_imageBuffer) {
- m_imageBuffer->resetCanvas(m_recorder->getRecordingCanvas());
+ m_imageBuffer->resetCanvas(canvas);
}
m_recordingPixelCount = 0;
}
@@ -548,8 +553,13 @@ SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) {
wantAcceleration ? m_contextProvider->grContext() : nullptr, m_size,
m_msaaSampleCount, m_opacityMode, m_colorSpace, &surfaceIsAccelerated);
- if (!m_surface)
+ if (m_surface) {
+ // Always save an initial frame, to support resetting the top level matrix
+ // and clip.
+ m_surface->getCanvas()->save();
+ } else {
reportSurfaceCreationFailure();
+ }
if (m_surface && surfaceIsAccelerated && !m_layer) {
m_layer = wrapUnique(

Powered by Google App Engine
This is Rietveld 408576698