| 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/picture_layer.h" | 9 #include "cc/layers/picture_layer.h" |
| 10 #include "cc/playback/display_item_list.h" | 10 #include "cc/playback/display_item_list.h" |
| 11 #include "cc/playback/display_item_list_settings.h" | 11 #include "cc/playback/display_item_list_settings.h" |
| 12 #include "cc/playback/drawing_display_item.h" | 12 #include "cc/playback/drawing_display_item.h" |
| 13 #include "cc/playback/transform_display_item.h" | 13 #include "cc/playback/transform_display_item.h" |
| 14 #include "cc/trees/layer_tree_host.h" | 14 #include "cc/trees/layer_tree_host.h" |
| 15 #include "cc/trees/property_tree.h" | 15 #include "cc/trees/property_tree.h" |
| 16 #include "platform/RuntimeEnabledFeatures.h" | 16 #include "platform/RuntimeEnabledFeatures.h" |
| 17 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 17 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| 18 #include "platform/graphics/paint/DisplayItem.h" | 18 #include "platform/graphics/paint/DisplayItem.h" |
| 19 #include "platform/graphics/paint/DrawingDisplayItem.h" | 19 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 20 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" | 20 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" |
| 21 #include "platform/graphics/paint/PaintArtifact.h" | 21 #include "platform/graphics/paint/PaintArtifact.h" |
| 22 #include "platform/graphics/paint/PropertyTreeState.h" |
| 22 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 23 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 23 #include "public/platform/Platform.h" | 24 #include "public/platform/Platform.h" |
| 24 #include "public/platform/WebCompositorSupport.h" | 25 #include "public/platform/WebCompositorSupport.h" |
| 25 #include "public/platform/WebLayer.h" | 26 #include "public/platform/WebLayer.h" |
| 26 #include "ui/gfx/geometry/point.h" | 27 #include "ui/gfx/geometry/point.h" |
| 27 #include "ui/gfx/geometry/point_f.h" | 28 #include "ui/gfx/geometry/point_f.h" |
| 28 #include "ui/gfx/geometry/rect.h" | 29 #include "ui/gfx/geometry/rect.h" |
| 29 #include "ui/gfx/geometry/rect_f.h" | 30 #include "ui/gfx/geometry/rect_f.h" |
| 30 #include "ui/gfx/geometry/size.h" | 31 #include "ui/gfx/geometry/size.h" |
| 31 #include "ui/gfx/geometry/size_conversions.h" | 32 #include "ui/gfx/geometry/size_conversions.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 TransformationMatrix matrix; | 117 TransformationMatrix matrix; |
| 117 while (currentSpace != targetSpace) { | 118 while (currentSpace != targetSpace) { |
| 118 TransformationMatrix localMatrix = currentSpace->matrix(); | 119 TransformationMatrix localMatrix = currentSpace->matrix(); |
| 119 localMatrix.applyTransformOrigin(currentSpace->origin()); | 120 localMatrix.applyTransformOrigin(currentSpace->origin()); |
| 120 matrix = localMatrix * matrix; | 121 matrix = localMatrix * matrix; |
| 121 currentSpace = currentSpace->parent(); | 122 currentSpace = currentSpace->parent(); |
| 122 } | 123 } |
| 123 return gfx::Transform(TransformationMatrix::toSkMatrix44(matrix)); | 124 return gfx::Transform(TransformationMatrix::toSkMatrix44(matrix)); |
| 124 } | 125 } |
| 125 | 126 |
| 126 unsigned clipNodeDepth(const ClipPaintPropertyNode* node) | |
| 127 { | |
| 128 unsigned depth = 0; | |
| 129 while (node) { | |
| 130 depth++; | |
| 131 node = node->parent(); | |
| 132 } | |
| 133 return depth; | |
| 134 } | |
| 135 | |
| 136 const ClipPaintPropertyNode* nearestCommonAncestor(const ClipPaintPropertyNode*
a, const ClipPaintPropertyNode* b) | |
| 137 { | |
| 138 // Measure both depths. | |
| 139 unsigned depthA = clipNodeDepth(a); | |
| 140 unsigned depthB = clipNodeDepth(b); | |
| 141 | |
| 142 // Make it so depthA >= depthB. | |
| 143 if (depthA < depthB) { | |
| 144 std::swap(a, b); | |
| 145 std::swap(depthA, depthB); | |
| 146 } | |
| 147 | |
| 148 // Make it so depthA == depthB. | |
| 149 while (depthA > depthB) { | |
| 150 a = a->parent(); | |
| 151 depthA--; | |
| 152 } | |
| 153 | |
| 154 // Walk up until we find the ancestor. | |
| 155 while (a != b) { | |
| 156 a = a->parent(); | |
| 157 b = b->parent(); | |
| 158 } | |
| 159 return a; | |
| 160 } | |
| 161 | |
| 162 const TransformPaintPropertyNode* localTransformSpace(const ClipPaintPropertyNod
e* clip) | 127 const TransformPaintPropertyNode* localTransformSpace(const ClipPaintPropertyNod
e* clip) |
| 163 { | 128 { |
| 164 return clip ? clip->localTransformSpace() : nullptr; | 129 return clip ? clip->localTransformSpace() : nullptr; |
| 165 } | 130 } |
| 166 | 131 |
| 167 scoped_refptr<cc::Layer> createClipLayer(const ClipPaintPropertyNode* node) | 132 scoped_refptr<cc::Layer> createClipLayer(const ClipPaintPropertyNode* node) |
| 168 { | 133 { |
| 169 // TODO(jbroman): Handle rounded-rect clips. | 134 // TODO(jbroman): Handle rounded-rect clips. |
| 170 // TODO(jbroman): Handle clips of non-integer size. | 135 // TODO(jbroman): Handle clips of non-integer size. |
| 171 gfx::RectF clipRect = node->clipRect().rect(); | 136 gfx::RectF clipRect = node->clipRect().rect(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 198 class ClipLayerManager { | 163 class ClipLayerManager { |
| 199 public: | 164 public: |
| 200 ClipLayerManager(cc::Layer* rootLayer) | 165 ClipLayerManager(cc::Layer* rootLayer) |
| 201 { | 166 { |
| 202 m_clipLayers.append(NodeLayerPair(nullptr, rootLayer)); | 167 m_clipLayers.append(NodeLayerPair(nullptr, rootLayer)); |
| 203 } | 168 } |
| 204 | 169 |
| 205 cc::Layer* switchToNewClipLayer(const ClipPaintPropertyNode* clip) | 170 cc::Layer* switchToNewClipLayer(const ClipPaintPropertyNode* clip) |
| 206 { | 171 { |
| 207 // Walk up to the nearest common ancestor. | 172 // Walk up to the nearest common ancestor. |
| 208 const auto* ancestor = nearestCommonAncestor(clip, m_clipLayers.last().f
irst); | 173 const auto* ancestor = propertyTreeNearestCommonAncestor<ClipPaintProper
tyNode>(clip, m_clipLayers.last().first); |
| 209 while (m_clipLayers.last().first != ancestor) | 174 while (m_clipLayers.last().first != ancestor) |
| 210 m_clipLayers.removeLast(); | 175 m_clipLayers.removeLast(); |
| 211 | 176 |
| 212 // If the new one was an ancestor, we're done. | 177 // If the new one was an ancestor, we're done. |
| 213 cc::Layer* ancestorClipLayer = m_clipLayers.last().second; | 178 cc::Layer* ancestorClipLayer = m_clipLayers.last().second; |
| 214 if (ancestor == clip) | 179 if (ancestor == clip) |
| 215 return ancestorClipLayer; | 180 return ancestorClipLayer; |
| 216 | 181 |
| 217 // Otherwise, we need to build new clip layers. | 182 // Otherwise, we need to build new clip layers. |
| 218 // We do this from the bottom up. | 183 // We do this from the bottom up. |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 if (m_extraDataForTestingEnabled) | 431 if (m_extraDataForTestingEnabled) |
| 467 m_extraDataForTesting->contentLayers.append(layer); | 432 m_extraDataForTesting->contentLayers.append(layer); |
| 468 } | 433 } |
| 469 | 434 |
| 470 // Mark the property trees as having been rebuilt. | 435 // Mark the property trees as having been rebuilt. |
| 471 host->property_trees()->sequence_number = kPropertyTreeSequenceNumber; | 436 host->property_trees()->sequence_number = kPropertyTreeSequenceNumber; |
| 472 host->property_trees()->needs_rebuild = false; | 437 host->property_trees()->needs_rebuild = false; |
| 473 } | 438 } |
| 474 | 439 |
| 475 } // namespace blink | 440 } // namespace blink |
| OLD | NEW |