haikuwebkit/LayoutTests/css3/masking/mask-luminance-svg.html

33 lines
849 B
HTML
Raw Permalink Normal View History

<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. Canonical link: https://commits.webkit.org/139896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-09-25 13:53:08 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<style>
#back {
width: 1000px;
height: 600px;
background-color: green;
}
#front {
width: 800px;
height: 400px;
background-color: red;
border: 50px solid blue;
padding: 50px;
-webkit-mask-image: url(resources/circle2.svg);
-webkit-mask-source-type: luminance;
-webkit-mask-size: 200px auto;
-webkit-mask-repeat: repeat;
-webkit-mask-origin: border-box;
-webkit-mask-clip: border-box;
}
</style>
</head>
<body>
<div id="back">
<div id="front" />
</div>
</body>
</html>