| 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 #ifndef SkPictureBuilder_h | 5 #ifndef SkPictureBuilder_h |
| 6 #define SkPictureBuilder_h | 6 #define SkPictureBuilder_h |
| 7 | 7 |
| 8 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 10 #include "platform/graphics/paint/DisplayItemList.h" | 10 #include "platform/graphics/paint/PaintController.h" |
| 11 #include "wtf/OwnPtr.h" | 11 #include "wtf/OwnPtr.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 // When slimming paint ships we can remove this SkPicture abstraction and | 15 // When slimming paint ships we can remove this SkPicture abstraction and |
| 16 // rely on DisplayItemList here. | 16 // rely on PaintController here. |
| 17 class SkPictureBuilder { | 17 class SkPictureBuilder { |
| 18 WTF_MAKE_NONCOPYABLE(SkPictureBuilder); | 18 WTF_MAKE_NONCOPYABLE(SkPictureBuilder); |
| 19 STACK_ALLOCATED(); | 19 STACK_ALLOCATED(); |
| 20 public: | 20 public: |
| 21 SkPictureBuilder(const FloatRect& bounds, SkMetaData* metaData = 0, Graphics
Context* containingContext = 0) | 21 SkPictureBuilder(const FloatRect& bounds, SkMetaData* metaData = 0, Graphics
Context* containingContext = 0) |
| 22 : m_bounds(bounds) | 22 : m_bounds(bounds) |
| 23 { | 23 { |
| 24 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDis
abled; | 24 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDis
abled; |
| 25 if (containingContext && containingContext->contextDisabled()) | 25 if (containingContext && containingContext->contextDisabled()) |
| 26 disabledMode = GraphicsContext::FullyDisabled; | 26 disabledMode = GraphicsContext::FullyDisabled; |
| 27 | 27 |
| 28 m_displayItemList = DisplayItemList::create(); | 28 m_paintController = PaintController::create(); |
| 29 m_context = adoptPtr(new GraphicsContext(m_displayItemList.get(), disabl
edMode, metaData)); | 29 m_context = adoptPtr(new GraphicsContext(m_paintController.get(), disabl
edMode, metaData)); |
| 30 | 30 |
| 31 if (containingContext) { | 31 if (containingContext) { |
| 32 m_context->setDeviceScaleFactor(containingContext->deviceScaleFactor
()); | 32 m_context->setDeviceScaleFactor(containingContext->deviceScaleFactor
()); |
| 33 m_context->setPrinting(containingContext->printing()); | 33 m_context->setPrinting(containingContext->printing()); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 GraphicsContext& context() { return *m_context; } | 37 GraphicsContext& context() { return *m_context; } |
| 38 | 38 |
| 39 PassRefPtr<const SkPicture> endRecording() | 39 PassRefPtr<const SkPicture> endRecording() |
| 40 { | 40 { |
| 41 m_context->beginRecording(m_bounds); | 41 m_context->beginRecording(m_bounds); |
| 42 m_displayItemList->commitNewDisplayItems(); | 42 m_paintController->commitNewDisplayItems(); |
| 43 m_displayItemList->paintArtifact().replay(*m_context); | 43 m_paintController->paintArtifact().replay(*m_context); |
| 44 return m_context->endRecording(); | 44 return m_context->endRecording(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 OwnPtr<DisplayItemList> m_displayItemList; | 48 OwnPtr<PaintController> m_paintController; |
| 49 OwnPtr<GraphicsContext> m_context; | 49 OwnPtr<GraphicsContext> m_context; |
| 50 FloatRect m_bounds; | 50 FloatRect m_bounds; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 } // namespace blink | 53 } // namespace blink |
| 54 | 54 |
| 55 #endif // SkPictureBuilder_h | 55 #endif // SkPictureBuilder_h |
| OLD | NEW |