OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
10 * | 10 * |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 } | 957 } |
958 | 958 |
959 static bool isFullCanvasCompositeMode(CompositeOperator op) | 959 static bool isFullCanvasCompositeMode(CompositeOperator op) |
960 { | 960 { |
961 // See 4.8.11.1.3 Compositing | 961 // See 4.8.11.1.3 Compositing |
962 // CompositeSourceAtop and CompositeDestinationOut are not listed here as th
e platforms already | 962 // CompositeSourceAtop and CompositeDestinationOut are not listed here as th
e platforms already |
963 // implement the specification's behavior. | 963 // implement the specification's behavior. |
964 return op == CompositeSourceIn || op == CompositeSourceOut || op == Composit
eDestinationIn || op == CompositeDestinationAtop; | 964 return op == CompositeSourceIn || op == CompositeSourceOut || op == Composit
eDestinationIn || op == CompositeDestinationAtop; |
965 } | 965 } |
966 | 966 |
967 static bool parseWinding(const String& windingRuleString, WindRule& windRule) | 967 static WindRule parseWinding(const String& windingRuleString) |
968 { | 968 { |
969 if (windingRuleString == "nonzero") | 969 if (windingRuleString == "nonzero") |
970 windRule = RULE_NONZERO; | 970 return RULE_NONZERO; |
971 else if (windingRuleString == "evenodd") | 971 if (windingRuleString == "evenodd") |
972 windRule = RULE_EVENODD; | 972 return RULE_EVENODD; |
973 else | |
974 return false; | |
975 | 973 |
976 return true; | 974 ASSERT_NOT_REACHED(); |
| 975 return RULE_EVENODD; |
977 } | 976 } |
978 | 977 |
979 void CanvasRenderingContext2D::fillInternal(const Path& path, const String& wind
ingRuleString) | 978 void CanvasRenderingContext2D::fillInternal(const Path& path, const String& wind
ingRuleString) |
980 { | 979 { |
981 if (path.isEmpty()) { | 980 if (path.isEmpty()) { |
982 return; | 981 return; |
983 } | 982 } |
984 GraphicsContext* c = drawingContext(); | 983 GraphicsContext* c = drawingContext(); |
985 if (!c) { | 984 if (!c) { |
986 return; | 985 return; |
987 } | 986 } |
988 if (!state().m_invertibleCTM) { | 987 if (!state().m_invertibleCTM) { |
989 return; | 988 return; |
990 } | 989 } |
991 FloatRect clipBounds; | 990 FloatRect clipBounds; |
992 if (!drawingContext()->getTransformedClipBounds(&clipBounds)) { | 991 if (!drawingContext()->getTransformedClipBounds(&clipBounds)) { |
993 return; | 992 return; |
994 } | 993 } |
995 | 994 |
996 // If gradient size is zero, then paint nothing. | 995 // If gradient size is zero, then paint nothing. |
997 Gradient* gradient = c->fillGradient(); | 996 Gradient* gradient = c->fillGradient(); |
998 if (gradient && gradient->isZeroSize()) { | 997 if (gradient && gradient->isZeroSize()) { |
999 return; | 998 return; |
1000 } | 999 } |
1001 | 1000 |
1002 WindRule windRule = c->fillRule(); | 1001 WindRule windRule = c->fillRule(); |
1003 WindRule newWindRule = RULE_NONZERO; | 1002 c->setFillRule(parseWinding(windingRuleString)); |
1004 if (!parseWinding(windingRuleString, newWindRule)) { | |
1005 return; | |
1006 } | |
1007 c->setFillRule(newWindRule); | |
1008 | 1003 |
1009 if (isFullCanvasCompositeMode(state().m_globalComposite)) { | 1004 if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
1010 fullCanvasCompositedFill(path); | 1005 fullCanvasCompositedFill(path); |
1011 didDraw(clipBounds); | 1006 didDraw(clipBounds); |
1012 } else if (state().m_globalComposite == CompositeCopy) { | 1007 } else if (state().m_globalComposite == CompositeCopy) { |
1013 clearCanvas(); | 1008 clearCanvas(); |
1014 c->fillPath(path); | 1009 c->fillPath(path); |
1015 didDraw(clipBounds); | 1010 didDraw(clipBounds); |
1016 } else { | 1011 } else { |
1017 FloatRect dirtyRect; | 1012 FloatRect dirtyRect; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 void CanvasRenderingContext2D::clipInternal(const Path& path, const String& wind
ingRuleString) | 1085 void CanvasRenderingContext2D::clipInternal(const Path& path, const String& wind
ingRuleString) |
1091 { | 1086 { |
1092 GraphicsContext* c = drawingContext(); | 1087 GraphicsContext* c = drawingContext(); |
1093 if (!c) { | 1088 if (!c) { |
1094 return; | 1089 return; |
1095 } | 1090 } |
1096 if (!state().m_invertibleCTM) { | 1091 if (!state().m_invertibleCTM) { |
1097 return; | 1092 return; |
1098 } | 1093 } |
1099 | 1094 |
1100 WindRule newWindRule = RULE_NONZERO; | |
1101 if (!parseWinding(windingRuleString, newWindRule)) { | |
1102 return; | |
1103 } | |
1104 | |
1105 realizeSaves(); | 1095 realizeSaves(); |
1106 c->canvasClip(path, newWindRule); | 1096 c->canvasClip(path, parseWinding(windingRuleString)); |
1107 } | 1097 } |
1108 | 1098 |
1109 void CanvasRenderingContext2D::clip(const String& windingRuleString) | 1099 void CanvasRenderingContext2D::clip(const String& windingRuleString) |
1110 { | 1100 { |
1111 clipInternal(m_path, windingRuleString); | 1101 clipInternal(m_path, windingRuleString); |
1112 } | 1102 } |
1113 | 1103 |
1114 void CanvasRenderingContext2D::clip(Path2D* domPath, ExceptionState& exceptionSt
ate) | 1104 void CanvasRenderingContext2D::clip(Path2D* domPath, ExceptionState& exceptionSt
ate) |
1115 { | 1105 { |
1116 clip(domPath, "nonzero", exceptionState); | 1106 clip(domPath, "nonzero", exceptionState); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 return false; | 1143 return false; |
1154 if (!state().m_invertibleCTM) | 1144 if (!state().m_invertibleCTM) |
1155 return false; | 1145 return false; |
1156 | 1146 |
1157 FloatPoint point(x, y); | 1147 FloatPoint point(x, y); |
1158 AffineTransform ctm = state().m_transform; | 1148 AffineTransform ctm = state().m_transform; |
1159 FloatPoint transformedPoint = ctm.inverse().mapPoint(point); | 1149 FloatPoint transformedPoint = ctm.inverse().mapPoint(point); |
1160 if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.
y())) | 1150 if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.
y())) |
1161 return false; | 1151 return false; |
1162 | 1152 |
1163 WindRule windRule = RULE_NONZERO; | 1153 return path.contains(transformedPoint, parseWinding(windingRuleString)); |
1164 if (!parseWinding(windingRuleString, windRule)) | |
1165 return false; | |
1166 | |
1167 return path.contains(transformedPoint, windRule); | |
1168 } | 1154 } |
1169 | 1155 |
1170 bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y) | 1156 bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y) |
1171 { | 1157 { |
1172 return isPointInStrokeInternal(m_path, x, y); | 1158 return isPointInStrokeInternal(m_path, x, y); |
1173 } | 1159 } |
1174 | 1160 |
1175 bool CanvasRenderingContext2D::isPointInStroke(Path2D* domPath, const float x, c
onst float y, ExceptionState& exceptionState) | 1161 bool CanvasRenderingContext2D::isPointInStroke(Path2D* domPath, const float x, c
onst float y, ExceptionState& exceptionState) |
1176 { | 1162 { |
1177 if (!domPath) { | 1163 if (!domPath) { |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2434 c->setAlphaAsFloat(1.0); | 2420 c->setAlphaAsFloat(1.0); |
2435 c->clearShadow(); | 2421 c->clearShadow(); |
2436 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); | 2422 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); |
2437 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2423 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
2438 c->restore(); | 2424 c->restore(); |
2439 | 2425 |
2440 didDraw(dirtyRect); | 2426 didDraw(dirtyRect); |
2441 } | 2427 } |
2442 | 2428 |
2443 } // namespace WebCore | 2429 } // namespace WebCore |
OLD | NEW |