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

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: fix typo 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 path_.close(); 358 path_.close();
359 } 359 }
360 360
361 void Path::AddEllipse(const FloatPoint& p, 361 void Path::AddEllipse(const FloatPoint& p,
362 float radius_x, 362 float radius_x,
363 float radius_y, 363 float radius_y,
364 float start_angle, 364 float start_angle,
365 float end_angle, 365 float end_angle,
366 bool anticlockwise) { 366 bool anticlockwise) {
367 ASSERT(EllipseIsRenderable(start_angle, end_angle)); 367 #if DCHECK_IS_ON()
368 ASSERT(start_angle >= 0 && start_angle < twoPiFloat); 368 DCHECK(EllipseIsRenderable(start_angle, end_angle));
369 ASSERT((anticlockwise && (start_angle - end_angle) >= 0) || 369 #endif
370 DCHECK_GE(start_angle, 0);
371 DCHECK_LT(start_angle, twoPiFloat);
372 DCHECK((anticlockwise && (start_angle - end_angle) >= 0) ||
370 (!anticlockwise && (end_angle - start_angle) >= 0)); 373 (!anticlockwise && (end_angle - start_angle) >= 0));
371 374
372 SkScalar cx = WebCoreFloatToSkScalar(p.X()); 375 SkScalar cx = WebCoreFloatToSkScalar(p.X());
373 SkScalar cy = WebCoreFloatToSkScalar(p.Y()); 376 SkScalar cy = WebCoreFloatToSkScalar(p.Y());
374 SkScalar radius_x_scalar = WebCoreFloatToSkScalar(radius_x); 377 SkScalar radius_x_scalar = WebCoreFloatToSkScalar(radius_x);
375 SkScalar radius_y_scalar = WebCoreFloatToSkScalar(radius_y); 378 SkScalar radius_y_scalar = WebCoreFloatToSkScalar(radius_y);
376 379
377 SkRect oval; 380 SkRect oval;
378 oval.set(cx - radius_x_scalar, cy - radius_y_scalar, cx + radius_x_scalar, 381 oval.set(cx - radius_x_scalar, cy - radius_y_scalar, cx + radius_x_scalar,
379 cy + radius_y_scalar); 382 cy + radius_y_scalar);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 path_.addRect(rect, SkPath::kCW_Direction, 0); 421 path_.addRect(rect, SkPath::kCW_Direction, 0);
419 } 422 }
420 423
421 void Path::AddEllipse(const FloatPoint& p, 424 void Path::AddEllipse(const FloatPoint& p,
422 float radius_x, 425 float radius_x,
423 float radius_y, 426 float radius_y,
424 float rotation, 427 float rotation,
425 float start_angle, 428 float start_angle,
426 float end_angle, 429 float end_angle,
427 bool anticlockwise) { 430 bool anticlockwise) {
428 ASSERT(EllipseIsRenderable(start_angle, end_angle)); 431 #if DCHECK_IS_ON()
429 ASSERT(start_angle >= 0 && start_angle < twoPiFloat); 432 DCHECK(EllipseIsRenderable(start_angle, end_angle));
430 ASSERT((anticlockwise && (start_angle - end_angle) >= 0) || 433 #endif
434 DCHECK_GE(start_angle, 0);
435 DCHECK_LT(start_angle, twoPiFloat);
436 DCHECK((anticlockwise && (start_angle - end_angle) >= 0) ||
431 (!anticlockwise && (end_angle - start_angle) >= 0)); 437 (!anticlockwise && (end_angle - start_angle) >= 0));
432 438
433 if (!rotation) { 439 if (!rotation) {
434 AddEllipse(FloatPoint(p.X(), p.Y()), radius_x, radius_y, start_angle, 440 AddEllipse(FloatPoint(p.X(), p.Y()), radius_x, radius_y, start_angle,
435 end_angle, anticlockwise); 441 end_angle, anticlockwise);
436 return; 442 return;
437 } 443 }
438 444
439 // Add an arc after the relevant transform. 445 // Add an arc after the relevant transform.
440 AffineTransform ellipse_transform = 446 AffineTransform ellipse_transform =
441 AffineTransform::Translation(p.X(), p.Y()).RotateRadians(rotation); 447 AffineTransform::Translation(p.X(), p.Y()).RotateRadians(rotation);
442 ASSERT(ellipse_transform.IsInvertible()); 448 DCHECK(ellipse_transform.IsInvertible());
443 AffineTransform inverse_ellipse_transform = ellipse_transform.Inverse(); 449 AffineTransform inverse_ellipse_transform = ellipse_transform.Inverse();
444 Transform(inverse_ellipse_transform); 450 Transform(inverse_ellipse_transform);
445 AddEllipse(FloatPoint::Zero(), radius_x, radius_y, start_angle, end_angle, 451 AddEllipse(FloatPoint::Zero(), radius_x, radius_y, start_angle, end_angle,
446 anticlockwise); 452 anticlockwise);
447 Transform(ellipse_transform); 453 Transform(ellipse_transform);
448 } 454 }
449 455
450 void Path::AddEllipse(const FloatRect& rect) { 456 void Path::AddEllipse(const FloatRect& rect) {
451 // Start at 3 o'clock, add clock-wise. 457 // Start at 3 o'clock, add clock-wise.
452 path_.addOval(rect, SkPath::kCW_Direction, 1); 458 path_.addOval(rect, SkPath::kCW_Direction, 1);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 } 552 }
547 553
548 #if DCHECK_IS_ON() 554 #if DCHECK_IS_ON()
549 bool EllipseIsRenderable(float start_angle, float end_angle) { 555 bool EllipseIsRenderable(float start_angle, float end_angle) {
550 return (std::abs(end_angle - start_angle) < twoPiFloat) || 556 return (std::abs(end_angle - start_angle) < twoPiFloat) ||
551 WebCoreFloatNearlyEqual(std::abs(end_angle - start_angle), twoPiFloat); 557 WebCoreFloatNearlyEqual(std::abs(end_angle - start_angle), twoPiFloat);
552 } 558 }
553 #endif 559 #endif
554 560
555 } // namespace blink 561 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698