| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/paint/SkPictureBuilder.h" | 5 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 6 | 6 |
| 7 #include "platform/geometry/FloatRect.h" | 7 #include "platform/geometry/FloatRect.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/paint/PaintController.h" | 9 #include "platform/graphics/paint/PaintController.h" |
| 10 #include "wtf/PtrUtil.h" | 10 #include "wtf/PtrUtil.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 SkPictureBuilder::SkPictureBuilder(const FloatRect& bounds, | 14 SkPictureBuilder::SkPictureBuilder(const FloatRect& bounds, |
| 15 SkMetaData* metaData, | 15 SkMetaData* metaData, |
| 16 GraphicsContext* containingContext) | 16 GraphicsContext* containingContext, |
| 17 : m_bounds(bounds) { | 17 PaintController* paintController) |
| 18 : m_paintController(nullptr), m_bounds(bounds) { |
| 18 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled; | 19 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled; |
| 19 if (containingContext && containingContext->contextDisabled()) | 20 if (containingContext && containingContext->contextDisabled()) |
| 20 disabledMode = GraphicsContext::FullyDisabled; | 21 disabledMode = GraphicsContext::FullyDisabled; |
| 21 | 22 |
| 22 m_paintController = PaintController::create(); | 23 if (paintController) { |
| 23 m_paintController->beginSkippingCache(); | 24 m_paintController = paintController; |
| 25 } else { |
| 26 m_paintControllerPtr = PaintController::create(); |
| 27 m_paintController = m_paintControllerPtr.get(); |
| 28 } |
| 24 m_context = wrapUnique( | 29 m_context = wrapUnique( |
| 25 new GraphicsContext(*m_paintController, disabledMode, metaData)); | 30 new GraphicsContext(*m_paintController, disabledMode, metaData)); |
| 26 | 31 |
| 27 if (containingContext) { | 32 if (containingContext) { |
| 28 m_context->setDeviceScaleFactor(containingContext->deviceScaleFactor()); | 33 m_context->setDeviceScaleFactor(containingContext->deviceScaleFactor()); |
| 29 m_context->setPrinting(containingContext->printing()); | 34 m_context->setPrinting(containingContext->printing()); |
| 30 } | 35 } |
| 31 } | 36 } |
| 32 | 37 |
| 33 SkPictureBuilder::~SkPictureBuilder() {} | 38 SkPictureBuilder::~SkPictureBuilder() {} |
| 34 | 39 |
| 35 sk_sp<SkPicture> SkPictureBuilder::endRecording() { | 40 sk_sp<SkPicture> SkPictureBuilder::endRecording() { |
| 36 m_context->beginRecording(m_bounds); | 41 m_context->beginRecording(m_bounds); |
| 37 m_paintController->endSkippingCache(); | |
| 38 m_paintController->commitNewDisplayItems(); | 42 m_paintController->commitNewDisplayItems(); |
| 39 m_paintController->paintArtifact().replay(*m_context); | 43 m_paintController->paintArtifact().replay(*m_context); |
| 40 return m_context->endRecording(); | 44 return m_context->endRecording(); |
| 41 } | 45 } |
| 42 | 46 |
| 43 } // namespace blink | 47 } // namespace blink |
| OLD | NEW |