Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/SkPictureBuilder.cpp

Issue 2632823002: SPv2: Paint SVG images and self-contained recorded pictures with their own trees. (Closed)
Patch Set: none Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 PaintController* paintController) 17 PaintController* paintController)
18 : m_paintController(nullptr), m_bounds(bounds) { 18 : m_paintController(nullptr), m_bounds(bounds) {
19 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled; 19 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled;
20 if (containingContext && containingContext->contextDisabled()) 20 if (containingContext && containingContext->contextDisabled())
21 disabledMode = GraphicsContext::FullyDisabled; 21 disabledMode = GraphicsContext::FullyDisabled;
22 22
23 if (paintController) { 23 if (paintController) {
24 m_paintController = paintController; 24 m_paintController = paintController;
25 } else { 25 } else {
26 m_paintControllerPtr = PaintController::create(); 26 m_paintControllerPtr = PaintController::create();
27 m_paintController = m_paintControllerPtr.get(); 27 m_paintController = m_paintControllerPtr.get();
28
29 // Content painted with a new paint controller in SPv2 will have an
30 // independent property tree set.
31 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
32 PaintChunk::Id id(*this, DisplayItem::kSVGImage);
33 PropertyTreeState state(
34 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
35 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root());
36 m_paintController->updateCurrentPaintChunkProperties(&id, state);
37 }
28 } 38 }
29 #if DCHECK_IS_ON() 39 #if DCHECK_IS_ON()
30 m_paintController->setUsage(PaintController::ForSkPictureBuilder); 40 m_paintController->setUsage(PaintController::ForSkPictureBuilder);
31 #endif 41 #endif
32 42
33 m_context = WTF::wrapUnique( 43 m_context = WTF::wrapUnique(
34 new GraphicsContext(*m_paintController, disabledMode, metaData)); 44 new GraphicsContext(*m_paintController, disabledMode, metaData));
35 45
36 if (containingContext) { 46 if (containingContext) {
37 m_context->setDeviceScaleFactor(containingContext->deviceScaleFactor()); 47 m_context->setDeviceScaleFactor(containingContext->deviceScaleFactor());
38 m_context->setPrinting(containingContext->printing()); 48 m_context->setPrinting(containingContext->printing());
39 } 49 }
40 } 50 }
41 51
42 SkPictureBuilder::~SkPictureBuilder() { 52 SkPictureBuilder::~SkPictureBuilder() {
43 #if DCHECK_IS_ON() 53 #if DCHECK_IS_ON()
44 m_paintController->setUsage(PaintController::ForNormalUsage); 54 m_paintController->setUsage(PaintController::ForNormalUsage);
45 #endif 55 #endif
46 } 56 }
47 57
48 sk_sp<SkPicture> SkPictureBuilder::endRecording() { 58 sk_sp<SkPicture> SkPictureBuilder::endRecording() {
49 m_context->beginRecording(m_bounds); 59 m_context->beginRecording(m_bounds);
50 m_paintController->commitNewDisplayItems(); 60 m_paintController->commitNewDisplayItems();
51 m_paintController->paintArtifact().replay(*m_context); 61 m_paintController->paintArtifact().replay(*m_context);
52 return m_context->endRecording(); 62 return m_context->endRecording();
53 } 63 }
54 64
55 } // namespace blink 65 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698