Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp |
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
index 2cd9089ad9828e9810c7662a74b118c34507b769..456dbdffaab8a264629d0e8bb9afd24102cca2bb 100644 |
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
@@ -870,8 +870,11 @@ static bool parseWinding(const String& windingRuleString, WindRule& windRule) |
return true; |
} |
-void CanvasRenderingContext2D::fill(const String& windingRuleString) |
+void CanvasRenderingContext2D::fillInternal(const Path& path, const String& windingRuleString) |
{ |
+ if (path.isEmpty()) { |
+ return; |
+ } |
GraphicsContext* c = drawingContext(); |
if (!c) |
return; |
@@ -886,34 +889,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->fillInternal(m_path, windingRuleString); |
eseidel
2014/02/20 18:59:52
Why is this-> needed?
jcgregorio
2014/02/20 19:28:30
It's not, fixed. (I'm confusing blink style with s
|
+} |
+ |
+void CanvasRenderingContext2D::fill(DOMPath* domPath, const String& windingRuleString) |
+{ |
+ this->fillInternal(domPath->path(), windingRuleString); |
+} |
+ |
+void CanvasRenderingContext2D::strokeInternal(const Path& path) |
{ |
+ if (path.isEmpty()) { |
+ return; |
eseidel
2014/02/20 18:59:52
This CL inconsistently uses { } around oneline ifs
jcgregorio
2014/02/20 19:28:30
Fixed all the functions I touched in this CL to us
|
+ } |
GraphicsContext* c = drawingContext(); |
if (!c) |
return; |
@@ -925,18 +939,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->strokeInternal(m_path); |
+} |
+ |
+void CanvasRenderingContext2D::stroke(DOMPath* domPath) |
+{ |
+ this->strokeInternal(domPath->path()); |
+} |
+ |
+void CanvasRenderingContext2D::clipInternal(const Path& path, const String& windingRuleString) |
{ |
GraphicsContext* c = drawingContext(); |
if (!c) |
@@ -949,7 +971,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->clipInternal(m_path, windingRuleString); |
+} |
+ |
+void CanvasRenderingContext2D::clip(DOMPath* domPath, const String& windingRuleString) |
+{ |
+ this->clipInternal(domPath->path(), windingRuleString); |
} |
bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) |