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

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

Issue 332453002: remove GetDeviceConfig/SetDeviceConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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 | « include/core/SkImageDecoder.h ('k') | src/ports/SkImageDecoder_empty.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 static SkBitmap::Config gDeviceConfig = SkBitmap::kNo_Config;
18
19 SkBitmap::Config SkImageDecoder::GetDeviceConfig()
20 {
21 return gDeviceConfig;
22 }
23
24 void SkImageDecoder::SetDeviceConfig(SkBitmap::Config config)
25 {
26 gDeviceConfig = config;
27 }
28
29 ///////////////////////////////////////////////////////////////////////////////
30
31 SkImageDecoder::SkImageDecoder() 17 SkImageDecoder::SkImageDecoder()
32 : fPeeker(NULL) 18 : fPeeker(NULL)
33 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER 19 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
34 , fChooser(NULL) 20 , fChooser(NULL)
35 #endif 21 #endif
36 , fAllocator(NULL) 22 , fAllocator(NULL)
37 , fSampleSize(1) 23 , fSampleSize(1)
38 , fDefaultPref(SkBitmap::kNo_Config) 24 , fDefaultPref(SkBitmap::kNo_Config)
39 , fDitherImage(true) 25 , fDitherImage(true)
40 , fUsePrefTable(false) 26 , fUsePrefTable(false)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return bitmap->allocPixels(fAllocator, ctable); 138 return bitmap->allocPixels(fAllocator, ctable);
153 } 139 }
154 140
155 /////////////////////////////////////////////////////////////////////////////// 141 ///////////////////////////////////////////////////////////////////////////////
156 142
157 void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) { 143 void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) {
158 fUsePrefTable = true; 144 fUsePrefTable = true;
159 fPrefTable = prefTable; 145 fPrefTable = prefTable;
160 } 146 }
161 147
162 // TODO: use colortype in fPrefTable, fDefaultPref and GetDeviceConfig() 148 // TODO: use colortype in fPrefTable, fDefaultPref so we can stop using SkBitmap ConfigToColorType()
163 // so we can stop using SkBitmapConfigToColorType()
164 // 149 //
165 SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha ) const { 150 SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha ) const {
166 SkBitmap::Config config = SkBitmap::kNo_Config; 151 SkBitmap::Config config = SkBitmap::kNo_Config;
167 152
168 if (fUsePrefTable) { 153 if (fUsePrefTable) {
169 switch (srcDepth) { 154 switch (srcDepth) {
170 case kIndex_SrcDepth: 155 case kIndex_SrcDepth:
171 config = srcHasAlpha ? fPrefTable.fPrefFor_8Index_YesAlpha_src 156 config = srcHasAlpha ? fPrefTable.fPrefFor_8Index_YesAlpha_src
172 : fPrefTable.fPrefFor_8Index_NoAlpha_src; 157 : fPrefTable.fPrefFor_8Index_NoAlpha_src;
173 break; 158 break;
174 case k8BitGray_SrcDepth: 159 case k8BitGray_SrcDepth:
175 config = fPrefTable.fPrefFor_8Gray_src; 160 config = fPrefTable.fPrefFor_8Gray_src;
176 break; 161 break;
177 case k32Bit_SrcDepth: 162 case k32Bit_SrcDepth:
178 config = srcHasAlpha ? fPrefTable.fPrefFor_8bpc_YesAlpha_src 163 config = srcHasAlpha ? fPrefTable.fPrefFor_8bpc_YesAlpha_src
179 : fPrefTable.fPrefFor_8bpc_NoAlpha_src; 164 : fPrefTable.fPrefFor_8bpc_NoAlpha_src;
180 break; 165 break;
181 } 166 }
182 } else { 167 } else {
183 config = fDefaultPref; 168 config = fDefaultPref;
184 } 169 }
185 170
186 if (SkBitmap::kNo_Config == config) {
187 config = SkImageDecoder::GetDeviceConfig();
188 }
189 return SkBitmapConfigToColorType(config); 171 return SkBitmapConfigToColorType(config);
190 } 172 }
191 173
192 bool SkImageDecoder::decode(SkStream* stream, SkBitmap* bm, 174 bool SkImageDecoder::decode(SkStream* stream, SkBitmap* bm,
193 SkBitmap::Config pref, Mode mode) { 175 SkBitmap::Config pref, Mode mode) {
194 // we reset this to false before calling onDecode 176 // we reset this to false before calling onDecode
195 fShouldCancelDecode = false; 177 fShouldCancelDecode = false;
196 // assign this, for use by getPrefConfig(), in case fUsePrefTable is false 178 // assign this, for use by getPrefConfig(), in case fUsePrefTable is false
197 fDefaultPref = pref; 179 fDefaultPref = pref;
198 180
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 if (kUnknown_Format == *format) { 297 if (kUnknown_Format == *format) {
316 if (stream->rewind()) { 298 if (stream->rewind()) {
317 *format = GetStreamFormat(stream); 299 *format = GetStreamFormat(stream);
318 } 300 }
319 } 301 }
320 } 302 }
321 delete codec; 303 delete codec;
322 } 304 }
323 return success; 305 return success;
324 } 306 }
OLDNEW
« no previous file with comments | « include/core/SkImageDecoder.h ('k') | src/ports/SkImageDecoder_empty.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698