2011-07-28 14:26:00 +00:00
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#ifndef SkPicture_DEFINED
|
|
|
|
#define SkPicture_DEFINED
|
|
|
|
|
2013-02-22 21:38:35 +00:00
|
|
|
#include "SkBitmap.h"
|
2014-06-24 15:29:06 +00:00
|
|
|
#include "SkDrawPictureCallback.h"
|
2013-06-28 21:32:00 +00:00
|
|
|
#include "SkImageDecoder.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
#include "SkRefCnt.h"
|
2014-07-08 13:12:22 +00:00
|
|
|
#include "SkTDArray.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-03-19 21:24:25 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
class GrContext;
|
|
|
|
#endif
|
|
|
|
|
2012-11-01 17:10:32 +00:00
|
|
|
class SkBBoxHierarchy;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkCanvas;
|
2013-05-21 20:31:23 +00:00
|
|
|
class SkData;
|
2014-07-01 15:47:04 +00:00
|
|
|
class SkPictureData;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkPictureRecord;
|
|
|
|
class SkStream;
|
|
|
|
class SkWStream;
|
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
struct SkPictInfo;
|
|
|
|
|
2014-06-23 19:13:26 +00:00
|
|
|
class SkRecord;
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** \class SkPicture
|
|
|
|
|
|
|
|
The SkPicture class records the drawing commands made to a canvas, to
|
|
|
|
be played back at a later time.
|
|
|
|
*/
|
2011-04-25 20:02:38 +00:00
|
|
|
class SK_API SkPicture : public SkRefCnt {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2012-06-21 20:25:03 +00:00
|
|
|
SK_DECLARE_INST_COUNT(SkPicture)
|
|
|
|
|
2014-03-16 19:46:36 +00:00
|
|
|
// AccelData provides a base class for device-specific acceleration
|
2014-03-17 03:02:17 +00:00
|
|
|
// data. It is added to the picture via a call to a device's optimize
|
2014-03-16 19:46:36 +00:00
|
|
|
// method.
|
|
|
|
class AccelData : public SkRefCnt {
|
|
|
|
public:
|
|
|
|
typedef uint8_t Domain;
|
|
|
|
typedef uint32_t Key;
|
|
|
|
|
|
|
|
AccelData(Key key) : fKey(key) { }
|
|
|
|
|
|
|
|
const Key& getKey() const { return fKey; }
|
|
|
|
|
|
|
|
// This entry point allows user's to get a unique domain prefix
|
|
|
|
// for their keys
|
|
|
|
static Domain GenerateDomain();
|
|
|
|
private:
|
|
|
|
Key fKey;
|
|
|
|
|
|
|
|
typedef SkRefCnt INHERITED;
|
|
|
|
};
|
|
|
|
|
2014-07-13 16:00:50 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_DEFAULT_PICTURE_CTOR
|
2008-12-17 15:59:43 +00:00
|
|
|
SkPicture();
|
2014-07-13 16:00:50 +00:00
|
|
|
#endif
|
2013-02-22 21:38:35 +00:00
|
|
|
|
2014-03-16 19:46:36 +00:00
|
|
|
/** PRIVATE / EXPERIMENTAL -- do not call */
|
2014-06-23 19:13:26 +00:00
|
|
|
void EXPERIMENTAL_addAccelData(const AccelData*) const;
|
|
|
|
|
2014-03-16 19:46:36 +00:00
|
|
|
/** PRIVATE / EXPERIMENTAL -- do not call */
|
2014-06-23 19:13:26 +00:00
|
|
|
const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key) const;
|
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.
|
|
|
|
* @param SkStream Serialized picture data.
|
|
|
|
* @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&);
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual ~SkPicture();
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2014-06-27 19:34:44 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE
|
2012-08-29 18:52:07 +00:00
|
|
|
/**
|
|
|
|
* Creates a thread-safe clone of the picture that is ready for playback.
|
|
|
|
*/
|
|
|
|
SkPicture* clone() const;
|
2014-06-27 19:34:44 +00:00
|
|
|
#endif
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2014-06-08 12:55:05 +00:00
|
|
|
/** Replays the drawing commands on the specified canvas.
|
2013-05-20 17:02:41 +00:00
|
|
|
@param canvas the canvas receiving the drawing commands.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-06-04 12:40:44 +00:00
|
|
|
void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Return the width of the picture's recording canvas. This
|
|
|
|
value reflects what was passed to setSize(), and does not necessarily
|
|
|
|
reflect the bounds of what has been recorded into the picture.
|
|
|
|
@return the width of the picture's recording canvas
|
|
|
|
*/
|
|
|
|
int width() const { return fWidth; }
|
|
|
|
|
|
|
|
/** Return the height of the picture's recording canvas. This
|
|
|
|
value reflects what was passed to setSize(), and does not necessarily
|
|
|
|
reflect the bounds of what has been recorded into the picture.
|
|
|
|
@return the height of the picture's recording canvas
|
|
|
|
*/
|
|
|
|
int height() const { return fHeight; }
|
|
|
|
|
2014-04-03 03:04:26 +00:00
|
|
|
/** Return a non-zero, unique value representing the picture. This call is
|
|
|
|
only valid when not recording. Between a beginRecording/endRecording
|
2014-04-07 18:26:22 +00:00
|
|
|
pair it will just return 0 (the invalid ID). Each beginRecording/
|
2014-04-02 23:51:13 +00:00
|
|
|
endRecording pair will cause a different generation ID to be returned.
|
|
|
|
*/
|
2014-04-07 18:26:22 +00:00
|
|
|
uint32_t uniqueID() const;
|
2014-04-02 23:51:13 +00:00
|
|
|
|
2013-02-22 22:04:19 +00:00
|
|
|
/**
|
2013-05-21 20:31:23 +00:00
|
|
|
* Function to encode an SkBitmap to an SkData. A function with this
|
2014-01-30 18:58:24 +00:00
|
|
|
* signature can be passed to serialize() and SkWriteBuffer.
|
|
|
|
* Returning NULL will tell the SkWriteBuffer to use
|
2013-05-21 20:31:23 +00:00
|
|
|
* SkBitmap::flatten() to store the bitmap.
|
2014-01-08 15:42:01 +00:00
|
|
|
*
|
|
|
|
* @param pixelRefOffset DEPRECATED -- caller assumes it will return 0.
|
2013-05-21 20:31:23 +00:00
|
|
|
* @return SkData If non-NULL, holds encoded data representing the passed
|
|
|
|
* in bitmap. The caller is responsible for calling unref().
|
2013-02-22 22:04:19 +00:00
|
|
|
*/
|
2013-05-21 20:31:23 +00:00
|
|
|
typedef SkData* (*EncodeBitmap)(size_t* pixelRefOffset, const SkBitmap& bm);
|
2013-02-22 22:04:19 +00:00
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Serialize to a stream. If non NULL, encoder will be used to encode
|
|
|
|
* any bitmaps in the picture.
|
2013-05-21 20:31:23 +00:00
|
|
|
* encoder will never be called with a NULL pixelRefOffset.
|
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
|
|
|
*/
|
2013-02-22 22:04:19 +00:00
|
|
|
void serialize(SkWStream*, EncodeBitmap encoder = 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.
|
|
|
|
*/
|
|
|
|
bool willPlayBackBitmaps() const;
|
|
|
|
|
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*);
|
|
|
|
static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*);
|
|
|
|
|
2014-03-19 21:24:25 +00:00
|
|
|
/** Return true if the picture is suitable for rendering on the GPU.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
2014-05-30 21:52:52 +00:00
|
|
|
bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const;
|
2014-03-19 21:24:25 +00:00
|
|
|
#endif
|
|
|
|
|
2014-07-22 17:18:06 +00:00
|
|
|
class DeletionListener : public SkRefCnt {
|
|
|
|
public:
|
|
|
|
virtual void onDeletion(uint32_t pictureID) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Takes ref on listener.
|
|
|
|
void addDeletionListener(DeletionListener* listener) const;
|
|
|
|
|
2014-08-15 02:17:18 +00:00
|
|
|
/** 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.
|
|
|
|
*/
|
|
|
|
int approximateOpCount() const;
|
|
|
|
|
2014-08-18 19:59:55 +00:00
|
|
|
/** Return true if this picture contains text.
|
|
|
|
*/
|
|
|
|
bool hasText() const;
|
|
|
|
|
2014-07-08 15:38:18 +00:00
|
|
|
private:
|
2012-11-13 20:41:18 +00:00
|
|
|
// V2 : adds SkPixelRef's generation ID.
|
|
|
|
// V3 : PictInfo tag at beginning, and EOF tag at the end
|
|
|
|
// V4 : move SkPictInfo to be the header
|
|
|
|
// V5 : don't read/write FunctionPtr on cross-process (we can detect that)
|
|
|
|
// V6 : added serialization of SkPath's bounds (and packed its flags tighter)
|
|
|
|
// V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect)
|
|
|
|
// V8 : Add an option for encoding bitmaps
|
|
|
|
// V9 : Allow the reader and writer of an SKP disagree on whether to support
|
|
|
|
// SK_SUPPORT_HINTING_SCALE_FACTOR
|
2012-12-12 20:48:18 +00:00
|
|
|
// V10: add drawRRect, drawOval, clipRRect
|
2013-04-30 02:32:41 +00:00
|
|
|
// V11: modify how readBitmap and writeBitmap store their info.
|
2013-05-31 15:17:50 +00:00
|
|
|
// V12: add conics to SkPath, use new SkPathRef flattening
|
2013-08-16 10:24:37 +00:00
|
|
|
// V13: add flag to drawBitmapRectToRect
|
2013-08-27 16:14:03 +00:00
|
|
|
// parameterize blurs by sigma rather than radius
|
2013-09-26 12:18:23 +00:00
|
|
|
// V14: Add flags word to PathRef serialization
|
2014-04-02 23:51:13 +00:00
|
|
|
// V15: Remove A1 bitmap config (and renumber remaining configs)
|
2013-12-03 16:43:54 +00:00
|
|
|
// V16: Move SkPath's isOval flag to SkPathRef
|
2013-12-13 19:58:46 +00:00
|
|
|
// V17: SkPixelRef now writes SkImageInfo
|
2014-01-08 15:42:01 +00:00
|
|
|
// V18: SkBitmap now records x,y for its pixelref origin, instead of offset.
|
2014-01-23 15:16:05 +00:00
|
|
|
// V19: encode matrices and regions into the ops stream
|
2014-02-07 12:20:04 +00:00
|
|
|
// V20: added bool to SkPictureImageFilter's serialization (to allow SkPicture serialization)
|
2014-02-27 17:40:13 +00:00
|
|
|
// V21: add pushCull, popCull
|
2014-03-05 18:25:20 +00:00
|
|
|
// V22: SK_PICT_FACTORY_TAG's size is now the chunk size in bytes
|
2014-04-16 12:58:02 +00:00
|
|
|
// V23: SkPaint::FilterLevel became a real enum
|
2014-04-21 13:10:25 +00:00
|
|
|
// V24: SkTwoPointConicalGradient now has fFlipped flag for gradient flipping
|
2014-04-22 15:21:18 +00:00
|
|
|
// V25: SkDashPathEffect now only writes phase and interval array when flattening
|
2014-04-24 16:54:46 +00:00
|
|
|
// V26: Removed boolean from SkColorShader for inheriting color from SkPaint.
|
2014-05-22 12:27:41 +00:00
|
|
|
// V27: Remove SkUnitMapper from gradients (and skia).
|
2014-05-23 13:21:55 +00:00
|
|
|
// V28: No longer call bitmap::flatten inside SkWriteBuffer::writeBitmap.
|
2014-06-30 14:13:28 +00:00
|
|
|
// V29: Removed SaveFlags parameter from save().
|
2014-07-11 17:42:12 +00:00
|
|
|
// V30: Remove redundant SkMatrix from SkLocalMatrixShader.
|
2014-07-30 18:26:46 +00:00
|
|
|
// V31: Add a serialized UniqueID to SkImageFilter.
|
2014-08-14 13:29:02 +00:00
|
|
|
// V32: Removed SkPaintOptionsAndroid from SkPaint
|
2014-02-18 22:08:16 +00:00
|
|
|
|
|
|
|
// Note: If the picture version needs to be increased then please follow the
|
|
|
|
// steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw
|
2014-02-25 02:16:10 +00:00
|
|
|
|
|
|
|
// Only SKPs within the min/current picture version range (inclusive) can be read.
|
|
|
|
static const uint32_t MIN_PICTURE_VERSION = 19;
|
2014-08-21 14:59:51 +00:00
|
|
|
static const uint32_t CURRENT_PICTURE_VERSION = 33;
|
2012-11-13 20:41:18 +00:00
|
|
|
|
2014-04-07 18:26:22 +00:00
|
|
|
mutable uint32_t fUniqueID;
|
2014-04-02 23:51:13 +00:00
|
|
|
|
2014-07-08 16:58:20 +00:00
|
|
|
// TODO: make SkPictureData const when clone method goes away
|
|
|
|
SkAutoTDelete<SkPictureData> fData;
|
2014-03-16 19:46:36 +00:00
|
|
|
int fWidth, fHeight;
|
2014-06-23 19:13:26 +00:00
|
|
|
mutable SkAutoTUnref<const AccelData> fAccelData;
|
2012-10-24 19:30:41 +00:00
|
|
|
|
2014-07-22 17:18:06 +00:00
|
|
|
mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are refed
|
|
|
|
|
2014-04-07 18:26:22 +00:00
|
|
|
void needsNewGenID() { fUniqueID = SK_InvalidGenID; }
|
2014-07-22 17:18:06 +00:00
|
|
|
void callDeletionListeners();
|
2014-04-02 23:51:13 +00:00
|
|
|
|
2014-07-13 16:00:50 +00:00
|
|
|
// Create a new SkPicture from an existing SkPictureData. The new picture
|
|
|
|
// takes ownership of 'data'.
|
2014-07-01 15:47:04 +00:00
|
|
|
SkPicture(SkPictureData* data, int width, int height);
|
2013-06-28 21:32:00 +00:00
|
|
|
|
2014-06-12 12:51:22 +00:00
|
|
|
SkPicture(int width, int height, const SkPictureRecord& record, bool deepCopyOps);
|
2014-04-23 22:35:42 +00:00
|
|
|
|
2014-03-18 17:45:32 +00:00
|
|
|
// An OperationList encapsulates a set of operation offsets into the picture byte
|
|
|
|
// stream along with the CTMs needed for those operation.
|
2014-04-07 19:34:38 +00:00
|
|
|
class OperationList : ::SkNoncopyable {
|
2014-03-18 17:45:32 +00:00
|
|
|
public:
|
|
|
|
// The following three entry points should only be accessed if
|
|
|
|
// 'valid' returns true.
|
2014-07-08 13:12:22 +00:00
|
|
|
int numOps() const { return fOps.count(); }
|
2014-03-18 17:45:32 +00:00
|
|
|
// The offset in the picture of the operation to execute.
|
2014-07-08 13:12:22 +00:00
|
|
|
uint32_t offset(int index) const;
|
2014-03-18 17:45:32 +00:00
|
|
|
// The CTM that must be installed for the operation to behave correctly
|
2014-07-08 13:12:22 +00:00
|
|
|
const SkMatrix& matrix(int index) const;
|
|
|
|
|
|
|
|
SkTDArray<void*> fOps;
|
2014-03-18 17:45:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** PRIVATE / EXPERIMENTAL -- do not call
|
|
|
|
Return the operations required to render the content inside 'queryRect'.
|
|
|
|
*/
|
2014-07-07 20:46:35 +00:00
|
|
|
const OperationList* EXPERIMENTAL_getActiveOps(const SkIRect& queryRect) const;
|
2014-03-24 19:40:49 +00:00
|
|
|
|
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
|
|
|
void createHeader(SkPictInfo* info) const;
|
|
|
|
static bool IsValidPictInfo(const SkPictInfo& info);
|
2014-02-07 12:20:04 +00:00
|
|
|
|
2014-07-10 16:35:12 +00:00
|
|
|
friend class SkPictureData; // to access OperationList
|
|
|
|
friend class SkPictureRecorder; // just for SkPicture-based constructor
|
|
|
|
friend class SkGpuDevice; // for EXPERIMENTAL_getActiveOps/OperationList
|
|
|
|
friend class GrGatherCanvas; // needs to know if old or new picture
|
|
|
|
friend class SkPicturePlayback; // to get fData & OperationList
|
2014-07-10 14:21:27 +00:00
|
|
|
friend class SkPictureReplacementPlayback; // to access OperationList
|
2012-06-21 20:25:03 +00:00
|
|
|
|
|
|
|
typedef SkRefCnt INHERITED;
|
2014-06-23 19:13:26 +00:00
|
|
|
|
2014-08-11 15:08:43 +00:00
|
|
|
// Takes ownership of the SkRecord, refs the (optional) BBH.
|
|
|
|
SkPicture(int width, int height, SkRecord*, SkBBoxHierarchy*);
|
2014-08-20 21:22:58 +00:00
|
|
|
// Return as a new SkPicture that's backed by SkRecord.
|
|
|
|
static SkPicture* Forwardport(const SkPicture&);
|
2014-08-11 15:08:43 +00:00
|
|
|
|
|
|
|
SkAutoTDelete<SkRecord> fRecord;
|
|
|
|
SkAutoTUnref<SkBBoxHierarchy> fBBH;
|
2014-08-20 12:29:41 +00:00
|
|
|
|
|
|
|
struct Analysis {
|
2014-08-20 15:09:46 +00:00
|
|
|
Analysis() {} // Only used by SkPictureData codepath.
|
|
|
|
explicit Analysis(const SkRecord&);
|
2014-08-20 12:29:41 +00:00
|
|
|
|
|
|
|
bool suitableForGpuRasterization(const char** reason, int sampleCount) const;
|
|
|
|
|
|
|
|
bool fWillPlaybackBitmaps;
|
2014-08-20 15:09:46 +00:00
|
|
|
bool fHasText;
|
2014-08-20 12:29:41 +00:00
|
|
|
int fNumPaintWithPathEffectUses;
|
|
|
|
int fNumFastPathDashEffects;
|
|
|
|
int fNumAAConcavePaths;
|
|
|
|
int fNumAAHairlineConcavePaths;
|
2014-08-20 15:09:46 +00:00
|
|
|
} fAnalysis;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|