| 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" | |
| 11 | 10 |
| 12 namespace blink { | 11 namespace blink { |
| 13 | 12 |
| 14 SkPictureBuilder::SkPictureBuilder(const FloatRect& bounds, SkMetaData* metaData
, GraphicsContext* containingContext) | 13 SkPictureBuilder::SkPictureBuilder(const FloatRect& bounds, SkMetaData* metaData
, GraphicsContext* containingContext) |
| 15 : m_bounds(bounds) | 14 : m_bounds(bounds) |
| 16 { | 15 { |
| 17 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisable
d; | 16 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisable
d; |
| 18 if (containingContext && containingContext->contextDisabled()) | 17 if (containingContext && containingContext->contextDisabled()) |
| 19 disabledMode = GraphicsContext::FullyDisabled; | 18 disabledMode = GraphicsContext::FullyDisabled; |
| 20 | 19 |
| 21 m_paintController = PaintController::create(); | 20 m_paintController = PaintController::create(); |
| 22 m_paintController->beginSkippingCache(); | 21 m_paintController->beginSkippingCache(); |
| 23 m_context = wrapUnique(new GraphicsContext(*m_paintController, disabledMode,
metaData)); | 22 m_context = adoptPtr(new GraphicsContext(*m_paintController, disabledMode, m
etaData)); |
| 24 | 23 |
| 25 if (containingContext) { | 24 if (containingContext) { |
| 26 m_context->setDeviceScaleFactor(containingContext->deviceScaleFactor()); | 25 m_context->setDeviceScaleFactor(containingContext->deviceScaleFactor()); |
| 27 m_context->setPrinting(containingContext->printing()); | 26 m_context->setPrinting(containingContext->printing()); |
| 28 } | 27 } |
| 29 } | 28 } |
| 30 | 29 |
| 31 SkPictureBuilder::~SkPictureBuilder() {} | 30 SkPictureBuilder::~SkPictureBuilder() {} |
| 32 | 31 |
| 33 PassRefPtr<SkPicture> SkPictureBuilder::endRecording() | 32 PassRefPtr<SkPicture> SkPictureBuilder::endRecording() |
| 34 { | 33 { |
| 35 m_context->beginRecording(m_bounds); | 34 m_context->beginRecording(m_bounds); |
| 36 m_paintController->endSkippingCache(); | 35 m_paintController->endSkippingCache(); |
| 37 m_paintController->commitNewDisplayItems(); | 36 m_paintController->commitNewDisplayItems(); |
| 38 m_paintController->paintArtifact().replay(*m_context); | 37 m_paintController->paintArtifact().replay(*m_context); |
| 39 return m_context->endRecording(); | 38 return m_context->endRecording(); |
| 40 } | 39 } |
| 41 | 40 |
| 42 } // namespace blink | 41 } // namespace blink |
| OLD | NEW |