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

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

Issue 13493016: Fixing SkTileGrid to clamp rather than clip content and querries that are outside the bounds of the… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkTileGrid.cpp » ('j') | src/core/SkTileGrid.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkMath_DEFINED 10 #ifndef SkMath_DEFINED
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #define SkCLZ(x) SkCLZ_portable(x) 48 #define SkCLZ(x) SkCLZ_portable(x)
49 #endif 49 #endif
50 50
51 /** 51 /**
52 * Returns (value < 0 ? 0 : value) efficiently (i.e. no compares or branches) 52 * Returns (value < 0 ? 0 : value) efficiently (i.e. no compares or branches)
53 */ 53 */
54 static inline int SkClampPos(int value) { 54 static inline int SkClampPos(int value) {
55 return value & ~(value >> 31); 55 return value & ~(value >> 31);
56 } 56 }
57 57
58 /** Given an integer and an integer range, return the value
59 * pinned against min and max, inclusive.
60 * @param value The value we want returned pinned between [min...max]
Tom Hudson 2013/04/09 10:10:50 Nit: Skia doesn't usually use @param when it's com
61 * @param min The min value
62 * @param max The max value
63 * @return min if value < min, max if value > max, else value
64 */
65 static inline int SkClampMinMax(int value, int min, int max) {
Tom Hudson 2013/04/09 10:10:50 Given that SkClampMax doesn't use the trinary oper
Justin Novosad 2013/04/09 14:47:50 Ternary operators are actually more likely to trig
66 return (value < min ? min : (value > max ? max : value));
67 }
68
58 /** Given an integer and a positive (max) integer, return the value 69 /** Given an integer and a positive (max) integer, return the value
59 * pinned against 0 and max, inclusive. 70 * pinned against 0 and max, inclusive.
60 * @param value The value we want returned pinned between [0...max] 71 * @param value The value we want returned pinned between [0...max]
61 * @param max The positive max value 72 * @param max The positive max value
62 * @return 0 if value < 0, max if value > max, else value 73 * @return 0 if value < 0, max if value > max, else value
63 */ 74 */
64 static inline int SkClampMax(int value, int max) { 75 static inline int SkClampMax(int value, int max) {
65 // ensure that max is positive 76 // ensure that max is positive
66 SkASSERT(max >= 0); 77 SkASSERT(max >= 0);
67 if (value < 0) { 78 if (value < 0) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 * a and b are 0..255 163 * a and b are 0..255
153 */ 164 */
154 static inline U8CPU SkMulDiv255Round(U8CPU a, U8CPU b) { 165 static inline U8CPU SkMulDiv255Round(U8CPU a, U8CPU b) {
155 SkASSERT((uint8_t)a == a); 166 SkASSERT((uint8_t)a == a);
156 SkASSERT((uint8_t)b == b); 167 SkASSERT((uint8_t)b == b);
157 unsigned prod = SkMulS16(a, b) + 128; 168 unsigned prod = SkMulS16(a, b) + 128;
158 return (prod + (prod >> 8)) >> 8; 169 return (prod + (prod >> 8)) >> 8;
159 } 170 }
160 171
161 #endif 172 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkTileGrid.cpp » ('j') | src/core/SkTileGrid.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698