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

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

Issue 18083026: Allow decoding JPEG into A8. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Naming improvements, remove obsolete, add a test. Created 7 years, 5 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 | Annotate | Revision Log
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"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return bitmap->allocPixels(fAllocator, ctable); 138 return bitmap->allocPixels(fAllocator, ctable);
139 } 139 }
140 140
141 /////////////////////////////////////////////////////////////////////////////// 141 ///////////////////////////////////////////////////////////////////////////////
142 142
143 void SkImageDecoder::setPrefConfigTable(const SkBitmap::Config pref[6]) { 143 void SkImageDecoder::setPrefConfigTable(const SkBitmap::Config pref[6]) {
144 if (NULL == pref) { 144 if (NULL == pref) {
145 fUsePrefTable = false; 145 fUsePrefTable = false;
146 } else { 146 } else {
147 fUsePrefTable = true; 147 fUsePrefTable = true;
148 memcpy(fPrefTable, pref, sizeof(fPrefTable)); 148 fPrefTable.fPrefFor_8Index_NoAlpha_src = pref[0];
149 fPrefTable.fPrefFor_8Index_YesAlpha_src = pref[1];
150 fPrefTable.fPrefFor_8Gray_src = SkBitmap::kNo_Config;
151 fPrefTable.fPrefFor_8bpc_NoAlpha_src = pref[4];
152 fPrefTable.fPrefFor_8bpc_YesAlpha_src = pref[5];
149 } 153 }
150 } 154 }
151 155
156 void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) {
157 fUsePrefTable = true;
158 fPrefTable = prefTable;
159 }
160
152 SkBitmap::Config SkImageDecoder::getPrefConfig(SrcDepth srcDepth, 161 SkBitmap::Config SkImageDecoder::getPrefConfig(SrcDepth srcDepth,
153 bool srcHasAlpha) const { 162 bool srcHasAlpha) const {
154 SkBitmap::Config config; 163 SkBitmap::Config config;
155 164
156 if (fUsePrefTable) { 165 if (fUsePrefTable) {
157 int index = 0;
158 switch (srcDepth) { 166 switch (srcDepth) {
159 case kIndex_SrcDepth: 167 case kIndex_SrcDepth:
160 index = 0; 168 config = srcHasAlpha ? fPrefTable.fPrefFor_8Index_YesAlpha_src
169 : fPrefTable.fPrefFor_8Index_NoAlpha_src;
161 break; 170 break;
162 case k16Bit_SrcDepth: 171 case k8BitGray_SrcDepth:
163 index = 2; 172 config = fPrefTable.fPrefFor_8Gray_src;
164 break; 173 break;
165 case k32Bit_SrcDepth: 174 case k32Bit_SrcDepth:
166 index = 4; 175 config = srcHasAlpha ? fPrefTable.fPrefFor_8bpc_YesAlpha_src
176 : fPrefTable.fPrefFor_8bpc_NoAlpha_src;
167 break; 177 break;
168 } 178 }
169 if (srcHasAlpha) {
170 index += 1;
171 }
172 config = fPrefTable[index];
173 } else { 179 } else {
174 config = fDefaultPref; 180 config = fDefaultPref;
175 } 181 }
176 182
177 if (SkBitmap::kNo_Config == config) { 183 if (SkBitmap::kNo_Config == config) {
178 config = SkImageDecoder::GetDeviceConfig(); 184 config = SkImageDecoder::GetDeviceConfig();
179 } 185 }
180 return config; 186 return config;
181 } 187 }
182 188
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 if (kUnknown_Format == *format) { 460 if (kUnknown_Format == *format) {
455 if (stream->rewind()) { 461 if (stream->rewind()) {
456 *format = GetStreamFormat(stream); 462 *format = GetStreamFormat(stream);
457 } 463 }
458 } 464 }
459 } 465 }
460 delete codec; 466 delete codec;
461 } 467 }
462 return success; 468 return success;
463 } 469 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698