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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp

Issue 1879133004: Allow fallbackFactory to be null in RecordingImageBufferSurface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/RecordingImageBufferSurface.h" 5 #include "platform/graphics/RecordingImageBufferSurface.h"
6 6
7 #include "platform/Histogram.h" 7 #include "platform/Histogram.h"
8 #include "platform/graphics/CanvasMetrics.h" 8 #include "platform/graphics/CanvasMetrics.h"
9 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" 9 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
10 #include "platform/graphics/GraphicsContext.h" 10 #include "platform/graphics/GraphicsContext.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if (x <= 0 && y <= 0 && x + origInfo.width() >= size().width() && y + or igInfo.height() >= size().height()) { 63 if (x <= 0 && y <= 0 && x + origInfo.width() >= size().width() && y + or igInfo.height() >= size().height()) {
64 willOverwriteCanvas(); 64 willOverwriteCanvas();
65 } 65 }
66 fallBackToRasterCanvas(FallbackReasonWritePixels); 66 fallBackToRasterCanvas(FallbackReasonWritePixels);
67 } 67 }
68 return m_fallbackSurface->writePixels(origInfo, pixels, rowBytes, x, y); 68 return m_fallbackSurface->writePixels(origInfo, pixels, rowBytes, x, y);
69 } 69 }
70 70
71 void RecordingImageBufferSurface::fallBackToRasterCanvas(FallbackReason reason) 71 void RecordingImageBufferSurface::fallBackToRasterCanvas(FallbackReason reason)
72 { 72 {
73 ASSERT(m_fallbackFactory);
74
73 if (m_fallbackSurface) { 75 if (m_fallbackSurface) {
74 ASSERT(!m_currentFrame); 76 ASSERT(!m_currentFrame);
75 return; 77 return;
76 } 78 }
77 79
78 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, canvasFallbackHistogra m, new EnumerationHistogram("Canvas.DisplayListFallbackReason", FallbackReasonCo unt)); 80 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, canvasFallbackHistogra m, new EnumerationHistogram("Canvas.DisplayListFallbackReason", FallbackReasonCo unt));
79 canvasFallbackHistogram.count(reason); 81 canvasFallbackHistogram.count(reason);
80 82
81 m_fallbackSurface = m_fallbackFactory->createSurface(size(), getOpacityMode( )); 83 m_fallbackSurface = m_fallbackFactory->createSurface(size(), getOpacityMode( ));
82 m_fallbackSurface->setImageBuffer(m_imageBuffer); 84 m_fallbackSurface->setImageBuffer(m_imageBuffer);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 173
172 PassRefPtr<SkPicture> RecordingImageBufferSurface::getPicture() 174 PassRefPtr<SkPicture> RecordingImageBufferSurface::getPicture()
173 { 175 {
174 if (m_fallbackSurface) 176 if (m_fallbackSurface)
175 return nullptr; 177 return nullptr;
176 178
177 FallbackReason fallbackReason = FallbackReasonUnknown; 179 FallbackReason fallbackReason = FallbackReasonUnknown;
178 bool canUsePicture = finalizeFrameInternal(&fallbackReason); 180 bool canUsePicture = finalizeFrameInternal(&fallbackReason);
179 m_imageBuffer->didFinalizeFrame(); 181 m_imageBuffer->didFinalizeFrame();
180 182
183 ASSERT(canUsePicture || m_fallbackFactory);
184
181 if (canUsePicture) { 185 if (canUsePicture) {
182 return m_previousFrame; 186 return m_previousFrame;
183 } 187 }
184 188
185 if (!m_fallbackSurface) 189 if (!m_fallbackSurface)
186 fallBackToRasterCanvas(fallbackReason); 190 fallBackToRasterCanvas(fallbackReason);
187 return nullptr; 191 return nullptr;
188 } 192 }
189 193
190 void RecordingImageBufferSurface::finalizeFrame(const FloatRect &dirtyRect) 194 void RecordingImageBufferSurface::finalizeFrame(const FloatRect &dirtyRect)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 initializeCurrentFrame(); 259 initializeCurrentFrame();
256 } 260 }
257 return m_currentFrame.get(); 261 return m_currentFrame.get();
258 } 262 }
259 263
260 if (!m_frameWasCleared) { 264 if (!m_frameWasCleared) {
261 *fallbackReason = FallbackReasonCanvasNotClearedBetweenFrames; 265 *fallbackReason = FallbackReasonCanvasNotClearedBetweenFrames;
262 return false; 266 return false;
263 } 267 }
264 268
265 if (m_currentFrame->getRecordingCanvas()->getSaveCount() > ExpensiveCanvasHe uristicParameters::ExpensiveRecordingStackDepth) { 269 if (m_fallbackFactory && m_currentFrame->getRecordingCanvas()->getSaveCount( ) > ExpensiveCanvasHeuristicParameters::ExpensiveRecordingStackDepth) {
266 *fallbackReason = FallbackReasonRunawayStateStack; 270 *fallbackReason = FallbackReasonRunawayStateStack;
267 return false; 271 return false;
268 } 272 }
269 273
270 m_previousFrame = fromSkSp(m_currentFrame->finishRecordingAsPicture()); 274 m_previousFrame = fromSkSp(m_currentFrame->finishRecordingAsPicture());
271 m_previousFrameHasExpensiveOp = m_currentFrameHasExpensiveOp; 275 m_previousFrameHasExpensiveOp = m_currentFrameHasExpensiveOp;
272 m_previousFramePixelCount = m_currentFramePixelCount; 276 m_previousFramePixelCount = m_currentFramePixelCount;
273 initializeCurrentFrame(); 277 initializeCurrentFrame();
274 278
275 m_frameWasCleared = false; 279 m_frameWasCleared = false;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 347
344 void RecordingImageBufferSurface::setIsHidden(bool hidden) 348 void RecordingImageBufferSurface::setIsHidden(bool hidden)
345 { 349 {
346 if (m_fallbackSurface) 350 if (m_fallbackSurface)
347 m_fallbackSurface->setIsHidden(hidden); 351 m_fallbackSurface->setIsHidden(hidden);
348 else 352 else
349 ImageBufferSurface::setIsHidden(hidden); 353 ImageBufferSurface::setIsHidden(hidden);
350 } 354 }
351 355
352 } // namespace blink 356 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698