Changeset 164294 in webkit
- Timestamp:
- Feb 18, 2014 9:10:37 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 69 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r164291 r164294 1 2014-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 1 82 2014-02-18 Michał Pakuła vel Rutka <m.pakula@samsung.com> 2 83 -
trunk/Source/WebCore/ChangeLog
r164293 r164294 1 2014-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 1 56 2014-02-18 ChangSeok Oh <changseok.oh@collabora.com> 2 57 -
trunk/Source/WebCore/rendering/RenderElement.cpp
r164224 r164294 929 929 removeAnonymousWrappersForInlinesIfNecessary(); 930 930 931 SVGRenderSupport::styleChanged(*this );931 SVGRenderSupport::styleChanged(*this, oldStyle); 932 932 933 933 if (!m_parent) -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r164115 r164294 971 971 bool hasBlendMode() const { return static_cast<BlendMode>(rareNonInheritedData->m_effectiveBlendMode) != BlendModeNormal; } 972 972 #else 973 BlendMode blendMode() const { return BlendModeNormal; } 973 974 bool hasBlendMode() const { return false; } 974 975 #endif -
trunk/Source/WebCore/rendering/style/SVGRenderStyle.h
r163751 r164294 365 365 bool hasFill() const { return fillPaintType() != SVGPaint::SVG_PAINTTYPE_NONE; } 366 366 bool isVerticalWritingMode() const { return writingMode() == WM_TBRL || writingMode() == WM_TB; } 367 bool isolatesBlending() const { return hasMasker() || hasFilter() || shadow(); } 367 368 368 369 protected: -
trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp
r163440 r164294 441 441 } 442 442 443 void SVGRenderSupport::styleChanged(RenderElement& renderer )443 void SVGRenderSupport::styleChanged(RenderElement& renderer, const RenderStyle* oldStyle) 444 444 { 445 445 auto parent = renderer.parent(); 446 446 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) 457 bool SVGRenderSupport::isolatesBlending(const RenderStyle& style) 458 { 459 return style.svgStyle().isolatesBlending() || style.hasBlendMode() || style.opacity() < 1.0f; 460 } 461 462 void 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 84 84 85 85 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 87 92 88 93 // FIXME: These methods do not belong here. -
trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp
r163764 r164294 104 104 float opacity = isRenderingMask ? 1 : style.opacity(); 105 105 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) { 107 117 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 111 125 m_paintInfo->context->beginTransparencyLayer(opacity); 126 127 if (hasBlendMode) 128 m_paintInfo->context->setCompositeOperation(m_paintInfo->context->compositeOperation(), BlendModeNormal); 129 112 130 m_renderingFlags |= EndOpacityLayer; 113 131 } 114 132 115 133 if (shadow) { 116 m_paintInfo->context->clip(repaintRect);117 134 m_paintInfo->context->setShadow(IntSize(roundToInt(shadow->x()), roundToInt(shadow->y())), shadow->radius(), shadow->color(), style.colorSpace()); 118 135 m_paintInfo->context->beginTransparencyLayer(1); -
trunk/Source/WebCore/svg/SVGGraphicsElement.cpp
r163440 r164294 43 43 SVGGraphicsElement::SVGGraphicsElement(const QualifiedName& tagName, Document& document) 44 44 : SVGElement(tagName, document) 45 , m_shouldIsolateBlending(false) 45 46 { 46 47 registerAnimatedPropertiesForSVGGraphicsElement(); -
trunk/Source/WebCore/svg/SVGGraphicsElement.h
r163440 r164294 47 47 virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) override; 48 48 49 bool shouldIsolateBlending() const { return m_shouldIsolateBlending; } 50 void setShouldIsolateBlending(bool isolate) { m_shouldIsolateBlending = isolate; } 51 49 52 // "base class" methods for all the elements which render as paths 50 53 virtual void toClipPath(Path&); … … 72 75 // Used by <animateMotion> 73 76 std::unique_ptr<AffineTransform> m_supplementalTransform; 77 78 // Used to isolate blend operations caused by masking. 79 bool m_shouldIsolateBlending; 74 80 }; 75 81
Note: See TracChangeset
for help on using the changeset viewer.