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

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

Issue 226733004: Simplify CRC2D winding rule handling (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update virtual/gpu/ expectations. Created 6 years, 8 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 | « LayoutTests/virtual/gpu/fast/canvas/canvas-path-context-fill-expected.txt ('k') | no next file » | 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 a0807a878501ba7dbf78ad80b7d9f2cee8a31d97..e2560e240a889f28c45aabb5666f891cb3a53b61 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -964,16 +964,15 @@ static bool isFullCanvasCompositeMode(CompositeOperator op)
return op == CompositeSourceIn || op == CompositeSourceOut || op == CompositeDestinationIn || op == CompositeDestinationAtop;
}
-static bool parseWinding(const String& windingRuleString, WindRule& windRule)
+static WindRule parseWinding(const String& windingRuleString)
{
if (windingRuleString == "nonzero")
- windRule = RULE_NONZERO;
- else if (windingRuleString == "evenodd")
- windRule = RULE_EVENODD;
- else
- return false;
+ return RULE_NONZERO;
+ if (windingRuleString == "evenodd")
+ return RULE_EVENODD;
- return true;
+ ASSERT_NOT_REACHED();
+ return RULE_EVENODD;
}
void CanvasRenderingContext2D::fillInternal(const Path& path, const String& windingRuleString)
@@ -1000,11 +999,7 @@ void CanvasRenderingContext2D::fillInternal(const Path& path, const String& wind
}
WindRule windRule = c->fillRule();
- WindRule newWindRule = RULE_NONZERO;
- if (!parseWinding(windingRuleString, newWindRule)) {
- return;
- }
- c->setFillRule(newWindRule);
+ c->setFillRule(parseWinding(windingRuleString));
if (isFullCanvasCompositeMode(state().m_globalComposite)) {
fullCanvasCompositedFill(path);
@@ -1097,13 +1092,8 @@ void CanvasRenderingContext2D::clipInternal(const Path& path, const String& wind
return;
}
- WindRule newWindRule = RULE_NONZERO;
- if (!parseWinding(windingRuleString, newWindRule)) {
- return;
- }
-
realizeSaves();
- c->canvasClip(path, newWindRule);
+ c->canvasClip(path, parseWinding(windingRuleString));
}
void CanvasRenderingContext2D::clip(const String& windingRuleString)
@@ -1160,11 +1150,7 @@ bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const flo
if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.y()))
return false;
- WindRule windRule = RULE_NONZERO;
- if (!parseWinding(windingRuleString, windRule))
- return false;
-
- return path.contains(transformedPoint, windRule);
+ return path.contains(transformedPoint, parseWinding(windingRuleString));
}
bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y)
« no previous file with comments | « LayoutTests/virtual/gpu/fast/canvas/canvas-path-context-fill-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698