2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2007 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPicture_DEFINED
|
|
|
|
#define SkPicture_DEFINED
|
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
#include "SkImageDecoder.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
#include "SkRefCnt.h"
|
2015-05-19 18:11:26 +00:00
|
|
|
#include "SkTypes.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-03-19 21:24:25 +00:00
|
|
|
class GrContext;
|
2015-05-19 18:11:26 +00:00
|
|
|
class SkBigPicture;
|
2015-01-07 15:28:41 +00:00
|
|
|
class SkBitmap;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkCanvas;
|
2014-07-01 15:47:04 +00:00
|
|
|
class SkPictureData;
|
2014-12-11 18:53:58 +00:00
|
|
|
class SkPixelSerializer;
|
2015-08-18 15:29:59 +00:00
|
|
|
class SkRefCntSet;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkStream;
|
2015-08-18 15:29:59 +00:00
|
|
|
class SkTypefacePlayback;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkWStream;
|
2013-06-28 21:32:00 +00:00
|
|
|
struct SkPictInfo;
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** \class SkPicture
|
|
|
|
|
2015-05-19 18:11:26 +00:00
|
|
|
An SkPicture records drawing commands made to a canvas to be played back at a later time.
|
|
|
|
This base class handles serialization and a few other miscellany.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2015-05-20 17:55:49 +00:00
|
|
|
class SK_API SkPicture : public SkRefCnt {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2015-05-19 18:11:26 +00:00
|
|
|
virtual ~SkPicture();
|
2014-03-16 19:46:36 +00:00
|
|
|
|
2012-06-25 14:36:28 +00:00
|
|
|
/**
|
2013-02-22 21:38:35 +00:00
|
|
|
* 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
|
|
|
|
* copied. If the pixelref defers the actual decode until its lockPixels() is called, then it
|
|
|
|
* must make a copy of the src buffer.
|
|
|
|
* @param src Encoded data.
|
|
|
|
* @param length Size of the encoded data, in bytes.
|
|
|
|
* @param dst SkBitmap to install the pixel ref on.
|
|
|
|
* @param bool Whether or not a pixel ref was successfully installed.
|
2012-06-25 14:36:28 +00:00
|
|
|
*/
|
2013-02-22 21:38:35 +00:00
|
|
|
typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap* dst);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recreate a picture that was serialized into a stream.
|
2015-01-21 20:09:53 +00:00
|
|
|
* @param SkStream Serialized picture data. Ownership is unchanged by this call.
|
2013-02-22 21:38:35 +00:00
|
|
|
* @param proc Function pointer for installing pixelrefs on SkBitmaps representing the
|
|
|
|
* encoded bitmap data from the stream.
|
2013-06-28 21:32:00 +00:00
|
|
|
* @return A new SkPicture representing the serialized data, or NULL if the stream is
|
|
|
|
* invalid.
|
2013-02-22 21:38:35 +00:00
|
|
|
*/
|
2013-06-28 21:32:00 +00:00
|
|
|
static SkPicture* CreateFromStream(SkStream*,
|
|
|
|
InstallPixelRefProc proc = &SkImageDecoder::DecodeMemory);
|
2013-02-22 21:38:35 +00:00
|
|
|
|
2014-02-07 12:20:04 +00:00
|
|
|
/**
|
|
|
|
* Recreate a picture that was serialized into a buffer. If the creation requires bitmap
|
|
|
|
* decoding, the decoder must be set on the SkReadBuffer parameter by calling
|
|
|
|
* SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuffer().
|
|
|
|
* @param SkReadBuffer Serialized picture data.
|
|
|
|
* @return A new SkPicture representing the serialized data, or NULL if the buffer is
|
|
|
|
* invalid.
|
|
|
|
*/
|
|
|
|
static SkPicture* CreateFromBuffer(SkReadBuffer&);
|
|
|
|
|
2015-01-07 15:28:41 +00:00
|
|
|
/**
|
|
|
|
* Subclasses of this can be passed to playback(). During the playback
|
|
|
|
* of the picture, this callback will periodically be invoked. If its
|
|
|
|
* abort() returns true, then picture playback will be interrupted.
|
|
|
|
*
|
|
|
|
* The resulting drawing is undefined, as there is no guarantee how often the
|
|
|
|
* callback will be invoked. If the abort happens inside some level of nested
|
|
|
|
* calls to save(), restore will automatically be called to return the state
|
|
|
|
* to the same level it was before the playback call was made.
|
|
|
|
*/
|
|
|
|
class SK_API AbortCallback {
|
|
|
|
public:
|
|
|
|
AbortCallback() {}
|
|
|
|
virtual ~AbortCallback() {}
|
|
|
|
virtual bool abort() = 0;
|
|
|
|
};
|
|
|
|
|
2014-09-04 15:42:50 +00:00
|
|
|
/** Replays the drawing commands on the specified canvas. Note that
|
|
|
|
this has the effect of unfurling this picture into the destination
|
|
|
|
canvas. Using the SkCanvas::drawPicture entry point gives the destination
|
|
|
|
canvas the option of just taking a ref.
|
2013-05-20 17:02:41 +00:00
|
|
|
@param canvas the canvas receiving the drawing commands.
|
2014-09-04 15:42:50 +00:00
|
|
|
@param callback a callback that allows interruption of playback
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2015-05-19 18:11:26 +00:00
|
|
|
virtual void playback(SkCanvas*, AbortCallback* = NULL) const = 0;
|
2015-05-18 20:47:17 +00:00
|
|
|
|
2015-05-19 18:11:26 +00:00
|
|
|
/** Return a cull rect for this picture.
|
|
|
|
Ops recorded into this picture that attempt to draw outside the cull might not be drawn.
|
Revert of Sketch splitting SkPicture into an interface and SkBigPicture. (patchset #25 id:480001 of https://codereview.chromium.org/1112523006/)
Reason for revert:
win_chromium_compile_dbg_ng
FAILED: ninja -t msvc -e environment.x86 -- E:\b\build\goma/gomacc "E:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\third_party\skia\src\core\skia.SkBitmapHeap.obj.rsp /c ..\..\third_party\skia\src\core\SkBitmapHeap.cpp /Foobj\third_party\skia\src\core\skia.SkBitmapHeap.obj /Fdobj\skia\skia.cc.pdb
e:\b\build\slave\win\build\src\third_party\skia\include\core\skpicture.h(176) : error C2487: 'CURRENT_PICTURE_VERSION' : member of dll interface class may not be declared with dll interface
Original issue's description:
> Sketch splitting SkPicture into an interface and SkBigPicture.
>
> Adds small pictures for drawRect(), drawTextBlob(), and drawPath().
> These cover about 89% of draw calls from Blink SKPs,
> and about 25% of draw calls from our GMs.
>
> SkPicture handles:
> - serialization and deserialization
> - unique IDs
>
> Everything else is left to the subclasses:
> - playback(), cullRect()
> - hasBitmap(), hasText(), suitableForGPU(), etc.
> - LayerInfo / AccelData if applicable.
>
> The time to record a 1-op picture improves a good chunk
> (2 mallocs to 1), and the time to record a 0-op picture
> greatly improves (2 mallocs to none):
>
> picture_overhead_draw: 450ns -> 350ns
> picture_overhead_nodraw: 300ns -> 90ns
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/c92c129ff85b05a714bd1bf921c02d5e14651f8b
>
> Latest blink_linux_rel:
>
> http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/61248
>
> Committed: https://skia.googlesource.com/skia/+/15877b6eae33a9282458bdb904a6d00440eca0ec
TBR=reed@google.com,robertphillips@google.com,fmalita@chromium.org,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1130283004
2015-05-18 21:53:43 +00:00
|
|
|
*/
|
2015-05-19 18:11:26 +00:00
|
|
|
virtual SkRect cullRect() const = 0;
|
|
|
|
|
|
|
|
/** Returns a non-zero value unique among all pictures. */
|
2015-04-07 13:34:05 +00:00
|
|
|
uint32_t uniqueID() const;
|
2014-04-02 23:51:13 +00:00
|
|
|
|
2014-12-11 18:53:58 +00:00
|
|
|
/**
|
|
|
|
* Serialize to a stream. If non NULL, serializer will be used to serialize
|
2015-09-04 18:36:39 +00:00
|
|
|
* bitmaps and images in the picture.
|
Add the ability to provide function pointers to SkPicture serialization
and deserialization for encoding and decoding bitmaps.
Remove kForceFlattenBitmapPixels_Flag, which is no longer used.
When an SkOrderedReadBuffer needs to read a bitmap, if it does not
have an image decoder, use a dummy bitmap.
In GM, add a tolerance option for color differences, used when
testing picture serialization, so it can assume two images are the
same even though PNG encoding/decoding may have resulted in small
differences.
Create dummy implementations for SkImageDecoder and SkImageEncoder
functions in SkImageDecoder_empty so that a project that does not
want to include the images project it can still build.
Allow ports to build without images project.
In Mac's image encoder, copy 4444 to 8888 before encoding.
Add SkWriter32::reservePad, to provide a pointer to write non 4 byte
aligned data, padded with zeroes.
In bench_ and render_ pictures, pass decode function to SkPicture
creation from a stream.
BUG=https://code.google.com/p/skia/issues/detail?id=842
Review URL: https://codereview.appspot.com/6551071
git-svn-id: http://skia.googlecode.com/svn/trunk@5818 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-10-04 21:46:08 +00:00
|
|
|
*/
|
2015-05-19 18:11:26 +00:00
|
|
|
void serialize(SkWStream*, SkPixelSerializer* = NULL) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-02-07 12:20:04 +00:00
|
|
|
/**
|
|
|
|
* Serialize to a buffer.
|
|
|
|
*/
|
|
|
|
void flatten(SkWriteBuffer&) const;
|
|
|
|
|
2013-10-24 11:12:47 +00:00
|
|
|
/**
|
|
|
|
* Returns true if any bitmaps may be produced when this SkPicture
|
|
|
|
* is replayed.
|
|
|
|
*/
|
2015-05-19 18:11:26 +00:00
|
|
|
virtual bool willPlayBackBitmaps() const = 0;
|
|
|
|
|
|
|
|
/** Return the approximate number of operations in this picture. This
|
|
|
|
* number may be greater or less than the number of SkCanvas calls
|
|
|
|
* recorded: some calls may be recorded as more than one operation, or some
|
|
|
|
* calls may be optimized away.
|
|
|
|
*/
|
|
|
|
virtual int approximateOpCount() const = 0;
|
|
|
|
|
|
|
|
/** Return true if this picture contains text.
|
|
|
|
*/
|
|
|
|
virtual bool hasText() const = 0;
|
|
|
|
|
|
|
|
/** Returns the approximate byte size of this picture, not including large ref'd objects. */
|
|
|
|
virtual size_t approximateBytesUsed() const = 0;
|
2013-10-24 11:12:47 +00:00
|
|
|
|
2014-03-03 19:18:39 +00:00
|
|
|
/** Return true if the SkStream/Buffer represents a serialized picture, and
|
|
|
|
fills out SkPictInfo. After this function returns, the data source is not
|
2014-03-04 03:02:32 +00:00
|
|
|
rewound so it will have to be manually reset before passing to
|
2014-03-03 19:18:39 +00:00
|
|
|
CreateFromStream or CreateFromBuffer. Note, CreateFromStream and
|
|
|
|
CreateFromBuffer perform this check internally so these entry points are
|
|
|
|
intended for stand alone tools.
|
|
|
|
If false is returned, SkPictInfo is unmodified.
|
|
|
|
*/
|
|
|
|
static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*);
|
2014-08-29 15:03:56 +00:00
|
|
|
static bool InternalOnly_BufferIsSKP(SkReadBuffer*, SkPictInfo*);
|
2014-03-03 19:18:39 +00:00
|
|
|
|
2015-05-19 18:11:26 +00:00
|
|
|
/** Return true if the picture is suitable for rendering on the GPU. */
|
|
|
|
bool suitableForGpuRasterization(GrContext*, const char** whyNot = NULL) const;
|
Revert of Sketch splitting SkPicture into an interface and SkBigPicture. (patchset #22 id:420001 of https://codereview.chromium.org/1112523006/)
Reason for revert:
speculative revert to fix failures in DEPS roll
Original issue's description:
> Sketch splitting SkPicture into an interface and SkBigPicture.
>
> Adds small pictures for drawRect(), drawTextBlob(), and drawPath().
> These cover about 89% of draw calls from Blink SKPs,
> and about 25% of draw calls from our GMs.
>
> SkPicture handles:
> - serialization and deserialization
> - unique IDs
>
> Everything else is left to the subclasses:
> - playback(), cullRect()
> - hasBitmap(), hasText(), suitableForGPU(), etc.
> - LayerInfo / AccelData if applicable.
>
> The time to record a 1-op picture improves a good chunk
> (2 mallocs to 1), and the time to record a 0-op picture
> greatly improves (2 mallocs to none):
>
> picture_overhead_draw: 450ns -> 350ns
> picture_overhead_nodraw: 300ns -> 90ns
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/c92c129ff85b05a714bd1bf921c02d5e14651f8b
TBR=reed@google.com,robertphillips@google.com,mtklein@google.com,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1130333002
2015-05-08 00:30:13 +00:00
|
|
|
|
2015-05-19 18:11:26 +00:00
|
|
|
// Sent via SkMessageBus from destructor.
|
|
|
|
struct DeletionMessage { int32_t fUniqueID; }; // TODO: -> uint32_t?
|
2014-11-21 19:06:04 +00:00
|
|
|
|
2015-05-19 18:11:26 +00:00
|
|
|
// Returns NULL if this is not an SkBigPicture.
|
|
|
|
virtual const SkBigPicture* asSkBigPicture() const { return NULL; }
|
2014-11-24 16:20:57 +00:00
|
|
|
|
2015-06-16 16:28:37 +00:00
|
|
|
// Global setting to enable or disable security precautions for serialization.
|
|
|
|
static void SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set);
|
|
|
|
static bool PictureIOSecurityPrecautionsEnabled();
|
|
|
|
|
2015-05-19 18:11:26 +00:00
|
|
|
private:
|
|
|
|
// Subclass whitelist.
|
|
|
|
SkPicture();
|
|
|
|
friend class SkBigPicture;
|
|
|
|
friend class SkEmptyPicture;
|
|
|
|
template <typename> friend class SkMiniPicture;
|
Revert of Sketch splitting SkPicture into an interface and SkBigPicture. (patchset #25 id:480001 of https://codereview.chromium.org/1112523006/)
Reason for revert:
win_chromium_compile_dbg_ng
FAILED: ninja -t msvc -e environment.x86 -- E:\b\build\goma/gomacc "E:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\third_party\skia\src\core\skia.SkBitmapHeap.obj.rsp /c ..\..\third_party\skia\src\core\SkBitmapHeap.cpp /Foobj\third_party\skia\src\core\skia.SkBitmapHeap.obj /Fdobj\skia\skia.cc.pdb
e:\b\build\slave\win\build\src\third_party\skia\include\core\skpicture.h(176) : error C2487: 'CURRENT_PICTURE_VERSION' : member of dll interface class may not be declared with dll interface
Original issue's description:
> Sketch splitting SkPicture into an interface and SkBigPicture.
>
> Adds small pictures for drawRect(), drawTextBlob(), and drawPath().
> These cover about 89% of draw calls from Blink SKPs,
> and about 25% of draw calls from our GMs.
>
> SkPicture handles:
> - serialization and deserialization
> - unique IDs
>
> Everything else is left to the subclasses:
> - playback(), cullRect()
> - hasBitmap(), hasText(), suitableForGPU(), etc.
> - LayerInfo / AccelData if applicable.
>
> The time to record a 1-op picture improves a good chunk
> (2 mallocs to 1), and the time to record a 0-op picture
> greatly improves (2 mallocs to none):
>
> picture_overhead_draw: 450ns -> 350ns
> picture_overhead_nodraw: 300ns -> 90ns
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/c92c129ff85b05a714bd1bf921c02d5e14651f8b
>
> Latest blink_linux_rel:
>
> http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/61248
>
> Committed: https://skia.googlesource.com/skia/+/15877b6eae33a9282458bdb904a6d00440eca0ec
TBR=reed@google.com,robertphillips@google.com,fmalita@chromium.org,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1130283004
2015-05-18 21:53:43 +00:00
|
|
|
|
2015-08-18 15:29:59 +00:00
|
|
|
void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const;
|
|
|
|
static SkPicture* CreateFromStream(SkStream*,
|
|
|
|
InstallPixelRefProc proc,
|
|
|
|
SkTypefacePlayback*);
|
|
|
|
friend class SkPictureData;
|
|
|
|
|
2015-05-19 18:11:26 +00:00
|
|
|
virtual int numSlowPaths() const = 0;
|
|
|
|
friend struct SkPathCounter;
|
Revert of Sketch splitting SkPicture into an interface and SkBigPicture. (patchset #25 id:480001 of https://codereview.chromium.org/1112523006/)
Reason for revert:
win_chromium_compile_dbg_ng
FAILED: ninja -t msvc -e environment.x86 -- E:\b\build\goma/gomacc "E:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\third_party\skia\src\core\skia.SkBitmapHeap.obj.rsp /c ..\..\third_party\skia\src\core\SkBitmapHeap.cpp /Foobj\third_party\skia\src\core\skia.SkBitmapHeap.obj /Fdobj\skia\skia.cc.pdb
e:\b\build\slave\win\build\src\third_party\skia\include\core\skpicture.h(176) : error C2487: 'CURRENT_PICTURE_VERSION' : member of dll interface class may not be declared with dll interface
Original issue's description:
> Sketch splitting SkPicture into an interface and SkBigPicture.
>
> Adds small pictures for drawRect(), drawTextBlob(), and drawPath().
> These cover about 89% of draw calls from Blink SKPs,
> and about 25% of draw calls from our GMs.
>
> SkPicture handles:
> - serialization and deserialization
> - unique IDs
>
> Everything else is left to the subclasses:
> - playback(), cullRect()
> - hasBitmap(), hasText(), suitableForGPU(), etc.
> - LayerInfo / AccelData if applicable.
>
> The time to record a 1-op picture improves a good chunk
> (2 mallocs to 1), and the time to record a 0-op picture
> greatly improves (2 mallocs to none):
>
> picture_overhead_draw: 450ns -> 350ns
> picture_overhead_nodraw: 300ns -> 90ns
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/c92c129ff85b05a714bd1bf921c02d5e14651f8b
>
> Latest blink_linux_rel:
>
> http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/61248
>
> Committed: https://skia.googlesource.com/skia/+/15877b6eae33a9282458bdb904a6d00440eca0ec
TBR=reed@google.com,robertphillips@google.com,fmalita@chromium.org,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1130283004
2015-05-18 21:53:43 +00:00
|
|
|
|
2014-08-29 15:03:56 +00:00
|
|
|
// V35: Store SkRect (rather then width & height) in header
|
2014-09-29 19:10:27 +00:00
|
|
|
// V36: Remove (obsolete) alphatype from SkColorTable
|
2014-12-04 15:50:14 +00:00
|
|
|
// V37: Added shadow only option to SkDropShadowImageFilter (last version to record CLEAR)
|
2014-12-09 21:07:22 +00:00
|
|
|
// V38: Added PictureResolution option to SkPictureImageFilter
|
|
|
|
// V39: Added FilterLevel option to SkPictureImageFilter
|
2015-03-18 20:14:54 +00:00
|
|
|
// V40: Remove UniqueID serialization from SkImageFilter.
|
2015-04-10 15:39:58 +00:00
|
|
|
// V41: Added serialization of SkBitmapSource's filterQuality parameter
|
2015-05-20 19:05:15 +00:00
|
|
|
// V42: Added a bool to SkPictureShader serialization to indicate did-we-serialize-a-picture?
|
2015-06-22 19:48:26 +00:00
|
|
|
// V43: Added DRAW_IMAGE and DRAW_IMAGE_RECT opt codes to serialized data
|
2014-02-18 22:08:16 +00:00
|
|
|
|
2014-02-25 02:16:10 +00:00
|
|
|
// Only SKPs within the min/current picture version range (inclusive) can be read.
|
2015-05-19 18:11:26 +00:00
|
|
|
static const uint32_t MIN_PICTURE_VERSION = 35; // Produced by Chrome M39.
|
2015-06-22 19:48:26 +00:00
|
|
|
static const uint32_t CURRENT_PICTURE_VERSION = 43;
|
2012-11-13 20:41:18 +00:00
|
|
|
|
2015-04-17 18:00:06 +00:00
|
|
|
static_assert(MIN_PICTURE_VERSION <= 41,
|
|
|
|
"Remove kFontFileName and related code from SkFontDescriptor.cpp.");
|
|
|
|
|
2015-06-15 20:15:31 +00:00
|
|
|
static_assert(MIN_PICTURE_VERSION <= 42,
|
|
|
|
"Remove COMMENT API handlers from SkPicturePlayback.cpp");
|
|
|
|
|
2015-09-25 16:15:55 +00:00
|
|
|
static_assert(MIN_PICTURE_VERSION <= 43,
|
|
|
|
"Remove SkBitmapSourceDeserializer.");
|
|
|
|
|
Fixing SkPicture serialization
Fixed a few issues while attempting to use the new
serialization path for SkPicture inside a fuzzer:
- SkReadBuffer and SkValidatingReadBuffer both had a fReader
member instead of sharing the same member, which leads to
problems if a base class function is used
- In SkPicture, a header is now written as a single chunk of
data, so it also has to be read as a single chunk of data
- In the SkPicturePlayback destructor, a bad deserialization
would lead to a crash if we don't safely unref fOpData
- Also in SkPicturePlayback, if we only use a ReadBuffer for
the whole deserialization, additional tags must be added to
parseBufferTag()
- SkValidatingReadBuffer::readBitmap() was broken, but this
path wasn't usen't since the only use case for
SkValidatingReadBuffer is currently image filters and
bitmaps are unflattened as part of the deserialization of
SkBitmapSource
- SkPictureImageFilter was not deserializable. Added it to
SkGlobalInitialization*
- Added a test that exercises the SkPicture serialization /
deserialization code
BUG=skia:
R=senorblanco@google.com, senorblanco@chromium.org, reed@google.com, robertphillips@google.com
Author: sugoi@chromium.org
Review URL: https://codereview.chromium.org/195223003
git-svn-id: http://skia.googlecode.com/svn/trunk@13764 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-03-12 14:46:41 +00:00
|
|
|
static bool IsValidPictInfo(const SkPictInfo& info);
|
2014-11-17 14:45:18 +00:00
|
|
|
static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*);
|
Revert of Sketch splitting SkPicture into an interface and SkBigPicture. (patchset #22 id:420001 of https://codereview.chromium.org/1112523006/)
Reason for revert:
speculative revert to fix failures in DEPS roll
Original issue's description:
> Sketch splitting SkPicture into an interface and SkBigPicture.
>
> Adds small pictures for drawRect(), drawTextBlob(), and drawPath().
> These cover about 89% of draw calls from Blink SKPs,
> and about 25% of draw calls from our GMs.
>
> SkPicture handles:
> - serialization and deserialization
> - unique IDs
>
> Everything else is left to the subclasses:
> - playback(), cullRect()
> - hasBitmap(), hasText(), suitableForGPU(), etc.
> - LayerInfo / AccelData if applicable.
>
> The time to record a 1-op picture improves a good chunk
> (2 mallocs to 1), and the time to record a 0-op picture
> greatly improves (2 mallocs to none):
>
> picture_overhead_draw: 450ns -> 350ns
> picture_overhead_nodraw: 300ns -> 90ns
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/c92c129ff85b05a714bd1bf921c02d5e14651f8b
TBR=reed@google.com,robertphillips@google.com,mtklein@google.com,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1130333002
2015-05-08 00:30:13 +00:00
|
|
|
|
2015-05-19 18:11:26 +00:00
|
|
|
SkPictInfo createHeader() const;
|
|
|
|
SkPictureData* backport() const;
|
2014-11-17 14:45:18 +00:00
|
|
|
|
2015-05-19 18:11:26 +00:00
|
|
|
mutable uint32_t fUniqueID;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|