| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 5 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
| 10 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved. | 10 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 ASSERT(startAngle >= 0 && startAngle < twoPiFloat); | 259 ASSERT(startAngle >= 0 && startAngle < twoPiFloat); |
| 260 ASSERT((anticlockwise && (startAngle - endAngle) >= 0) || | 260 ASSERT((anticlockwise && (startAngle - endAngle) >= 0) || |
| 261 (!anticlockwise && (endAngle - startAngle) >= 0)); | 261 (!anticlockwise && (endAngle - startAngle) >= 0)); |
| 262 | 262 |
| 263 FloatPoint center(x, y); | 263 FloatPoint center(x, y); |
| 264 AffineTransform rotationMatrix; | 264 AffineTransform rotationMatrix; |
| 265 rotationMatrix.rotateRadians(rotation); | 265 rotationMatrix.rotateRadians(rotation); |
| 266 // First, if the object's path has any subpaths, then the method must add a | 266 // First, if the object's path has any subpaths, then the method must add a |
| 267 // straight line from the last point in the subpath to the start point of the | 267 // straight line from the last point in the subpath to the start point of the |
| 268 // arc. | 268 // arc. |
| 269 lineToFloatPoint(path, center + | 269 lineToFloatPoint(path, |
| 270 rotationMatrix.mapPoint(getPointOnEllipse( | 270 center + |
| 271 radiusX, radiusY, startAngle))); | 271 rotationMatrix.mapPoint( |
| 272 getPointOnEllipse(radiusX, radiusY, startAngle))); |
| 272 if ((!radiusX && !radiusY) || startAngle == endAngle) | 273 if ((!radiusX && !radiusY) || startAngle == endAngle) |
| 273 return; | 274 return; |
| 274 | 275 |
| 275 if (!anticlockwise) { | 276 if (!anticlockwise) { |
| 276 // startAngle - fmodf(startAngle, piOverTwoFloat) + piOverTwoFloat is the | 277 // startAngle - fmodf(startAngle, piOverTwoFloat) + piOverTwoFloat is the |
| 277 // one of (0, 0.5Pi, Pi, 1.5Pi, 2Pi) that is the closest to startAngle on | 278 // one of (0, 0.5Pi, Pi, 1.5Pi, 2Pi) that is the closest to startAngle on |
| 278 // the clockwise direction. | 279 // the clockwise direction. |
| 279 for (float angle = | 280 for (float angle = |
| 280 startAngle - fmodf(startAngle, piOverTwoFloat) + piOverTwoFloat; | 281 startAngle - fmodf(startAngle, piOverTwoFloat) + piOverTwoFloat; |
| 281 angle < endAngle; angle += piOverTwoFloat) | 282 angle < endAngle; angle += piOverTwoFloat) |
| 282 lineToFloatPoint(path, center + | 283 lineToFloatPoint(path, |
| 283 rotationMatrix.mapPoint(getPointOnEllipse( | 284 center + |
| 284 radiusX, radiusY, angle))); | 285 rotationMatrix.mapPoint( |
| 286 getPointOnEllipse(radiusX, radiusY, angle))); |
| 285 } else { | 287 } else { |
| 286 for (float angle = startAngle - fmodf(startAngle, piOverTwoFloat); | 288 for (float angle = startAngle - fmodf(startAngle, piOverTwoFloat); |
| 287 angle > endAngle; angle -= piOverTwoFloat) | 289 angle > endAngle; angle -= piOverTwoFloat) |
| 288 lineToFloatPoint(path, center + | 290 lineToFloatPoint(path, |
| 289 rotationMatrix.mapPoint(getPointOnEllipse( | 291 center + |
| 290 radiusX, radiusY, angle))); | 292 rotationMatrix.mapPoint( |
| 293 getPointOnEllipse(radiusX, radiusY, angle))); |
| 291 } | 294 } |
| 292 | 295 |
| 293 lineToFloatPoint(path, center + | 296 lineToFloatPoint(path, |
| 294 rotationMatrix.mapPoint(getPointOnEllipse( | 297 center + |
| 295 radiusX, radiusY, endAngle))); | 298 rotationMatrix.mapPoint( |
| 299 getPointOnEllipse(radiusX, radiusY, endAngle))); |
| 296 } | 300 } |
| 297 | 301 |
| 298 } // namespace | 302 } // namespace |
| 299 | 303 |
| 300 void CanvasPathMethods::arc(float x, | 304 void CanvasPathMethods::arc(float x, |
| 301 float y, | 305 float y, |
| 302 float radius, | 306 float radius, |
| 303 float startAngle, | 307 float startAngle, |
| 304 float endAngle, | 308 float endAngle, |
| 305 bool anticlockwise, | 309 bool anticlockwise, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 float startAngle, | 342 float startAngle, |
| 339 float endAngle, | 343 float endAngle, |
| 340 bool anticlockwise, | 344 bool anticlockwise, |
| 341 ExceptionState& exceptionState) { | 345 ExceptionState& exceptionState) { |
| 342 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radiusX) || | 346 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radiusX) || |
| 343 !std::isfinite(radiusY) || !std::isfinite(rotation) || | 347 !std::isfinite(radiusY) || !std::isfinite(rotation) || |
| 344 !std::isfinite(startAngle) || !std::isfinite(endAngle)) | 348 !std::isfinite(startAngle) || !std::isfinite(endAngle)) |
| 345 return; | 349 return; |
| 346 | 350 |
| 347 if (radiusX < 0) { | 351 if (radiusX < 0) { |
| 348 exceptionState.throwDOMException( | 352 exceptionState.throwDOMException(IndexSizeError, |
| 349 IndexSizeError, "The major-axis radius provided (" + | 353 "The major-axis radius provided (" + |
| 350 String::number(radiusX) + ") is negative."); | 354 String::number(radiusX) + |
| 355 ") is negative."); |
| 351 return; | 356 return; |
| 352 } | 357 } |
| 353 if (radiusY < 0) { | 358 if (radiusY < 0) { |
| 354 exceptionState.throwDOMException( | 359 exceptionState.throwDOMException(IndexSizeError, |
| 355 IndexSizeError, "The minor-axis radius provided (" + | 360 "The minor-axis radius provided (" + |
| 356 String::number(radiusY) + ") is negative."); | 361 String::number(radiusY) + |
| 362 ") is negative."); |
| 357 return; | 363 return; |
| 358 } | 364 } |
| 359 | 365 |
| 360 if (!isTransformInvertible()) | 366 if (!isTransformInvertible()) |
| 361 return; | 367 return; |
| 362 | 368 |
| 363 canonicalizeAngle(&startAngle, &endAngle); | 369 canonicalizeAngle(&startAngle, &endAngle); |
| 364 float adjustedEndAngle = adjustEndAngle(startAngle, endAngle, anticlockwise); | 370 float adjustedEndAngle = adjustEndAngle(startAngle, endAngle, anticlockwise); |
| 365 if (!radiusX || !radiusY || startAngle == adjustedEndAngle) { | 371 if (!radiusX || !radiusY || startAngle == adjustedEndAngle) { |
| 366 // The ellipse is empty but we still need to draw the connecting line to | 372 // The ellipse is empty but we still need to draw the connecting line to |
| (...skipping 11 matching lines...) Expand all Loading... |
| 378 if (!isTransformInvertible()) | 384 if (!isTransformInvertible()) |
| 379 return; | 385 return; |
| 380 | 386 |
| 381 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(width) || | 387 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(width) || |
| 382 !std::isfinite(height)) | 388 !std::isfinite(height)) |
| 383 return; | 389 return; |
| 384 | 390 |
| 385 m_path.addRect(FloatRect(x, y, width, height)); | 391 m_path.addRect(FloatRect(x, y, width, height)); |
| 386 } | 392 } |
| 387 } // namespace blink | 393 } // namespace blink |
| OLD | NEW |