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

Side by Side 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 unified diff | Download patch
OLDNEW
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 clearCHROMIUMImageCache(); 160 clearCHROMIUMImageCache();
161 #endif // USE_IOSURFACE_FOR_2D_CANVAS 161 #endif // USE_IOSURFACE_FOR_2D_CANVAS
162 162
163 m_layer.reset(); 163 m_layer.reset();
164 DCHECK_EQ(0u, m_mailboxes.size()); 164 DCHECK_EQ(0u, m_mailboxes.size());
165 } 165 }
166 166
167 void Canvas2DLayerBridge::startRecording() { 167 void Canvas2DLayerBridge::startRecording() {
168 DCHECK(m_isDeferralEnabled); 168 DCHECK(m_isDeferralEnabled);
169 m_recorder = wrapUnique(new SkPictureRecorder); 169 m_recorder = wrapUnique(new SkPictureRecorder);
170 m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr); 170 SkCanvas* canvas =
171 m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr);
172 // Always save an initial frame, to support resetting the top level matrix
173 // and clip.
174 canvas->save();
175
171 if (m_imageBuffer) { 176 if (m_imageBuffer) {
172 m_imageBuffer->resetCanvas(m_recorder->getRecordingCanvas()); 177 m_imageBuffer->resetCanvas(canvas);
173 } 178 }
174 m_recordingPixelCount = 0; 179 m_recordingPixelCount = 0;
175 } 180 }
176 181
177 void Canvas2DLayerBridge::setLoggerForTesting(std::unique_ptr<Logger> logger) { 182 void Canvas2DLayerBridge::setLoggerForTesting(std::unique_ptr<Logger> logger) {
178 m_logger = std::move(logger); 183 m_logger = std::move(logger);
179 } 184 }
180 185
181 bool Canvas2DLayerBridge::shouldAccelerate(AccelerationHint hint) const { 186 bool Canvas2DLayerBridge::shouldAccelerate(AccelerationHint hint) const {
182 bool accelerate; 187 bool accelerate;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 wantAcceleration) { 546 wantAcceleration) {
542 wantAcceleration = false; 547 wantAcceleration = false;
543 m_softwareRenderingWhileHidden = true; 548 m_softwareRenderingWhileHidden = true;
544 } 549 }
545 550
546 bool surfaceIsAccelerated; 551 bool surfaceIsAccelerated;
547 m_surface = createSkSurface( 552 m_surface = createSkSurface(
548 wantAcceleration ? m_contextProvider->grContext() : nullptr, m_size, 553 wantAcceleration ? m_contextProvider->grContext() : nullptr, m_size,
549 m_msaaSampleCount, m_opacityMode, m_colorSpace, &surfaceIsAccelerated); 554 m_msaaSampleCount, m_opacityMode, m_colorSpace, &surfaceIsAccelerated);
550 555
551 if (!m_surface) 556 if (m_surface) {
557 // Always save an initial frame, to support resetting the top level matrix
558 // and clip.
559 m_surface->getCanvas()->save();
560 } else {
552 reportSurfaceCreationFailure(); 561 reportSurfaceCreationFailure();
562 }
553 563
554 if (m_surface && surfaceIsAccelerated && !m_layer) { 564 if (m_surface && surfaceIsAccelerated && !m_layer) {
555 m_layer = wrapUnique( 565 m_layer = wrapUnique(
556 Platform::current()->compositorSupport()->createExternalTextureLayer( 566 Platform::current()->compositorSupport()->createExternalTextureLayer(
557 this)); 567 this));
558 m_layer->setOpaque(m_opacityMode == Opaque); 568 m_layer->setOpaque(m_opacityMode == Opaque);
559 m_layer->setBlendBackgroundColor(m_opacityMode != Opaque); 569 m_layer->setBlendBackgroundColor(m_opacityMode != Opaque);
560 GraphicsLayer::registerContentsLayer(m_layer->layer()); 570 GraphicsLayer::registerContentsLayer(m_layer->layer());
561 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality); 571 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality);
562 } 572 }
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 default; 1132 default;
1123 1133
1124 void Canvas2DLayerBridge::Logger::reportHibernationEvent( 1134 void Canvas2DLayerBridge::Logger::reportHibernationEvent(
1125 HibernationEvent event) { 1135 HibernationEvent event) {
1126 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, 1136 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram,
1127 ("Canvas.HibernationEvents", HibernationEventCount)); 1137 ("Canvas.HibernationEvents", HibernationEventCount));
1128 hibernationHistogram.count(event); 1138 hibernationHistogram.count(event);
1129 } 1139 }
1130 1140
1131 } // namespace blink 1141 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698