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

Unified Diff: src/images/SkImageDecoder.cpp

Issue 371273007: add setPreserveSrcDepth to replace PrefTable API for android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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
« include/core/SkImageDecoder.h ('K') | « include/core/SkImageDecoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder.cpp
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index fe61906357d43bd88bb52299dbeb903a4d60f90e..8447ed46f71abc0e39492e5aeb47a6c614257da9 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -22,6 +22,7 @@ SkImageDecoder::SkImageDecoder()
, fAllocator(NULL)
, fSampleSize(1)
, fDefaultPref(kUnknown_SkColorType)
+ , fPreserveSrcDepth(false)
, fDitherImage(true)
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
, fUsePrefTable(false)
@@ -156,7 +157,6 @@ void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) {
SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha) const {
SkColorType ct = fDefaultPref;
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
-
if (fUsePrefTable) {
// Until we kill or change the PrefTable, we have to go into Config land for a moment.
SkBitmap::Config config = SkBitmap::kNo_Config;
@@ -177,6 +177,19 @@ SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha
ct = SkBitmapConfigToColorType(config);
}
#endif
+ if (fPreserveSrcDepth) {
+ switch (srcDepth) {
+ case kIndex_SrcDepth:
+ ct = kIndex_8_SkColorType;
+ break;
+ case k8BitGray_SrcDepth:
+ ct = kN32_SkColorType;
+ break;
+ case k32Bit_SrcDepth:
+ ct = kN32_SkColorType;
+ break;
+ }
+ }
return ct;
}
« include/core/SkImageDecoder.h ('K') | « include/core/SkImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698