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

Side by Side Diff: src/codec/SkCodecPriv.h

Issue 1282073004: Support decoding opaque images to unpremul/premul (Closed) Base URL: https://skia.googlesource.com/skia.git@CodexTestCleanup
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | src/codec/SkJpegCodec.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 2015 The Android Open Source Project 2 * Copyright 2015 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 SkCodecPriv_DEFINED 8 #ifndef SkCodecPriv_DEFINED
9 #define SkCodecPriv_DEFINED 9 #define SkCodecPriv_DEFINED
10 10
(...skipping 15 matching lines...) Expand all
26 #define UPDATE_RESULT_ALPHA(alpha) \ 26 #define UPDATE_RESULT_ALPHA(alpha) \
27 zeroAlpha |= (alpha); \ 27 zeroAlpha |= (alpha); \
28 maxAlpha &= (alpha); 28 maxAlpha &= (alpha);
29 29
30 #define COMPUTE_RESULT_ALPHA \ 30 #define COMPUTE_RESULT_ALPHA \
31 SkSwizzler::GetResult(zeroAlpha, maxAlpha); 31 SkSwizzler::GetResult(zeroAlpha, maxAlpha);
32 32
33 static inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) { 33 static inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) {
34 // Check for supported alpha types 34 // Check for supported alpha types
35 if (srcAlpha != dstAlpha) { 35 if (srcAlpha != dstAlpha) {
36 if (kOpaque_SkAlphaType == srcAlpha) { 36 if (kOpaque_SkAlphaType == dstAlpha) {
37 // If the source is opaque, we must decode to opaque
38 return false; 37 return false;
39 } 38 }
40 39
41 // The source is not opaque
42 switch (dstAlpha) { 40 switch (dstAlpha) {
41 case kOpaque_SkAlphaType:
42 // If the source is not opaque, we cannot decode to opaque
43 return false;
43 case kPremul_SkAlphaType: 44 case kPremul_SkAlphaType:
44 case kUnpremul_SkAlphaType: 45 case kUnpremul_SkAlphaType:
45 // The source is not opaque, so either of these is okay 46 // Opaque can trivially be treated as both, so no conversion is
47 // actually necessary.
48 // Switching between premul and unpremul is supported.
46 break; 49 break;
47 default: 50 default:
48 // We cannot decode a non-opaque image to opaque (or unknown) 51 // We cannot decode a non-opaque image to opaque (or unknown
49 return false; 52 return false;
50 } 53 }
51 } 54 }
52 return true; 55 return true;
53 } 56 }
54 57
55 /* 58 /*
56 * If there is a color table, get a pointer to the colors, otherwise return NULL 59 * If there is a color table, get a pointer to the colors, otherwise return NULL
57 */ 60 */
58 static const SkPMColor* get_color_ptr(SkColorTable* colorTable) { 61 static const SkPMColor* get_color_ptr(SkColorTable* colorTable) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 #endif 141 #endif
139 } 142 }
140 143
141 #ifdef SK_PRINT_CODEC_MESSAGES 144 #ifdef SK_PRINT_CODEC_MESSAGES
142 #define SkCodecPrintf SkDebugf 145 #define SkCodecPrintf SkDebugf
143 #else 146 #else
144 #define SkCodecPrintf(...) 147 #define SkCodecPrintf(...)
145 #endif 148 #endif
146 149
147 #endif // SkCodecPriv_DEFINED 150 #endif // SkCodecPriv_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkJpegCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698