diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-06-28 21:32:00 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-06-28 21:32:00 +0000 |
commit | f1754ec69131801c1a6ed3c704501a9400bbf324 (patch) | |
tree | 1a54d42c519ed1d15b25ed291f04274cbb0d0120 /include/core/SkPicture.h | |
parent | 925cdca8055fe6d6aab7c271d93d224d9b4e4fc8 (diff) |
Replace SkPicture(SkStream) constructors with a factory.
SkPicture:
Remove the constructors which take an SkStream as an argument. Rather
than having to check a variable for success, the factory will return
NULL on failure.
Add a protected function for determining if an SkStream is an SKP
to share code with SkTimedPicture.
In the factory, check for a NULL SkStream.
Use a default decoder (from BUG:
https://code.google.com/p/skia/issues/detail?id=1325)
SkDebuggerGUI:
Call SkPicture::CreateFromStream when necessary.
Write a factory for creating SkTimedPictures and use it.
Use the factory throughout tools.
Add include/lazy to utils and effects gyp include_dirs so SkPicture.h
can reference SkImageDecoder.h which references SkBitmapFactory.h (in
include/lazy).
Changes code Chromium uses, so this will require a temporary Skia
and then a change to Chromium to use the new Skia code.
TODO: Create a decoder that does nothing to be used by pinspect,
lua pictures, etc, and allow it to not assert in SkOrderedReadBuffer.
R=reed@google.com
Review URL: https://codereview.chromium.org/17113004
git-svn-id: http://skia.googlecode.com/svn/trunk@9822 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkPicture.h')
-rw-r--r-- | include/core/SkPicture.h | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h index d01cadce89..0bac3f7e9e 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; |