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

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 a change in behavior 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
« no previous file with comments | « gyp/utils.gyp ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPicture.h
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index d01cadce891598b77c08db554c5ec4f42051fb10..0bac3f7e9ed62fb4bf8fbe1370594d1ddc9d2ac8 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();
@@ -220,13 +217,20 @@ protected:
SkPictureRecord* fRecord;
int fWidth, fHeight;
+ // Create a new SkPicture from an existing SkPicturePlayback. Ref count of
+ // playback is unchanged.
+ SkPicture(SkPicturePlayback*, int width, int height);
+
// For testing. Derived classes may instantiate an alternate
// 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 unmodified.
+ static bool StreamIsSKP(SkStream*, SkPictInfo*);
private:
- void initFromStream(SkStream*, bool* success, InstallPixelRefProc);
-
friend class SkFlatPicture;
friend class SkPicturePlayback;
« no previous file with comments | « gyp/utils.gyp ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698