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 "core/paint/PaintPropertyTreeBuilder.h" | 5 #include "core/paint/PaintPropertyTreeBuilder.h" |
6 | 6 |
7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
10 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
11 #include "core/layout/LayoutView.h" | 11 #include "core/layout/LayoutView.h" |
| 12 #include "core/layout/compositing/CompositingReasonFinder.h" |
12 #include "core/layout/svg/LayoutSVGRoot.h" | 13 #include "core/layout/svg/LayoutSVGRoot.h" |
13 #include "core/paint/FindPropertiesNeedingUpdate.h" | 14 #include "core/paint/FindPropertiesNeedingUpdate.h" |
14 #include "core/paint/ObjectPaintProperties.h" | 15 #include "core/paint/ObjectPaintProperties.h" |
15 #include "core/paint/PaintLayer.h" | 16 #include "core/paint/PaintLayer.h" |
16 #include "core/paint/SVGRootPainter.h" | 17 #include "core/paint/SVGRootPainter.h" |
17 #include "platform/transforms/TransformationMatrix.h" | 18 #include "platform/transforms/TransformationMatrix.h" |
18 #include "wtf/PtrUtil.h" | 19 #include "wtf/PtrUtil.h" |
19 #include <memory> | 20 #include <memory> |
20 | 21 |
21 namespace blink { | 22 namespace blink { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 302 } |
302 } | 303 } |
303 | 304 |
304 if (object.paintProperties() && object.paintProperties()->transform()) { | 305 if (object.paintProperties() && object.paintProperties()->transform()) { |
305 context.current.transform = object.paintProperties()->transform(); | 306 context.current.transform = object.paintProperties()->transform(); |
306 context.current.shouldFlattenInheritedTransform = false; | 307 context.current.shouldFlattenInheritedTransform = false; |
307 context.current.renderingContextID = 0; | 308 context.current.renderingContextID = 0; |
308 } | 309 } |
309 } | 310 } |
310 | 311 |
| 312 static CompositingReasons compositingReasonsForTransform( |
| 313 const LayoutObject& object) { |
| 314 CompositingReasons compositingReasons = CompositingReasonNone; |
| 315 if (CompositingReasonFinder::requiresCompositingForTransform(object)) |
| 316 compositingReasons |= CompositingReason3DTransform; |
| 317 |
| 318 if (object.styleRef().hasWillChangeCompositingHint() && |
| 319 !object.styleRef().subtreeWillChangeContents()) |
| 320 compositingReasons |= CompositingReasonWillChangeCompositingHint; |
| 321 |
| 322 return compositingReasons; |
| 323 } |
| 324 |
311 void PaintPropertyTreeBuilder::updateTransform( | 325 void PaintPropertyTreeBuilder::updateTransform( |
312 const LayoutObject& object, | 326 const LayoutObject& object, |
313 PaintPropertyTreeBuilderContext& context) { | 327 PaintPropertyTreeBuilderContext& context) { |
314 if (object.isSVG() && !object.isSVGRoot()) { | 328 if (object.isSVG() && !object.isSVGRoot()) { |
315 updateTransformForNonRootSVG(object, context); | 329 updateTransformForNonRootSVG(object, context); |
316 return; | 330 return; |
317 } | 331 } |
318 | 332 |
319 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 333 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
320 const ComputedStyle& style = object.styleRef(); | 334 const ComputedStyle& style = object.styleRef(); |
321 if (object.isBox() && (style.hasTransform() || style.preserves3D())) { | 335 |
| 336 CompositingReasons compositingReasons = |
| 337 compositingReasonsForTransform(object); |
| 338 |
| 339 // A transform node is allocated for transforms, preserves-3d and any |
| 340 // direct compositing reason. The latter is required because this is the |
| 341 // only way to represent compositing both an element and its stacking |
| 342 // descendants. |
| 343 if (object.isBox() && (style.hasTransform() || style.preserves3D() || |
| 344 compositingReasons != CompositingReasonNone)) { |
322 TransformationMatrix matrix; | 345 TransformationMatrix matrix; |
323 style.applyTransform( | 346 style.applyTransform( |
324 matrix, toLayoutBox(object).size(), | 347 matrix, toLayoutBox(object).size(), |
325 ComputedStyle::ExcludeTransformOrigin, | 348 ComputedStyle::ExcludeTransformOrigin, |
326 ComputedStyle::IncludeMotionPath, | 349 ComputedStyle::IncludeMotionPath, |
327 ComputedStyle::IncludeIndependentTransformProperties); | 350 ComputedStyle::IncludeIndependentTransformProperties); |
328 | 351 |
329 // TODO(trchen): transform-style should only be respected if a PaintLayer | 352 // TODO(trchen): transform-style should only be respected if a PaintLayer |
330 // is created. | 353 // is created. |
331 // If a node with transform-style: preserve-3d does not exist in an | 354 // If a node with transform-style: preserve-3d does not exist in an |
332 // existing rendering context, it establishes a new one. | 355 // existing rendering context, it establishes a new one. |
333 unsigned renderingContextID = context.current.renderingContextID; | 356 unsigned renderingContextID = context.current.renderingContextID; |
334 if (style.preserves3D() && !renderingContextID) | 357 if (style.preserves3D() && !renderingContextID) |
335 renderingContextID = PtrHash<const LayoutObject>::hash(&object); | 358 renderingContextID = PtrHash<const LayoutObject>::hash(&object); |
336 | 359 |
337 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 360 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
338 context.forceSubtreeUpdate |= properties.updateTransform( | 361 context.forceSubtreeUpdate |= properties.updateTransform( |
339 context.current.transform, matrix, | 362 context.current.transform, matrix, |
340 transformOrigin(toLayoutBox(object)), | 363 transformOrigin(toLayoutBox(object)), |
341 context.current.shouldFlattenInheritedTransform, renderingContextID); | 364 context.current.shouldFlattenInheritedTransform, renderingContextID, |
| 365 compositingReasons); |
342 } else { | 366 } else { |
343 if (auto* properties = object.getMutableForPainting().paintProperties()) | 367 if (auto* properties = object.getMutableForPainting().paintProperties()) |
344 context.forceSubtreeUpdate |= properties->clearTransform(); | 368 context.forceSubtreeUpdate |= properties->clearTransform(); |
345 } | 369 } |
346 } | 370 } |
347 | 371 |
348 const auto* properties = object.paintProperties(); | 372 const auto* properties = object.paintProperties(); |
349 if (properties && properties->transform()) { | 373 if (properties && properties->transform()) { |
350 context.current.transform = properties->transform(); | 374 context.current.transform = properties->transform(); |
351 if (object.styleRef().preserves3D()) { | 375 if (object.styleRef().preserves3D()) { |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 #endif | 929 #endif |
906 | 930 |
907 updateOverflowClip(object, context); | 931 updateOverflowClip(object, context); |
908 updatePerspective(object, context); | 932 updatePerspective(object, context); |
909 updateSvgLocalToBorderBoxTransform(object, context); | 933 updateSvgLocalToBorderBoxTransform(object, context); |
910 updateScrollAndScrollTranslation(object, context); | 934 updateScrollAndScrollTranslation(object, context); |
911 updateOutOfFlowContext(object, context); | 935 updateOutOfFlowContext(object, context); |
912 } | 936 } |
913 | 937 |
914 } // namespace blink | 938 } // namespace blink |
OLD | NEW |