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

Unified Diff: include/core/SkImageDecoder.h

Issue 18083026: Allow decoding JPEG into A8. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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
« no previous file with comments | « no previous file | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImageDecoder.h
diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h
index 191fe53f4c588a0584486fee25b68ee7a2c7ab1f..ea2dcd2341833f7a2f56fffa9a9414f9abfb6762 100644
--- a/include/core/SkImageDecoder.h
+++ b/include/core/SkImageDecoder.h
@@ -139,14 +139,17 @@ public:
Chooser* getChooser() const { return fChooser; }
Chooser* setChooser(Chooser*);
- /** This optional table describes the caller's preferred config based on
+ /**
+ @Deprecated. Use the struct version instead.
+
+ This optional table describes the caller's preferred config based on
information about the src data. For this table, the src attributes are
described in terms of depth (index (8), 16, 32/24) and if there is
per-pixel alpha. These inputs combine to create an index into the
pref[] table, which contains the caller's preferred config for that
input, or kNo_Config if there is no preference.
- To specify no preferrence, call setPrefConfigTable(NULL), which is
+ To specify no preference, call setPrefConfigTable(NULL), which is
the default.
Note, it is still at the discretion of the codec as to what output
@@ -166,6 +169,50 @@ public:
*/
void setPrefConfigTable(const SkBitmap::Config pref[6]);
+ /**
+ * Optional table describing the caller's preferred config based on
+ * information about the src data. The src attributes are described
+ * in terms of depth (8 (index or grayscale), 16, 32/24) and whether
+ * there is per-pixel alpha (does not apply to grayscale). If there
+ * is no preference, kNo_Config should be used for that src config.
+ *
+ * NOTE ABOUT PREFERRED CONFIGS:
+ * If a config is preferred, either using a pref table or as a parameter
+ * to some flavor of decode, it is still at the discretion of the codec
+ * as to what output config is actually returned, as it may not be able
+ * to support the caller's preference.
+ *
+ * If a bitmap is decoded into SkBitmap::A8_Config, the resulting bitmap
+ * will either be a conversion of the grayscale in the case of a
+ * grayscale source or the alpha channel in the case of a source with
+ * an alpha channel.
+ */
+ struct PrefConfigTable {
+ SkBitmap::Config f8Index_NoAlpha;
+ SkBitmap::Config f8Index_YesAlpha;
+ SkBitmap::Config f8Gray;
+ SkBitmap::Config f16bit_NoAlpha;
+ SkBitmap::Config f16bit_YesAlpha;
+ SkBitmap::Config f32_24bit_NoAlpha;
+ SkBitmap::Config f32_24bit_YesAlpha;
+ };
+
+ /**
+ * Set an optional table for specifying the caller's preferred config
+ * based on information about the src data.
+ *
+ * The default is no preference, which will assume the config set by
+ * decode is preferred.
+ */
+ void setPrefConfigTable(const PrefConfigTable&);
+
+ /**
+ * Do not use a PrefConfigTable to determine the output config. This
+ * is the default, so there is no need to call unless a PrefConfigTable
+ * was previously set.
+ */
+ void ignorePrefConfigTable() { fUsePrefTable = false; }
+
SkBitmap::Allocator* getAllocator() const { return fAllocator; }
SkBitmap::Allocator* setAllocator(SkBitmap::Allocator*);
@@ -269,12 +316,8 @@ public:
/** Decode the image stored in the specified file, and store the result
in bitmap. Return true for success or false on failure.
- If pref is kNo_Config, then the decoder is free to choose the most natural
- config given the image data. If pref something other than kNo_Config,
- the decoder will attempt to decode the image into that format, unless
- there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
- config does not support that), in which case the decoder will choose a
- closest match configuration.
+ @param prefConfig If the PrefConfigTable is not set, prefer this config.
+ See NOTE ABOUT PREFERRED CONFIGS.
@param format On success, if format is non-null, it is set to the format
of the decoded file. On failure it is ignored.
@@ -289,12 +332,8 @@ public:
/** Decode the image stored in the specified memory buffer, and store the
result in bitmap. Return true for success or false on failure.
- If pref is kNo_Config, then the decoder is free to choose the most natural
- config given the image data. If pref something other than kNo_Config,
- the decoder will attempt to decode the image into that format, unless
- there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
- config does not support that), in which case the decoder will choose a
- closest match configuration.
+ @param prefConfig If the PrefConfigTable is not set, prefer this config.
+ See NOTE ABOUT PREFERRED CONFIGS.
@param format On success, if format is non-null, it is set to the format
of the decoded buffer. On failure it is ignored.
@@ -337,12 +376,8 @@ public:
/** Decode the image stored in the specified SkStream, and store the result
in bitmap. Return true for success or false on failure.
- If pref is kNo_Config, then the decoder is free to choose the most
- natural config given the image data. If pref something other than
- kNo_Config, the decoder will attempt to decode the image into that
- format, unless there is a conflict (e.g. the image has per-pixel alpha
- and the bitmap's config does not support that), in which case the
- decoder will choose a closest match configuration.
+ @param prefConfig If the PrefConfigTable is not set, prefer this config.
+ See NOTE ABOUT PREFERRED CONFIGS.
@param format On success, if format is non-null, it is set to the format
of the decoded stream. On failure it is ignored.
@@ -443,8 +478,9 @@ protected:
enum SrcDepth {
kIndex_SrcDepth,
+ k8BitGray_SrcDepth,
k16Bit_SrcDepth,
scroggo 2013/07/11 20:37:29 Removed this, since it was never used.
- k32Bit_SrcDepth
+ k32Bit_SrcDepth,
};
/** The subclass, inside onDecode(), calls this to determine the config of
the returned bitmap. SrcDepth and hasAlpha reflect the raw data of the
@@ -462,7 +498,7 @@ private:
SkBitmap::Allocator* fAllocator;
int fSampleSize;
SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false
- SkBitmap::Config fPrefTable[6]; // use if fUsePrefTable is true
+ PrefConfigTable fPrefTable; // use if fUsePrefTable is true
bool fDitherImage;
bool fUsePrefTable;
mutable bool fShouldCancelDecode;
« no previous file with comments | « no previous file | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698