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

Unified Diff: src/images/SkImageDecoder_libwebp.cpp

Issue 23477009: Change SkImageDecoders to take an SkStreamRewindable. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Remove accidental whitespace change Created 7 years, 4 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
Index: src/images/SkImageDecoder_libwebp.cpp
diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp
index 7fb1cf0e312194e9f5c17ffb6fc4d0806adc9886..57465934645076db952bcb92d0d877fd42dbadeb 100644
--- a/src/images/SkImageDecoder_libwebp.cpp
+++ b/src/images/SkImageDecoder_libwebp.cpp
@@ -58,7 +58,7 @@ static const size_t WEBP_VP8_HEADER_SIZE = 64;
static const size_t WEBP_IDECODE_BUFFER_SZ = (1 << 16);
// Parse headers of RIFF container, and check for valid Webp (VP8) content.
-static bool webp_parse_header(SkStream* stream, int* width, int* height, int* alpha) {
+static bool webp_parse_header(SkStreamRewindable* stream, int* width, int* height, int* alpha) {
unsigned char buffer[WEBP_VP8_HEADER_SIZE];
size_t bytesToRead = WEBP_VP8_HEADER_SIZE;
size_t totalBytesRead = 0;
@@ -117,9 +117,9 @@ public:
}
protected:
- 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;
- virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
+ virtual bool onDecode(SkStreamRewindable* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
private:
/**
@@ -133,10 +133,10 @@ private:
bool setDecodeConfig(SkBitmap* decodedBitmap, int width, int height);
- SkStream* fInputStream;
- int fOrigWidth;
- int fOrigHeight;
- int fHasAlpha;
+ SkStreamRewindable* fInputStream;
+ int fOrigWidth;
+ int fOrigHeight;
+ int fHasAlpha;
bungeman-skia 2013/09/19 16:15:49 Vertical aligning declarations (aka table style de
scroggo 2013/09/25 20:25:09 I could have sworn this was in our style guide. It
typedef SkImageDecoder INHERITED;
};
@@ -192,7 +192,7 @@ static WEBP_CSP_MODE webp_decode_mode(const SkBitmap* decodedBitmap, bool premul
// Incremental WebP image decoding. Reads input buffer of 64K size iteratively
// and decodes this block to appropriate color-space as per config object.
-static bool webp_idecode(SkStream* stream, WebPDecoderConfig* config) {
+static bool webp_idecode(SkStreamRewindable* stream, WebPDecoderConfig* config) {
WebPIDecoder* idec = WebPIDecode(NULL, 0, config);
if (NULL == idec) {
WebPFreeDecBuffer(&config->output);
@@ -307,7 +307,7 @@ bool SkWEBPImageDecoder::setDecodeConfig(SkBitmap* decodedBitmap,
return true;
}
-bool SkWEBPImageDecoder::onBuildTileIndex(SkStream* stream,
+bool SkWEBPImageDecoder::onBuildTileIndex(SkStreamRewindable* stream,
int *width, int *height) {
int origWidth, origHeight, hasAlpha;
if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) {
@@ -407,7 +407,7 @@ bool SkWEBPImageDecoder::onDecodeSubset(SkBitmap* decodedBitmap,
return true;
}
-bool SkWEBPImageDecoder::onDecode(SkStream* stream, SkBitmap* decodedBitmap,
+bool SkWEBPImageDecoder::onDecode(SkStreamRewindable* stream, SkBitmap* decodedBitmap,
Mode mode) {
#ifdef TIME_DECODE
AutoTimeMillis atm("WEBP Decode");
@@ -584,7 +584,7 @@ DEFINE_ENCODER_CREATOR(WEBPImageEncoder);
#include "SkTRegistry.h"
-static SkImageDecoder* sk_libwebp_dfactory(SkStream* stream) {
+static SkImageDecoder* sk_libwebp_dfactory(SkStreamRewindable* stream) {
int width, height, hasAlpha;
if (!webp_parse_header(stream, &width, &height, &hasAlpha)) {
return NULL;
@@ -594,7 +594,7 @@ static SkImageDecoder* sk_libwebp_dfactory(SkStream* stream) {
return SkNEW(SkWEBPImageDecoder);
}
-static SkImageDecoder::Format get_format_webp(SkStream* stream) {
+static SkImageDecoder::Format get_format_webp(SkStreamRewindable* stream) {
int width, height, hasAlpha;
if (webp_parse_header(stream, &width, &height, &hasAlpha)) {
return SkImageDecoder::kWEBP_Format;
@@ -606,6 +606,6 @@ static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NULL;
}
-static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libwebp_dfactory);
-static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_webp);
+static SkTRegistry<SkImageDecoder*, SkStreamRewindable*> gDReg(sk_libwebp_dfactory);
+static SkTRegistry<SkImageDecoder::Format, SkStreamRewindable*> gFormatReg(get_format_webp);
static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libwebp_efactory);

Powered by Google App Engine
This is Rietveld 408576698