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

Side by Side Diff: src/core/SkColor.cpp

Issue 16410009: Add an option to create unpremultiplied bitmaps. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: ImageDecodeBench does no rendering. Created 7 years, 6 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
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 #include "SkColor.h" 10 #include "SkColor.h"
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 12
13 SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { 13 SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
14 return SkPremultiplyARGBInline(a, r, g, b); 14 return SkPremultiplyARGBInline(a, r, g, b);
15 } 15 }
16 16
17 SkPMColor SkPreMultiplyColor(SkColor c) { 17 SkPMColor SkPreMultiplyColor(SkColor c) {
18 return SkPremultiplyARGBInline(SkColorGetA(c), SkColorGetR(c), 18 return SkPremultiplyARGBInline(SkColorGetA(c), SkColorGetR(c),
19 SkColorGetG(c), SkColorGetB(c)); 19 SkColorGetG(c), SkColorGetB(c));
20 } 20 }
21 21
22 /**
23 * Interprets c as an unpremultiplied color, and returns the
24 * premultiplied equivalent.
25 */
26 SkPMColor SkPreMultiplyUnPMColor(SkPMColor c) {
reed1 2013/06/13 19:33:07 Since there is no header for this method, and it i
scroggo 2013/06/13 20:10:40 Done.
27 U8CPU a = SkGetPackedA32(c);
28 U8CPU r = SkGetPackedR32(c);
29 U8CPU g = SkGetPackedG32(c);
30 U8CPU b = SkGetPackedB32(c);
31 return SkPreMultiplyARGB(a, r, g, b);
32 }
33
22 /////////////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////////////
23 35
24 static inline SkScalar ByteToScalar(U8CPU x) { 36 static inline SkScalar ByteToScalar(U8CPU x) {
25 SkASSERT(x <= 255); 37 SkASSERT(x <= 255);
26 return SkIntToScalar(x) / 255; 38 return SkIntToScalar(x) / 255;
27 } 39 }
28 40
29 static inline SkScalar ByteDivToScalar(int numer, U8CPU denom) { 41 static inline SkScalar ByteDivToScalar(int numer, U8CPU denom) {
30 // cast to keep the answer signed 42 // cast to keep the answer signed
31 return SkIntToScalar(numer) / (int)denom; 43 return SkIntToScalar(numer) / (int)denom;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 switch (hx >> 16) { 116 switch (hx >> 16) {
105 case 0: r = v; g = t; b = p; break; 117 case 0: r = v; g = t; b = p; break;
106 case 1: r = q; g = v; b = p; break; 118 case 1: r = q; g = v; b = p; break;
107 case 2: r = p; g = v; b = t; break; 119 case 2: r = p; g = v; b = t; break;
108 case 3: r = p; g = q; b = v; break; 120 case 3: r = p; g = q; b = v; break;
109 case 4: r = t; g = p; b = v; break; 121 case 4: r = t; g = p; b = v; break;
110 default: r = v; g = p; b = q; break; 122 default: r = v; g = p; b = q; break;
111 } 123 }
112 return SkColorSetARGB(a, r, g, b); 124 return SkColorSetARGB(a, r, g, b);
113 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698