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

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 658603002: 2D canvas: fix shadow rendering with compositing modes that require temp layers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comment fix Created 6 years, 2 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
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.h ('k') | Source/platform/graphics/GraphicsContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index 98b4897eeb82c05a94b3f35f635d057e2afea26b..ff3d2d920050d1dd6bc5f80d5fcbcdb67819f4dd 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -1410,7 +1410,7 @@ void CanvasRenderingContext2D::setShadow(const FloatSize& offset, float blur, RG
applyShadow();
}
-void CanvasRenderingContext2D::applyShadow()
+void CanvasRenderingContext2D::applyShadow(ShadowMode shadowMode)
{
GraphicsContext* c = drawingContext();
if (!c)
@@ -1418,7 +1418,7 @@ void CanvasRenderingContext2D::applyShadow()
if (shouldDrawShadows()) {
c->setShadow(state().m_shadowOffset, state().m_shadowBlur, state().m_shadowColor,
- DrawLooperBuilder::ShadowIgnoresTransforms);
+ DrawLooperBuilder::ShadowIgnoresTransforms, DrawLooperBuilder::ShadowRespectsAlpha, shadowMode);
} else {
c->clearShadow();
}
@@ -1648,8 +1648,24 @@ template<CanvasRenderingContext2D::DrawingType drawingType, class T> void Canvas
GraphicsContext* c = drawingContext();
ASSERT(c);
- c->beginLayer(1, state().m_globalComposite);
+
CompositeOperator previousOperator = c->compositeOperation();
+ if (shouldDrawShadows()) {
+ // unroll into two independently composited passes if drawing shadows
+ c->beginLayer(1, state().m_globalComposite);
+ c->setCompositeOperation(CompositeSourceOver);
+ applyShadow(DrawShadowOnly);
+ if (drawingType == Fill) {
+ fillPrimitive(area, c);
+ } else {
+ strokePrimitive(area, c);
+ }
+ c->setCompositeOperation(previousOperator);
+ c->endLayer();
+ }
+
+ c->beginLayer(1, state().m_globalComposite);
+ c->clearShadow();
c->setCompositeOperation(CompositeSourceOver);
if (drawingType == Fill) {
fillPrimitive(area, c);
@@ -1658,6 +1674,7 @@ template<CanvasRenderingContext2D::DrawingType drawingType, class T> void Canvas
}
c->setCompositeOperation(previousOperator);
c->endLayer();
+ applyShadow(DrawShadowAndForeground); // go back to normal shadows mode
}
PassRefPtrWillBeRawPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGradient(float x0, float y0, float x1, float y1)
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.h ('k') | Source/platform/graphics/GraphicsContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698