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/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" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 const LayoutObject& object, | 350 const LayoutObject& object, |
| 351 PaintPropertyTreeBuilderContext& context) { | 351 PaintPropertyTreeBuilderContext& context) { |
| 352 if (object.isSVG() && !object.isSVGRoot()) { | 352 if (object.isSVG() && !object.isSVGRoot()) { |
| 353 updateTransformForNonRootSVG(object, context); | 353 updateTransformForNonRootSVG(object, context); |
| 354 return; | 354 return; |
| 355 } | 355 } |
| 356 | 356 |
| 357 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 357 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 358 const ComputedStyle& style = object.styleRef(); | 358 const ComputedStyle& style = object.styleRef(); |
| 359 | 359 |
| 360 CompositingReasons compositingReasons = | 360 bool needsTransformNode = false; |
| 361 compositingReasonsForTransform(object); | 361 CompositingReasons compositingReasons = CompositingReasonNone; |
| 362 if (object.isBox()) { | |
| 363 // A transform node is allocated for transforms, preserves-3d (SPv2) and | |
| 364 // any direct compositing reason (SPv2). The latter is required because | |
| 365 // this is the only way to represent compositing both an element and its | |
| 366 // stacking descendants. | |
| 367 needsTransformNode |= style.hasTransform(); | |
| 368 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 369 needsTransformNode |= style.preserves3D(); | |
|
chrishtr
2016/12/28 18:15:18
Are you sure preserve-3D is not required for Slimm
Xianzhu
2016/12/28 18:25:29
Yes. GeometryMapper doesn't use FlattenInheritedTr
| |
| 370 compositingReasons = compositingReasonsForTransform(object); | |
| 371 needsTransformNode |= (compositingReasons != CompositingReasonNone); | |
| 372 } | |
| 373 } | |
| 362 | 374 |
| 363 // A transform node is allocated for transforms, preserves-3d and any | 375 if (needsTransformNode) { |
| 364 // direct compositing reason. The latter is required because this is the | |
| 365 // only way to represent compositing both an element and its stacking | |
| 366 // descendants. | |
| 367 if (object.isBox() && (style.hasTransform() || style.preserves3D() || | |
| 368 compositingReasons != CompositingReasonNone)) { | |
| 369 auto& box = toLayoutBox(object); | 376 auto& box = toLayoutBox(object); |
| 370 TransformationMatrix matrix; | 377 TransformationMatrix matrix; |
| 371 style.applyTransform( | 378 style.applyTransform( |
| 372 matrix, box.size(), ComputedStyle::ExcludeTransformOrigin, | 379 matrix, box.size(), ComputedStyle::ExcludeTransformOrigin, |
| 373 ComputedStyle::IncludeMotionPath, | 380 ComputedStyle::IncludeMotionPath, |
| 374 ComputedStyle::IncludeIndependentTransformProperties); | 381 ComputedStyle::IncludeIndependentTransformProperties); |
| 375 | 382 |
| 376 // TODO(trchen): transform-style should only be respected if a PaintLayer | 383 // TODO(trchen): transform-style should only be respected if a PaintLayer |
| 377 // is created. | 384 // is created. |
| 378 // If a node with transform-style: preserve-3d does not exist in an | 385 // If a node with transform-style: preserve-3d does not exist in an |
| 379 // existing rendering context, it establishes a new one. | 386 // existing rendering context, it establishes a new one. |
| 380 unsigned renderingContextID = context.current.renderingContextID; | 387 unsigned renderingContextID = context.current.renderingContextID; |
| 381 if (style.preserves3D() && !renderingContextID) | 388 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 389 style.preserves3D() && !renderingContextID) | |
| 382 renderingContextID = PtrHash<const LayoutObject>::hash(&object); | 390 renderingContextID = PtrHash<const LayoutObject>::hash(&object); |
| 383 | 391 |
| 384 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 392 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 385 context.forceSubtreeUpdate |= properties.updateTransform( | 393 context.forceSubtreeUpdate |= properties.updateTransform( |
| 386 context.current.transform, matrix, transformOrigin(box), | 394 context.current.transform, matrix, transformOrigin(box), |
| 387 context.current.shouldFlattenInheritedTransform, renderingContextID, | 395 context.current.shouldFlattenInheritedTransform, renderingContextID, |
| 388 compositingReasons); | 396 compositingReasons); |
| 389 } else { | 397 } else { |
| 390 if (auto* properties = object.getMutableForPainting().paintProperties()) | 398 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 391 context.forceSubtreeUpdate |= properties->clearTransform(); | 399 context.forceSubtreeUpdate |= properties->clearTransform(); |
| 392 } | 400 } |
| 393 } | 401 } |
| 394 | 402 |
| 395 const auto* properties = object.paintProperties(); | 403 const auto* properties = object.paintProperties(); |
| 396 if (properties && properties->transform()) { | 404 if (properties && properties->transform()) { |
| 397 context.current.transform = properties->transform(); | 405 context.current.transform = properties->transform(); |
| 398 if (object.styleRef().preserves3D()) { | 406 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 407 object.styleRef().preserves3D()) { | |
| 399 context.current.renderingContextID = | 408 context.current.renderingContextID = |
| 400 properties->transform()->renderingContextID(); | 409 properties->transform()->renderingContextID(); |
| 401 context.current.shouldFlattenInheritedTransform = false; | 410 context.current.shouldFlattenInheritedTransform = false; |
| 402 } else { | 411 } else { |
| 403 context.current.renderingContextID = 0; | 412 context.current.renderingContextID = 0; |
| 404 context.current.shouldFlattenInheritedTransform = true; | 413 context.current.shouldFlattenInheritedTransform = true; |
| 405 } | 414 } |
| 406 } | 415 } |
| 407 } | 416 } |
| 408 | 417 |
| 409 void PaintPropertyTreeBuilder::updateEffect( | 418 void PaintPropertyTreeBuilder::updateEffect( |
| 410 const LayoutObject& object, | 419 const LayoutObject& object, |
| 411 PaintPropertyTreeBuilderContext& context) { | 420 PaintPropertyTreeBuilderContext& context) { |
| 421 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 422 return; | |
| 423 | |
| 412 const ComputedStyle& style = object.styleRef(); | 424 const ComputedStyle& style = object.styleRef(); |
| 413 | 425 |
| 414 const bool isCSSIsolatedGroup = | 426 const bool isCSSIsolatedGroup = |
| 415 object.isBoxModelObject() && style.isStackingContext(); | 427 object.isBoxModelObject() && style.isStackingContext(); |
| 416 const bool isSVGExceptRoot = object.isSVG() && !object.isSVGRoot(); | 428 const bool isSVGExceptRoot = object.isSVG() && !object.isSVGRoot(); |
| 417 if (!isCSSIsolatedGroup && !isSVGExceptRoot) { | 429 if (!isCSSIsolatedGroup && !isSVGExceptRoot) { |
| 418 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 430 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 419 if (auto* properties = object.getMutableForPainting().paintProperties()) | 431 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 420 context.forceSubtreeUpdate |= properties->clearEffect(); | 432 context.forceSubtreeUpdate |= properties->clearEffect(); |
| 421 } | 433 } |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 988 updateOverflowClip(object, context); | 1000 updateOverflowClip(object, context); |
| 989 updatePerspective(object, context); | 1001 updatePerspective(object, context); |
| 990 updateSvgLocalToBorderBoxTransform(object, context); | 1002 updateSvgLocalToBorderBoxTransform(object, context); |
| 991 updateScrollAndScrollTranslation(object, context); | 1003 updateScrollAndScrollTranslation(object, context); |
| 992 updateOutOfFlowContext(object, context); | 1004 updateOutOfFlowContext(object, context); |
| 993 | 1005 |
| 994 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 1006 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
| 995 } | 1007 } |
| 996 | 1008 |
| 997 } // namespace blink | 1009 } // namespace blink |
| OLD | NEW |