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/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
6 | 6 |
7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/layers/layer_settings.h" | 9 #include "cc/layers/layer_settings.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 return 0; | 58 return 0; |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
62 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; | 62 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; |
63 gfx::Rect m_paintableRegion; | 63 gfx::Rect m_paintableRegion; |
64 }; | 64 }; |
65 | 65 |
66 PaintArtifactCompositor::PaintArtifactCompositor() | 66 PaintArtifactCompositor::PaintArtifactCompositor() |
67 { | 67 { |
| 68 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 69 return; |
| 70 m_rootLayer = cc::Layer::Create(cc::LayerSettings()); |
| 71 m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerF
romCCLayer(m_rootLayer.get())); |
68 } | 72 } |
69 | 73 |
70 PaintArtifactCompositor::~PaintArtifactCompositor() | 74 PaintArtifactCompositor::~PaintArtifactCompositor() |
71 { | 75 { |
72 } | 76 } |
73 | 77 |
74 void PaintArtifactCompositor::initializeIfNeeded() | |
75 { | |
76 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | |
77 if (m_rootLayer) | |
78 return; | |
79 | |
80 m_rootLayer = cc::Layer::Create(cc::LayerSettings()); | |
81 m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerF
romCCLayer(m_rootLayer.get())); | |
82 } | |
83 | |
84 namespace { | 78 namespace { |
85 | 79 |
86 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem,
cc::DisplayItemList* list) | 80 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem,
cc::DisplayItemList* list) |
87 { | 81 { |
88 if (DisplayItem::isDrawingType(displayItem.type())) { | 82 if (DisplayItem::isDrawingType(displayItem.type())) { |
89 const SkPicture* picture = static_cast<const DrawingDisplayItem&>(displa
yItem).picture(); | 83 const SkPicture* picture = static_cast<const DrawingDisplayItem&>(displa
yItem).picture(); |
90 if (!picture) | 84 if (!picture) |
91 return; | 85 return; |
92 gfx::Rect bounds = gfx::SkIRectToRect(picture->cullRect().roundOut()); | 86 gfx::Rect bounds = gfx::SkIRectToRect(picture->cullRect().roundOut()); |
93 list->CreateAndAppendItem<cc::DrawingDisplayItem>(bounds, skia::SharePtr
(picture)); | 87 list->CreateAndAppendItem<cc::DrawingDisplayItem>(bounds, skia::SharePtr
(picture)); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 if (paintChunk.knownToBeOpaque) | 277 if (paintChunk.knownToBeOpaque) |
284 layer->SetContentsOpaque(true); | 278 layer->SetContentsOpaque(true); |
285 layer->SetNeedsDisplay(); | 279 layer->SetNeedsDisplay(); |
286 | 280 |
287 m_contentLayerClients.append(contentLayerClient.release()); | 281 m_contentLayerClients.append(contentLayerClient.release()); |
288 parent->AddChild(std::move(layer)); | 282 parent->AddChild(std::move(layer)); |
289 } | 283 } |
290 } | 284 } |
291 | 285 |
292 } // namespace blink | 286 } // namespace blink |
OLD | NEW |