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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « bench/GeometryBench.cpp ('k') | src/core/SkRect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 /* 1 /*
3 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9
10 #ifndef SkRect_DEFINED 8 #ifndef SkRect_DEFINED
11 #define SkRect_DEFINED 9 #define SkRect_DEFINED
12 10
13 #include "SkPoint.h" 11 #include "SkPoint.h"
14 #include "SkSize.h" 12 #include "SkSize.h"
15 13
16 /** \struct SkIRect 14 /** \struct SkIRect
17 15
18 SkIRect holds four 32 bit integer coordinates for a rectangle 16 SkIRect holds four 32 bit integer coordinates for a rectangle
19 */ 17 */
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 this->round(&ir); 833 this->round(&ir);
836 return ir; 834 return ir;
837 } 835 }
838 836
839 /** 837 /**
840 * Swap top/bottom or left/right if there are flipped (i.e. if width() 838 * Swap top/bottom or left/right if there are flipped (i.e. if width()
841 * or height() would have returned a negative value.) This should be called 839 * or height() would have returned a negative value.) This should be called
842 * if the edges are computed separately, and may have crossed over each 840 * if the edges are computed separately, and may have crossed over each
843 * other. When this returns, left <= right && top <= bottom 841 * other. When this returns, left <= right && top <= bottom
844 */ 842 */
845 void sort(); 843 void sort() {
844 SkScalar min = SkMinScalar(fLeft, fRight);
845 SkScalar max = SkMaxScalar(fLeft, fRight);
846 fLeft = min;
847 fRight = max;
848
849 min = SkMinScalar(fTop, fBottom);
850 max = SkMaxScalar(fTop, fBottom);
851 fTop = min;
852 fBottom = max;
853 }
846 854
847 /** 855 /**
848 * cast-safe way to treat the rect as an array of (4) SkScalars. 856 * cast-safe way to treat the rect as an array of (4) SkScalars.
849 */ 857 */
850 const SkScalar* asScalars() const { return &fLeft; } 858 const SkScalar* asScalars() const { return &fLeft; }
851 859
852 #ifdef SK_DEVELOPER 860 #ifdef SK_DEVELOPER
853 /** 861 /**
854 * Dumps the rect using SkDebugf. This is intended for Skia development debu gging. Don't 862 * Dumps the rect using SkDebugf. This is intended for Skia development debu gging. Don't
855 * rely on the existence of this function or the formatting of its output. 863 * rely on the existence of this function or the formatting of its output.
856 */ 864 */
857 void dump() const { 865 void dump() const {
858 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom) ; 866 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom) ;
859 } 867 }
860 #endif 868 #endif
861 869
862 }; 870 };
863 871
864 #endif 872 #endif
OLDNEW
« 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