<https://webkit.org/b/120476> [CSS Masking] Implement luminance masking
Source/WebCore:
Added implementation for luminance masking. A luminance mask is applied by transforming its RGB values into
an alpha value, using luminance-to-alpha coefficients. Because this conversion is already implemented in
the ImageBuffer class, we used it in our implementation.
Patch by Andrei Parvu <parvu@adobe.com> on 2013-09-25
Reviewed by Dirk Schulze.
Tests: css3/masking/mask-luminance-gradient.html
css3/masking/mask-luminance-png.html
css3/masking/mask-luminance-svg.html
* platform/graphics/BitmapImage.cpp: Add a drawPattern method, in which an ImageBuffer is created and converted from alpha to luminance, if there is a luminance mask.
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::drawPattern):
* platform/graphics/BitmapImage.h:
* platform/graphics/GeneratorGeneratedImage.cpp: Convert the ImageBuffer to luminance, if necessary.
(WebCore::GeneratorGeneratedImage::drawPattern):
* platform/graphics/GraphicsContext.cpp: Add methods which set and check if a luminance mask is drawn.
(WebCore::GraphicsContext::setDrawLuminanceMask):
(WebCore::GraphicsContext::drawLuminanceMask):
* platform/graphics/GraphicsContext.h: Add property to ContextState for luminance drawing.
(WebCore::GraphicsContextState::GraphicsContextState):
* rendering/RenderBoxModelObject.cpp: Set the luminance property of the mask, if the layer has a mask source type of luminance.
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* svg/graphics/SVGImage.cpp: Convert the ImageBuffer to luminance, if necessary.
(WebCore::SVGImage::drawPatternForContainer):
* svg/graphics/SVGImageForContainer.cpp: Pass the luminance property to the SVG image.
(WebCore::SVGImageForContainer::drawPattern):
LayoutTests:
Added tests to verify the implementation of luminance masking.
Patch by Andrei Parvu <parvu@adobe.com> on 2013-09-25
Reviewed by Dirk Schulze.
* css3/masking/mask-luminance-gradient-expected.html: Added.
* css3/masking/mask-luminance-gradient.html: Added.
* css3/masking/mask-luminance-png.html: Added.
* css3/masking/mask-luminance-svg-expected.html: Added.
* css3/masking/mask-luminance-svg.html: Added.
* css3/masking/resources/circle-alpha.svg: Added.
* css3/masking/resources/circle2.svg: Added.
* css3/masking/resources/dice.png: Added.
* platform/mac/css3/masking/mask-luminance-png-expected.txt: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed