aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2014-10-10 05:50:15 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-10 05:50:15 -0700
commit40636a53037eadd957b8e43f0961f640aaa93e84 (patch)
treeddd687900a7bb6965c63e97663deefd7c11f0015 /include
parent0ad24bee47e734b1a8f86f40d7eb240cc20c618c (diff)
faster SkRect::sort
Diffstat (limited to 'include')
-rw-r--r--include/core/SkRect.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index d9ef7a5ecf..995beb8662 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -1,4 +1,3 @@
-
/*
* Copyright 2006 The Android Open Source Project
*
@@ -6,7 +5,6 @@
* found in the LICENSE file.
*/
-
#ifndef SkRect_DEFINED
#define SkRect_DEFINED
@@ -842,7 +840,17 @@ public:
* if the edges are computed separately, and may have crossed over each
* other. When this returns, left <= right && top <= bottom
*/
- void sort();
+ void sort() {
+ SkScalar min = SkMinScalar(fLeft, fRight);
+ SkScalar max = SkMaxScalar(fLeft, fRight);
+ fLeft = min;
+ fRight = max;
+
+ min = SkMinScalar(fTop, fBottom);
+ max = SkMaxScalar(fTop, fBottom);
+ fTop = min;
+ fBottom = max;
+ }
/**
* cast-safe way to treat the rect as an array of (4) SkScalars.