| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "platform/graphics/RecordingImageBufferSurface.h" | 7 #include "platform/graphics/RecordingImageBufferSurface.h" |
| 8 | 8 |
| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 if (m_currentFrame) { | 85 if (m_currentFrame) { |
| 86 RefPtr<SkPicture> currentPicture = adoptRef(m_currentFrame->endRecording
()); | 86 RefPtr<SkPicture> currentPicture = adoptRef(m_currentFrame->endRecording
()); |
| 87 currentPicture->playback(m_fallbackSurface->canvas()); | 87 currentPicture->playback(m_fallbackSurface->canvas()); |
| 88 m_currentFrame.clear(); | 88 m_currentFrame.clear(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 if (m_imageBuffer) { | 91 if (m_imageBuffer) { |
| 92 m_imageBuffer->resetCanvas(m_fallbackSurface->canvas()); | 92 m_imageBuffer->resetCanvas(m_fallbackSurface->canvas()); |
| 93 m_imageBuffer->context()->setAccelerated(m_fallbackSurface->isAccelerate
d()); | |
| 94 } | 93 } |
| 95 | 94 |
| 96 } | 95 } |
| 97 | 96 |
| 98 PassRefPtr<SkImage> RecordingImageBufferSurface::newImageSnapshot() const | 97 PassRefPtr<SkImage> RecordingImageBufferSurface::newImageSnapshot() const |
| 99 { | 98 { |
| 100 if (!m_fallbackSurface) | 99 if (!m_fallbackSurface) |
| 101 const_cast<RecordingImageBufferSurface*>(this)->fallBackToRasterCanvas()
; | 100 const_cast<RecordingImageBufferSurface*>(this)->fallBackToRasterCanvas()
; |
| 102 return m_fallbackSurface->newImageSnapshot(); | 101 return m_fallbackSurface->newImageSnapshot(); |
| 103 } | 102 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 return true; | 187 return true; |
| 189 } | 188 } |
| 190 | 189 |
| 191 void RecordingImageBufferSurface::willDrawVideo() | 190 void RecordingImageBufferSurface::willDrawVideo() |
| 192 { | 191 { |
| 193 // Video draws need to be synchronous | 192 // Video draws need to be synchronous |
| 194 if (!m_fallbackSurface) | 193 if (!m_fallbackSurface) |
| 195 fallBackToRasterCanvas(); | 194 fallBackToRasterCanvas(); |
| 196 } | 195 } |
| 197 | 196 |
| 198 void RecordingImageBufferSurface::draw(GraphicsContext* context, const FloatRect
& destRect, const FloatRect& srcRect, SkXfermode::Mode op, bool needsCopy) | 197 void RecordingImageBufferSurface::draw(GraphicsContext* context, const FloatRect
& destRect, const FloatRect& srcRect, SkXfermode::Mode op) |
| 199 { | 198 { |
| 200 if (m_fallbackSurface) { | 199 if (m_fallbackSurface) { |
| 201 m_fallbackSurface->draw(context, destRect, srcRect, op, needsCopy); | 200 m_fallbackSurface->draw(context, destRect, srcRect, op); |
| 202 return; | 201 return; |
| 203 } | 202 } |
| 204 | 203 |
| 205 RefPtr<SkPicture> picture = getPicture(); | 204 RefPtr<SkPicture> picture = getPicture(); |
| 206 if (picture) { | 205 if (picture) { |
| 207 context->compositePicture(picture.get(), destRect, srcRect, op); | 206 context->compositePicture(picture.get(), destRect, srcRect, op); |
| 208 } else { | 207 } else { |
| 209 ImageBufferSurface::draw(context, destRect, srcRect, op, needsCopy); | 208 ImageBufferSurface::draw(context, destRect, srcRect, op); |
| 210 } | 209 } |
| 211 } | 210 } |
| 212 | 211 |
| 213 bool RecordingImageBufferSurface::isExpensiveToPaint() | 212 bool RecordingImageBufferSurface::isExpensiveToPaint() |
| 214 { | 213 { |
| 215 if (m_fallbackSurface) | 214 if (m_fallbackSurface) |
| 216 return m_fallbackSurface->isExpensiveToPaint(); | 215 return m_fallbackSurface->isExpensiveToPaint(); |
| 217 | 216 |
| 218 if (m_didRecordDrawCommandsInCurrentFrame) { | 217 if (m_didRecordDrawCommandsInCurrentFrame) { |
| 219 if (m_currentFrameHasExpensiveOp) | 218 if (m_currentFrameHasExpensiveOp) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 305 |
| 307 void RecordingImageBufferSurface::setIsHidden(bool hidden) | 306 void RecordingImageBufferSurface::setIsHidden(bool hidden) |
| 308 { | 307 { |
| 309 if (m_fallbackSurface) | 308 if (m_fallbackSurface) |
| 310 m_fallbackSurface->setIsHidden(hidden); | 309 m_fallbackSurface->setIsHidden(hidden); |
| 311 else | 310 else |
| 312 ImageBufferSurface::setIsHidden(hidden); | 311 ImageBufferSurface::setIsHidden(hidden); |
| 313 } | 312 } |
| 314 | 313 |
| 315 } // namespace blink | 314 } // namespace blink |
| OLD | NEW |