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

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

Issue 1277213002: Support more swizzles to 565 in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update new 565 swizzling functions for scaling 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 break; 46 break;
47 default: 47 default:
48 // We cannot decode a non-opaque image to opaque (or unknown) 48 // We cannot decode a non-opaque image to opaque (or unknown)
49 return false; 49 return false;
50 } 50 }
51 } 51 }
52 return true; 52 return true;
53 } 53 }
54 54
55 /* 55 /*
56 * Most of our codecs support the same conversions:
57 * - profileType must be the same
58 * - opaque only to opaque (and 565 only if opaque)
59 * - premul to unpremul and vice versa
60 * - always support N32
61 * - otherwise match the src color type
62 */
63 static bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) {
64 if (dst.profileType() != src.profileType()) {
65 return false;
66 }
67
68 // Ensure the alpha type is valid
69 if (!valid_alpha(dst.alphaType(), src.alphaType())) {
70 return false;
71 }
72
73 // Check for supported color types
74 switch (dst.colorType()) {
75 case kN32_SkColorType:
76 return true;
77 case kRGB_565_SkColorType:
78 return src.alphaType() == kOpaque_SkAlphaType;
79 default:
80 return dst.colorType() == src.colorType();
81 }
82 }
83
84 /*
56 * If there is a color table, get a pointer to the colors, otherwise return NULL 85 * If there is a color table, get a pointer to the colors, otherwise return NULL
57 */ 86 */
58 static const SkPMColor* get_color_ptr(SkColorTable* colorTable) { 87 static const SkPMColor* get_color_ptr(SkColorTable* colorTable) {
59 return NULL != colorTable ? colorTable->readColors() : NULL; 88 return NULL != colorTable ? colorTable->readColors() : NULL;
60 } 89 }
61 90
62 /* 91 /*
63 * 92 *
64 * Copy the codec color table back to the client when kIndex8 color type is requ ested 93 * Copy the codec color table back to the client when kIndex8 color type is requ ested
65 */ 94 */
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 #endif 167 #endif
139 } 168 }
140 169
141 #ifdef SK_PRINT_CODEC_MESSAGES 170 #ifdef SK_PRINT_CODEC_MESSAGES
142 #define SkCodecPrintf SkDebugf 171 #define SkCodecPrintf SkDebugf
143 #else 172 #else
144 #define SkCodecPrintf(...) 173 #define SkCodecPrintf(...)
145 #endif 174 #endif
146 175
147 #endif // SkCodecPriv_DEFINED 176 #endif // SkCodecPriv_DEFINED
OLDNEW
« no previous file with comments | « src/codec/SkCodec.cpp ('k') | src/codec/SkCodec_libgif.cpp » ('j') | src/codec/SkSwizzler.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698