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

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

Issue 102813002: SkSplay and SkUnsplay work on any uint32_t, not just SkPMColor. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: less zealous Created 7 years 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 | 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 /* 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 SkColorPriv_DEFINED 10 #ifndef SkColorPriv_DEFINED
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 */ 264 */
265 static inline SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, 265 static inline SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst,
266 U8CPU srcWeight) { 266 U8CPU srcWeight) {
267 unsigned scale = SkAlpha255To256(srcWeight); 267 unsigned scale = SkAlpha255To256(srcWeight);
268 return SkFourByteInterp256(src, dst, scale); 268 return SkFourByteInterp256(src, dst, scale);
269 } 269 }
270 270
271 /** 271 /**
272 * 0xAARRGGBB -> 0x00AA00GG, 0x00RR00BB 272 * 0xAARRGGBB -> 0x00AA00GG, 0x00RR00BB
273 */ 273 */
274 static inline void SkSplay(SkPMColor color, uint32_t* ag, uint32_t* rb) { 274 static inline void SkSplay(uint32_t color, uint32_t* ag, uint32_t* rb) {
275 const uint32_t mask = 0x00FF00FF; 275 const uint32_t mask = 0x00FF00FF;
276 *ag = (color >> 8) & mask; 276 *ag = (color >> 8) & mask;
277 *rb = color & mask; 277 *rb = color & mask;
278 } 278 }
279 279
280 /** 280 /**
281 * 0xAARRGGBB -> 0x00AA00GG00RR00BB 281 * 0xAARRGGBB -> 0x00AA00GG00RR00BB
282 * (note, ARGB -> AGRB) 282 * (note, ARGB -> AGRB)
283 */ 283 */
284 static inline uint64_t SkSplay(SkPMColor color) { 284 static inline uint64_t SkSplay(uint32_t color) {
285 const uint32_t mask = 0x00FF00FF; 285 const uint32_t mask = 0x00FF00FF;
286 uint64_t agrb = (color >> 8) & mask; // 0x0000000000AA00GG 286 uint64_t agrb = (color >> 8) & mask; // 0x0000000000AA00GG
287 agrb <<= 32; // 0x00AA00GG00000000 287 agrb <<= 32; // 0x00AA00GG00000000
288 agrb |= color & mask; // 0x00AA00GG00RR00BB 288 agrb |= color & mask; // 0x00AA00GG00RR00BB
289 return agrb; 289 return agrb;
290 } 290 }
291 291
292 /** 292 /**
293 * 0xAAxxGGxx, 0xRRxxBBxx-> 0xAARRGGBB 293 * 0xAAxxGGxx, 0xRRxxBBxx-> 0xAARRGGBB
294 */ 294 */
295 static inline SkPMColor SkUnsplay(uint32_t ag, uint32_t rb) { 295 static inline uint32_t SkUnsplay(uint32_t ag, uint32_t rb) {
296 const uint32_t mask = 0xFF00FF00; 296 const uint32_t mask = 0xFF00FF00;
297 return (ag & mask) | ((rb & mask) >> 8); 297 return (ag & mask) | ((rb & mask) >> 8);
298 } 298 }
299 299
300 /** 300 /**
301 * 0xAAxxGGxxRRxxBBxx -> 0xAARRGGBB 301 * 0xAAxxGGxxRRxxBBxx -> 0xAARRGGBB
302 * (note, AGRB -> ARGB) 302 * (note, AGRB -> ARGB)
303 */ 303 */
304 static inline SkPMColor SkUnsplay(uint64_t agrb) { 304 static inline uint32_t SkUnsplay(uint64_t agrb) {
305 const uint32_t mask = 0xFF00FF00; 305 const uint32_t mask = 0xFF00FF00;
306 return SkPMColor( 306 return SkPMColor(
307 ((agrb & mask) >> 8) | // 0x00RR00BB 307 ((agrb & mask) >> 8) | // 0x00RR00BB
308 ((agrb >> 32) & mask)); // 0xAARRGGBB 308 ((agrb >> 32) & mask)); // 0xAARRGGBB
309 } 309 }
310 310
311 static inline SkPMColor SkFastFourByteInterp256_32(SkPMColor src, SkPMColor dst, unsigned scale) { 311 static inline SkPMColor SkFastFourByteInterp256_32(SkPMColor src, SkPMColor dst, unsigned scale) {
312 SkASSERT(scale <= 256); 312 SkASSERT(scale <= 256);
313 313
314 // Two 8-bit blends per two 32-bit registers, with space to make sure the ma th doesn't collide. 314 // Two 8-bit blends per two 32-bit registers, with space to make sure the ma th doesn't collide.
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 int srcG = SkColorGetG(src); 907 int srcG = SkColorGetG(src);
908 int srcB = SkColorGetB(src); 908 int srcB = SkColorGetB(src);
909 909
910 for (int i = 0; i < width; i++) { 910 for (int i = 0; i < width; i++) {
911 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], 911 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i],
912 opaqueDst); 912 opaqueDst);
913 } 913 }
914 } 914 }
915 915
916 #endif 916 #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