OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
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 #include "SkCGUtils.h" | 8 #include "SkCGUtils.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
11 | 11 |
12 static CGBitmapInfo ComputeCGAlphaInfo_RGBA(SkAlphaType at) { | 12 static CGBitmapInfo ComputeCGAlphaInfo_RGBA(SkAlphaType at) { |
13 CGBitmapInfo info = kCGBitmapByteOrder32Big; | 13 CGBitmapInfo info = kCGBitmapByteOrder32Big; |
14 switch (at) { | 14 switch (at) { |
15 case kUnknown_SkAlphaType: | |
16 break; | |
17 case kOpaque_SkAlphaType: | 15 case kOpaque_SkAlphaType: |
| 16 case kIgnore_SkAlphaType: |
18 info |= kCGImageAlphaNoneSkipLast; | 17 info |= kCGImageAlphaNoneSkipLast; |
19 break; | 18 break; |
20 case kPremul_SkAlphaType: | 19 case kPremul_SkAlphaType: |
21 info |= kCGImageAlphaPremultipliedLast; | 20 info |= kCGImageAlphaPremultipliedLast; |
22 break; | 21 break; |
23 case kUnpremul_SkAlphaType: | 22 case kUnpremul_SkAlphaType: |
24 info |= kCGImageAlphaLast; | 23 info |= kCGImageAlphaLast; |
25 break; | 24 break; |
26 } | 25 } |
27 return info; | 26 return info; |
28 } | 27 } |
29 | 28 |
30 static CGBitmapInfo ComputeCGAlphaInfo_BGRA(SkAlphaType at) { | 29 static CGBitmapInfo ComputeCGAlphaInfo_BGRA(SkAlphaType at) { |
31 CGBitmapInfo info = kCGBitmapByteOrder32Little; | 30 CGBitmapInfo info = kCGBitmapByteOrder32Little; |
32 switch (at) { | 31 switch (at) { |
33 case kUnknown_SkAlphaType: | |
34 break; | |
35 case kOpaque_SkAlphaType: | 32 case kOpaque_SkAlphaType: |
| 33 case kIgnore_SkAlphaType: |
36 info |= kCGImageAlphaNoneSkipFirst; | 34 info |= kCGImageAlphaNoneSkipFirst; |
37 break; | 35 break; |
38 case kPremul_SkAlphaType: | 36 case kPremul_SkAlphaType: |
39 info |= kCGImageAlphaPremultipliedFirst; | 37 info |= kCGImageAlphaPremultipliedFirst; |
40 break; | 38 break; |
41 case kUnpremul_SkAlphaType: | 39 case kUnpremul_SkAlphaType: |
42 info |= kCGImageAlphaFirst; | 40 info |= kCGImageAlphaFirst; |
43 break; | 41 break; |
44 } | 42 } |
45 return info; | 43 return info; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 default: | 297 default: |
300 // we don't know if we're opaque or not, so compute it. | 298 // we don't know if we're opaque or not, so compute it. |
301 if (SkBitmap::ComputeIsOpaque(tmp)) { | 299 if (SkBitmap::ComputeIsOpaque(tmp)) { |
302 tmp.setAlphaType(kOpaque_SkAlphaType); | 300 tmp.setAlphaType(kOpaque_SkAlphaType); |
303 } | 301 } |
304 } | 302 } |
305 | 303 |
306 *dst = tmp; | 304 *dst = tmp; |
307 return true; | 305 return true; |
308 } | 306 } |
OLD | NEW |