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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Path.cpp

Issue 2807923002: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/graphics (Closed)
Patch Set: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/graphics Created 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
3 * 2006 Rob Buis <buis@kde.org> 3 * 2006 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2013 Google Inc. All rights reserved. 5 * Copyright (C) 2013 Google Inc. All rights reserved.
6 * Copyright (C) 2013 Intel Corporation. All rights reserved. 6 * Copyright (C) 2013 Intel Corporation. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 void Path::closeSubpath() { 357 void Path::closeSubpath() {
358 m_path.close(); 358 m_path.close();
359 } 359 }
360 360
361 void Path::addEllipse(const FloatPoint& p, 361 void Path::addEllipse(const FloatPoint& p,
362 float radiusX, 362 float radiusX,
363 float radiusY, 363 float radiusY,
364 float startAngle, 364 float startAngle,
365 float endAngle, 365 float endAngle,
366 bool anticlockwise) { 366 bool anticlockwise) {
367 ASSERT(ellipseIsRenderable(startAngle, endAngle)); 367 #if DCHECK_IS_ON()
368 ASSERT(startAngle >= 0 && startAngle < twoPiFloat); 368 DCHECK(ellipseIsRenderable(startAngle, endAngle));
369 ASSERT((anticlockwise && (startAngle - endAngle) >= 0) || 369 #endif
370 DCHECK(startAngle >= 0 && startAngle < twoPiFloat);
tkent 2017/04/09 23:17:27 Split this into two DCHECKs.
Hwanseung Lee 2017/04/11 22:24:10 Done.
371 DCHECK((anticlockwise && (startAngle - endAngle) >= 0) ||
370 (!anticlockwise && (endAngle - startAngle) >= 0)); 372 (!anticlockwise && (endAngle - startAngle) >= 0));
371 373
372 SkScalar cx = WebCoreFloatToSkScalar(p.x()); 374 SkScalar cx = WebCoreFloatToSkScalar(p.x());
373 SkScalar cy = WebCoreFloatToSkScalar(p.y()); 375 SkScalar cy = WebCoreFloatToSkScalar(p.y());
374 SkScalar radiusXScalar = WebCoreFloatToSkScalar(radiusX); 376 SkScalar radiusXScalar = WebCoreFloatToSkScalar(radiusX);
375 SkScalar radiusYScalar = WebCoreFloatToSkScalar(radiusY); 377 SkScalar radiusYScalar = WebCoreFloatToSkScalar(radiusY);
376 378
377 SkRect oval; 379 SkRect oval;
378 oval.set(cx - radiusXScalar, cy - radiusYScalar, cx + radiusXScalar, 380 oval.set(cx - radiusXScalar, cy - radiusYScalar, cx + radiusXScalar,
379 cy + radiusYScalar); 381 cy + radiusYScalar);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 m_path.addRect(rect, SkPath::kCW_Direction, 0); 420 m_path.addRect(rect, SkPath::kCW_Direction, 0);
419 } 421 }
420 422
421 void Path::addEllipse(const FloatPoint& p, 423 void Path::addEllipse(const FloatPoint& p,
422 float radiusX, 424 float radiusX,
423 float radiusY, 425 float radiusY,
424 float rotation, 426 float rotation,
425 float startAngle, 427 float startAngle,
426 float endAngle, 428 float endAngle,
427 bool anticlockwise) { 429 bool anticlockwise) {
428 ASSERT(ellipseIsRenderable(startAngle, endAngle)); 430 #if DCHECK_IS_ON()
429 ASSERT(startAngle >= 0 && startAngle < twoPiFloat); 431 DCHECK(ellipseIsRenderable(startAngle, endAngle));
430 ASSERT((anticlockwise && (startAngle - endAngle) >= 0) || 432 #endif
433 DCHECK(startAngle >= 0 && startAngle < twoPiFloat);
tkent 2017/04/09 23:17:27 Split this into two DCHECKs.
Hwanseung Lee 2017/04/11 22:24:10 Done.
434 DCHECK((anticlockwise && (startAngle - endAngle) >= 0) ||
431 (!anticlockwise && (endAngle - startAngle) >= 0)); 435 (!anticlockwise && (endAngle - startAngle) >= 0));
432 436
433 if (!rotation) { 437 if (!rotation) {
434 addEllipse(FloatPoint(p.x(), p.y()), radiusX, radiusY, startAngle, endAngle, 438 addEllipse(FloatPoint(p.x(), p.y()), radiusX, radiusY, startAngle, endAngle,
435 anticlockwise); 439 anticlockwise);
436 return; 440 return;
437 } 441 }
438 442
439 // Add an arc after the relevant transform. 443 // Add an arc after the relevant transform.
440 AffineTransform ellipseTransform = 444 AffineTransform ellipseTransform =
441 AffineTransform::translation(p.x(), p.y()).rotateRadians(rotation); 445 AffineTransform::translation(p.x(), p.y()).rotateRadians(rotation);
442 ASSERT(ellipseTransform.isInvertible()); 446 DCHECK(ellipseTransform.isInvertible());
443 AffineTransform inverseEllipseTransform = ellipseTransform.inverse(); 447 AffineTransform inverseEllipseTransform = ellipseTransform.inverse();
444 transform(inverseEllipseTransform); 448 transform(inverseEllipseTransform);
445 addEllipse(FloatPoint::zero(), radiusX, radiusY, startAngle, endAngle, 449 addEllipse(FloatPoint::zero(), radiusX, radiusY, startAngle, endAngle,
446 anticlockwise); 450 anticlockwise);
447 transform(ellipseTransform); 451 transform(ellipseTransform);
448 } 452 }
449 453
450 void Path::addEllipse(const FloatRect& rect) { 454 void Path::addEllipse(const FloatRect& rect) {
451 // Start at 3 o'clock, add clock-wise. 455 // Start at 3 o'clock, add clock-wise.
452 m_path.addOval(rect, SkPath::kCW_Direction, 1); 456 m_path.addOval(rect, SkPath::kCW_Direction, 1);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 } 549 }
546 550
547 #if DCHECK_IS_ON() 551 #if DCHECK_IS_ON()
548 bool ellipseIsRenderable(float startAngle, float endAngle) { 552 bool ellipseIsRenderable(float startAngle, float endAngle) {
549 return (std::abs(endAngle - startAngle) < twoPiFloat) || 553 return (std::abs(endAngle - startAngle) < twoPiFloat) ||
550 WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); 554 WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat);
551 } 555 }
552 #endif 556 #endif
553 557
554 } // namespace blink 558 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698