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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 context.current.shouldFlattenInheritedTransform = true; | 357 context.current.shouldFlattenInheritedTransform = true; |
| 358 } | 358 } |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 void PaintPropertyTreeBuilder::updateEffect( | 362 void PaintPropertyTreeBuilder::updateEffect( |
| 363 const LayoutObject& object, | 363 const LayoutObject& object, |
| 364 PaintPropertyTreeBuilderContext& context) { | 364 PaintPropertyTreeBuilderContext& context) { |
| 365 const ComputedStyle& style = object.styleRef(); | 365 const ComputedStyle& style = object.styleRef(); |
| 366 | 366 |
| 367 // TODO(crbug.com/673500): style.isStackingContext() is only meaningful for | |
| 368 // HTML elements. What we really want to ask is whether the element starts | |
| 369 // an isolated group, and SVGs use a different rule. | |
| 367 if (!style.isStackingContext()) { | 370 if (!style.isStackingContext()) { |
| 368 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 371 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 369 if (auto* properties = object.getMutableForPainting().paintProperties()) | 372 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 370 context.forceSubtreeUpdate |= properties->clearEffect(); | 373 context.forceSubtreeUpdate |= properties->clearEffect(); |
| 371 } | 374 } |
| 372 return; | 375 return; |
| 373 } | 376 } |
| 374 | 377 |
| 375 // TODO(trchen): Can't omit effect node if we have 3D children. | 378 // TODO(trchen): Can't omit effect node if we have 3D children. |
| 376 // TODO(trchen): Can't omit effect node if we have blending children. | |
| 377 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 379 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 378 bool effectNodeNeeded = false; | 380 bool effectNodeNeeded = false; |
| 379 | 381 |
| 382 // Can't omit effect node if we have paint children with exotic blending. | |
| 383 if (object.isSVG()) { | |
| 384 // Yes, including LayoutSVGRoot, because SVG layout objects don't create | |
|
pdr.
2016/12/14 01:05:18
Do we need to special-case isSVG here?
IOW, could
trchen
2016/12/14 01:12:35
Type checking needs to come first. object may not
| |
| 385 // PaintLayer so PaintLayer::hasNonIsolatedDescendantWithBlendMode() | |
| 386 // doesn't catch SVG descendants. | |
| 387 if (object.hasNonIsolatedBlendingDescendants()) | |
| 388 effectNodeNeeded = true; | |
| 389 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { | |
| 390 if (layer->hasNonIsolatedDescendantWithBlendMode()) | |
| 391 effectNodeNeeded = true; | |
| 392 } | |
| 393 | |
| 394 SkBlendMode blendMode = | |
| 395 WebCoreCompositeToSkiaComposite(CompositeSourceOver, style.blendMode()); | |
| 396 if (blendMode != SkBlendMode::kSrcOver) | |
| 397 effectNodeNeeded = true; | |
| 398 | |
| 380 float opacity = style.opacity(); | 399 float opacity = style.opacity(); |
| 381 if (opacity != 1.0f) | 400 if (opacity != 1.0f) |
| 382 effectNodeNeeded = true; | 401 effectNodeNeeded = true; |
| 383 | 402 |
| 384 CompositorFilterOperations filter; | 403 CompositorFilterOperations filter; |
| 385 if (object.isSVG() && !object.isSVGRoot()) { | 404 if (object.isSVG() && !object.isSVGRoot()) { |
| 386 // TODO(trchen): SVG caches filters in SVGResources. Implement it. | 405 // TODO(trchen): SVG caches filters in SVGResources. Implement it. |
| 387 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { | 406 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { |
| 388 // TODO(trchen): Eliminate PaintLayer dependency. | 407 // TODO(trchen): Eliminate PaintLayer dependency. |
| 389 filter = layer->createCompositorFilterOperationsForFilter(style); | 408 filter = layer->createCompositorFilterOperationsForFilter(style); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 414 | 433 |
| 415 // TODO(trchen): A filter may contain spatial operations such that an | 434 // TODO(trchen): A filter may contain spatial operations such that an |
| 416 // output pixel may depend on an input pixel outside of the output clip. | 435 // output pixel may depend on an input pixel outside of the output clip. |
| 417 // We should generate a special clip node to represent this expansion. | 436 // We should generate a special clip node to represent this expansion. |
| 418 } | 437 } |
| 419 | 438 |
| 420 if (effectNodeNeeded) { | 439 if (effectNodeNeeded) { |
| 421 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 440 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 422 context.forceSubtreeUpdate |= properties.updateEffect( | 441 context.forceSubtreeUpdate |= properties.updateEffect( |
| 423 context.currentEffect, context.current.transform, outputClip, | 442 context.currentEffect, context.current.transform, outputClip, |
| 424 std::move(filter), opacity); | 443 std::move(filter), opacity, blendMode); |
| 425 } else { | 444 } else { |
| 426 if (auto* properties = object.getMutableForPainting().paintProperties()) | 445 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 427 context.forceSubtreeUpdate |= properties->clearEffect(); | 446 context.forceSubtreeUpdate |= properties->clearEffect(); |
| 428 } | 447 } |
| 429 } | 448 } |
| 430 | 449 |
| 431 const auto* properties = object.paintProperties(); | 450 const auto* properties = object.paintProperties(); |
| 432 if (properties && properties->effect()) { | 451 if (properties && properties->effect()) { |
| 433 context.currentEffect = properties->effect(); | 452 context.currentEffect = properties->effect(); |
| 434 if (!properties->effect()->filter().isEmpty()) { | 453 if (!properties->effect()->filter().isEmpty()) { |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 907 #endif | 926 #endif |
| 908 | 927 |
| 909 updateOverflowClip(object, context); | 928 updateOverflowClip(object, context); |
| 910 updatePerspective(object, context); | 929 updatePerspective(object, context); |
| 911 updateSvgLocalToBorderBoxTransform(object, context); | 930 updateSvgLocalToBorderBoxTransform(object, context); |
| 912 updateScrollAndScrollTranslation(object, context); | 931 updateScrollAndScrollTranslation(object, context); |
| 913 updateOutOfFlowContext(object, context); | 932 updateOutOfFlowContext(object, context); |
| 914 } | 933 } |
| 915 | 934 |
| 916 } // namespace blink | 935 } // namespace blink |
| OLD | NEW |