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

Unified Diff: ui/gfx/skia_util.cc

Issue 2744423002: Handle large rects better. (Closed)
Patch Set: Followup fixes Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/skia_util.cc
diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc
index 6f7818d9a5b02ab1de42200006be406d4e80d0b7..70a427f99082e3a82951261b27e8404a305193d8 100644
--- a/ui/gfx/skia_util.cc
+++ b/ui/gfx/skia_util.cc
@@ -46,20 +46,10 @@ SkIRect RectToSkIRect(const Rect& rect) {
return SkIRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
}
-// Produces a non-negative integer for the difference between min and max,
-// yielding 0 if it would be negative and INT_MAX if it would overflow.
-// This yields a length such that min+length is in range as well.
-static int ClampLengthFromRange(int min, int max) {
- if (min > max)
- return 0;
- return (base::CheckedNumeric<int>(max) - min)
- .ValueOrDefault(std::numeric_limits<int>::max());
-}
-
Rect SkIRectToRect(const SkIRect& rect) {
- return Rect(rect.x(), rect.y(),
- ClampLengthFromRange(rect.left(), rect.right()),
- ClampLengthFromRange(rect.top(), rect.bottom()));
+ Rect result;
+ result.SetByBounds(rect.left(), rect.right(), rect.top(), rect.bottom());
+ return result;
}
SkRect RectFToSkRect(const RectF& rect) {

Powered by Google App Engine
This is Rietveld 408576698