| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 transform.Translate(offset.x(), offset.y()); | 179 transform.Translate(offset.x(), offset.y()); |
| 181 if (node->parent()) { | 180 if (node->parent()) { |
| 182 FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect
().location(); | 181 FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect
().location(); |
| 183 gfx::Transform undoClipOffset; | 182 gfx::Transform undoClipOffset; |
| 184 undoClipOffset.Translate(-offsetDueToParentClipOffset.x(), -offsetDueToP
arentClipOffset.y()); | 183 undoClipOffset.Translate(-offsetDueToParentClipOffset.x(), -offsetDueToP
arentClipOffset.y()); |
| 185 transform.PreconcatTransform(undoClipOffset); | 184 transform.PreconcatTransform(undoClipOffset); |
| 186 } | 185 } |
| 187 | 186 |
| 188 scoped_refptr<cc::Layer> layer = cc::Layer::Create(cc::LayerSettings()); | 187 scoped_refptr<cc::Layer> layer = cc::Layer::Create(); |
| 189 layer->SetIsDrawable(false); | 188 layer->SetIsDrawable(false); |
| 190 layer->SetMasksToBounds(true); | 189 layer->SetMasksToBounds(true); |
| 191 layer->SetPosition(gfx::PointF()); | 190 layer->SetPosition(gfx::PointF()); |
| 192 layer->SetBounds(gfx::ToRoundedSize(clipRect.size())); | 191 layer->SetBounds(gfx::ToRoundedSize(clipRect.size())); |
| 193 layer->SetTransform(transform); | 192 layer->SetTransform(transform); |
| 194 return layer; | 193 return layer; |
| 195 } | 194 } |
| 196 | 195 |
| 197 class ClipLayerManager { | 196 class ClipLayerManager { |
| 198 public: | 197 public: |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 298 |
| 300 // If a clip was applied, its origin needs to be cancelled out in | 299 // If a clip was applied, its origin needs to be cancelled out in |
| 301 // this transform. | 300 // this transform. |
| 302 if (const auto* clip = paintChunk.properties.clip.get()) { | 301 if (const auto* clip = paintChunk.properties.clip.get()) { |
| 303 FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location(); | 302 FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location(); |
| 304 gfx::Transform undoClipOffset; | 303 gfx::Transform undoClipOffset; |
| 305 undoClipOffset.Translate(-offsetDueToClipOffset.x(), -offsetDueToClipOff
set.y()); | 304 undoClipOffset.Translate(-offsetDueToClipOffset.x(), -offsetDueToClipOff
set.y()); |
| 306 transform.PreconcatTransform(undoClipOffset); | 305 transform.PreconcatTransform(undoClipOffset); |
| 307 } | 306 } |
| 308 | 307 |
| 309 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(cc::LayerSe
ttings(), contentLayerClient.get()); | 308 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(contentLaye
rClient.get()); |
| 310 layer->SetBounds(combinedBounds.size()); | 309 layer->SetBounds(combinedBounds.size()); |
| 311 layer->SetTransform(transform); | 310 layer->SetTransform(transform); |
| 312 layer->SetIsDrawable(true); | 311 layer->SetIsDrawable(true); |
| 313 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden); | 312 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden); |
| 314 if (paintChunk.knownToBeOpaque) | 313 if (paintChunk.knownToBeOpaque) |
| 315 layer->SetContentsOpaque(true); | 314 layer->SetContentsOpaque(true); |
| 316 m_contentLayerClients.append(contentLayerClient.release()); | 315 m_contentLayerClients.append(contentLayerClient.release()); |
| 317 return layer; | 316 return layer; |
| 318 } | 317 } |
| 319 | 318 |
| 320 | 319 |
| 321 } // namespace blink | 320 } // namespace blink |
| OLD | NEW |