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

Unified Diff: include/core/SkPicture.h

Issue 17113004: Replace SkPicture(SkStream) constructors with a factory. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Remove dead function declaration. Created 7 years, 6 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: include/core/SkPicture.h
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index d01cadce891598b77c08db554c5ec4f42051fb10..fd66e7e1c53ef22cea9738fc840d088162d7c4f7 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -11,6 +11,7 @@
#define SkPicture_DEFINED
#include "SkBitmap.h"
+#include "SkImageDecoder.h"
#include "SkRefCnt.h"
class SkBBoxHierarchy;
@@ -22,6 +23,8 @@ class SkPictureRecord;
class SkStream;
class SkWStream;
+struct SkPictInfo;
+
/** \class SkPicture
The SkPicture class records the drawing commands made to a canvas, to
@@ -42,13 +45,6 @@ public:
SkPicture(const SkPicture& src);
/**
- * Recreate a picture that was serialized into a stream.
- * On failure, silently creates an empty picture.
- * @param SkStream Serialized picture data.
- */
- explicit SkPicture(SkStream*);
-
- /**
* Function signature defining a function that sets up an SkBitmap from encoded data. On
* success, the SkBitmap should have its Config, width, height, rowBytes and pixelref set.
* If the installed pixelref has decoded the data into pixels, then the src buffer need not be
@@ -64,12 +60,13 @@ public:
/**
* Recreate a picture that was serialized into a stream.
* @param SkStream Serialized picture data.
- * @param success Output parameter. If non-NULL, will be set to true if the picture was
- * deserialized successfully and false otherwise.
* @param proc Function pointer for installing pixelrefs on SkBitmaps representing the
* encoded bitmap data from the stream.
+ * @return A new SkPicture representing the serialized data, or NULL if the stream is
+ * invalid.
*/
- SkPicture(SkStream*, bool* success, InstallPixelRefProc proc);
+ static SkPicture* CreateFromStream(SkStream*,
+ InstallPixelRefProc proc = &SkImageDecoder::DecodeMemory);
virtual ~SkPicture();
@@ -224,9 +221,12 @@ protected:
// SkBBoxHierarchy implementation
virtual SkBBoxHierarchy* createBBoxHierarchy() const;
+ // Return true if the SkStream represents a serialized picture, and fills out
+ // SkPictInfo. After this function returns, the SkStream is not rewound; it
+ // will be ready to be parsed to create an SkPicturePlayback.
+ // If false is returned, SkPictInfo is still modified.
+ static bool StreamIsSKP(SkStream*, SkPictInfo*);
private:
- void initFromStream(SkStream*, bool* success, InstallPixelRefProc);
-
friend class SkFlatPicture;
friend class SkPicturePlayback;

Powered by Google App Engine
This is Rietveld 408576698