Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp |
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
index 40ab5a15c6532b7cf092c045d9c9dca078070a3e..5adc325321daf95dadae7a2d2e0e2dbfabc07cf9 100644 |
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
@@ -883,8 +883,11 @@ static bool parseWinding(const String& windingRuleString, WindRule& windRule) |
return true; |
} |
-void CanvasRenderingContext2D::fill(const String& windingRuleString) |
+void CanvasRenderingContext2D::fillImpl(const Path& path, const String& windingRuleString) |
{ |
+ if (path.isEmpty()) { |
+ return; |
+ } |
GraphicsContext* c = drawingContext(); |
if (!c) |
return; |
@@ -899,34 +902,45 @@ void CanvasRenderingContext2D::fill(const String& windingRuleString) |
if (gradient && gradient->isZeroSize()) |
return; |
- if (!m_path.isEmpty()) { |
- WindRule windRule = c->fillRule(); |
- WindRule newWindRule = RULE_NONZERO; |
- if (!parseWinding(windingRuleString, newWindRule)) |
- return; |
- c->setFillRule(newWindRule); |
- |
- if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
- fullCanvasCompositedFill(m_path); |
- didDraw(clipBounds); |
- } else if (state().m_globalComposite == CompositeCopy) { |
- clearCanvas(); |
- c->fillPath(m_path); |
- didDraw(clipBounds); |
- } else { |
- FloatRect dirtyRect; |
- if (computeDirtyRect(m_path.boundingRect(), clipBounds, &dirtyRect)) { |
- c->fillPath(m_path); |
- didDraw(dirtyRect); |
- } |
- } |
+ WindRule windRule = c->fillRule(); |
+ WindRule newWindRule = RULE_NONZERO; |
+ if (!parseWinding(windingRuleString, newWindRule)) |
+ return; |
+ c->setFillRule(newWindRule); |
- c->setFillRule(windRule); |
+ if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
+ fullCanvasCompositedFill(path); |
+ didDraw(clipBounds); |
+ } else if (state().m_globalComposite == CompositeCopy) { |
+ clearCanvas(); |
+ c->fillPath(path); |
+ didDraw(clipBounds); |
+ } else { |
+ FloatRect dirtyRect; |
+ if (computeDirtyRect(path.boundingRect(), clipBounds, &dirtyRect)) { |
+ c->fillPath(path); |
+ didDraw(dirtyRect); |
+ } |
} |
+ |
+ c->setFillRule(windRule); |
} |
-void CanvasRenderingContext2D::stroke() |
+void CanvasRenderingContext2D::fill(const String& windingRuleString) |
+{ |
+ this->fillImpl(m_path, windingRuleString); |
+} |
+ |
+void CanvasRenderingContext2D::fill(DOMPath* domPath, const String& windingRuleString) |
+{ |
+ this->fillImpl(domPath->path(), windingRuleString); |
+} |
+ |
+void CanvasRenderingContext2D::strokeImpl(const Path& path) |
{ |
+ if (path.isEmpty()) { |
+ return; |
+ } |
GraphicsContext* c = drawingContext(); |
if (!c) |
return; |
@@ -938,18 +952,26 @@ void CanvasRenderingContext2D::stroke() |
if (gradient && gradient->isZeroSize()) |
return; |
- if (!m_path.isEmpty()) { |
- FloatRect bounds = m_path.boundingRect(); |
- inflateStrokeRect(bounds); |
- FloatRect dirtyRect; |
- if (computeDirtyRect(bounds, &dirtyRect)) { |
- c->strokePath(m_path); |
- didDraw(dirtyRect); |
- } |
+ FloatRect bounds = path.boundingRect(); |
+ inflateStrokeRect(bounds); |
+ FloatRect dirtyRect; |
+ if (computeDirtyRect(bounds, &dirtyRect)) { |
+ c->strokePath(path); |
+ didDraw(dirtyRect); |
} |
} |
-void CanvasRenderingContext2D::clip(const String& windingRuleString) |
+void CanvasRenderingContext2D::stroke() |
+{ |
+ this->strokeImpl(m_path); |
+} |
+ |
+void CanvasRenderingContext2D::stroke(DOMPath* domPath) |
+{ |
+ this->strokeImpl(domPath->path()); |
+} |
+ |
+void CanvasRenderingContext2D::clipImpl(const Path& path, const String& windingRuleString) |
{ |
GraphicsContext* c = drawingContext(); |
if (!c) |
@@ -962,7 +984,17 @@ void CanvasRenderingContext2D::clip(const String& windingRuleString) |
return; |
realizeSaves(); |
- c->canvasClip(m_path, newWindRule); |
+ c->canvasClip(path, newWindRule); |
+} |
+ |
+void CanvasRenderingContext2D::clip(const String& windingRuleString) |
+{ |
+ this->clipImpl(m_path, windingRuleString); |
+} |
+ |
+void CanvasRenderingContext2D::clip(DOMPath* domPath, const String& windingRuleString) |
+{ |
+ this->clipImpl(domPath->path(), windingRuleString); |
} |
bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) |