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

Unified Diff: src/images/SkDecodingImageGenerator.h

Issue 101973005: SkDecodingImageGenerator now uses SkStreamRewindable (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebased again Created 7 years 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 | « include/core/SkImageDecoder.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkDecodingImageGenerator.h
diff --git a/src/images/SkDecodingImageGenerator.h b/src/images/SkDecodingImageGenerator.h
index 49f1295bf3538cdd69451c8f86cb383eea44596a..dba234bcf19c400d5a005c5c5ac4efe057733267 100644
--- a/src/images/SkDecodingImageGenerator.h
+++ b/src/images/SkDecodingImageGenerator.h
@@ -10,8 +10,10 @@
#include "SkDiscardableMemory.h"
#include "SkImageGenerator.h"
+#include "SkImageInfo.h"
class SkBitmap;
+class SkStreamRewindable;
/**
* Calls into SkImageDecoder::DecodeMemoryToTarget to implement a
@@ -23,7 +25,32 @@ public:
* The constructor will take a reference to the SkData. The
* destructor will unref() it.
*/
- SkDecodingImageGenerator(SkData* data);
+ explicit SkDecodingImageGenerator(SkData* data);
+
+ /*
+ * The SkData version of this constructor is preferred. If the
+ * stream has an underlying SkData (such as a SkMemoryStream)
+ * pass that in.
+ *
+ * This object will unref the stream when done. Since streams
+ * have internal state (position), the caller should not pass a
+ * shared stream in. Pass either a new duplicated stream in or
+ * transfer ownership of the stream. In the latter case, be sure
+ * that there are no other consumers of the stream who will
+ * modify the stream's position. This constructor asserts
+ * stream->unique().
+ *
+ * For example:
+ * SkStreamRewindable* stream;
+ * ...
+ * SkImageGenerator* gen
+ * = SkNEW_ARGS(SkDecodingImageGenerator,
+ * (stream->duplicate()));
+ * ...
+ * SkDELETE(gen);
+ */
+ explicit SkDecodingImageGenerator(SkStreamRewindable* stream);
+
virtual ~SkDecodingImageGenerator();
virtual SkData* refEncodedData() SK_OVERRIDE;
@@ -52,8 +79,42 @@ public:
*/
static bool Install(SkData* data, SkBitmap* destination,
SkDiscardableMemory::Factory* factory = NULL);
+ /**
+ * Install the stream into the destination bitmap, using a new
+ * SkDiscardablePixelRef and a new SkDecodingImageGenerator.
+ *
+ * The SkData version of this function is preferred. If the
+ * stream has an underlying SkData (such as a SkMemoryStream)
+ * pass that in.
+ *
+ * @param stream The source of encoded data that will be passed
+ * to the decoder. The installed SkDecodingImageGenerator will
+ * unref the stream when done. If false is returned, this
+ * function will perform the unref. Since streams have internal
+ * state (position), the caller should not pass a shared stream
+ * in. Pass either a new duplicated stream in or transfer
+ * ownership of the stream. In the latter case, be sure that
+ * there are no other consumers of the stream who will modify the
+ * stream's position. This function will fail if
+ * (!stream->unique()).
+ *
+ * @param destination Upon success, this bitmap will be
+ * configured and have a pixelref installed.
+ *
+ * @param factory If not NULL, this object will be used as a
+ * source of discardable memory when decoding. If NULL, then
+ * SkDiscardableMemory::Create() will be called.
+ *
+ * @return true iff successful.
+ */
+ static bool Install(SkStreamRewindable* stream, SkBitmap* destination,
+ SkDiscardableMemory::Factory* factory = NULL);
private:
- SkData* fData;
+ SkData* fData;
+ SkStreamRewindable* fStream;
+ SkImageInfo fInfo;
+ bool fHasInfo;
+ bool fDoCopyTo;
};
#endif // SkDecodingImageGenerator_DEFINED
« no previous file with comments | « include/core/SkImageDecoder.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698