Change SkImageDecoders to take an SkStreamRewindable.
Only affects factories, static functions that will use the factories,
and subset decoding, which all require rewinding. The decoders
themselves continue to take an SkStream. This is merely documentation
stating which functions will possibly rewind the passed in SkStream.
This is part of the general change to coordinate SkStreams with
Android's streams, which don't necessarily support rewinding in all
cases.
Update callers to use SkStreamRewindable.
BUG=skia:1572
R=bungeman@google.com, reed@google.com
Review URL: https://codereview.chromium.org/23477009
git-svn-id: http://skia.googlecode.com/svn/trunk@11460 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index 56c19fd..b6aa329 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -42,7 +42,7 @@
class SkPNGImageIndex {
public:
- SkPNGImageIndex(SkStream* stream, png_structp png_ptr, png_infop info_ptr)
+ SkPNGImageIndex(SkStreamRewindable* stream, png_structp png_ptr, png_infop info_ptr)
: fStream(stream)
, fPng_ptr(png_ptr)
, fInfo_ptr(info_ptr)
@@ -56,10 +56,10 @@
}
}
- SkAutoTUnref<SkStream> fStream;
- png_structp fPng_ptr;
- png_infop fInfo_ptr;
- SkBitmap::Config fConfig;
+ SkAutoTUnref<SkStreamRewindable> fStream;
+ png_structp fPng_ptr;
+ png_infop fInfo_ptr;
+ SkBitmap::Config fConfig;
};
class SkPNGImageDecoder : public SkImageDecoder {
@@ -77,7 +77,7 @@
protected:
#ifdef SK_BUILD_FOR_ANDROID
- virtual bool onBuildTileIndex(SkStream *stream, int *width, int *height) SK_OVERRIDE;
+ virtual bool onBuildTileIndex(SkStreamRewindable *stream, int *width, int *height) SK_OVERRIDE;
virtual bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& region) SK_OVERRIDE;
#endif
virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
@@ -123,7 +123,7 @@
#ifdef SK_BUILD_FOR_ANDROID
static void sk_seek_fn(png_structp png_ptr, png_uint_32 offset) {
- SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr);
+ SkStreamRewindable* sk_stream = (SkStreamRewindable*) png_get_io_ptr(png_ptr);
if (!sk_stream->rewind()) {
png_error(png_ptr, "Failed to rewind stream!");
}
@@ -667,7 +667,7 @@
#ifdef SK_BUILD_FOR_ANDROID
-bool SkPNGImageDecoder::onBuildTileIndex(SkStream* sk_stream, int *width, int *height) {
+bool SkPNGImageDecoder::onBuildTileIndex(SkStreamRewindable* sk_stream, int *width, int *height) {
png_structp png_ptr;
png_infop info_ptr;
@@ -1174,7 +1174,7 @@
DEFINE_ENCODER_CREATOR(PNGImageEncoder);
///////////////////////////////////////////////////////////////////////////////
-static bool is_png(SkStream* stream) {
+static bool is_png(SkStreamRewindable* stream) {
char buf[PNG_BYTES_TO_CHECK];
if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK &&
!png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) {
@@ -1183,14 +1183,14 @@
return false;
}
-SkImageDecoder* sk_libpng_dfactory(SkStream* stream) {
+SkImageDecoder* sk_libpng_dfactory(SkStreamRewindable* stream) {
if (is_png(stream)) {
return SkNEW(SkPNGImageDecoder);
}
return NULL;
}
-static SkImageDecoder::Format get_format_png(SkStream* stream) {
+static SkImageDecoder::Format get_format_png(SkStreamRewindable* stream) {
if (is_png(stream)) {
return SkImageDecoder::kPNG_Format;
}