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

Side by Side Diff: sky/engine/core/html/canvas/CanvasPathMethods.cpp

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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) 2012, 2013 Adobe Systems Incorporated. All rights reserved. 9 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved.
10 * 10 *
(...skipping 17 matching lines...) Expand all
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
31 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35 #include "sky/engine/config.h" 35 #include "sky/engine/config.h"
36 #include "sky/engine/core/html/canvas/CanvasPathMethods.h" 36 #include "sky/engine/core/html/canvas/CanvasPathMethods.h"
37 37
38 #include "sky/engine/bindings/core/v8/ExceptionState.h" 38 #include "sky/engine/bindings2/exception_state.h"
39 #include "sky/engine/core/dom/ExceptionCode.h" 39 #include "sky/engine/core/dom/ExceptionCode.h"
40 #include "sky/engine/platform/geometry/FloatRect.h" 40 #include "sky/engine/platform/geometry/FloatRect.h"
41 #include "sky/engine/platform/transforms/AffineTransform.h" 41 #include "sky/engine/platform/transforms/AffineTransform.h"
42 #include "sky/engine/wtf/MathExtras.h" 42 #include "sky/engine/wtf/MathExtras.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 void CanvasPathMethods::closePath() 46 void CanvasPathMethods::closePath()
47 { 47 {
48 if (m_path.isEmpty()) 48 if (m_path.isEmpty())
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (p1 != m_path.currentPoint() || p1 != cp1 || p1 != cp2) 106 if (p1 != m_path.currentPoint() || p1 != cp1 || p1 != cp2)
107 m_path.addBezierCurveTo(cp1, cp2, p1); 107 m_path.addBezierCurveTo(cp1, cp2, p1);
108 } 108 }
109 109
110 void CanvasPathMethods::arcTo(float x1, float y1, float x2, float y2, float r, E xceptionState& exceptionState) 110 void CanvasPathMethods::arcTo(float x1, float y1, float x2, float y2, float r, E xceptionState& exceptionState)
111 { 111 {
112 if (!std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(x2) || !std:: isfinite(y2) || !std::isfinite(r)) 112 if (!std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(x2) || !std:: isfinite(y2) || !std::isfinite(r))
113 return; 113 return;
114 114
115 if (r < 0) { 115 if (r < 0) {
116 exceptionState.throwDOMException(IndexSizeError, "The radius provided (" + String::number(r) + ") is negative."); 116 exceptionState.ThrowDOMException(IndexSizeError, "The radius provided (" + String::number(r) + ") is negative.");
117 return; 117 return;
118 } 118 }
119 119
120 if (!isTransformInvertible()) 120 if (!isTransformInvertible())
121 return; 121 return;
122 122
123 FloatPoint p1 = FloatPoint(x1, y1); 123 FloatPoint p1 = FloatPoint(x1, y1);
124 FloatPoint p2 = FloatPoint(x2, y2); 124 FloatPoint p2 = FloatPoint(x2, y2);
125 125
126 if (!m_path.hasCurrentPoint()) 126 if (!m_path.hasCurrentPoint())
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 250 }
251 251
252 } // namespace 252 } // namespace
253 253
254 void CanvasPathMethods::arc(float x, float y, float radius, float startAngle, fl oat endAngle, bool anticlockwise, ExceptionState& exceptionState) 254 void CanvasPathMethods::arc(float x, float y, float radius, float startAngle, fl oat endAngle, bool anticlockwise, ExceptionState& exceptionState)
255 { 255 {
256 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radius) || !std ::isfinite(startAngle) || !std::isfinite(endAngle)) 256 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radius) || !std ::isfinite(startAngle) || !std::isfinite(endAngle))
257 return; 257 return;
258 258
259 if (radius < 0) { 259 if (radius < 0) {
260 exceptionState.throwDOMException(IndexSizeError, "The radius provided (" + String::number(radius) + ") is negative."); 260 exceptionState.ThrowDOMException(IndexSizeError, "The radius provided (" + String::number(radius) + ") is negative.");
261 return; 261 return;
262 } 262 }
263 263
264 if (!isTransformInvertible()) 264 if (!isTransformInvertible())
265 return; 265 return;
266 266
267 if (!radius || startAngle == endAngle) { 267 if (!radius || startAngle == endAngle) {
268 // The arc is empty but we still need to draw the connecting line. 268 // The arc is empty but we still need to draw the connecting line.
269 lineTo(x + radius * cosf(startAngle), y + radius * sinf(startAngle)); 269 lineTo(x + radius * cosf(startAngle), y + radius * sinf(startAngle));
270 return; 270 return;
271 } 271 }
272 272
273 canonicalizeAngle(&startAngle, &endAngle); 273 canonicalizeAngle(&startAngle, &endAngle);
274 float adjustedEndAngle = adjustEndAngle(startAngle, endAngle, anticlockwise) ; 274 float adjustedEndAngle = adjustEndAngle(startAngle, endAngle, anticlockwise) ;
275 m_path.addArc(FloatPoint(x, y), radius, startAngle, adjustedEndAngle, anticl ockwise); 275 m_path.addArc(FloatPoint(x, y), radius, startAngle, adjustedEndAngle, anticl ockwise);
276 } 276 }
277 277
278 void CanvasPathMethods::ellipse(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise, ExceptionS tate& exceptionState) 278 void CanvasPathMethods::ellipse(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise, ExceptionS tate& exceptionState)
279 { 279 {
280 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radiusX) || !st d::isfinite(radiusY) || !std::isfinite(rotation) || !std::isfinite(startAngle) | | !std::isfinite(endAngle)) 280 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radiusX) || !st d::isfinite(radiusY) || !std::isfinite(rotation) || !std::isfinite(startAngle) | | !std::isfinite(endAngle))
281 return; 281 return;
282 282
283 if (radiusX < 0) { 283 if (radiusX < 0) {
284 exceptionState.throwDOMException(IndexSizeError, "The major-axis radius provided (" + String::number(radiusX) + ") is negative."); 284 exceptionState.ThrowDOMException(IndexSizeError, "The major-axis radius provided (" + String::number(radiusX) + ") is negative.");
285 return; 285 return;
286 } 286 }
287 if (radiusY < 0) { 287 if (radiusY < 0) {
288 exceptionState.throwDOMException(IndexSizeError, "The minor-axis radius provided (" + String::number(radiusY) + ") is negative."); 288 exceptionState.ThrowDOMException(IndexSizeError, "The minor-axis radius provided (" + String::number(radiusY) + ") is negative.");
289 return; 289 return;
290 } 290 }
291 291
292 if (!isTransformInvertible()) 292 if (!isTransformInvertible())
293 return; 293 return;
294 294
295 canonicalizeAngle(&startAngle, &endAngle); 295 canonicalizeAngle(&startAngle, &endAngle);
296 float adjustedEndAngle = adjustEndAngle(startAngle, endAngle, anticlockwise) ; 296 float adjustedEndAngle = adjustEndAngle(startAngle, endAngle, anticlockwise) ;
297 if (!radiusX || !radiusY || startAngle == adjustedEndAngle) { 297 if (!radiusX || !radiusY || startAngle == adjustedEndAngle) {
298 // The ellipse is empty but we still need to draw the connecting line to start point. 298 // The ellipse is empty but we still need to draw the connecting line to start point.
(...skipping 13 matching lines...) Expand all
312 return; 312 return;
313 313
314 if (!width && !height) { 314 if (!width && !height) {
315 m_path.moveTo(FloatPoint(x, y)); 315 m_path.moveTo(FloatPoint(x, y));
316 return; 316 return;
317 } 317 }
318 318
319 m_path.addRect(FloatRect(x, y, width, height)); 319 m_path.addRect(FloatRect(x, y, width, height));
320 } 320 }
321 } 321 }
OLDNEW
« no previous file with comments | « sky/engine/core/html/canvas/CanvasGradient.cpp ('k') | sky/engine/core/html/canvas/CanvasPattern.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698