Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp |
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
index 8c1868a912c388283ab4321f24fbcf2047db13b4..a1183e98a6f77e5a7758010769af53d315366428 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,47 @@ 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) |
+{ |
+ if (!domPath) |
+ return; |
+ this->fillImpl(domPath->path(), windingRuleString); |
+} |
+ |
+void CanvasRenderingContext2D::strokeImpl(const Path& path) |
+{ |
+ if (path.isEmpty()) { |
+ return; |
+ } |
GraphicsContext* c = drawingContext(); |
if (!c) |
return; |
@@ -938,18 +954,28 @@ 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) |
+{ |
+ if (!domPath) |
+ return; |
+ this->strokeImpl(domPath->path()); |
+} |
+ |
+void CanvasRenderingContext2D::clipImpl(const Path& path, const String& windingRuleString) |
{ |
GraphicsContext* c = drawingContext(); |
if (!c) |
@@ -962,7 +988,19 @@ 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) |
+{ |
+ if (!domPath) |
+ return; |
dshwang
2014/01/23 21:17:17
Could v8 binder fire dom exception if domPath is n
jcgregorio
2014/01/29 17:51:49
Updated IDL to match the spec, Path is no longer o
dshwang
2014/01/31 12:29:00
I mean this 'if statement' is not necessary becaus
jcgregorio
2014/01/31 18:08:49
Done.
|
+ this->clipImpl(domPath->path(), windingRuleString); |
} |
bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) |