Chromium Code Reviews| 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/dom/DOMNodeIds.h" | |
| 7 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 9 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| 10 #include "core/layout/LayoutInline.h" | 11 #include "core/layout/LayoutInline.h" |
| 11 #include "core/layout/LayoutView.h" | 12 #include "core/layout/LayoutView.h" |
| 12 #include "core/layout/compositing/CompositingReasonFinder.h" | 13 #include "core/layout/compositing/CompositingReasonFinder.h" |
| 13 #include "core/layout/svg/LayoutSVGRoot.h" | 14 #include "core/layout/svg/LayoutSVGRoot.h" |
| 14 #include "core/layout/svg/SVGLayoutSupport.h" | 15 #include "core/layout/svg/SVGLayoutSupport.h" |
| 15 #include "core/paint/FindPropertiesNeedingUpdate.h" | 16 #include "core/paint/FindPropertiesNeedingUpdate.h" |
| 16 #include "core/paint/ObjectPaintProperties.h" | 17 #include "core/paint/ObjectPaintProperties.h" |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 | 369 |
| 369 // TODO(trchen): transform-style should only be respected if a | 370 // TODO(trchen): transform-style should only be respected if a |
| 370 // PaintLayer | 371 // PaintLayer |
| 371 // is created. | 372 // is created. |
| 372 // If a node with transform-style: preserve-3d does not exist in an | 373 // If a node with transform-style: preserve-3d does not exist in an |
| 373 // existing rendering context, it establishes a new one. | 374 // existing rendering context, it establishes a new one. |
| 374 unsigned renderingContextID = context.current.renderingContextID; | 375 unsigned renderingContextID = context.current.renderingContextID; |
| 375 if (style.preserves3D() && !renderingContextID) | 376 if (style.preserves3D() && !renderingContextID) |
| 376 renderingContextID = PtrHash<const LayoutObject>::hash(&object); | 377 renderingContextID = PtrHash<const LayoutObject>::hash(&object); |
| 377 | 378 |
| 379 CompositorElementId compositorElementId; | |
| 380 if (style.hasCurrentTransformAnimation()) { | |
|
wkorman
2016/12/29 20:22:54
To call out, I made a judgement call here (and sam
Xianzhu
2016/12/29 20:40:38
Is there any extra cost for a paint property node
wkorman
2016/12/29 20:59:15
Yes, we use DOMNodeIds::idForNode() which uses a W
| |
| 381 updateCompositorElementId(object, compositorElementId); | |
| 382 } | |
| 383 | |
| 378 auto& properties = | 384 auto& properties = |
| 379 object.getMutableForPainting().ensurePaintProperties(); | 385 object.getMutableForPainting().ensurePaintProperties(); |
| 380 context.forceSubtreeUpdate |= properties.updateTransform( | 386 context.forceSubtreeUpdate |= properties.updateTransform( |
| 381 context.current.transform, matrix, transformOrigin(box), | 387 context.current.transform, matrix, transformOrigin(box), |
| 382 context.current.shouldFlattenInheritedTransform, renderingContextID, | 388 context.current.shouldFlattenInheritedTransform, renderingContextID, |
| 383 compositingReasons); | 389 compositingReasons, compositorElementId); |
| 384 hasTransform = true; | 390 hasTransform = true; |
| 385 } | 391 } |
| 386 } | 392 } |
| 387 if (!hasTransform) { | 393 if (!hasTransform) { |
| 388 if (auto* properties = object.getMutableForPainting().paintProperties()) | 394 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 389 context.forceSubtreeUpdate |= properties->clearTransform(); | 395 context.forceSubtreeUpdate |= properties->clearTransform(); |
| 390 } | 396 } |
| 391 } | 397 } |
| 392 | 398 |
| 393 const auto* properties = object.paintProperties(); | 399 const auto* properties = object.paintProperties(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 if (!filter.isEmpty()) { | 483 if (!filter.isEmpty()) { |
| 478 effectNodeNeeded = true; | 484 effectNodeNeeded = true; |
| 479 outputClip = context.current.clip; | 485 outputClip = context.current.clip; |
| 480 | 486 |
| 481 // TODO(trchen): A filter may contain spatial operations such that an | 487 // TODO(trchen): A filter may contain spatial operations such that an |
| 482 // output pixel may depend on an input pixel outside of the output clip. | 488 // output pixel may depend on an input pixel outside of the output clip. |
| 483 // We should generate a special clip node to represent this expansion. | 489 // We should generate a special clip node to represent this expansion. |
| 484 } | 490 } |
| 485 | 491 |
| 486 CompositingReasons compositingReasons = | 492 CompositingReasons compositingReasons = |
| 487 CompositingReasonFinder::requiresCompositingForEffectAnimation( | 493 CompositingReasonFinder::requiresCompositingForEffectAnimation(style); |
| 488 object.styleRef()); | |
| 489 if (compositingReasons != CompositingReasonNone) | 494 if (compositingReasons != CompositingReasonNone) |
| 490 effectNodeNeeded = true; | 495 effectNodeNeeded = true; |
| 491 | 496 |
| 497 CompositorElementId compositorElementId; | |
| 498 if (style.hasCurrentOpacityAnimation() || | |
| 499 style.hasCurrentFilterAnimation() || | |
| 500 style.hasCurrentBackdropFilterAnimation()) { | |
| 501 updateCompositorElementId(object, compositorElementId); | |
| 502 } | |
| 503 | |
| 492 if (effectNodeNeeded) { | 504 if (effectNodeNeeded) { |
| 493 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 505 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 494 context.forceSubtreeUpdate |= properties.updateEffect( | 506 context.forceSubtreeUpdate |= properties.updateEffect( |
| 495 context.currentEffect, context.current.transform, outputClip, | 507 context.currentEffect, context.current.transform, outputClip, |
| 496 std::move(filter), opacity, blendMode, compositingReasons); | 508 std::move(filter), opacity, blendMode, compositingReasons, |
| 509 compositorElementId); | |
| 497 } else { | 510 } else { |
| 498 if (auto* properties = object.getMutableForPainting().paintProperties()) | 511 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 499 context.forceSubtreeUpdate |= properties->clearEffect(); | 512 context.forceSubtreeUpdate |= properties->clearEffect(); |
| 500 } | 513 } |
| 501 } | 514 } |
| 502 | 515 |
| 503 const auto* properties = object.paintProperties(); | 516 const auto* properties = object.paintProperties(); |
| 504 if (properties && properties->effect()) { | 517 if (properties && properties->effect()) { |
| 505 context.currentEffect = properties->effect(); | 518 context.currentEffect = properties->effect(); |
| 506 if (!properties->effect()->filter().isEmpty()) { | 519 if (!properties->effect()->filter().isEmpty()) { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 return; | 841 return; |
| 829 } | 842 } |
| 830 } | 843 } |
| 831 | 844 |
| 832 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 845 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 833 if (auto* properties = object.getMutableForPainting().paintProperties()) | 846 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 834 context.forceSubtreeUpdate |= properties->clearCssClipFixedPosition(); | 847 context.forceSubtreeUpdate |= properties->clearCssClipFixedPosition(); |
| 835 } | 848 } |
| 836 } | 849 } |
| 837 | 850 |
| 851 void PaintPropertyTreeBuilder::updateCompositorElementId( | |
| 852 const LayoutObject& object, | |
| 853 CompositorElementId& compositorElementId) { | |
| 854 compositorElementId = createCompositorElementId( | |
| 855 DOMNodeIds::idForNode(object.node()), CompositorSubElementId::Primary); | |
| 856 } | |
| 857 | |
| 838 // Override ContainingBlockContext based on the properties of a containing block | 858 // Override ContainingBlockContext based on the properties of a containing block |
| 839 // that was previously walked in a subtree other than the current subtree being | 859 // that was previously walked in a subtree other than the current subtree being |
| 840 // walked. Used for out-of-flow positioned descendants of multi-column spanner | 860 // walked. Used for out-of-flow positioned descendants of multi-column spanner |
| 841 // when the containing block is not in the normal tree walk order. | 861 // when the containing block is not in the normal tree walk order. |
| 842 // For example: | 862 // For example: |
| 843 // <div id="columns" style="columns: 2"> | 863 // <div id="columns" style="columns: 2"> |
| 844 // <div id="relative" style="position: relative"> | 864 // <div id="relative" style="position: relative"> |
| 845 // <div id="spanner" style="column-span: all"> | 865 // <div id="spanner" style="column-span: all"> |
| 846 // <div id="absolute" style="position: absolute"></div> | 866 // <div id="absolute" style="position: absolute"></div> |
| 847 // </div> | 867 // </div> |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 986 updateOverflowClip(object, context); | 1006 updateOverflowClip(object, context); |
| 987 updatePerspective(object, context); | 1007 updatePerspective(object, context); |
| 988 updateSvgLocalToBorderBoxTransform(object, context); | 1008 updateSvgLocalToBorderBoxTransform(object, context); |
| 989 updateScrollAndScrollTranslation(object, context); | 1009 updateScrollAndScrollTranslation(object, context); |
| 990 updateOutOfFlowContext(object, context); | 1010 updateOutOfFlowContext(object, context); |
| 991 | 1011 |
| 992 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 1012 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
| 993 } | 1013 } |
| 994 | 1014 |
| 995 } // namespace blink | 1015 } // namespace blink |
| OLD | NEW |