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

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') | 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 /* 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 * @return min if value < min, max if value > max, else value
61 */
62 static inline int SkClampMinMax(int value, int min, int max) {
reed1 2013/04/09 15:23:42 How is this different from SkPin32() ?
63 return (value < min ? min : (value > max ? max : value));
64 }
65
58 /** Given an integer and a positive (max) integer, return the value 66 /** Given an integer and a positive (max) integer, return the value
59 * pinned against 0 and max, inclusive. 67 * pinned against 0 and max, inclusive.
60 * @param value The value we want returned pinned between [0...max] 68 * @param value The value we want returned pinned between [0...max]
61 * @param max The positive max value 69 * @param max The positive max value
62 * @return 0 if value < 0, max if value > max, else value 70 * @return 0 if value < 0, max if value > max, else value
63 */ 71 */
64 static inline int SkClampMax(int value, int max) { 72 static inline int SkClampMax(int value, int max) {
65 // ensure that max is positive 73 // ensure that max is positive
66 SkASSERT(max >= 0); 74 SkASSERT(max >= 0);
67 if (value < 0) { 75 if (value < 0) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 * a and b are 0..255 160 * a and b are 0..255
153 */ 161 */
154 static inline U8CPU SkMulDiv255Round(U8CPU a, U8CPU b) { 162 static inline U8CPU SkMulDiv255Round(U8CPU a, U8CPU b) {
155 SkASSERT((uint8_t)a == a); 163 SkASSERT((uint8_t)a == a);
156 SkASSERT((uint8_t)b == b); 164 SkASSERT((uint8_t)b == b);
157 unsigned prod = SkMulS16(a, b) + 128; 165 unsigned prod = SkMulS16(a, b) + 128;
158 return (prod + (prod >> 8)) >> 8; 166 return (prod + (prod >> 8)) >> 8;
159 } 167 }
160 168
161 #endif 169 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkTileGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698