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

Unified Diff: include/core/SkRect.h

Issue 646863002: faster SkRect::sort (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « bench/GeometryBench.cpp ('k') | src/core/SkRect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRect.h
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index d9ef7a5ecfc2cbc2ee79bbcb717c13c0eac461a2..995beb8662ee8a8e395b50435c8e33c44ecce2ca 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.
« no previous file with comments | « bench/GeometryBench.cpp ('k') | src/core/SkRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698