| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 void RecordingImageBufferSurface::didDraw(const FloatRect& rect) | 252 void RecordingImageBufferSurface::didDraw(const FloatRect& rect) |
| 253 { | 253 { |
| 254 m_didRecordDrawCommandsInCurrentFrame = true; | 254 m_didRecordDrawCommandsInCurrentFrame = true; |
| 255 IntRect pixelBounds = enclosingIntRect(rect); | 255 IntRect pixelBounds = enclosingIntRect(rect); |
| 256 m_currentFramePixelCount += pixelBounds.width() * pixelBounds.height(); | 256 m_currentFramePixelCount += pixelBounds.width() * pixelBounds.height(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 bool RecordingImageBufferSurface::finalizeFrameInternal(FallbackReason* fallback
Reason) | 259 bool RecordingImageBufferSurface::finalizeFrameInternal(FallbackReason* fallback
Reason) |
| 260 { | 260 { |
| 261 ASSERT(!m_fallbackSurface); | 261 CHECK(!m_fallbackSurface); |
| 262 ASSERT(m_currentFrame); | 262 CHECK(m_currentFrame); |
| 263 ASSERT(m_currentFrame->getRecordingCanvas()); | 263 ASSERT(m_currentFrame->getRecordingCanvas()); |
| 264 ASSERT(fallbackReason); | 264 ASSERT(fallbackReason); |
| 265 ASSERT(*fallbackReason == FallbackReasonUnknown); | 265 ASSERT(*fallbackReason == FallbackReasonUnknown); |
| 266 | 266 |
| 267 if (!m_imageBuffer->isDirty()) { | 267 if (!m_imageBuffer->isDirty()) { |
| 268 if (!m_previousFrame) { | 268 if (!m_previousFrame) { |
| 269 // Create an initial blank frame | 269 // Create an initial blank frame |
| 270 m_previousFrame = fromSkSp(m_currentFrame->finishRecordingAsPicture(
)); | 270 m_previousFrame = fromSkSp(m_currentFrame->finishRecordingAsPicture(
)); |
| 271 initializeCurrentFrame(); | 271 initializeCurrentFrame(); |
| 272 } | 272 } |
| 273 return m_currentFrame.get(); | 273 CHECK(m_currentFrame); |
| 274 return true; |
| 274 } | 275 } |
| 275 | 276 |
| 276 if (!m_frameWasCleared) { | 277 if (!m_frameWasCleared) { |
| 277 *fallbackReason = FallbackReasonCanvasNotClearedBetweenFrames; | 278 *fallbackReason = FallbackReasonCanvasNotClearedBetweenFrames; |
| 278 return false; | 279 return false; |
| 279 } | 280 } |
| 280 | 281 |
| 281 if (m_fallbackFactory && m_currentFrame->getRecordingCanvas()->getSaveCount(
) > ExpensiveCanvasHeuristicParameters::ExpensiveRecordingStackDepth) { | 282 if (m_fallbackFactory && m_currentFrame->getRecordingCanvas()->getSaveCount(
) > ExpensiveCanvasHeuristicParameters::ExpensiveRecordingStackDepth) { |
| 282 *fallbackReason = FallbackReasonRunawayStateStack; | 283 *fallbackReason = FallbackReasonRunawayStateStack; |
| 283 return false; | 284 return false; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 360 |
| 360 void RecordingImageBufferSurface::setIsHidden(bool hidden) | 361 void RecordingImageBufferSurface::setIsHidden(bool hidden) |
| 361 { | 362 { |
| 362 if (m_fallbackSurface) | 363 if (m_fallbackSurface) |
| 363 m_fallbackSurface->setIsHidden(hidden); | 364 m_fallbackSurface->setIsHidden(hidden); |
| 364 else | 365 else |
| 365 ImageBufferSurface::setIsHidden(hidden); | 366 ImageBufferSurface::setIsHidden(hidden); |
| 366 } | 367 } |
| 367 | 368 |
| 368 } // namespace blink | 369 } // namespace blink |
| OLD | NEW |