haikuwebkit/LayoutTests/svg/canvas/canvas-global-alpha-svg-exp...

35 lines
520 B
HTML
Raw Permalink Normal View History

Drawing an SVG image into a canvas using drawImage() ignores globalAlpha. https://bugs.webkit.org/show_bug.cgi?id=141729. Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-02-23 Reviewed by Simon Fraser. Source/WebCore: When drawing an SVG image and the drawing context is set to be transparent, make sure this transparency is applied to the compositing layer. Test: svg/canvas/canvas-global-alpha-svg.html * platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::setAlpha): Make setAlpha() calls the platform function and sets 'm_state.alpha' to the input value. (WebCore::GraphicsContext::alpha): Add a new function 'alpha()' which returns the value of the global alpha. * platform/graphics/GraphicsContext.h: (WebCore::GraphicsContextState::GraphicsContextState): Add a new member 'alpha' to the context state since the getter function CGContextGetAlpha is defined only in a private header file. Also move single line functions from the source file to the header file. * platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::GraphicsContext::setPlatformAlpha): (WebCore::GraphicsContext::setAlpha): Deleted. * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::setPlatformAlpha): (WebCore::GraphicsContext::setAlpha): Deleted. Rename setAlpha() to setPlatformAlpha() in the platform files. Add setAlpha() to the core file. setAlpha() will set the value of 'm_state.alpha' and call setPlatformAlpha(). * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::draw): If the drawing context is transparent, apply its global alpha value to the compositing layer. LayoutTests: Add a new test which draws an SVG image on a canvas after setting its globalAlpha to a value less than 1. * svg/canvas/canvas-global-alpha-svg-expected.html: Added. * svg/canvas/canvas-global-alpha-svg.html: Added. Canonical link: https://commits.webkit.org/159934@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180511 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-02-23 20:31:04 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
div {
border-width: 25px;
border-style: solid;
border-color: green;
}
.main {
width: 100px;
height: 100px;
}
.sub {
width: 50px;
height: 50px;
}
.sub-sub {
width: 0px;
height: 0px;
}
.low-opacity {
opacity: 0.2;
}
</style>
</head>
<body>
<div class="main">
<div class="sub low-opacity">
<div class="sub-sub low-opacity"></div>
</div>
</div>
</body>
</html>