Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp |
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
index 84a4294e2697b7ceb24dd1a81faf75eaa08f334c..3028a8cf6ee482b83d11999d571fbd27f5d9f24f 100644 |
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
@@ -1014,7 +1014,7 @@ void CanvasRenderingContext2D::fillInternal(const Path& path, const String& wind |
c->setFillRule(newWindRule); |
if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
- fullCanvasCompositedFill(path); |
+ fullCanvasComposite(path, &GraphicsContext::fillPath); |
didDraw(clipBounds); |
} else if (state().m_globalComposite == CompositeCopy) { |
clearCanvas(); |
@@ -1063,6 +1063,9 @@ void CanvasRenderingContext2D::strokeInternal(const Path& path) |
if (!state().m_invertibleCTM) { |
return; |
} |
+ FloatRect clipBounds; |
+ if (!c->getTransformedClipBounds(&clipBounds)) |
+ return; |
// If gradient size is zero, then paint nothing. |
Gradient* gradient = c->strokeGradient(); |
@@ -1070,12 +1073,21 @@ void CanvasRenderingContext2D::strokeInternal(const Path& path) |
return; |
} |
- FloatRect bounds = path.boundingRect(); |
- inflateStrokeRect(bounds); |
- FloatRect dirtyRect; |
- if (computeDirtyRect(bounds, &dirtyRect)) { |
+ if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
+ fullCanvasComposite(path, &GraphicsContext::strokePath); |
+ didDraw(clipBounds); |
+ } else if (state().m_globalComposite == CompositeCopy) { |
+ clearCanvas(); |
c->strokePath(path); |
- didDraw(dirtyRect); |
+ didDraw(clipBounds); |
+ } else { |
+ FloatRect bounds = path.boundingRect(); |
+ inflateStrokeRect(bounds); |
+ FloatRect dirtyRect; |
+ if (computeDirtyRect(path.boundingRect(), &dirtyRect)) { |
+ c->strokePath(path); |
+ didDraw(dirtyRect); |
+ } |
} |
} |
@@ -1324,7 +1336,7 @@ void CanvasRenderingContext2D::fillRect(float x, float y, float width, float hei |
c->fillRect(rect); |
didDraw(clipBounds); |
} else if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
- fullCanvasCompositedFill(rect); |
+ fullCanvasComposite(rect, &GraphicsContext::fillRect); |
didDraw(clipBounds); |
} else if (state().m_globalComposite == CompositeCopy) { |
clearCanvas(); |
@@ -1352,6 +1364,9 @@ void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float h |
return; |
if (!state().m_invertibleCTM) |
return; |
+ FloatRect clipBounds; |
+ if (!c->getTransformedClipBounds(&clipBounds)) |
+ return; |
// If gradient size is zero, then paint nothing. |
Gradient* gradient = c->strokeGradient(); |
@@ -1360,12 +1375,20 @@ void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float h |
FloatRect rect(x, y, width, height); |
- FloatRect boundingRect = rect; |
- boundingRect.inflate(state().m_lineWidth / 2); |
- FloatRect dirtyRect; |
- if (computeDirtyRect(boundingRect, &dirtyRect)) { |
- c->strokeRect(rect, state().m_lineWidth); |
- didDraw(dirtyRect); |
+ if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
+ fullCanvasComposite(rect, &GraphicsContext::strokeRect); |
+ didDraw(clipBounds); |
+ } else if (state().m_globalComposite == CompositeCopy) { |
+ clearCanvas(); |
+ c->strokeRect(rect); |
+ didDraw(clipBounds); |
+ } else { |
+ FloatRect boundingRect = rect; |
+ FloatRect dirtyRect; |
+ if (computeDirtyRect(boundingRect, &dirtyRect)) { |
+ c->strokeRect(rect); |
+ didDraw(dirtyRect); |
+ } |
} |
} |
@@ -1654,17 +1677,7 @@ template<class T> void CanvasRenderingContext2D::fullCanvasCompositedDrawImage( |
drawingContext()->endLayer(); |
} |
-static void fillPrimitive(const FloatRect& rect, GraphicsContext* context) |
-{ |
- context->fillRect(rect); |
-} |
- |
-static void fillPrimitive(const Path& path, GraphicsContext* context) |
-{ |
- context->fillPath(path); |
-} |
- |
-template<class T> void CanvasRenderingContext2D::fullCanvasCompositedFill(const T& area) |
+template<class T> void CanvasRenderingContext2D::fullCanvasComposite(const T& area, void (GraphicsContext::*drawOperation)(const T&)) |
Justin Novosad
2014/04/07 18:03:14
drawOperation is an unnecessary indirection. A si
|
{ |
ASSERT(isFullCanvasCompositeMode(state().m_globalComposite)); |
@@ -1673,7 +1686,7 @@ template<class T> void CanvasRenderingContext2D::fullCanvasCompositedFill(const |
c->beginLayer(1, state().m_globalComposite); |
CompositeOperator previousOperator = c->compositeOperation(); |
c->setCompositeOperation(CompositeSourceOver); |
- fillPrimitive(area, c); |
+ (c->*drawOperation)(area); |
c->setCompositeOperation(previousOperator); |
c->endLayer(); |
} |