| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // Transform origin has no effect without a transform or motion path. | 330 // Transform origin has no effect without a transform or motion path. |
| 330 if (!style.hasTransform()) | 331 if (!style.hasTransform()) |
| 331 return FloatPoint3D(); | 332 return FloatPoint3D(); |
| 332 FloatSize borderBoxSize(box.size()); | 333 FloatSize borderBoxSize(box.size()); |
| 333 return FloatPoint3D( | 334 return FloatPoint3D( |
| 334 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), | 335 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), |
| 335 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), | 336 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), |
| 336 style.transformOriginZ()); | 337 style.transformOriginZ()); |
| 337 } | 338 } |
| 338 | 339 |
| 340 namespace { |
| 341 |
| 342 CompositorElementId createDomNodeBasedCompositorElementId( |
| 343 const LayoutObject& object) { |
| 344 return createCompositorElementId(DOMNodeIds::idForNode(object.node()), |
| 345 CompositorSubElementId::Primary); |
| 346 } |
| 347 |
| 348 } // namespace |
| 349 |
| 339 void PaintPropertyTreeBuilder::updateTransform( | 350 void PaintPropertyTreeBuilder::updateTransform( |
| 340 const LayoutObject& object, | 351 const LayoutObject& object, |
| 341 PaintPropertyTreeBuilderContext& context) { | 352 PaintPropertyTreeBuilderContext& context) { |
| 342 if (object.isSVG() && !object.isSVGRoot()) { | 353 if (object.isSVG() && !object.isSVGRoot()) { |
| 343 updateTransformForNonRootSVG(object, context); | 354 updateTransformForNonRootSVG(object, context); |
| 344 return; | 355 return; |
| 345 } | 356 } |
| 346 | 357 |
| 347 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 358 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 348 const ComputedStyle& style = object.styleRef(); | 359 const ComputedStyle& style = object.styleRef(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 368 | 379 |
| 369 // TODO(trchen): transform-style should only be respected if a | 380 // TODO(trchen): transform-style should only be respected if a |
| 370 // PaintLayer | 381 // PaintLayer |
| 371 // is created. | 382 // is created. |
| 372 // If a node with transform-style: preserve-3d does not exist in an | 383 // If a node with transform-style: preserve-3d does not exist in an |
| 373 // existing rendering context, it establishes a new one. | 384 // existing rendering context, it establishes a new one. |
| 374 unsigned renderingContextId = context.current.renderingContextId; | 385 unsigned renderingContextId = context.current.renderingContextId; |
| 375 if (style.preserves3D() && !renderingContextId) | 386 if (style.preserves3D() && !renderingContextId) |
| 376 renderingContextId = PtrHash<const LayoutObject>::hash(&object); | 387 renderingContextId = PtrHash<const LayoutObject>::hash(&object); |
| 377 | 388 |
| 389 CompositorElementId compositorElementId = |
| 390 style.hasCurrentTransformAnimation() |
| 391 ? createDomNodeBasedCompositorElementId(object) |
| 392 : CompositorElementId(); |
| 393 |
| 378 auto& properties = | 394 auto& properties = |
| 379 object.getMutableForPainting().ensurePaintProperties(); | 395 object.getMutableForPainting().ensurePaintProperties(); |
| 380 context.forceSubtreeUpdate |= properties.updateTransform( | 396 context.forceSubtreeUpdate |= properties.updateTransform( |
| 381 context.current.transform, matrix, transformOrigin(box), | 397 context.current.transform, matrix, transformOrigin(box), |
| 382 context.current.shouldFlattenInheritedTransform, renderingContextId, | 398 context.current.shouldFlattenInheritedTransform, renderingContextId, |
| 383 compositingReasons); | 399 compositingReasons, compositorElementId); |
| 384 hasTransform = true; | 400 hasTransform = true; |
| 385 } | 401 } |
| 386 } | 402 } |
| 387 if (!hasTransform) { | 403 if (!hasTransform) { |
| 388 if (auto* properties = object.getMutableForPainting().paintProperties()) | 404 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 389 context.forceSubtreeUpdate |= properties->clearTransform(); | 405 context.forceSubtreeUpdate |= properties->clearTransform(); |
| 390 } | 406 } |
| 391 } | 407 } |
| 392 | 408 |
| 393 const auto* properties = object.paintProperties(); | 409 const auto* properties = object.paintProperties(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 if (!filter.isEmpty()) { | 493 if (!filter.isEmpty()) { |
| 478 effectNodeNeeded = true; | 494 effectNodeNeeded = true; |
| 479 outputClip = context.current.clip; | 495 outputClip = context.current.clip; |
| 480 | 496 |
| 481 // TODO(trchen): A filter may contain spatial operations such that an | 497 // 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. | 498 // 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. | 499 // We should generate a special clip node to represent this expansion. |
| 484 } | 500 } |
| 485 | 501 |
| 486 CompositingReasons compositingReasons = | 502 CompositingReasons compositingReasons = |
| 487 CompositingReasonFinder::requiresCompositingForEffectAnimation( | 503 CompositingReasonFinder::requiresCompositingForEffectAnimation(style); |
| 488 object.styleRef()); | |
| 489 if (compositingReasons != CompositingReasonNone) | 504 if (compositingReasons != CompositingReasonNone) |
| 490 effectNodeNeeded = true; | 505 effectNodeNeeded = true; |
| 491 | 506 |
| 507 CompositorElementId compositorElementId = |
| 508 (style.hasCurrentOpacityAnimation() || |
| 509 style.hasCurrentFilterAnimation() || |
| 510 style.hasCurrentBackdropFilterAnimation()) |
| 511 ? createDomNodeBasedCompositorElementId(object) |
| 512 : CompositorElementId(); |
| 513 |
| 492 if (effectNodeNeeded) { | 514 if (effectNodeNeeded) { |
| 493 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 515 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 494 context.forceSubtreeUpdate |= properties.updateEffect( | 516 context.forceSubtreeUpdate |= properties.updateEffect( |
| 495 context.currentEffect, context.current.transform, outputClip, | 517 context.currentEffect, context.current.transform, outputClip, |
| 496 std::move(filter), opacity, blendMode, compositingReasons); | 518 std::move(filter), opacity, blendMode, compositingReasons, |
| 519 compositorElementId); |
| 497 } else { | 520 } else { |
| 498 if (auto* properties = object.getMutableForPainting().paintProperties()) | 521 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 499 context.forceSubtreeUpdate |= properties->clearEffect(); | 522 context.forceSubtreeUpdate |= properties->clearEffect(); |
| 500 } | 523 } |
| 501 } | 524 } |
| 502 | 525 |
| 503 const auto* properties = object.paintProperties(); | 526 const auto* properties = object.paintProperties(); |
| 504 if (properties && properties->effect()) { | 527 if (properties && properties->effect()) { |
| 505 context.currentEffect = properties->effect(); | 528 context.currentEffect = properties->effect(); |
| 506 if (!properties->effect()->filter().isEmpty()) { | 529 if (!properties->effect()->filter().isEmpty()) { |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 updateOverflowClip(object, context); | 1009 updateOverflowClip(object, context); |
| 987 updatePerspective(object, context); | 1010 updatePerspective(object, context); |
| 988 updateSvgLocalToBorderBoxTransform(object, context); | 1011 updateSvgLocalToBorderBoxTransform(object, context); |
| 989 updateScrollAndScrollTranslation(object, context); | 1012 updateScrollAndScrollTranslation(object, context); |
| 990 updateOutOfFlowContext(object, context); | 1013 updateOutOfFlowContext(object, context); |
| 991 | 1014 |
| 992 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 1015 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
| 993 } | 1016 } |
| 994 | 1017 |
| 995 } // namespace blink | 1018 } // namespace blink |
| OLD | NEW |