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