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

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

Issue 270023002: fix TriColorShader to respect the paint's alpha (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add Sk255To256 Created 6 years, 7 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/SkDraw.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 * 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 SkColorPriv_DEFINED 8 #ifndef SkColorPriv_DEFINED
9 #define SkColorPriv_DEFINED 9 #define SkColorPriv_DEFINED
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 In debugging, asserts that alpha is 0..255 175 In debugging, asserts that alpha is 0..255
176 */ 176 */
177 static inline unsigned SkAlpha255To256(U8CPU alpha) { 177 static inline unsigned SkAlpha255To256(U8CPU alpha) {
178 SkASSERT(SkToU8(alpha) == alpha); 178 SkASSERT(SkToU8(alpha) == alpha);
179 // this one assues that blending on top of an opaque dst keeps it that way 179 // this one assues that blending on top of an opaque dst keeps it that way
180 // even though it is less accurate than a+(a>>7) for non-opaque dsts 180 // even though it is less accurate than a+(a>>7) for non-opaque dsts
181 return alpha + 1; 181 return alpha + 1;
182 } 182 }
183 183
184 /**
185 * Turn a 0..255 value into a 0..256 value, rounding up if the value is >= 0x80 .
186 * This is slightly more accurate than SkAlpha255To256.
187 */
188 static inline unsigned Sk255To256(U8CPU value) {
189 SkASSERT(SkToU8(value) == value);
190 return value + (value >> 7);
191 }
192
184 /** Multiplify value by 0..256, and shift the result down 8 193 /** Multiplify value by 0..256, and shift the result down 8
185 (i.e. return (value * alpha256) >> 8) 194 (i.e. return (value * alpha256) >> 8)
186 */ 195 */
187 #define SkAlphaMul(value, alpha256) (SkMulS16(value, alpha256) >> 8) 196 #define SkAlphaMul(value, alpha256) (SkMulS16(value, alpha256) >> 8)
188 197
189 // The caller may want negative values, so keep all params signed (int) 198 // The caller may want negative values, so keep all params signed (int)
190 // so we don't accidentally slip into unsigned math and lose the sign 199 // so we don't accidentally slip into unsigned math and lose the sign
191 // extension when we shift (in SkAlphaMul) 200 // extension when we shift (in SkAlphaMul)
192 static inline int SkAlphaBlend(int src, int dst, int scale256) { 201 static inline int SkAlphaBlend(int src, int dst, int scale256) {
193 SkASSERT((unsigned)scale256 <= 256); 202 SkASSERT((unsigned)scale256 <= 256);
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 int srcG = SkColorGetG(src); 1052 int srcG = SkColorGetG(src);
1044 int srcB = SkColorGetB(src); 1053 int srcB = SkColorGetB(src);
1045 1054
1046 for (int i = 0; i < width; i++) { 1055 for (int i = 0; i < width; i++) {
1047 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], 1056 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i],
1048 opaqueDst); 1057 opaqueDst);
1049 } 1058 }
1050 } 1059 }
1051 1060
1052 #endif 1061 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698