Changeset 163955 in webkit


Ignore:
Timestamp:
Feb 12, 2014 4:40:08 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Element Blending] Implement the software path of -webkit-blend-mode with Core Graphics.
https://bugs.webkit.org/show_bug.cgi?id=99119

Patch by Mihai Tica <mitica@adobe.com> on 2014-02-12
Reviewed by Simon Fraser.

Source/WebCore:

This patch adds support for -webkit-blend-mode with Core Graphics.
The layer promotion code that forced compositing when blending was detected has been removed.
Remaining work for the software path is to detect and implement isolation of the blending operation:
as stated in the spec, blending should be limited to the parent stacking context.

Tests: css3/compositing/blend-mode-blended-element-overlapping-composited-sibling-should-have-compositing-layer.html

css3/compositing/blend-mode-parent-of-composited-blended-has-layer.html
css3/compositing/blend-mode-simple-composited.html
css3/compositing/blend-mode-with-composited-descendant-should-have-layer.html

  • inspector/InspectorLayerTreeAgent.cpp:

(WebCore::InspectorLayerTreeAgent::reasonsForCompositingLayer): Remove CompositingReasonBlending.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::beginTransparencyLayers): Set the blendMode on the GraphicsContext.

  • rendering/RenderLayer.h: paintsWithTransparency should return true when a blendMode is set.
  • rendering/RenderLayerCompositor.cpp: Remove promotion code when a blendMode is detected.

(WebCore::RenderLayerCompositor::requiresCompositingLayer): Remove CompositingReasonBlending reason.
(WebCore::RenderLayerCompositor::requiresOwnBackingStore): Remove CompositingReasonBlending reason.
(WebCore::RenderLayerCompositor::reasonsForCompositing): Remove CompositingReasonBlending reason.
(WebCore::RenderLayerCompositor::logReasonsForCompositing): Remove CompositingReasonBlending reason.

  • rendering/RenderLayerCompositor.h:
  • Remove the requiresCompositingForBlending method
  • Remove the CompositingReasonBlending from the CompositingReasons enum.

LayoutTests:

  • css3/compositing/blend-mode-blended-element-overlapping-composited-sibling-should-have-compositing-layer-expected.txt: Copied from LayoutTests/css3/compositing/blend-mode-should-not-have-compositing-layer-expected.txt.
  • css3/compositing/blend-mode-blended-element-overlapping-composited-sibling-should-have-compositing-layer.html: Test if having an overlapping composited sibling forces compositing of a blended element.
  • css3/compositing/blend-mode-layers.html: Update to test both the software and the hardware path.
  • css3/compositing/blend-mode-parent-of-composited-blended-has-layer-expected.txt: Renamed from LayoutTests/css3/compositing/should-have-compositing-layer-expected.txt.
  • css3/compositing/blend-mode-parent-of-composited-blended-has-layer.html: Test if the parent of an accelerated element with -webkit-blend-mode is promoted.
  • css3/compositing/blend-mode-reflection.html: Update to test both the software and the hardware path.
  • css3/compositing/blend-mode-should-not-have-compositing-layer.html: Removed.
  • css3/compositing/blend-mode-simple-composited.html: Test all the blend modes for the hardware path.
  • css3/compositing/blend-mode-with-composited-descendant-should-have-layer-expected.txt: Renamed from LayoutTests/css3/compositing/blend-mode-should-not-have-compositing-layer-expected.txt.
  • css3/compositing/blend-mode-with-composited-descendant-should-have-layer.html: Test to ensure that an element with -webkit-blend-mode and a composited descendant is also accelerated.
  • css3/compositing/should-have-compositing-layer.html: Removed.
  • platform/mac/css3/compositing/blend-mode-layers-expected.png:
  • platform/mac/css3/compositing/blend-mode-layers-expected.txt:
  • platform/mac/css3/compositing/blend-mode-overflow-expected.png:
  • platform/mac/css3/compositing/blend-mode-overflow-expected.txt: Added.
  • platform/mac/css3/compositing/blend-mode-reflection-expected.png:
  • platform/mac/css3/compositing/blend-mode-reflection-expected.txt:
  • platform/mac/css3/compositing/blend-mode-simple-composited-expected.png: Added.
  • platform/mac/css3/compositing/blend-mode-simple-composited-expected.txt: Added.
  • platform/mac/css3/compositing/blend-mode-simple-expected.png:
Location:
trunk
Files:
7 added
2 deleted
15 edited
1 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r163953 r163955  
     12014-02-12  Mihai Tica  <mitica@adobe.com>
     2
     3        [CSS Element Blending] Implement the software path of -webkit-blend-mode with Core Graphics.
     4        https://bugs.webkit.org/show_bug.cgi?id=99119
     5
     6        Reviewed by Simon Fraser.
     7
     8        * css3/compositing/blend-mode-blended-element-overlapping-composited-sibling-should-have-compositing-layer-expected.txt: Copied from LayoutTests/css3/compositing/blend-mode-should-not-have-compositing-layer-expected.txt.
     9        * css3/compositing/blend-mode-blended-element-overlapping-composited-sibling-should-have-compositing-layer.html: Test if having an overlapping composited sibling forces compositing of a blended element.
     10        * css3/compositing/blend-mode-layers.html: Update to test both the software and the hardware path.
     11        * css3/compositing/blend-mode-parent-of-composited-blended-has-layer-expected.txt: Renamed from LayoutTests/css3/compositing/should-have-compositing-layer-expected.txt.
     12        * css3/compositing/blend-mode-parent-of-composited-blended-has-layer.html: Test if the parent of an accelerated element with -webkit-blend-mode is promoted.
     13        * css3/compositing/blend-mode-reflection.html: Update to test both the software and the hardware path.
     14        * css3/compositing/blend-mode-should-not-have-compositing-layer.html: Removed.
     15        * css3/compositing/blend-mode-simple-composited.html: Test all the blend modes for the hardware path.
     16        * css3/compositing/blend-mode-with-composited-descendant-should-have-layer-expected.txt: Renamed from LayoutTests/css3/compositing/blend-mode-should-not-have-compositing-layer-expected.txt.
     17        * css3/compositing/blend-mode-with-composited-descendant-should-have-layer.html: Test to ensure that an element with -webkit-blend-mode and a composited descendant is also accelerated.
     18        * css3/compositing/should-have-compositing-layer.html: Removed.
     19        * platform/mac/css3/compositing/blend-mode-layers-expected.png:
     20        * platform/mac/css3/compositing/blend-mode-layers-expected.txt:
     21        * platform/mac/css3/compositing/blend-mode-overflow-expected.png:
     22        * platform/mac/css3/compositing/blend-mode-overflow-expected.txt: Added.
     23        * platform/mac/css3/compositing/blend-mode-reflection-expected.png:
     24        * platform/mac/css3/compositing/blend-mode-reflection-expected.txt:
     25        * platform/mac/css3/compositing/blend-mode-simple-composited-expected.png: Added.
     26        * platform/mac/css3/compositing/blend-mode-simple-composited-expected.txt: Added.
     27        * platform/mac/css3/compositing/blend-mode-simple-expected.png:
     28
    1292014-02-12  Michał Pakuła vel Rutka  <m.pakula@samsung.com>
    230
  • trunk/LayoutTests/css3/compositing/blend-mode-blended-element-overlapping-composited-sibling-should-have-compositing-layer-expected.txt

    r163954 r163955  
    1 
    21(GraphicsLayer
    32  (bounds 800.00 600.00)
     
    109          (bounds 800.00 600.00)
    1110          (drawsContent 1)
    12           (children 1
     11          (children 2
    1312            (GraphicsLayer
    1413              (position 8.00 8.00)
    15               (bounds 784.00 90.00)
    16               (opacity 0.50)
    17               (drawsContent 1)
    18               (children 1
    19                 (GraphicsLayer
    20                   (bounds 160.00 90.00)
    21                 )
    22               )
     14              (bounds 100.00 100.00)
     15            )
     16            (GraphicsLayer
     17              (position 8.00 78.00)
     18              (bounds 100.00 100.00)
    2319            )
    2420          )
  • trunk/LayoutTests/css3/compositing/blend-mode-layers.html

    r163633 r163955  
    4747            float: left;
    4848        }
     49
     50        .composited {
     51            -webkit-transform: translateZ(0);
     52        }
    4953    </style>
    5054</head>
     
    5862        <!-- setting the blendmode will create a new stacking context which causes z-index to change -->
    5963        <li><div class="div1"><div class="div2" style="-webkit-blend-mode: multiply"><div class="div3"></div></div></div></li>
     64        <li><div class="div1"><div class="div2 composited" style="-webkit-blend-mode: multiply"><div class="div3"></div></div></div></li>
    6065
    6166        <!-- just setting slight opacity which causes a stacking context. This also causes z-index to be resolved to the stacking context -->
     
    6469        <!-- blending will now only happen upto the stacking context generated by opacity. Z-index is resolved against the stacking context of the div with the blendmode -->
    6570        <li><div class="div1" style="opacity:.99"><div class="div2" style="-webkit-blend-mode: multiply"><div class="div3"></div></div></div></li>
     71        <li><div class="div1" style="opacity:.99"><div class="div2 composited" style="-webkit-blend-mode: multiply"><div class="div3"></div></div></div></li>
    6672    </ul>
    6773</body>
  • trunk/LayoutTests/css3/compositing/blend-mode-parent-of-composited-blended-has-layer-expected.txt

    r163954 r163955  
    1 Test to make sure a blend mode creates a compositing layer. Test is successful of render tree shows compositing
    2 
    3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    4 
    5 
    6 PASS content has compositing layers
    7 
    81(GraphicsLayer
    92  (bounds 800.00 600.00)
     
    1811          (children 1
    1912            (GraphicsLayer
    20               (position 8.00 76.00)
    21               (bounds 160.00 90.00)
     13              (position 18.00 10.00)
     14              (bounds 100.00 100.00)
    2215            )
    2316          )
  • trunk/LayoutTests/css3/compositing/blend-mode-reflection.html

    r161628 r163955  
    2121            float: left;
    2222        }
     23
     24        .composited {
     25            -webkit-transform: translateZ(0);
     26        }
    2327     </style>
    2428 </head>
    2529
    26 <!-- This file should contain a duck on top of a gradient that has a reflection.
     30<!-- This file should contain two images of a duck on top of a gradient with reflection.
    2731Both the duck and the reflection should blend.  -->
    2832<body>
    2933    <ul><li><img style="-webkit-blend-mode: multiply" src="resources/ducky.png"></li></ul>
     34    <ul><li><img class="composited" style="-webkit-blend-mode: multiply" src="resources/ducky.png"></li></ul>
    3035</body>
  • trunk/LayoutTests/css3/compositing/blend-mode-with-composited-descendant-should-have-layer-expected.txt

    r163954 r163955  
    1 
    21(GraphicsLayer
    32  (bounds 800.00 600.00)
     
    1211          (children 1
    1312            (GraphicsLayer
    14               (position 8.00 8.00)
    15               (bounds 784.00 90.00)
    16               (opacity 0.50)
    17               (drawsContent 1)
     13              (position 8.00 10.00)
     14              (bounds 100.00 100.00)
    1815              (children 1
    1916                (GraphicsLayer
    20                   (bounds 160.00 90.00)
     17                  (position 10.00 0.00)
     18                  (bounds 100.00 100.00)
    2119                )
    2220              )
  • trunk/LayoutTests/platform/mac/css3/compositing/blend-mode-layers-expected.txt

    r161628 r163955  
    11layer at (0,0) size 800x600
    22  RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x191
    4   RenderBlock {HTML} at (0,0) size 800x191
     3layer at (0,0) size 800x366
     4  RenderBlock {HTML} at (0,0) size 800x366
    55    RenderBody {BODY} at (8,16) size 784x0
    66      RenderBlock {UL} at (0,0) size 784x0
     
    1010          RenderBlock {DIV} at (0,50) size 160x75 [bgcolor=#00FFFF]
    1111        RenderBlock (floating) {LI} at (385,5) size 160x50 [bgcolor=#FF00FF]
     12          RenderBlock {DIV} at (0,50) size 160x75 [bgcolor=#00FFFF]
    1213        RenderBlock (floating) {LI} at (555,5) size 160x50 [bgcolor=#FF00FF]
     14        RenderBlock (floating) {LI} at (45,180) size 160x50 [bgcolor=#FF00FF]
     15        RenderBlock (floating) {LI} at (215,180) size 160x50 [bgcolor=#FF00FF]
    1316layer at (73,31) size 160x160
    1417  RenderBlock (relative positioned) {DIV} at (0,0) size 160x160
     
    1922layer at (223,41) size 80x150
    2023  RenderBlock (relative positioned) {DIV} at (0,0) size 80x150 [bgcolor=#FFFF00]
    21 layer at (393,71) size 160x75
    22   RenderBlock {DIV} at (0,50) size 160x75 [bgcolor=#00FFFF]
    2324layer at (413,31) size 160x160
    2425  RenderBlock (relative positioned) {DIV} at (0,0) size 160x160
     
    3132layer at (563,41) size 80x150
    3233  RenderBlock (relative positioned) {DIV} at (0,0) size 80x150 [bgcolor=#FFFF00]
     34layer at (53,246) size 160x75
     35  RenderBlock {DIV} at (0,50) size 160x75 [bgcolor=#00FFFF]
     36layer at (73,206) size 160x160
     37  RenderBlock (relative positioned) {DIV} at (0,0) size 160x160
     38layer at (53,216) size 80x150
     39  RenderBlock (relative positioned) {DIV} at (0,0) size 80x150 [bgcolor=#FFFF00]
     40layer at (223,246) size 160x75
     41  RenderBlock {DIV} at (0,50) size 160x75 [bgcolor=#00FFFF]
     42layer at (243,206) size 160x160
     43  RenderBlock (relative positioned) {DIV} at (0,0) size 160x160
     44layer at (223,216) size 80x150
     45  RenderBlock (relative positioned) {DIV} at (0,0) size 80x150 [bgcolor=#FFFF00]
  • trunk/LayoutTests/platform/mac/css3/compositing/blend-mode-reflection-expected.txt

    r161628 r163955  
    66      RenderBlock {UL} at (0,0) size 784x0
    77        RenderBlock (floating) {LI} at (45,5) size 130x260
     8      RenderBlock {UL} at (0,0) size 784x0
     9        RenderBlock (floating) {LI} at (185,5) size 130x260
    810layer at (53,21) size 130x130
    911  RenderImage {IMG} at (0,0) size 130x130
     12layer at (193,21) size 130x130
     13  RenderImage {IMG} at (0,0) size 130x130
  • trunk/Source/WebCore/ChangeLog

    r163944 r163955  
     12014-02-12  Mihai Tica  <mitica@adobe.com>
     2
     3        [CSS Element Blending] Implement the software path of -webkit-blend-mode with Core Graphics.
     4        https://bugs.webkit.org/show_bug.cgi?id=99119
     5
     6        Reviewed by Simon Fraser.
     7
     8        This patch adds support for -webkit-blend-mode with Core Graphics.
     9        The layer promotion code that forced compositing when blending was detected has been removed.
     10        Remaining work for the software path is to detect and implement isolation of the blending operation:
     11        as stated in the spec, blending should be limited to the parent stacking context.
     12
     13        Tests: css3/compositing/blend-mode-blended-element-overlapping-composited-sibling-should-have-compositing-layer.html
     14               css3/compositing/blend-mode-parent-of-composited-blended-has-layer.html
     15               css3/compositing/blend-mode-simple-composited.html
     16               css3/compositing/blend-mode-with-composited-descendant-should-have-layer.html
     17
     18        * inspector/InspectorLayerTreeAgent.cpp:
     19        (WebCore::InspectorLayerTreeAgent::reasonsForCompositingLayer): Remove CompositingReasonBlending.
     20        * rendering/RenderLayer.cpp:
     21        (WebCore::RenderLayer::beginTransparencyLayers): Set the blendMode on the GraphicsContext.
     22        * rendering/RenderLayer.h: paintsWithTransparency should return true when a blendMode is set.
     23        * rendering/RenderLayerCompositor.cpp: Remove promotion code when a blendMode is detected.
     24        (WebCore::RenderLayerCompositor::requiresCompositingLayer): Remove CompositingReasonBlending reason.
     25        (WebCore::RenderLayerCompositor::requiresOwnBackingStore): Remove CompositingReasonBlending reason.
     26        (WebCore::RenderLayerCompositor::reasonsForCompositing): Remove CompositingReasonBlending reason.
     27        (WebCore::RenderLayerCompositor::logReasonsForCompositing): Remove CompositingReasonBlending reason.
     28        * rendering/RenderLayerCompositor.h:
     29        - Remove the requiresCompositingForBlending method
     30        - Remove the CompositingReasonBlending from the CompositingReasons enum.
     31
    1322014-02-11  Zalan Bujtas  <zalan@apple.com>
    233
  • trunk/Source/WebCore/inspector/InspectorLayerTreeAgent.cpp

    r163568 r163955  
    295295    if (reasonsBitmask & CompositingReasonFilterWithCompositedDescendants)
    296296        compositingReasons->setFilterWithCompositedDescendants(true);
    297            
     297
    298298    if (reasonsBitmask & CompositingReasonBlendingWithCompositedDescendants)
    299299        compositingReasons->setBlendingWithCompositedDescendants(true);
     
    307307    if (reasonsBitmask & CompositingReasonRoot)
    308308        compositingReasons->setRoot(true);
    309 
    310     if (reasonsBitmask & CompositingReasonBlending)
    311         compositingReasons->setBlending(true);
    312309}
    313310
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r163944 r163955  
    16841684        LayoutRect clipRect = paintingExtent(rootLayer, paintDirtyRect, paintBehavior);
    16851685        context->clip(clipRect);
     1686
     1687#if ENABLE(CSS_COMPOSITING)
     1688        if (hasBlendMode())
     1689            context->setCompositeOperation(context->compositeOperation(), m_blendMode);
     1690#endif
     1691
    16861692        context->beginTransparencyLayer(renderer().opacity());
     1693
     1694#if ENABLE(CSS_COMPOSITING)
     1695        if (hasBlendMode())
     1696            context->setCompositeOperation(context->compositeOperation(), BlendModeNormal);
     1697#endif
     1698
    16871699#ifdef REVEAL_TRANSPARENCY_LAYERS
    16881700        context->setFillColor(Color(0.0f, 0.0f, 0.5f, 0.2f), ColorSpaceDeviceRGB);
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r163757 r163955  
    799799    bool paintsWithTransparency(PaintBehavior paintBehavior) const
    800800    {
    801         return isTransparent() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited());
     801        return (isTransparent() || hasBlendMode()) && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited());
    802802    }
    803803
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r163931 r163955  
    19901990        || requiresCompositingForScrolling(*renderer)
    19911991#endif
    1992         || requiresCompositingForOverflowScrolling(*renderer->layer())
    1993         || requiresCompositingForBlending(*renderer);
     1992        || requiresCompositingForOverflowScrolling(*renderer->layer());
    19941993}
    19951994
     
    20302029        || requiresCompositingForAnimation(renderer)
    20312030        || requiresCompositingForFilters(renderer)
    2032         || requiresCompositingForBlending(renderer)
    20332031        || requiresCompositingForPosition(renderer, layer)
    20342032        || requiresCompositingForOverflowScrolling(layer)
     
    20932091    if (requiresCompositingForFilters(*renderer))
    20942092        reasons |= CompositingReasonFilters;
    2095 
    2096     if (requiresCompositingForBlending(*renderer))
    2097         reasons |= CompositingReasonBlending;
    20982093
    20992094    if (requiresCompositingForPosition(*renderer, *renderer->layer()))
     
    21292124        if (renderer->hasFilter())
    21302125            reasons |= CompositingReasonFilterWithCompositedDescendants;
    2131            
     2126
    21322127        if (renderer->hasBlendMode())
    21332128            reasons |= CompositingReasonBlendingWithCompositedDescendants;
     2129
    21342130    } else if (renderer->layer()->indirectCompositingReason() == RenderLayer::IndirectCompositingForPerspective)
    21352131        reasons |= CompositingReasonPerspective;
     
    21712167    if (reasons & CompositingReasonFilters)
    21722168        return "filters";
    2173 
    2174     if (reasons & CompositingReasonBlending)
    2175         return "blending";
    21762169
    21772170    if (reasons & CompositingReasonPositionFixed)
     
    24422435
    24432436    return renderer.hasFilter();
    2444 #else
    2445     UNUSED_PARAM(renderer);
    2446     return false;
    2447 #endif
    2448 }
    2449 
    2450 bool RenderLayerCompositor::requiresCompositingForBlending(RenderLayerModelObject& renderer) const
    2451 {
    2452 #if ENABLE(CSS_COMPOSITING)
    2453     return renderer.hasBlendMode();
    24542437#else
    24552438    UNUSED_PARAM(renderer);
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r163931 r163955  
    8181    CompositingReasonPerspective                            = 1 << 21,
    8282    CompositingReasonPreserve3D                             = 1 << 22,
    83     CompositingReasonRoot                                   = 1 << 23,
    84     CompositingReasonBlending                               = 1 << 24
     83    CompositingReasonRoot                                   = 1 << 23
    8584};
    8685typedef unsigned CompositingReasons;
     
    394393    bool requiresCompositingForFrame(RenderLayerModelObject&) const;
    395394    bool requiresCompositingForFilters(RenderLayerModelObject&) const;
    396     bool requiresCompositingForBlending(RenderLayerModelObject&) const;
    397395    bool requiresCompositingForScrollableFrame() const;
    398396    bool requiresCompositingForPosition(RenderLayerModelObject&, const RenderLayer&, RenderLayer::ViewportConstrainedNotCompositedReason* = 0) const;
Note: See TracChangeset for help on using the changeset viewer.