Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp

Issue 2564193002: [SPv2] Add CSS mix-blend-mode support (Closed)
Patch Set: fix msvc warning Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 context.current.shouldFlattenInheritedTransform = true; 361 context.current.shouldFlattenInheritedTransform = true;
362 } 362 }
363 } 363 }
364 } 364 }
365 365
366 void PaintPropertyTreeBuilder::updateEffect( 366 void PaintPropertyTreeBuilder::updateEffect(
367 const LayoutObject& object, 367 const LayoutObject& object,
368 PaintPropertyTreeBuilderContext& context) { 368 PaintPropertyTreeBuilderContext& context) {
369 const ComputedStyle& style = object.styleRef(); 369 const ComputedStyle& style = object.styleRef();
370 370
371 // TODO(crbug.com/673500): style.isStackingContext() is only meaningful for
372 // HTML elements. What we really want to ask is whether the element starts
373 // an isolated group, and SVGs use a different rule.
371 if (!style.isStackingContext()) { 374 if (!style.isStackingContext()) {
372 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { 375 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) {
373 if (auto* properties = object.getMutableForPainting().paintProperties()) 376 if (auto* properties = object.getMutableForPainting().paintProperties())
374 context.forceSubtreeUpdate |= properties->clearEffect(); 377 context.forceSubtreeUpdate |= properties->clearEffect();
375 } 378 }
376 return; 379 return;
377 } 380 }
378 381
379 // TODO(trchen): Can't omit effect node if we have 3D children. 382 // TODO(trchen): Can't omit effect node if we have 3D children.
380 // TODO(trchen): Can't omit effect node if we have blending children.
381 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { 383 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) {
382 bool effectNodeNeeded = false; 384 bool effectNodeNeeded = false;
383 385
386 // Can't omit effect node if we have paint children with exotic blending.
387 if (object.isSVG()) {
388 // Yes, including LayoutSVGRoot, because SVG layout objects don't create
389 // PaintLayer so PaintLayer::hasNonIsolatedDescendantWithBlendMode()
390 // doesn't catch SVG descendants.
391 if (object.hasNonIsolatedBlendingDescendants())
392 effectNodeNeeded = true;
393 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) {
394 if (layer->hasNonIsolatedDescendantWithBlendMode())
395 effectNodeNeeded = true;
396 }
397
398 SkBlendMode blendMode =
399 WebCoreCompositeToSkiaComposite(CompositeSourceOver, style.blendMode());
400 if (blendMode != SkBlendMode::kSrcOver)
401 effectNodeNeeded = true;
402
384 float opacity = style.opacity(); 403 float opacity = style.opacity();
385 if (opacity != 1.0f) 404 if (opacity != 1.0f)
386 effectNodeNeeded = true; 405 effectNodeNeeded = true;
387 406
388 CompositorFilterOperations filter; 407 CompositorFilterOperations filter;
389 if (object.isSVG() && !object.isSVGRoot()) { 408 if (object.isSVG() && !object.isSVGRoot()) {
390 // TODO(trchen): SVG caches filters in SVGResources. Implement it. 409 // TODO(trchen): SVG caches filters in SVGResources. Implement it.
391 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { 410 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) {
392 // TODO(trchen): Eliminate PaintLayer dependency. 411 // TODO(trchen): Eliminate PaintLayer dependency.
393 filter = layer->createCompositorFilterOperationsForFilter(style); 412 filter = layer->createCompositorFilterOperationsForFilter(style);
(...skipping 24 matching lines...) Expand all
418 437
419 // TODO(trchen): A filter may contain spatial operations such that an 438 // TODO(trchen): A filter may contain spatial operations such that an
420 // output pixel may depend on an input pixel outside of the output clip. 439 // output pixel may depend on an input pixel outside of the output clip.
421 // We should generate a special clip node to represent this expansion. 440 // We should generate a special clip node to represent this expansion.
422 } 441 }
423 442
424 if (effectNodeNeeded) { 443 if (effectNodeNeeded) {
425 auto& properties = object.getMutableForPainting().ensurePaintProperties(); 444 auto& properties = object.getMutableForPainting().ensurePaintProperties();
426 context.forceSubtreeUpdate |= properties.updateEffect( 445 context.forceSubtreeUpdate |= properties.updateEffect(
427 context.currentEffect, context.current.transform, outputClip, 446 context.currentEffect, context.current.transform, outputClip,
428 std::move(filter), opacity); 447 std::move(filter), opacity, blendMode);
429 } else { 448 } else {
430 if (auto* properties = object.getMutableForPainting().paintProperties()) 449 if (auto* properties = object.getMutableForPainting().paintProperties())
431 context.forceSubtreeUpdate |= properties->clearEffect(); 450 context.forceSubtreeUpdate |= properties->clearEffect();
432 } 451 }
433 } 452 }
434 453
435 const auto* properties = object.paintProperties(); 454 const auto* properties = object.paintProperties();
436 if (properties && properties->effect()) { 455 if (properties && properties->effect()) {
437 context.currentEffect = properties->effect(); 456 context.currentEffect = properties->effect();
438 if (!properties->effect()->filter().isEmpty()) { 457 if (!properties->effect()->filter().isEmpty()) {
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 #endif 928 #endif
910 929
911 updateOverflowClip(object, context); 930 updateOverflowClip(object, context);
912 updatePerspective(object, context); 931 updatePerspective(object, context);
913 updateSvgLocalToBorderBoxTransform(object, context); 932 updateSvgLocalToBorderBoxTransform(object, context);
914 updateScrollAndScrollTranslation(object, context); 933 updateScrollAndScrollTranslation(object, context);
915 updateOutOfFlowContext(object, context); 934 updateOutOfFlowContext(object, context);
916 } 935 }
917 936
918 } // namespace blink 937 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698