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

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
« no previous file with comments | « 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..fcba91069a43faaf7fa1341d7af2fae741fd1a9e 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)
@@ -56,6 +57,7 @@ void SkImageDecoder::copyFieldsToOther(SkImageDecoder* other) {
other->fDefaultPref = fDefaultPref;
}
#endif
+ other->setPreserveSrcDepth(fPreserveSrcDepth);
other->setDitherImage(fDitherImage);
other->setSkipWritingZeroes(fSkipWritingZeroes);
other->setPreferQualityOverSpeed(fPreferQualityOverSpeed);
@@ -156,7 +158,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 +178,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;
}
« no previous file with comments | « include/core/SkImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698