epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2007 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #ifndef SkPicture_DEFINED |
| 11 | #define SkPicture_DEFINED |
| 12 | |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 13 | #include "SkBitmap.h" |
Mike Klein | c11530e | 2014-06-24 11:29:06 -0400 | [diff] [blame] | 14 | #include "SkDrawPictureCallback.h" |
scroggo@google.com | f1754ec | 2013-06-28 21:32:00 +0000 | [diff] [blame] | 15 | #include "SkImageDecoder.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 16 | #include "SkRefCnt.h" |
robertphillips | 3afef1f | 2014-07-08 06:12:22 -0700 | [diff] [blame] | 17 | #include "SkTDArray.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 18 | |
commit-bot@chromium.org | eb9547c | 2014-03-19 21:24:25 +0000 | [diff] [blame] | 19 | #if SK_SUPPORT_GPU |
| 20 | class GrContext; |
| 21 | #endif |
| 22 | |
junov@chromium.org | 35ac048 | 2012-11-01 17:10:32 +0000 | [diff] [blame] | 23 | class SkBBoxHierarchy; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 24 | class SkCanvas; |
scroggo@google.com | 1b1bcc3 | 2013-05-21 20:31:23 +0000 | [diff] [blame] | 25 | class SkData; |
robertphillips | db53990 | 2014-07-01 08:47:04 -0700 | [diff] [blame] | 26 | class SkPictureData; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 27 | class SkStream; |
| 28 | class SkWStream; |
| 29 | |
scroggo@google.com | f1754ec | 2013-06-28 21:32:00 +0000 | [diff] [blame] | 30 | struct SkPictInfo; |
| 31 | |
Mike Klein | 744fb73 | 2014-06-23 15:13:26 -0400 | [diff] [blame] | 32 | class SkRecord; |
| 33 | |
robertphillips | d8aa7b7 | 2014-10-30 16:45:02 -0700 | [diff] [blame] | 34 | namespace SkRecords { |
| 35 | class CollectLayers; |
| 36 | }; |
| 37 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 38 | /** \class SkPicture |
| 39 | |
| 40 | The SkPicture class records the drawing commands made to a canvas, to |
| 41 | be played back at a later time. |
| 42 | */ |
reed@google.com | 1a32d4a | 2011-04-25 20:02:38 +0000 | [diff] [blame] | 43 | class SK_API SkPicture : public SkRefCnt { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 44 | public: |
robertphillips@google.com | 15e9d3e | 2012-06-21 20:25:03 +0000 | [diff] [blame] | 45 | SK_DECLARE_INST_COUNT(SkPicture) |
| 46 | |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 47 | // AccelData provides a base class for device-specific acceleration |
robertphillips | 8236591 | 2014-11-12 09:32:34 -0800 | [diff] [blame] | 48 | // data. It is added to the picture via EXPERIMENTAL_addAccelData. |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 49 | class AccelData : public SkRefCnt { |
| 50 | public: |
| 51 | typedef uint8_t Domain; |
| 52 | typedef uint32_t Key; |
| 53 | |
| 54 | AccelData(Key key) : fKey(key) { } |
| 55 | |
| 56 | const Key& getKey() const { return fKey; } |
| 57 | |
| 58 | // This entry point allows user's to get a unique domain prefix |
| 59 | // for their keys |
| 60 | static Domain GenerateDomain(); |
| 61 | private: |
| 62 | Key fKey; |
| 63 | |
| 64 | typedef SkRefCnt INHERITED; |
| 65 | }; |
| 66 | |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 67 | /** PRIVATE / EXPERIMENTAL -- do not call */ |
Mike Klein | 744fb73 | 2014-06-23 15:13:26 -0400 | [diff] [blame] | 68 | void EXPERIMENTAL_addAccelData(const AccelData*) const; |
| 69 | |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 70 | /** PRIVATE / EXPERIMENTAL -- do not call */ |
Mike Klein | 744fb73 | 2014-06-23 15:13:26 -0400 | [diff] [blame] | 71 | const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key) const; |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 72 | |
reed@google.com | 34342f6 | 2012-06-25 14:36:28 +0000 | [diff] [blame] | 73 | /** |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 74 | * Function signature defining a function that sets up an SkBitmap from encoded data. On |
| 75 | * success, the SkBitmap should have its Config, width, height, rowBytes and pixelref set. |
| 76 | * If the installed pixelref has decoded the data into pixels, then the src buffer need not be |
| 77 | * copied. If the pixelref defers the actual decode until its lockPixels() is called, then it |
| 78 | * must make a copy of the src buffer. |
| 79 | * @param src Encoded data. |
| 80 | * @param length Size of the encoded data, in bytes. |
| 81 | * @param dst SkBitmap to install the pixel ref on. |
| 82 | * @param bool Whether or not a pixel ref was successfully installed. |
| 83 | */ |
| 84 | typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap* dst); |
| 85 | |
| 86 | /** |
| 87 | * Recreate a picture that was serialized into a stream. |
| 88 | * @param SkStream Serialized picture data. |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 89 | * @param proc Function pointer for installing pixelrefs on SkBitmaps representing the |
| 90 | * encoded bitmap data from the stream. |
scroggo@google.com | f1754ec | 2013-06-28 21:32:00 +0000 | [diff] [blame] | 91 | * @return A new SkPicture representing the serialized data, or NULL if the stream is |
| 92 | * invalid. |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 93 | */ |
scroggo@google.com | f1754ec | 2013-06-28 21:32:00 +0000 | [diff] [blame] | 94 | static SkPicture* CreateFromStream(SkStream*, |
| 95 | InstallPixelRefProc proc = &SkImageDecoder::DecodeMemory); |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 96 | |
commit-bot@chromium.org | 5e0995e | 2014-02-07 12:20:04 +0000 | [diff] [blame] | 97 | /** |
| 98 | * Recreate a picture that was serialized into a buffer. If the creation requires bitmap |
| 99 | * decoding, the decoder must be set on the SkReadBuffer parameter by calling |
| 100 | * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuffer(). |
| 101 | * @param SkReadBuffer Serialized picture data. |
| 102 | * @return A new SkPicture representing the serialized data, or NULL if the buffer is |
| 103 | * invalid. |
| 104 | */ |
| 105 | static SkPicture* CreateFromBuffer(SkReadBuffer&); |
| 106 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 107 | virtual ~SkPicture(); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 108 | |
robertphillips | c5ba71d | 2014-09-04 08:42:50 -0700 | [diff] [blame] | 109 | /** Replays the drawing commands on the specified canvas. Note that |
| 110 | this has the effect of unfurling this picture into the destination |
| 111 | canvas. Using the SkCanvas::drawPicture entry point gives the destination |
| 112 | canvas the option of just taking a ref. |
reed@google.com | 74babdf | 2013-05-20 17:02:41 +0000 | [diff] [blame] | 113 | @param canvas the canvas receiving the drawing commands. |
robertphillips | c5ba71d | 2014-09-04 08:42:50 -0700 | [diff] [blame] | 114 | @param callback a callback that allows interruption of playback |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 115 | */ |
robertphillips | c5ba71d | 2014-09-04 08:42:50 -0700 | [diff] [blame] | 116 | void playback(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const; |
| 117 | |
| 118 | #ifdef SK_LEGACY_PICTURE_DRAW_API |
| 119 | void draw(SkCanvas* canvas, SkDrawPictureCallback* callback = NULL) const { |
| 120 | this->playback(canvas, callback); |
| 121 | } |
| 122 | #endif |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 123 | |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 124 | #ifdef SK_LEGACY_PICTURE_SIZE_API |
| 125 | int width() const { return SkScalarCeilToInt(fCullWidth); } |
| 126 | int height() const { return SkScalarCeilToInt(fCullHeight); } |
| 127 | #endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 128 | |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 129 | /** Return the cull rect used when creating this picture: { 0, 0, cullWidth, cullHeight }. |
| 130 | It does not necessarily reflect the bounds of what has been recorded into the picture. |
| 131 | @return the cull rect used to create this picture |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 132 | */ |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 133 | const SkRect cullRect() const { return SkRect::MakeWH(fCullWidth, fCullHeight); } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 134 | |
skia.committer@gmail.com | a915772 | 2014-04-03 03:04:26 +0000 | [diff] [blame] | 135 | /** Return a non-zero, unique value representing the picture. This call is |
| 136 | only valid when not recording. Between a beginRecording/endRecording |
commit-bot@chromium.org | 2b4e370 | 2014-04-07 18:26:22 +0000 | [diff] [blame] | 137 | pair it will just return 0 (the invalid ID). Each beginRecording/ |
robertphillips@google.com | d550088 | 2014-04-02 23:51:13 +0000 | [diff] [blame] | 138 | endRecording pair will cause a different generation ID to be returned. |
| 139 | */ |
commit-bot@chromium.org | 2b4e370 | 2014-04-07 18:26:22 +0000 | [diff] [blame] | 140 | uint32_t uniqueID() const; |
robertphillips@google.com | d550088 | 2014-04-02 23:51:13 +0000 | [diff] [blame] | 141 | |
scroggo@google.com | 5a7c6be | 2012-10-04 21:46:08 +0000 | [diff] [blame] | 142 | /** |
scroggo@google.com | 1b1bcc3 | 2013-05-21 20:31:23 +0000 | [diff] [blame] | 143 | * Function to encode an SkBitmap to an SkData. A function with this |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 144 | * signature can be passed to serialize() and SkWriteBuffer. |
| 145 | * Returning NULL will tell the SkWriteBuffer to use |
scroggo@google.com | 1b1bcc3 | 2013-05-21 20:31:23 +0000 | [diff] [blame] | 146 | * SkBitmap::flatten() to store the bitmap. |
reed@google.com | 672588b | 2014-01-08 15:42:01 +0000 | [diff] [blame] | 147 | * |
| 148 | * @param pixelRefOffset DEPRECATED -- caller assumes it will return 0. |
scroggo@google.com | 1b1bcc3 | 2013-05-21 20:31:23 +0000 | [diff] [blame] | 149 | * @return SkData If non-NULL, holds encoded data representing the passed |
| 150 | * in bitmap. The caller is responsible for calling unref(). |
scroggo@google.com | 32ef131 | 2013-02-22 22:04:19 +0000 | [diff] [blame] | 151 | */ |
scroggo@google.com | 1b1bcc3 | 2013-05-21 20:31:23 +0000 | [diff] [blame] | 152 | typedef SkData* (*EncodeBitmap)(size_t* pixelRefOffset, const SkBitmap& bm); |
scroggo@google.com | 32ef131 | 2013-02-22 22:04:19 +0000 | [diff] [blame] | 153 | |
| 154 | /** |
scroggo@google.com | 5a7c6be | 2012-10-04 21:46:08 +0000 | [diff] [blame] | 155 | * Serialize to a stream. If non NULL, encoder will be used to encode |
| 156 | * any bitmaps in the picture. |
scroggo@google.com | 1b1bcc3 | 2013-05-21 20:31:23 +0000 | [diff] [blame] | 157 | * encoder will never be called with a NULL pixelRefOffset. |
scroggo@google.com | 5a7c6be | 2012-10-04 21:46:08 +0000 | [diff] [blame] | 158 | */ |
scroggo@google.com | 32ef131 | 2013-02-22 22:04:19 +0000 | [diff] [blame] | 159 | void serialize(SkWStream*, EncodeBitmap encoder = NULL) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 160 | |
tomhudson@google.com | 381010e | 2013-10-24 11:12:47 +0000 | [diff] [blame] | 161 | /** |
commit-bot@chromium.org | 5e0995e | 2014-02-07 12:20:04 +0000 | [diff] [blame] | 162 | * Serialize to a buffer. |
| 163 | */ |
| 164 | void flatten(SkWriteBuffer&) const; |
| 165 | |
| 166 | /** |
tomhudson@google.com | 381010e | 2013-10-24 11:12:47 +0000 | [diff] [blame] | 167 | * Returns true if any bitmaps may be produced when this SkPicture |
| 168 | * is replayed. |
tomhudson@google.com | 381010e | 2013-10-24 11:12:47 +0000 | [diff] [blame] | 169 | */ |
| 170 | bool willPlayBackBitmaps() const; |
| 171 | |
commit-bot@chromium.org | 6f4fb0f | 2014-03-03 19:18:39 +0000 | [diff] [blame] | 172 | /** Return true if the SkStream/Buffer represents a serialized picture, and |
| 173 | fills out SkPictInfo. After this function returns, the data source is not |
skia.committer@gmail.com | ade9a34 | 2014-03-04 03:02:32 +0000 | [diff] [blame] | 174 | rewound so it will have to be manually reset before passing to |
commit-bot@chromium.org | 6f4fb0f | 2014-03-03 19:18:39 +0000 | [diff] [blame] | 175 | CreateFromStream or CreateFromBuffer. Note, CreateFromStream and |
| 176 | CreateFromBuffer perform this check internally so these entry points are |
| 177 | intended for stand alone tools. |
| 178 | If false is returned, SkPictInfo is unmodified. |
| 179 | */ |
| 180 | static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*); |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 181 | static bool InternalOnly_BufferIsSKP(SkReadBuffer*, SkPictInfo*); |
commit-bot@chromium.org | 6f4fb0f | 2014-03-03 19:18:39 +0000 | [diff] [blame] | 182 | |
commit-bot@chromium.org | eb9547c | 2014-03-19 21:24:25 +0000 | [diff] [blame] | 183 | /** Return true if the picture is suitable for rendering on the GPU. |
| 184 | */ |
| 185 | |
| 186 | #if SK_SUPPORT_GPU |
commit-bot@chromium.org | a1ff26a | 2014-05-30 21:52:52 +0000 | [diff] [blame] | 187 | bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const; |
commit-bot@chromium.org | eb9547c | 2014-03-19 21:24:25 +0000 | [diff] [blame] | 188 | #endif |
| 189 | |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 190 | class DeletionListener : public SkRefCnt { |
| 191 | public: |
| 192 | virtual void onDeletion(uint32_t pictureID) = 0; |
| 193 | }; |
| 194 | |
| 195 | // Takes ref on listener. |
| 196 | void addDeletionListener(DeletionListener* listener) const; |
| 197 | |
mtklein | 5a246bb | 2014-08-14 19:17:18 -0700 | [diff] [blame] | 198 | /** Return the approximate number of operations in this picture. This |
| 199 | * number may be greater or less than the number of SkCanvas calls |
| 200 | * recorded: some calls may be recorded as more than one operation, or some |
| 201 | * calls may be optimized away. |
| 202 | */ |
| 203 | int approximateOpCount() const; |
| 204 | |
ajuma | 750ae26 | 2014-08-18 12:59:55 -0700 | [diff] [blame] | 205 | /** Return true if this picture contains text. |
| 206 | */ |
| 207 | bool hasText() const; |
| 208 | |
robertphillips | 6daadc7 | 2014-07-08 08:38:18 -0700 | [diff] [blame] | 209 | private: |
robertphillips@google.com | 9a5b570 | 2012-11-13 20:41:18 +0000 | [diff] [blame] | 210 | // V2 : adds SkPixelRef's generation ID. |
| 211 | // V3 : PictInfo tag at beginning, and EOF tag at the end |
| 212 | // V4 : move SkPictInfo to be the header |
| 213 | // V5 : don't read/write FunctionPtr on cross-process (we can detect that) |
| 214 | // V6 : added serialization of SkPath's bounds (and packed its flags tighter) |
| 215 | // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) |
| 216 | // V8 : Add an option for encoding bitmaps |
| 217 | // V9 : Allow the reader and writer of an SKP disagree on whether to support |
| 218 | // SK_SUPPORT_HINTING_SCALE_FACTOR |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 219 | // V10: add drawRRect, drawOval, clipRRect |
scroggo@google.com | 74b7ffd | 2013-04-30 02:32:41 +0000 | [diff] [blame] | 220 | // V11: modify how readBitmap and writeBitmap store their info. |
reed@google.com | 277c3f8 | 2013-05-31 15:17:50 +0000 | [diff] [blame] | 221 | // V12: add conics to SkPath, use new SkPathRef flattening |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 222 | // V13: add flag to drawBitmapRectToRect |
robertphillips@google.com | 7ce661d | 2013-08-27 16:14:03 +0000 | [diff] [blame] | 223 | // parameterize blurs by sigma rather than radius |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 224 | // V14: Add flags word to PathRef serialization |
robertphillips@google.com | d550088 | 2014-04-02 23:51:13 +0000 | [diff] [blame] | 225 | // V15: Remove A1 bitmap config (and renumber remaining configs) |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 226 | // V16: Move SkPath's isOval flag to SkPathRef |
reed@google.com | e132f50 | 2013-12-13 19:58:46 +0000 | [diff] [blame] | 227 | // V17: SkPixelRef now writes SkImageInfo |
reed@google.com | 672588b | 2014-01-08 15:42:01 +0000 | [diff] [blame] | 228 | // V18: SkBitmap now records x,y for its pixelref origin, instead of offset. |
commit-bot@chromium.org | fed2ab6 | 2014-01-23 15:16:05 +0000 | [diff] [blame] | 229 | // V19: encode matrices and regions into the ops stream |
commit-bot@chromium.org | 5e0995e | 2014-02-07 12:20:04 +0000 | [diff] [blame] | 230 | // V20: added bool to SkPictureImageFilter's serialization (to allow SkPicture serialization) |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 231 | // V21: add pushCull, popCull |
commit-bot@chromium.org | dcb8e54 | 2014-03-05 18:25:20 +0000 | [diff] [blame] | 232 | // V22: SK_PICT_FACTORY_TAG's size is now the chunk size in bytes |
commit-bot@chromium.org | 85faf50 | 2014-04-16 12:58:02 +0000 | [diff] [blame] | 233 | // V23: SkPaint::FilterLevel became a real enum |
commit-bot@chromium.org | 44d83c1 | 2014-04-21 13:10:25 +0000 | [diff] [blame] | 234 | // V24: SkTwoPointConicalGradient now has fFlipped flag for gradient flipping |
commit-bot@chromium.org | aec1438 | 2014-04-22 15:21:18 +0000 | [diff] [blame] | 235 | // V25: SkDashPathEffect now only writes phase and interval array when flattening |
commit-bot@chromium.org | 76a3b2a | 2014-04-24 16:54:46 +0000 | [diff] [blame] | 236 | // V26: Removed boolean from SkColorShader for inheriting color from SkPaint. |
commit-bot@chromium.org | 83f23d8 | 2014-05-22 12:27:41 +0000 | [diff] [blame] | 237 | // V27: Remove SkUnitMapper from gradients (and skia). |
commit-bot@chromium.org | 968edca | 2014-05-23 13:21:55 +0000 | [diff] [blame] | 238 | // V28: No longer call bitmap::flatten inside SkWriteBuffer::writeBitmap. |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 239 | // V29: Removed SaveFlags parameter from save(). |
scroggo | c870d49 | 2014-07-11 10:42:12 -0700 | [diff] [blame] | 240 | // V30: Remove redundant SkMatrix from SkLocalMatrixShader. |
senorblanco | 55b6d8b | 2014-07-30 11:26:46 -0700 | [diff] [blame] | 241 | // V31: Add a serialized UniqueID to SkImageFilter. |
djsollen | 3b62554 | 2014-08-14 06:29:02 -0700 | [diff] [blame] | 242 | // V32: Removed SkPaintOptionsAndroid from SkPaint |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 243 | // V33: Serialize only public API of effects. |
| 244 | // V34: Add SkTextBlob serialization. |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 245 | // V35: Store SkRect (rather then width & height) in header |
reed | c5e15a1 | 2014-09-29 12:10:27 -0700 | [diff] [blame] | 246 | // V36: Remove (obsolete) alphatype from SkColorTable |
sugoi | 234f036 | 2014-10-23 13:59:52 -0700 | [diff] [blame] | 247 | // V37: Added shadow only option to SkDropShadowImageFilter |
commit-bot@chromium.org | d281c92 | 2014-02-18 22:08:16 +0000 | [diff] [blame] | 248 | |
| 249 | // Note: If the picture version needs to be increased then please follow the |
| 250 | // steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw |
commit-bot@chromium.org | e8d9614 | 2014-02-25 02:16:10 +0000 | [diff] [blame] | 251 | |
| 252 | // Only SKPs within the min/current picture version range (inclusive) can be read. |
| 253 | static const uint32_t MIN_PICTURE_VERSION = 19; |
sugoi | 234f036 | 2014-10-23 13:59:52 -0700 | [diff] [blame] | 254 | static const uint32_t CURRENT_PICTURE_VERSION = 37; |
robertphillips@google.com | 9a5b570 | 2012-11-13 20:41:18 +0000 | [diff] [blame] | 255 | |
commit-bot@chromium.org | 2b4e370 | 2014-04-07 18:26:22 +0000 | [diff] [blame] | 256 | void needsNewGenID() { fUniqueID = SK_InvalidGenID; } |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 257 | void callDeletionListeners(); |
robertphillips@google.com | d550088 | 2014-04-02 23:51:13 +0000 | [diff] [blame] | 258 | |
commit-bot@chromium.org | 9e5f85e | 2014-03-12 14:46:41 +0000 | [diff] [blame] | 259 | void createHeader(SkPictInfo* info) const; |
| 260 | static bool IsValidPictInfo(const SkPictInfo& info); |
commit-bot@chromium.org | 5e0995e | 2014-02-07 12:20:04 +0000 | [diff] [blame] | 261 | |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 262 | // Takes ownership of the SkRecord, refs the (optional) BBH. |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 263 | SkPicture(SkScalar width, SkScalar height, SkRecord*, SkBBoxHierarchy*); |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 264 | |
mtklein | c6ad9ee | 2014-11-17 06:45:18 -0800 | [diff] [blame] | 265 | static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); |
| 266 | static SkPictureData* Backport(const SkRecord&, const SkPictInfo&); |
| 267 | |
| 268 | const SkScalar fCullWidth; |
| 269 | const SkScalar fCullHeight; |
| 270 | mutable SkAutoTUnref<const AccelData> fAccelData; |
| 271 | mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are refed |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 272 | SkAutoTDelete<SkRecord> fRecord; |
| 273 | SkAutoTUnref<SkBBoxHierarchy> fBBH; |
tomhudson | 3a0f279 | 2014-08-20 05:29:41 -0700 | [diff] [blame] | 274 | struct Analysis { |
mtklein | c551d9f | 2014-08-20 08:09:46 -0700 | [diff] [blame] | 275 | Analysis() {} // Only used by SkPictureData codepath. |
| 276 | explicit Analysis(const SkRecord&); |
tomhudson | 3a0f279 | 2014-08-20 05:29:41 -0700 | [diff] [blame] | 277 | |
| 278 | bool suitableForGpuRasterization(const char** reason, int sampleCount) const; |
| 279 | |
| 280 | bool fWillPlaybackBitmaps; |
mtklein | c551d9f | 2014-08-20 08:09:46 -0700 | [diff] [blame] | 281 | bool fHasText; |
tomhudson | 3a0f279 | 2014-08-20 05:29:41 -0700 | [diff] [blame] | 282 | int fNumPaintWithPathEffectUses; |
| 283 | int fNumFastPathDashEffects; |
| 284 | int fNumAAConcavePaths; |
| 285 | int fNumAAHairlineConcavePaths; |
jvanverth | f7007b0 | 2014-11-04 07:59:01 -0800 | [diff] [blame] | 286 | int fNumAADFEligibleConcavePaths; |
mtklein | c551d9f | 2014-08-20 08:09:46 -0700 | [diff] [blame] | 287 | } fAnalysis; |
mtklein | c6ad9ee | 2014-11-17 06:45:18 -0800 | [diff] [blame] | 288 | mutable uint32_t fUniqueID; |
| 289 | |
| 290 | struct PathCounter; |
| 291 | |
| 292 | friend class SkPictureRecorder; // SkRecord-based constructor. |
| 293 | friend class GrLayerHoister; // access to fRecord |
| 294 | friend class ReplaceDraw; |
| 295 | |
| 296 | typedef SkRefCnt INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 297 | }; |
| 298 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 299 | #endif |