Changeset 164294 in webkit


Ignore:
Timestamp:
Feb 18, 2014 9:10:37 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebCore: [CSS Blending] Add -webkit-blend-mode support for SVG.

https://bugs.webkit.org/show_bug.cgi?id=110427
Patch by Mihai Tica <mitica@adobe.com> on 2014-02-18
Reviewed by Dirk Schulze.

Add support for blend modes to SVG. This includes adding and validating isolation for blending.
Make masked elements isolate blending by creating a transparency layer.

Tests: css3/compositing/svg-blend-color-burn.html

css3/compositing/svg-blend-color-dodge.html
css3/compositing/svg-blend-color.html
css3/compositing/svg-blend-darken.html
css3/compositing/svg-blend-difference.html
css3/compositing/svg-blend-exclusion.html
css3/compositing/svg-blend-hard-light.html
css3/compositing/svg-blend-hue.html
css3/compositing/svg-blend-layer-blend.html
css3/compositing/svg-blend-layer-clip-path.html
css3/compositing/svg-blend-layer-filter.html
css3/compositing/svg-blend-layer-mask.html
css3/compositing/svg-blend-layer-opacity.html
css3/compositing/svg-blend-layer-shadow.html
css3/compositing/svg-blend-lighten.html
css3/compositing/svg-blend-luminosity.html
css3/compositing/svg-blend-multiply-alpha.html
css3/compositing/svg-blend-multiply.html
css3/compositing/svg-blend-normal.html
css3/compositing/svg-blend-overlay.html
css3/compositing/svg-blend-saturation.html
css3/compositing/svg-blend-screen.html
css3/compositing/svg-blend-soft-light.html

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::styleDidChange): Also pass a pointer to the old style when calling SVGRenderSupport::styleChanged.

  • rendering/style/RenderStyle.h: Add blendMode default getter when CSS_COMPOSITING is disabled.
  • rendering/style/SVGRenderStyle.h:

(WebCore::SVGRenderStyle::isolatesBlending): Add method.

  • rendering/svg/SVGRenderSupport.cpp:

(WebCore::SVGRenderSupport::styleChanged): Call updateMaskedAncestorShouldIsolateBlending only when a blend mode is set/unset.
(WebCore::SVGRenderSupport::isolatesBlending): Implement method that decides whether an SVGElement isolates or not blending.
(WebCore::SVGRenderSupport::updateMaskedAncestorShouldIsolateBlending): Traverse to the nearest ancestor having a mask.

  • Set a flag causing the creation of a transparency layer when rendering the masked element.
  • rendering/svg/SVGRenderSupport.h:
  • rendering/svg/SVGRenderingContext.cpp:

(WebCore::SVGRenderingContext::prepareToRenderSVGContent): Call GraphicsContext::setCompositeOperation.

  • Isolate blending by creating a transparency layer.
  • Isolate group when rendering a masked element having a blended child node.
  • svg/SVGGraphicsElement.cpp:

(WebCore::SVGGraphicsElement::SVGGraphicsElement): Set default m_shouldIsolateBlending to false.

  • svg/SVGGraphicsElement.h: Add m_shouldIsolateBlending member, getter and setter.

(WebCore::SVGGraphicsElement::shouldIsolateBlending):
(WebCore::SVGGraphicsElement::setShouldIsolateBlending):

LayoutTests: [CSS Blending] Add -webkit-blend-mode support for SVG.
https://bugs.webkit.org/show_bug.cgi?id=110427

Patch by Mihai Tica <mitica@adobe.com> on 2014-02-18
Reviewed by Dirk Schulze.

Test -webkit-blend-mode implementation for simple SVGs. This includes:

  • Test each blend operator.
  • Test that ensures blending is isolated by other properties: blending, filters, masks, shadow and opacity.
  • css3/compositing/svg-blend-color-burn.html: Test blend mode color-burn.
  • css3/compositing/svg-blend-color-dodge.html: Test blend mode color-dodge.
  • css3/compositing/svg-blend-color.html: Test blend mode color.
  • css3/compositing/svg-blend-darken.html: Test blend mode darken.
  • css3/compositing/svg-blend-difference.html: Test blend mode difference.
  • css3/compositing/svg-blend-exclusion.html: Test blend mode exclusion.
  • css3/compositing/svg-blend-hard-light.html: Test blend mode hard-light.
  • css3/compositing/svg-blend-hue.html: Test blend mode hue.
  • css3/compositing/svg-blend-layer-blend.html: mix-blend-mode should isolate for blending.
  • css3/compositing/svg-blend-layer-clip-path.html: clip-path should not isolate for blending.
  • css3/compositing/svg-blend-layer-filter.html: filters should isolate for blending.
  • css3/compositing/svg-blend-layer-mask.html: masks should isolate for blending.
  • css3/compositing/svg-blend-layer-opacity.html: opacity should isolate for blending.
  • css3/compositing/svg-blend-layer-shadow.html: -webkit-shadow should isolate for blending.
  • css3/compositing/svg-blend-lighten.html: Test blend mode lighten.
  • css3/compositing/svg-blend-luminosity.html: Test blend mode luminosity.
  • css3/compositing/svg-blend-multiply-alpha.html: Test blend mode multiply while also having alpha set.
  • css3/compositing/svg-blend-multiply.html: Test blend mode multiply.
  • css3/compositing/svg-blend-normal.html: Test blend mode normal. Note this blend mode has no effect.
  • css3/compositing/svg-blend-overlay.html: Test blend mode overlay.
  • css3/compositing/svg-blend-saturation.html: Test blend mode saturation.
  • css3/compositing/svg-blend-screen.html: Test blend mode screen.
  • css3/compositing/svg-blend-soft-light.html: Test blend mode soft-light.
  • platform/mac/css3/compositing/svg-blend-color-burn-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-color-burn-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-color-dodge-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-color-dodge-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-color-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-color-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-darken-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-darken-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-difference-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-difference-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-exclusion-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-exclusion-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-hard-light-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-hard-light-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-hue-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-hue-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-layer-blend-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-layer-blend-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-layer-clip-path-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-layer-clip-path-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-layer-filter-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-layer-filter-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-layer-mask-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-layer-mask-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-layer-opacity-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-layer-opacity-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-layer-shadow-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-layer-shadow-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-lighten-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-lighten-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-luminosity-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-luminosity-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-multiply-alpha-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-multiply-alpha-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-multiply-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-multiply-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-normal-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-normal-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-overlay-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-overlay-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-saturation-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-saturation-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-screen-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-screen-expected.txt: Added.
  • platform/mac/css3/compositing/svg-blend-soft-light-expected.png: Added.
  • platform/mac/css3/compositing/svg-blend-soft-light-expected.txt: Added.
Location:
trunk
Files:
69 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r164291 r164294  
     12014-02-18  Mihai Tica  <mitica@adobe.com>
     2
     3        [CSS Blending] Add -webkit-blend-mode support for SVG.
     4        https://bugs.webkit.org/show_bug.cgi?id=110427
     5
     6        Reviewed by Dirk Schulze.
     7
     8        Test -webkit-blend-mode implementation for simple SVGs. This includes:
     9        - Test each blend operator.
     10        - Test that ensures blending is isolated by other properties: blending, filters, masks, shadow and opacity.
     11
     12        * css3/compositing/svg-blend-color-burn.html: Test blend mode color-burn.
     13        * css3/compositing/svg-blend-color-dodge.html: Test blend mode color-dodge.
     14        * css3/compositing/svg-blend-color.html: Test blend mode color.
     15        * css3/compositing/svg-blend-darken.html: Test blend mode darken.
     16        * css3/compositing/svg-blend-difference.html: Test blend mode difference.
     17        * css3/compositing/svg-blend-exclusion.html: Test blend mode exclusion.
     18        * css3/compositing/svg-blend-hard-light.html: Test blend mode hard-light.
     19        * css3/compositing/svg-blend-hue.html: Test blend mode hue.
     20        * css3/compositing/svg-blend-layer-blend.html: mix-blend-mode should isolate for blending.
     21        * css3/compositing/svg-blend-layer-clip-path.html: clip-path should not isolate for blending.
     22        * css3/compositing/svg-blend-layer-filter.html: filters should isolate for blending.
     23        * css3/compositing/svg-blend-layer-mask.html: masks should isolate for blending.
     24        * css3/compositing/svg-blend-layer-opacity.html: opacity should isolate for blending.
     25        * css3/compositing/svg-blend-layer-shadow.html: -webkit-shadow should isolate for blending.
     26        * css3/compositing/svg-blend-lighten.html: Test blend mode lighten.
     27        * css3/compositing/svg-blend-luminosity.html: Test blend mode luminosity.
     28        * css3/compositing/svg-blend-multiply-alpha.html: Test blend mode multiply while also having alpha set.
     29        * css3/compositing/svg-blend-multiply.html: Test blend mode multiply.
     30        * css3/compositing/svg-blend-normal.html: Test blend mode normal. Note this blend mode has no effect.
     31        * css3/compositing/svg-blend-overlay.html: Test blend mode overlay.
     32        * css3/compositing/svg-blend-saturation.html: Test blend mode saturation.
     33        * css3/compositing/svg-blend-screen.html: Test blend mode screen.
     34        * css3/compositing/svg-blend-soft-light.html: Test blend mode soft-light.
     35        * platform/mac/css3/compositing/svg-blend-color-burn-expected.png: Added.
     36        * platform/mac/css3/compositing/svg-blend-color-burn-expected.txt: Added.
     37        * platform/mac/css3/compositing/svg-blend-color-dodge-expected.png: Added.
     38        * platform/mac/css3/compositing/svg-blend-color-dodge-expected.txt: Added.
     39        * platform/mac/css3/compositing/svg-blend-color-expected.png: Added.
     40        * platform/mac/css3/compositing/svg-blend-color-expected.txt: Added.
     41        * platform/mac/css3/compositing/svg-blend-darken-expected.png: Added.
     42        * platform/mac/css3/compositing/svg-blend-darken-expected.txt: Added.
     43        * platform/mac/css3/compositing/svg-blend-difference-expected.png: Added.
     44        * platform/mac/css3/compositing/svg-blend-difference-expected.txt: Added.
     45        * platform/mac/css3/compositing/svg-blend-exclusion-expected.png: Added.
     46        * platform/mac/css3/compositing/svg-blend-exclusion-expected.txt: Added.
     47        * platform/mac/css3/compositing/svg-blend-hard-light-expected.png: Added.
     48        * platform/mac/css3/compositing/svg-blend-hard-light-expected.txt: Added.
     49        * platform/mac/css3/compositing/svg-blend-hue-expected.png: Added.
     50        * platform/mac/css3/compositing/svg-blend-hue-expected.txt: Added.
     51        * platform/mac/css3/compositing/svg-blend-layer-blend-expected.png: Added.
     52        * platform/mac/css3/compositing/svg-blend-layer-blend-expected.txt: Added.
     53        * platform/mac/css3/compositing/svg-blend-layer-clip-path-expected.png: Added.
     54        * platform/mac/css3/compositing/svg-blend-layer-clip-path-expected.txt: Added.
     55        * platform/mac/css3/compositing/svg-blend-layer-filter-expected.png: Added.
     56        * platform/mac/css3/compositing/svg-blend-layer-filter-expected.txt: Added.
     57        * platform/mac/css3/compositing/svg-blend-layer-mask-expected.png: Added.
     58        * platform/mac/css3/compositing/svg-blend-layer-mask-expected.txt: Added.
     59        * platform/mac/css3/compositing/svg-blend-layer-opacity-expected.png: Added.
     60        * platform/mac/css3/compositing/svg-blend-layer-opacity-expected.txt: Added.
     61        * platform/mac/css3/compositing/svg-blend-layer-shadow-expected.png: Added.
     62        * platform/mac/css3/compositing/svg-blend-layer-shadow-expected.txt: Added.
     63        * platform/mac/css3/compositing/svg-blend-lighten-expected.png: Added.
     64        * platform/mac/css3/compositing/svg-blend-lighten-expected.txt: Added.
     65        * platform/mac/css3/compositing/svg-blend-luminosity-expected.png: Added.
     66        * platform/mac/css3/compositing/svg-blend-luminosity-expected.txt: Added.
     67        * platform/mac/css3/compositing/svg-blend-multiply-alpha-expected.png: Added.
     68        * platform/mac/css3/compositing/svg-blend-multiply-alpha-expected.txt: Added.
     69        * platform/mac/css3/compositing/svg-blend-multiply-expected.png: Added.
     70        * platform/mac/css3/compositing/svg-blend-multiply-expected.txt: Added.
     71        * platform/mac/css3/compositing/svg-blend-normal-expected.png: Added.
     72        * platform/mac/css3/compositing/svg-blend-normal-expected.txt: Added.
     73        * platform/mac/css3/compositing/svg-blend-overlay-expected.png: Added.
     74        * platform/mac/css3/compositing/svg-blend-overlay-expected.txt: Added.
     75        * platform/mac/css3/compositing/svg-blend-saturation-expected.png: Added.
     76        * platform/mac/css3/compositing/svg-blend-saturation-expected.txt: Added.
     77        * platform/mac/css3/compositing/svg-blend-screen-expected.png: Added.
     78        * platform/mac/css3/compositing/svg-blend-screen-expected.txt: Added.
     79        * platform/mac/css3/compositing/svg-blend-soft-light-expected.png: Added.
     80        * platform/mac/css3/compositing/svg-blend-soft-light-expected.txt: Added.
     81
    1822014-02-18  Michał Pakuła vel Rutka  <m.pakula@samsung.com>
    283
  • trunk/Source/WebCore/ChangeLog

    r164293 r164294  
     12014-02-18  Mihai Tica  <mitica@adobe.com>
     2
     3        [CSS Blending] Add -webkit-blend-mode support for SVG.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=110427
     6        Reviewed by Dirk Schulze.
     7
     8        Add support for blend modes to SVG. This includes adding and validating isolation for blending.
     9        Make masked elements isolate blending by creating a transparency layer.
     10
     11        Tests: css3/compositing/svg-blend-color-burn.html
     12               css3/compositing/svg-blend-color-dodge.html
     13               css3/compositing/svg-blend-color.html
     14               css3/compositing/svg-blend-darken.html
     15               css3/compositing/svg-blend-difference.html
     16               css3/compositing/svg-blend-exclusion.html
     17               css3/compositing/svg-blend-hard-light.html
     18               css3/compositing/svg-blend-hue.html
     19               css3/compositing/svg-blend-layer-blend.html
     20               css3/compositing/svg-blend-layer-clip-path.html
     21               css3/compositing/svg-blend-layer-filter.html
     22               css3/compositing/svg-blend-layer-mask.html
     23               css3/compositing/svg-blend-layer-opacity.html
     24               css3/compositing/svg-blend-layer-shadow.html
     25               css3/compositing/svg-blend-lighten.html
     26               css3/compositing/svg-blend-luminosity.html
     27               css3/compositing/svg-blend-multiply-alpha.html
     28               css3/compositing/svg-blend-multiply.html
     29               css3/compositing/svg-blend-normal.html
     30               css3/compositing/svg-blend-overlay.html
     31               css3/compositing/svg-blend-saturation.html
     32               css3/compositing/svg-blend-screen.html
     33               css3/compositing/svg-blend-soft-light.html
     34
     35        * rendering/RenderElement.cpp:
     36        (WebCore::RenderElement::styleDidChange): Also pass a pointer to the old style when calling SVGRenderSupport::styleChanged.
     37        * rendering/style/RenderStyle.h:  Add blendMode default getter when CSS_COMPOSITING is disabled.
     38        * rendering/style/SVGRenderStyle.h:
     39        (WebCore::SVGRenderStyle::isolatesBlending): Add method.
     40        * rendering/svg/SVGRenderSupport.cpp:
     41        (WebCore::SVGRenderSupport::styleChanged): Call updateMaskedAncestorShouldIsolateBlending only when a blend mode is set/unset.
     42        (WebCore::SVGRenderSupport::isolatesBlending): Implement method that decides whether an SVGElement isolates or not blending.
     43        (WebCore::SVGRenderSupport::updateMaskedAncestorShouldIsolateBlending): Traverse to the nearest ancestor having a mask.
     44        - Set a flag causing the creation of a transparency layer when rendering the masked element.
     45        * rendering/svg/SVGRenderSupport.h:
     46        * rendering/svg/SVGRenderingContext.cpp:
     47        (WebCore::SVGRenderingContext::prepareToRenderSVGContent): Call GraphicsContext::setCompositeOperation.
     48        - Isolate blending by creating a transparency layer.
     49        - Isolate group when rendering a masked element having a blended child node.
     50        * svg/SVGGraphicsElement.cpp:
     51        (WebCore::SVGGraphicsElement::SVGGraphicsElement): Set default m_shouldIsolateBlending to false.
     52        * svg/SVGGraphicsElement.h: Add m_shouldIsolateBlending member, getter and setter.
     53        (WebCore::SVGGraphicsElement::shouldIsolateBlending):
     54        (WebCore::SVGGraphicsElement::setShouldIsolateBlending):
     55
    1562014-02-18  ChangSeok Oh  <changseok.oh@collabora.com>
    257
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r164224 r164294  
    929929        removeAnonymousWrappersForInlinesIfNecessary();
    930930
    931     SVGRenderSupport::styleChanged(*this);
     931    SVGRenderSupport::styleChanged(*this, oldStyle);
    932932
    933933    if (!m_parent)
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r164115 r164294  
    971971    bool hasBlendMode() const { return static_cast<BlendMode>(rareNonInheritedData->m_effectiveBlendMode) != BlendModeNormal; }
    972972#else
     973    BlendMode blendMode() const { return BlendModeNormal; }
    973974    bool hasBlendMode() const { return false; }
    974975#endif
  • trunk/Source/WebCore/rendering/style/SVGRenderStyle.h

    r163751 r164294  
    365365    bool hasFill() const { return fillPaintType() != SVGPaint::SVG_PAINTTYPE_NONE; }
    366366    bool isVerticalWritingMode() const { return writingMode() == WM_TBRL || writingMode() == WM_TB; }
     367    bool isolatesBlending() const { return hasMasker() || hasFilter() || shadow(); }
    367368
    368369protected:
  • trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp

    r163440 r164294  
    441441}
    442442
    443 void SVGRenderSupport::styleChanged(RenderElement& renderer)
     443void SVGRenderSupport::styleChanged(RenderElement& renderer, const RenderStyle* oldStyle)
    444444{
    445445    auto parent = renderer.parent();
    446446    SVGRenderSupport::setRendererHasSVGShadow(renderer, (parent && SVGRenderSupport::rendererHasSVGShadow(*parent)) || renderer.style().svgStyle().shadow());
    447 }
    448 
    449 }
     447
     448#if ENABLE(CSS_COMPOSITING)
     449    if (renderer.element() && renderer.element()->isSVGElement() && (!oldStyle || renderer.style().hasBlendMode() != oldStyle->hasBlendMode()))
     450        SVGRenderSupport::updateMaskedAncestorShouldIsolateBlending(renderer);
     451#else
     452    UNUSED_PARAM(oldStyle);
     453#endif
     454}
     455
     456#if ENABLE(CSS_COMPOSITING)
     457bool SVGRenderSupport::isolatesBlending(const RenderStyle& style)
     458{
     459    return style.svgStyle().isolatesBlending() || style.hasBlendMode() || style.opacity() < 1.0f;
     460}
     461
     462void SVGRenderSupport::updateMaskedAncestorShouldIsolateBlending(const RenderElement& renderer)
     463{
     464    ASSERT(renderer.element());
     465    ASSERT(renderer.element()->isSVGElement());
     466
     467    bool maskedAncestorShouldIsolateBlending = renderer.style().hasBlendMode();
     468    for (auto ancestor = renderer.element()->parentElement(); ancestor && ancestor->isSVGElement(); ancestor = ancestor->parentElement()) {
     469        if (!toSVGElement(ancestor)->isSVGGraphicsElement() || !isolatesBlending(*ancestor->computedStyle()))
     470            continue;
     471
     472        if (ancestor->computedStyle()->svgStyle().hasMasker())
     473            toSVGGraphicsElement(ancestor)->setShouldIsolateBlending(maskedAncestorShouldIsolateBlending);
     474
     475        return;
     476    }
     477}
     478#endif
     479}
  • trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h

    r163440 r164294  
    8484
    8585    static void childAdded(RenderElement& parent, RenderObject& child);
    86     static void styleChanged(RenderElement&);
     86    static void styleChanged(RenderElement&, const RenderStyle*);
     87
     88#if ENABLE(CSS_COMPOSITING)
     89    static bool isolatesBlending(const RenderStyle&);
     90    static void updateMaskedAncestorShouldIsolateBlending(const RenderElement&);
     91#endif
    8792
    8893    // FIXME: These methods do not belong here.
  • trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp

    r163764 r164294  
    104104    float opacity = isRenderingMask ? 1 : style.opacity();
    105105    const ShadowData* shadow = svgStyle.shadow();
    106     if (opacity < 1 || shadow) {
     106    bool hasBlendMode = style.hasBlendMode();
     107    bool isolateMaskForBlending = false;
     108
     109#if ENABLE(CSS_COMPOSITING)
     110    if (svgStyle.hasMasker() && toSVGElement(renderer.element())->isSVGGraphicsElement()) {
     111        SVGGraphicsElement& graphicsElement = *toSVGGraphicsElement(renderer.element());
     112        isolateMaskForBlending = graphicsElement.shouldIsolateBlending();
     113    }
     114#endif
     115
     116    if (opacity < 1 || shadow || hasBlendMode || isolateMaskForBlending) {
    107117        FloatRect repaintRect = m_renderer->repaintRectInLocalCoordinates();
    108 
    109         if (opacity < 1) {
    110             m_paintInfo->context->clip(repaintRect);
     118        m_paintInfo->context->clip(repaintRect);
     119
     120        if (opacity < 1 || hasBlendMode || isolateMaskForBlending) {
     121
     122            if (hasBlendMode)
     123                m_paintInfo->context->setCompositeOperation(m_paintInfo->context->compositeOperation(), style.blendMode());
     124
    111125            m_paintInfo->context->beginTransparencyLayer(opacity);
     126
     127            if (hasBlendMode)
     128                m_paintInfo->context->setCompositeOperation(m_paintInfo->context->compositeOperation(), BlendModeNormal);
     129
    112130            m_renderingFlags |= EndOpacityLayer;
    113131        }
    114132
    115133        if (shadow) {
    116             m_paintInfo->context->clip(repaintRect);
    117134            m_paintInfo->context->setShadow(IntSize(roundToInt(shadow->x()), roundToInt(shadow->y())), shadow->radius(), shadow->color(), style.colorSpace());
    118135            m_paintInfo->context->beginTransparencyLayer(1);
  • trunk/Source/WebCore/svg/SVGGraphicsElement.cpp

    r163440 r164294  
    4343SVGGraphicsElement::SVGGraphicsElement(const QualifiedName& tagName, Document& document)
    4444    : SVGElement(tagName, document)
     45    , m_shouldIsolateBlending(false)
    4546{
    4647    registerAnimatedPropertiesForSVGGraphicsElement();
  • trunk/Source/WebCore/svg/SVGGraphicsElement.h

    r163440 r164294  
    4747    virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) override;
    4848
     49    bool shouldIsolateBlending() const { return m_shouldIsolateBlending; }
     50    void setShouldIsolateBlending(bool isolate) { m_shouldIsolateBlending = isolate; }
     51
    4952    // "base class" methods for all the elements which render as paths
    5053    virtual void toClipPath(Path&);
     
    7275    // Used by <animateMotion>
    7376    std::unique_ptr<AffineTransform> m_supplementalTransform;
     77
     78    // Used to isolate blend operations caused by masking.
     79    bool m_shouldIsolateBlending;
    7480};
    7581
Note: See TracChangeset for help on using the changeset viewer.