aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2014-06-12 17:40:00 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-12 17:40:00 -0700
commitbfefc7c95fc0e8ebd5000c68f6d16e1a3ea0e71e (patch)
tree9e68e04fa38c4e28ac478786bfe6d402a3bff239 /include
parent9a8699f45c2bd8dac0c06829a06b6b244d19b6b2 (diff)
hide Config in SkImageDecoder -- use SkColorType instead
patch from issue 334613003 TBR=scroggo Author: reed@chromium.org Review URL: https://codereview.chromium.org/334793002
Diffstat (limited to 'include')
-rw-r--r--include/core/SkImageDecoder.h83
1 files changed, 47 insertions, 36 deletions
diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h
index 58920992e1..ed17f0fbf8 100644
--- a/include/core/SkImageDecoder.h
+++ b/include/core/SkImageDecoder.h
@@ -239,22 +239,22 @@ public:
}
/** Passed to the decode method. If kDecodeBounds_Mode is passed, then
- only the bitmap's width/height/config need be set. If kDecodePixels_Mode
+ only the bitmap's info need be set. If kDecodePixels_Mode
is passed, then the bitmap must have pixels or a pixelRef.
*/
enum Mode {
- kDecodeBounds_Mode, //!< only return width/height/config in bitmap
+ kDecodeBounds_Mode, //!< only return info in bitmap
kDecodePixels_Mode //!< return entire bitmap (including pixels)
};
/** Given a stream, decode it into the specified bitmap.
- If the decoder can decompress the image, it calls bitmap.setConfig(),
+ If the decoder can decompress the image, it calls bitmap.setInfo(),
and then if the Mode is kDecodePixels_Mode, call allocPixelRef(),
which will allocated a pixelRef. To access the pixel memory, the codec
needs to call lockPixels/unlockPixels on the
bitmap. It can then set the pixels with the decompressed image.
* If the image cannot be decompressed, return false. After the
- * decoding, the function converts the decoded config in bitmap
+ * decoding, the function converts the decoded colortype in bitmap
* to pref if possible. Whether a conversion is feasible is
* tested by Bitmap::canCopyTo(pref).
@@ -265,13 +265,10 @@ public:
If a Peeker is installed via setPeeker, it may be used to peek into
meta data during the decode.
-
- If a Chooser is installed via setChooser, it may be used to select
- which image to return from a format that contains multiple images.
*/
- bool decode(SkStream*, SkBitmap* bitmap, SkBitmap::Config pref, Mode);
+ bool decode(SkStream*, SkBitmap* bitmap, SkColorType pref, Mode);
bool decode(SkStream* stream, SkBitmap* bitmap, Mode mode) {
- return this->decode(stream, bitmap, SkBitmap::kNo_Config, mode);
+ return this->decode(stream, bitmap, kUnknown_SkColorType, mode);
}
/**
@@ -290,7 +287,7 @@ public:
* Return true for success.
* Return false if the index is never built or failing in decoding.
*/
- bool decodeSubset(SkBitmap* bm, const SkIRect& subset, SkBitmap::Config pref);
+ 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.
@@ -300,34 +297,31 @@ public:
/** Decode the image stored in the specified file, 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.
+ @param pref If the PrefConfigTable is not set, prefer this colortype.
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.
*/
- static bool DecodeFile(const char file[], SkBitmap* bitmap,
- SkBitmap::Config prefConfig, Mode,
+ static bool DecodeFile(const char file[], SkBitmap* bitmap, SkColorType pref, Mode,
Format* format = NULL);
static bool DecodeFile(const char file[], SkBitmap* bitmap) {
- return DecodeFile(file, bitmap, SkBitmap::kNo_Config,
- kDecodePixels_Mode, NULL);
+ return DecodeFile(file, bitmap, kUnknown_SkColorType, kDecodePixels_Mode, NULL);
}
+
/** Decode the image stored in the specified memory buffer, 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.
+ @param pref If the PrefConfigTable is not set, prefer this colortype.
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.
*/
- static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap,
- SkBitmap::Config prefConfig, Mode,
- Format* format = NULL);
+ static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap, SkColorType pref,
+ Mode, Format* format = NULL);
static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap){
- return DecodeMemory(buffer, size, bitmap, SkBitmap::kNo_Config,
- kDecodePixels_Mode, NULL);
+ return DecodeMemory(buffer, size, bitmap, kUnknown_SkColorType, kDecodePixels_Mode, NULL);
}
/**
@@ -348,20 +342,39 @@ public:
/** 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.
+ @param pref If the PrefConfigTable is not set, prefer this colortype.
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,
+ static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap, SkColorType pref, Mode,
Format* format = NULL);
static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap) {
- return DecodeStream(stream, bitmap, SkBitmap::kNo_Config,
- kDecodePixels_Mode, NULL);
+ return DecodeStream(stream, bitmap, kUnknown_SkColorType, kDecodePixels_Mode, NULL);
}
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG
+ bool decode(SkStream*, SkBitmap* bitmap, SkBitmap::Config pref, Mode mode) {
+ return this->decode(stream, bitmap, SkBitmapConfigToColorType(pref), mode);
+ }
+ bool decodeSubset(SkBitmap* bm, const SkIRect& subset, SkBitmap::Config pref) {
+ return this->decodeSubset(bm, subset, SkBitmapConfigToColorType(pref));
+ }
+ static bool DecodeFile(const char file[], SkBitmap* bitmap, SkBitmapConfig pref, Mode mode,
+ Format* format = NULL) {
+ return DecodeFile(file, bitmap, SkBitmapConfigToColorType(pref), mode, format);
+ }
+ static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap,
+ SkBitmap::Config pref, Mode mode, Format* format = NULL) {
+ return DecodeMemory(buffer, size, bitmap, SkBitmapConfigToColorType(pref), mode, format);
+ }
+ static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap, SkBitmap::Config pref,
+ Mode mode, Format* format = NULL) {
+ return DecodeStream(stream, bitmap, SkBitmapConfigToColorType(pref), mode, format);
+ }
+#endif
+
protected:
// must be overridden in subclasses. This guy is called by decode(...)
virtual bool onDecode(SkStream*, SkBitmap* bitmap, Mode) = 0;
@@ -403,12 +416,6 @@ protected:
*/
void copyFieldsToOther(SkImageDecoder* other);
- /**
- * Return the default preference being used by the current or latest call to
- * decode.
- */
- SkBitmap::Config getDefaultPref() { return fDefaultPref; }
-
/** Can be queried from within onDecode, to see if the user (possibly in
a different thread) has requested the decode to cancel. If this returns
true, your onDecode() should stop and return false.
@@ -424,15 +431,19 @@ public:
protected:
SkImageDecoder();
+ /**
+ * Return the default preference being used by the current or latest call to decode.
+ */
+ SkColorType getDefaultPref() { return fDefaultPref; }
+
#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
// helper function for decoders to handle the (common) case where there is only
// once choice available in the image file.
bool chooseFromOneChoice(SkColorType, int width, int height) const;
#endif
- /* 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
- for an optional Allocator.
+ /* Helper for subclasses. Call this to allocate the pixel memory given the bitmap's info.
+ Returns true on success. This method handles checking for an optional Allocator.
*/
bool allocPixelRef(SkBitmap*, SkColorTable*) const;
@@ -461,7 +472,7 @@ private:
#endif
SkBitmap::Allocator* fAllocator;
int fSampleSize;
- SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false
+ SkColorType fDefaultPref; // use if fUsePrefTable is false
PrefConfigTable fPrefTable; // use if fUsePrefTable is true
bool fDitherImage;
bool fUsePrefTable;