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" | |
10 #include "cc/layers/picture_layer.h" | 9 #include "cc/layers/picture_layer.h" |
11 #include "cc/playback/display_item_list.h" | 10 #include "cc/playback/display_item_list.h" |
12 #include "cc/playback/display_item_list_settings.h" | 11 #include "cc/playback/display_item_list_settings.h" |
13 #include "cc/playback/drawing_display_item.h" | 12 #include "cc/playback/drawing_display_item.h" |
14 #include "cc/playback/transform_display_item.h" | 13 #include "cc/playback/transform_display_item.h" |
15 #include "platform/RuntimeEnabledFeatures.h" | 14 #include "platform/RuntimeEnabledFeatures.h" |
16 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 15 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
17 #include "platform/graphics/paint/DisplayItem.h" | 16 #include "platform/graphics/paint/DisplayItem.h" |
18 #include "platform/graphics/paint/DrawingDisplayItem.h" | 17 #include "platform/graphics/paint/DrawingDisplayItem.h" |
19 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" | 18 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 60 |
62 private: | 61 private: |
63 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; | 62 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; |
64 gfx::Rect m_paintableRegion; | 63 gfx::Rect m_paintableRegion; |
65 }; | 64 }; |
66 | 65 |
67 PaintArtifactCompositor::PaintArtifactCompositor() | 66 PaintArtifactCompositor::PaintArtifactCompositor() |
68 { | 67 { |
69 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 68 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
70 return; | 69 return; |
71 m_rootLayer = cc::Layer::Create(cc::LayerSettings()); | 70 m_rootLayer = cc::Layer::Create(); |
72 m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerF
romCCLayer(m_rootLayer.get())); | 71 m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerF
romCCLayer(m_rootLayer.get())); |
73 } | 72 } |
74 | 73 |
75 PaintArtifactCompositor::~PaintArtifactCompositor() | 74 PaintArtifactCompositor::~PaintArtifactCompositor() |
76 { | 75 { |
77 } | 76 } |
78 | 77 |
79 namespace { | 78 namespace { |
80 | 79 |
81 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem,
cc::DisplayItemList* list) | 80 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem,
cc::DisplayItemList* list) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // parent is an ancestor of this node's transform space. That's not | 175 // parent is an ancestor of this node's transform space. That's not |
177 // necessarily true, and this should be fixed. | 176 // necessarily true, and this should be fixed. |
178 gfx::Transform transform = transformToTransformSpace(localTransformSpace(nod
e), localTransformSpace(node->parent())); | 177 gfx::Transform transform = transformToTransformSpace(localTransformSpace(nod
e), localTransformSpace(node->parent())); |
179 gfx::Vector2dF offset = clipRect.OffsetFromOrigin(); | 178 gfx::Vector2dF offset = clipRect.OffsetFromOrigin(); |
180 if (node->parent()) { | 179 if (node->parent()) { |
181 FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect
().location(); | 180 FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect
().location(); |
182 offset -= gfx::Vector2dF(offsetDueToParentClipOffset.x(), offsetDueToPar
entClipOffset.y()); | 181 offset -= gfx::Vector2dF(offsetDueToParentClipOffset.x(), offsetDueToPar
entClipOffset.y()); |
183 } | 182 } |
184 transform.Translate(offset.x(), offset.y()); | 183 transform.Translate(offset.x(), offset.y()); |
185 | 184 |
186 scoped_refptr<cc::Layer> layer = cc::Layer::Create(cc::LayerSettings()); | 185 scoped_refptr<cc::Layer> layer = cc::Layer::Create(); |
187 layer->SetIsDrawable(false); | 186 layer->SetIsDrawable(false); |
188 layer->SetMasksToBounds(true); | 187 layer->SetMasksToBounds(true); |
189 layer->SetPosition(gfx::PointF()); | 188 layer->SetPosition(gfx::PointF()); |
190 layer->SetBounds(gfx::ToRoundedSize(clipRect.size())); | 189 layer->SetBounds(gfx::ToRoundedSize(clipRect.size())); |
191 layer->SetTransform(transform); | 190 layer->SetTransform(transform); |
192 return layer; | 191 return layer; |
193 } | 192 } |
194 | 193 |
195 class ClipLayerManager { | 194 class ClipLayerManager { |
196 public: | 195 public: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // parent's transform space). | 293 // parent's transform space). |
295 gfx::Vector2dF offset = gfx::PointF(combinedBounds.origin()).OffsetFromOrigi
n(); | 294 gfx::Vector2dF offset = gfx::PointF(combinedBounds.origin()).OffsetFromOrigi
n(); |
296 if (const auto* clip = paintChunk.properties.clip.get()) { | 295 if (const auto* clip = paintChunk.properties.clip.get()) { |
297 // If a clip was applied, its origin needs to be cancelled out in | 296 // If a clip was applied, its origin needs to be cancelled out in |
298 // this transform. | 297 // this transform. |
299 FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location(); | 298 FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location(); |
300 offset -= gfx::Vector2dF(offsetDueToClipOffset.x(), offsetDueToClipOffse
t.y()); | 299 offset -= gfx::Vector2dF(offsetDueToClipOffset.x(), offsetDueToClipOffse
t.y()); |
301 } | 300 } |
302 transform.Translate(offset.x(), offset.y()); | 301 transform.Translate(offset.x(), offset.y()); |
303 | 302 |
304 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(cc::LayerSe
ttings(), contentLayerClient.get()); | 303 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(contentLaye
rClient.get()); |
305 layer->SetBounds(combinedBounds.size()); | 304 layer->SetBounds(combinedBounds.size()); |
306 layer->SetTransform(transform); | 305 layer->SetTransform(transform); |
307 layer->SetIsDrawable(true); | 306 layer->SetIsDrawable(true); |
308 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden); | 307 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden); |
309 if (paintChunk.knownToBeOpaque) | 308 if (paintChunk.knownToBeOpaque) |
310 layer->SetContentsOpaque(true); | 309 layer->SetContentsOpaque(true); |
311 m_contentLayerClients.append(contentLayerClient.release()); | 310 m_contentLayerClients.append(contentLayerClient.release()); |
312 return layer; | 311 return layer; |
313 } | 312 } |
314 | 313 |
315 | 314 |
316 } // namespace blink | 315 } // namespace blink |
OLD | NEW |