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

Side by Side Diff: include/core/SkRect.h

Issue 695443005: Optimize SkRect::sort() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: minor fix Created 6 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkRect_DEFINED 8 #ifndef SkRect_DEFINED
9 #define SkRect_DEFINED 9 #define SkRect_DEFINED
10 10
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 return ir; 836 return ir;
837 } 837 }
838 838
839 /** 839 /**
840 * Swap top/bottom or left/right if there are flipped (i.e. if width() 840 * 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 841 * 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 842 * if the edges are computed separately, and may have crossed over each
843 * other. When this returns, left <= right && top <= bottom 843 * other. When this returns, left <= right && top <= bottom
844 */ 844 */
845 void sort() { 845 void sort() {
846 SkScalar min = SkMinScalar(fLeft, fRight); 846 if (fLeft > fRight) {
847 SkScalar max = SkMaxScalar(fLeft, fRight); 847 SkTSwap<SkScalar>(fLeft, fRight);
848 fLeft = min; 848 }
849 fRight = max; 849
850 850 if (fTop > fBottom) {
851 min = SkMinScalar(fTop, fBottom); 851 SkTSwap<SkScalar>(fTop, fBottom);
852 max = SkMaxScalar(fTop, fBottom); 852 }
853 fTop = min;
854 fBottom = max;
855 } 853 }
856 854
857 /** 855 /**
858 * 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.
859 */ 857 */
860 const SkScalar* asScalars() const { return &fLeft; } 858 const SkScalar* asScalars() const { return &fLeft; }
861 859
862 #ifdef SK_DEVELOPER 860 #ifdef SK_DEVELOPER
863 /** 861 /**
864 * 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
865 * 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.
866 */ 864 */
867 void dump() const { 865 void dump() const {
868 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) ;
869 } 867 }
870 #endif 868 #endif
871 869
872 }; 870 };
873 871
874 #endif 872 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698