| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |