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

Side by Side Diff: src/images/SkImageDecoder.cpp

Issue 340533002: hide SkBitmap::Config entirely (behind a flag) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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
« no previous file with comments | « src/image/SkImagePriv.cpp ('k') | tests/KtxTest.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 2006 The Android Open Source Project 2 * Copyright 2006 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 8
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkImagePriv.h" 11 #include "SkImagePriv.h"
12 #include "SkPixelRef.h" 12 #include "SkPixelRef.h"
13 #include "SkStream.h" 13 #include "SkStream.h"
14 #include "SkTemplates.h" 14 #include "SkTemplates.h"
15 #include "SkCanvas.h" 15 #include "SkCanvas.h"
16 16
17 SkImageDecoder::SkImageDecoder() 17 SkImageDecoder::SkImageDecoder()
18 : fPeeker(NULL) 18 : fPeeker(NULL)
19 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER 19 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
20 , fChooser(NULL) 20 , fChooser(NULL)
21 #endif 21 #endif
22 , fAllocator(NULL) 22 , fAllocator(NULL)
23 , fSampleSize(1) 23 , fSampleSize(1)
24 , fDefaultPref(kUnknown_SkColorType) 24 , fDefaultPref(kUnknown_SkColorType)
25 , fDitherImage(true) 25 , fDitherImage(true)
26 #ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
26 , fUsePrefTable(false) 27 , fUsePrefTable(false)
28 #endif
27 , fSkipWritingZeroes(false) 29 , fSkipWritingZeroes(false)
28 , fPreferQualityOverSpeed(false) 30 , fPreferQualityOverSpeed(false)
29 , fRequireUnpremultipliedColors(false) { 31 , fRequireUnpremultipliedColors(false) {
30 } 32 }
31 33
32 SkImageDecoder::~SkImageDecoder() { 34 SkImageDecoder::~SkImageDecoder() {
33 SkSafeUnref(fPeeker); 35 SkSafeUnref(fPeeker);
34 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER 36 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
35 SkSafeUnref(fChooser); 37 SkSafeUnref(fChooser);
36 #endif 38 #endif
37 SkSafeUnref(fAllocator); 39 SkSafeUnref(fAllocator);
38 } 40 }
39 41
40 void SkImageDecoder::copyFieldsToOther(SkImageDecoder* other) { 42 void SkImageDecoder::copyFieldsToOther(SkImageDecoder* other) {
41 if (NULL == other) { 43 if (NULL == other) {
42 return; 44 return;
43 } 45 }
44 other->setPeeker(fPeeker); 46 other->setPeeker(fPeeker);
45 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER 47 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
46 other->setChooser(fChooser); 48 other->setChooser(fChooser);
47 #endif 49 #endif
48 other->setAllocator(fAllocator); 50 other->setAllocator(fAllocator);
49 other->setSampleSize(fSampleSize); 51 other->setSampleSize(fSampleSize);
52 #ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
50 if (fUsePrefTable) { 53 if (fUsePrefTable) {
51 other->setPrefConfigTable(fPrefTable); 54 other->setPrefConfigTable(fPrefTable);
52 } else { 55 } else {
53 other->fDefaultPref = fDefaultPref; 56 other->fDefaultPref = fDefaultPref;
54 } 57 }
58 #endif
55 other->setDitherImage(fDitherImage); 59 other->setDitherImage(fDitherImage);
56 other->setSkipWritingZeroes(fSkipWritingZeroes); 60 other->setSkipWritingZeroes(fSkipWritingZeroes);
57 other->setPreferQualityOverSpeed(fPreferQualityOverSpeed); 61 other->setPreferQualityOverSpeed(fPreferQualityOverSpeed);
58 other->setRequireUnpremultipliedColors(fRequireUnpremultipliedColors); 62 other->setRequireUnpremultipliedColors(fRequireUnpremultipliedColors);
59 } 63 }
60 64
61 SkImageDecoder::Format SkImageDecoder::getFormat() const { 65 SkImageDecoder::Format SkImageDecoder::getFormat() const {
62 return kUnknown_Format; 66 return kUnknown_Format;
63 } 67 }
64 68
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 137 }
134 #endif 138 #endif
135 139
136 bool SkImageDecoder::allocPixelRef(SkBitmap* bitmap, 140 bool SkImageDecoder::allocPixelRef(SkBitmap* bitmap,
137 SkColorTable* ctable) const { 141 SkColorTable* ctable) const {
138 return bitmap->allocPixels(fAllocator, ctable); 142 return bitmap->allocPixels(fAllocator, ctable);
139 } 143 }
140 144
141 /////////////////////////////////////////////////////////////////////////////// 145 ///////////////////////////////////////////////////////////////////////////////
142 146
147 #ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
143 void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) { 148 void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) {
144 fUsePrefTable = true; 149 fUsePrefTable = true;
145 fPrefTable = prefTable; 150 fPrefTable = prefTable;
146 } 151 }
152 #endif
147 153
148 // TODO: use colortype in fPrefTable, fDefaultPref so we can stop using SkBitmap ConfigToColorType() 154 // TODO: use colortype in fPrefTable, fDefaultPref so we can stop using SkBitmap ConfigToColorType()
149 // 155 //
150 SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha ) const { 156 SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha ) const {
151 SkColorType ct = fDefaultPref; 157 SkColorType ct = fDefaultPref;
158 #ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
152 159
153 if (fUsePrefTable) { 160 if (fUsePrefTable) {
154 // Until we kill or change the PrefTable, we have to go into Config land for a moment. 161 // Until we kill or change the PrefTable, we have to go into Config land for a moment.
155 SkBitmap::Config config = SkBitmap::kNo_Config; 162 SkBitmap::Config config = SkBitmap::kNo_Config;
156 switch (srcDepth) { 163 switch (srcDepth) {
157 case kIndex_SrcDepth: 164 case kIndex_SrcDepth:
158 config = srcHasAlpha ? fPrefTable.fPrefFor_8Index_YesAlpha_src 165 config = srcHasAlpha ? fPrefTable.fPrefFor_8Index_YesAlpha_src
159 : fPrefTable.fPrefFor_8Index_NoAlpha_src; 166 : fPrefTable.fPrefFor_8Index_NoAlpha_src;
160 break; 167 break;
161 case k8BitGray_SrcDepth: 168 case k8BitGray_SrcDepth:
162 config = fPrefTable.fPrefFor_8Gray_src; 169 config = fPrefTable.fPrefFor_8Gray_src;
163 break; 170 break;
164 case k32Bit_SrcDepth: 171 case k32Bit_SrcDepth:
165 config = srcHasAlpha ? fPrefTable.fPrefFor_8bpc_YesAlpha_src 172 config = srcHasAlpha ? fPrefTable.fPrefFor_8bpc_YesAlpha_src
166 : fPrefTable.fPrefFor_8bpc_NoAlpha_src; 173 : fPrefTable.fPrefFor_8bpc_NoAlpha_src;
167 break; 174 break;
168 } 175 }
169 // now return to SkColorType land 176 // now return to SkColorType land
170 ct = SkBitmapConfigToColorType(config); 177 ct = SkBitmapConfigToColorType(config);
171 } 178 }
179 #endif
172 return ct; 180 return ct;
173 } 181 }
174 182
175 bool SkImageDecoder::decode(SkStream* stream, SkBitmap* bm, SkColorType pref, Mo de mode) { 183 bool SkImageDecoder::decode(SkStream* stream, SkBitmap* bm, SkColorType pref, Mo de mode) {
176 // we reset this to false before calling onDecode 184 // we reset this to false before calling onDecode
177 fShouldCancelDecode = false; 185 fShouldCancelDecode = false;
178 // assign this, for use by getPrefColorType(), in case fUsePrefTable is fals e 186 // assign this, for use by getPrefColorType(), in case fUsePrefTable is fals e
179 fDefaultPref = pref; 187 fDefaultPref = pref;
180 188
181 // pass a temporary bitmap, so that if we return false, we are assured of 189 // pass a temporary bitmap, so that if we return false, we are assured of
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (kUnknown_Format == *format) { 302 if (kUnknown_Format == *format) {
295 if (stream->rewind()) { 303 if (stream->rewind()) {
296 *format = GetStreamFormat(stream); 304 *format = GetStreamFormat(stream);
297 } 305 }
298 } 306 }
299 } 307 }
300 delete codec; 308 delete codec;
301 } 309 }
302 return success; 310 return success;
303 } 311 }
OLDNEW
« no previous file with comments | « src/image/SkImagePriv.cpp ('k') | tests/KtxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698