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

Unified Diff: src/images/SkImageDecoder_libjpeg.cpp

Issue 23477009: Change SkImageDecoders to take an SkStreamRewindable. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Only switch to SkStreamRewindable when necessary. Created 7 years, 3 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 | « src/images/SkImageDecoder_libico.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libjpeg.cpp
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
index d50e4eb015689335b3910c97f58104bb41dc14c7..43e87a3b4d716eaaf8afaf9dccbf4cd494dd7829 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -65,7 +65,7 @@ static void initialize_info(jpeg_decompress_struct* cinfo, skjpeg_source_mgr* sr
#ifdef SK_BUILD_FOR_ANDROID
class SkJPEGImageIndex {
public:
- SkJPEGImageIndex(SkStream* stream, SkImageDecoder* decoder)
+ SkJPEGImageIndex(SkStreamRewindable* stream, SkImageDecoder* decoder)
: fSrcMgr(stream, decoder)
, fInfoInitialized(false)
, fHuffmanCreated(false)
@@ -195,7 +195,7 @@ public:
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& rect) SK_OVERRIDE;
#endif
virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
@@ -637,7 +637,7 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
}
#ifdef SK_BUILD_FOR_ANDROID
-bool SkJPEGImageDecoder::onBuildTileIndex(SkStream* stream, int *width, int *height) {
+bool SkJPEGImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, int *width, int *height) {
SkAutoTDelete<SkJPEGImageIndex> imageIndex(SkNEW_ARGS(SkJPEGImageIndex, (stream, this)));
jpeg_decompress_struct* cinfo = imageIndex->cinfo();
@@ -1120,7 +1120,7 @@ DEFINE_DECODER_CREATOR(JPEGImageDecoder);
DEFINE_ENCODER_CREATOR(JPEGImageEncoder);
///////////////////////////////////////////////////////////////////////////////
-static bool is_jpeg(SkStream* stream) {
+static bool is_jpeg(SkStreamRewindable* stream) {
static const unsigned char gHeader[] = { 0xFF, 0xD8, 0xFF };
static const size_t HEADER_SIZE = sizeof(gHeader);
@@ -1136,14 +1136,15 @@ static bool is_jpeg(SkStream* stream) {
return true;
}
-static SkImageDecoder* sk_libjpeg_dfactory(SkStream* stream) {
+
+static SkImageDecoder* sk_libjpeg_dfactory(SkStreamRewindable* stream) {
if (is_jpeg(stream)) {
return SkNEW(SkJPEGImageDecoder);
}
return NULL;
}
-static SkImageDecoder::Format get_format_jpeg(SkStream* stream) {
+static SkImageDecoder::Format get_format_jpeg(SkStreamRewindable* stream) {
if (is_jpeg(stream)) {
return SkImageDecoder::kJPEG_Format;
}
@@ -1154,7 +1155,6 @@ static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) {
return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL;
}
-
static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory);
static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg);
static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory);
« no previous file with comments | « src/images/SkImageDecoder_libico.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698