Index: include/core/SkImageDecoder.h |
diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h |
index bec40631e7c4813394729adb4668011d33156a92..d8d5b6d85935dc2abe7c3eb875c8028083c01c28 100644 |
--- a/include/core/SkImageDecoder.h |
+++ b/include/core/SkImageDecoder.h |
@@ -1,4 +1,3 @@ |
- |
/* |
* Copyright 2006 The Android Open Source Project |
* |
@@ -6,7 +5,6 @@ |
* found in the LICENSE file. |
*/ |
- |
#ifndef SkImageDecoder_DEFINED |
#define SkImageDecoder_DEFINED |
@@ -17,6 +15,8 @@ |
#include "SkTRegistry.h" |
#include "SkTypes.h" |
+#define SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG |
+ |
class SkStream; |
class SkStreamRewindable; |
@@ -145,7 +145,10 @@ public: |
SK_DECLARE_INST_COUNT(Chooser) |
virtual void begin(int count) {} |
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG |
virtual void inspect(int index, SkBitmap::Config config, int width, int height) {} |
+#endif |
+ virtual void inspect(int index, SkColorType, int width, int height) {} |
/** Return the index of the subimage you want, or -1 to choose none of them. |
*/ |
virtual int choose() = 0; |
@@ -265,10 +268,13 @@ public: |
If a Chooser is installed via setChooser, it may be used to select |
which image to return from a format that contains multiple images. |
*/ |
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG |
bool decode(SkStream*, SkBitmap* bitmap, SkBitmap::Config pref, Mode); |
bool decode(SkStream* stream, SkBitmap* bitmap, Mode mode) { |
return this->decode(stream, bitmap, SkBitmap::kNo_Config, mode); |
} |
+#endif |
+ bool decode(SkStream*, SkBitmap*, SkColorType pref, Mode); |
/** |
* Given a stream, build an index for doing tile-based decode. |
@@ -286,18 +292,21 @@ public: |
* Return true for success. |
* Return false if the index is never built or failing in decoding. |
*/ |
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG |
bool decodeSubset(SkBitmap* bm, const SkIRect& subset, SkBitmap::Config pref); |
- |
SK_ATTR_DEPRECATED("use decodeSubset() instead") |
bool decodeRegion(SkBitmap* bitmap, const SkIRect& rect, SkBitmap::Config pref) { |
return this->decodeSubset(bitmap, rect, pref); |
} |
+#endif |
+ bool decodeSubset(SkBitmap* bm, const SkIRect& subset, SkColorType pref); |
/** Given a stream, this will try to find an appropriate decoder object. |
If none is found, the method returns NULL. |
*/ |
static SkImageDecoder* Factory(SkStreamRewindable*); |
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG |
/** Decode the image stored in the specified file, and store the result |
in bitmap. Return true for success or false on failure. |
@@ -331,6 +340,44 @@ public: |
kDecodePixels_Mode, NULL); |
} |
+ /** Decode the image stored in the specified SkStreamRewindable, and store the result |
+ in bitmap. Return true for success or false on failure. |
+ |
+ @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. |
+ */ |
+ static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap, |
+ SkBitmap::Config prefConfig, Mode, |
+ Format* format = NULL); |
+ static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap) { |
+ return DecodeStream(stream, bitmap, SkBitmap::kNo_Config, |
+ kDecodePixels_Mode, NULL); |
+ } |
+ |
+ /** Return the default config for the running device. |
+ Currently this used as a suggestion to image decoders that need to guess |
+ what config they should decode into. |
+ Default is kNo_Config, but this can be changed with SetDeviceConfig() |
+ */ |
+ static SkBitmap::Config GetDeviceConfig(); |
+ /** Set the default config for the running device. |
+ Currently this used as a suggestion to image decoders that need to guess |
+ what config they should decode into. |
+ Default is kNo_Config. |
+ This can be queried with GetDeviceConfig() |
+ */ |
+ static void SetDeviceConfig(SkBitmap::Config); |
+#endif |
+ static bool DecodeFile(const char file[], SkBitmap* bitmap, |
+ SkColorType pref, Mode, Format* format = NULL); |
+ static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap, |
+ SkColorType pref, Mode, Format* format = NULL); |
+ static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap, |
+ SkColorType pref, Mode, Format* format = NULL); |
+ |
/** |
* Struct containing information about a pixel destination. |
*/ |
@@ -346,37 +393,6 @@ public: |
size_t fRowBytes; |
}; |
- /** Decode the image stored in the specified SkStreamRewindable, and store the result |
- in bitmap. Return true for success or false on failure. |
- |
- @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. |
- */ |
- static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap, |
- SkBitmap::Config prefConfig, Mode, |
- Format* format = NULL); |
- static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap) { |
- return DecodeStream(stream, bitmap, SkBitmap::kNo_Config, |
- kDecodePixels_Mode, NULL); |
- } |
- |
- /** Return the default config for the running device. |
- Currently this used as a suggestion to image decoders that need to guess |
- what config they should decode into. |
- Default is kNo_Config, but this can be changed with SetDeviceConfig() |
- */ |
- static SkBitmap::Config GetDeviceConfig(); |
- /** Set the default config for the running device. |
- Currently this used as a suggestion to image decoders that need to guess |
- what config they should decode into. |
- Default is kNo_Config. |
- This can be queried with GetDeviceConfig() |
- */ |
- static void SetDeviceConfig(SkBitmap::Config); |
- |
protected: |
// must be overridden in subclasses. This guy is called by decode(...) |
virtual bool onDecode(SkStream*, SkBitmap* bitmap, Mode) = 0; |
@@ -439,9 +455,12 @@ public: |
protected: |
SkImageDecoder(); |
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG |
// helper function for decoders to handle the (common) case where there is only |
// once choice available in the image file. |
bool chooseFromOneChoice(SkBitmap::Config config, int width, int height) const; |
+#endif |
+ bool chooseFromOneChoice(SkColorType, int width, int height) const; |
/* Helper for subclasses. Call this to allocate the pixel memory given the bitmap's |
width/height/rowbytes/config. Returns true on success. This method handles checking |
@@ -468,14 +487,20 @@ protected: |
Note: this also takes into account GetDeviceConfig(), so the subclass |
need not call that. |
*/ |
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG |
SkBitmap::Config getPrefConfig(SrcDepth, bool hasAlpha) const; |
+#endif |
+ SkColorType getPrefColorType(SrcDepth, bool hasAlpha) const; |
private: |
Peeker* fPeeker; |
Chooser* fChooser; |
SkBitmap::Allocator* fAllocator; |
int fSampleSize; |
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG |
SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false |
+#endif |
+ SkColorType fDefaultColorType; |
PrefConfigTable fPrefTable; // use if fUsePrefTable is true |
bool fDitherImage; |
bool fUsePrefTable; |