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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/images/SkImageDecoder.cpp
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index 5d94bb1c2db97efd618320213210ef91ee363329..ccdc6dfcdeab8083d6dcdaede08ee5abfe46111c 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -145,31 +145,37 @@ void SkImageDecoder::setPrefConfigTable(const SkBitmap::Config pref[6]) {
fUsePrefTable = false;
} else {
fUsePrefTable = true;
- memcpy(fPrefTable, pref, sizeof(fPrefTable));
+ fPrefTable.fPrefFor_8Index_NoAlpha_src = pref[0];
+ fPrefTable.fPrefFor_8Index_YesAlpha_src = pref[1];
+ fPrefTable.fPrefFor_8Gray_src = SkBitmap::kNo_Config;
+ fPrefTable.fPrefFor_8bpc_NoAlpha_src = pref[4];
+ fPrefTable.fPrefFor_8bpc_YesAlpha_src = pref[5];
}
}
+void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) {
+ fUsePrefTable = true;
+ fPrefTable = prefTable;
+}
+
SkBitmap::Config SkImageDecoder::getPrefConfig(SrcDepth srcDepth,
bool srcHasAlpha) const {
SkBitmap::Config config;
if (fUsePrefTable) {
- int index = 0;
switch (srcDepth) {
case kIndex_SrcDepth:
- index = 0;
+ config = srcHasAlpha ? fPrefTable.fPrefFor_8Index_YesAlpha_src
+ : fPrefTable.fPrefFor_8Index_NoAlpha_src;
break;
- case k16Bit_SrcDepth:
- index = 2;
+ case k8BitGray_SrcDepth:
+ config = fPrefTable.fPrefFor_8Gray_src;
break;
case k32Bit_SrcDepth:
- index = 4;
+ config = srcHasAlpha ? fPrefTable.fPrefFor_8bpc_YesAlpha_src
+ : fPrefTable.fPrefFor_8bpc_NoAlpha_src;
break;
}
- if (srcHasAlpha) {
- index += 1;
- }
- config = fPrefTable[index];
} else {
config = fDefaultPref;
}

Powered by Google App Engine
This is Rietveld 408576698