Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Unified Diff: Source/core/svg/graphics/SVGImage.cpp

Issue 181633002: Apply .globalAlpha to SVG-images painted using <canvas> drawImage() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/svg/graphics/SVGImage.cpp
diff --git a/Source/core/svg/graphics/SVGImage.cpp b/Source/core/svg/graphics/SVGImage.cpp
index efa8c7411982a6fedb9f5f5edb0bee63576aa03e..2514abf62f7ab967d0b4986bee537b4941902271 100644
--- a/Source/core/svg/graphics/SVGImage.cpp
+++ b/Source/core/svg/graphics/SVGImage.cpp
@@ -247,9 +247,11 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
context->clip(enclosingIntRect(dstRect));
bool compositingRequiresTransparencyLayer = compositeOp != CompositeSourceOver || blendMode != blink::WebBlendModeNormal;
- if (compositingRequiresTransparencyLayer) {
- context->beginTransparencyLayer(1);
- context->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal);
+ bool requiresTransparencyLayer = compositingRequiresTransparencyLayer || context->alpha() < 1;
+ if (requiresTransparencyLayer) {
+ context->beginTransparencyLayer(context->alpha());
+ if (compositingRequiresTransparencyLayer)
+ context->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal);
}
FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height());
@@ -270,7 +272,7 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
view->paint(context, enclosingIntRect(srcRect));
- if (compositingRequiresTransparencyLayer)
+ if (requiresTransparencyLayer)
context->endLayer();
stateSaver.restore();
« no previous file with comments | « LayoutTests/svg/canvas/canvas-draw-image-globalalpha-expected.html ('k') | Source/platform/graphics/GraphicsContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698