reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2007 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 8 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | #ifndef SkPicture_DEFINED |
| 10 | #define SkPicture_DEFINED |
| 11 | |
scroggo@google.com | f1754ec | 2013-06-28 21:32:00 +0000 | [diff] [blame] | 12 | #include "SkImageDecoder.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 13 | #include "SkRefCnt.h" |
robertphillips | 3afef1f | 2014-07-08 06:12:22 -0700 | [diff] [blame] | 14 | #include "SkTDArray.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 15 | |
commit-bot@chromium.org | eb9547c | 2014-03-19 21:24:25 +0000 | [diff] [blame] | 16 | #if SK_SUPPORT_GPU |
| 17 | class GrContext; |
| 18 | #endif |
| 19 | |
robertphillips | 783fe16 | 2015-01-07 07:28:41 -0800 | [diff] [blame] | 20 | class SkBitmap; |
junov@chromium.org | 35ac048 | 2012-11-01 17:10:32 +0000 | [diff] [blame] | 21 | class SkBBoxHierarchy; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 22 | class SkCanvas; |
scroggo@google.com | 1b1bcc3 | 2013-05-21 20:31:23 +0000 | [diff] [blame] | 23 | class SkData; |
robertphillips | db53990 | 2014-07-01 08:47:04 -0700 | [diff] [blame] | 24 | class SkPictureData; |
scroggo | 895c43b | 2014-12-11 10:53:58 -0800 | [diff] [blame] | 25 | class SkPixelSerializer; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 26 | class SkStream; |
| 27 | class SkWStream; |
| 28 | |
scroggo@google.com | f1754ec | 2013-06-28 21:32:00 +0000 | [diff] [blame] | 29 | struct SkPictInfo; |
| 30 | |
Mike Klein | 744fb73 | 2014-06-23 15:13:26 -0400 | [diff] [blame] | 31 | class SkRecord; |
| 32 | |
robertphillips | d8aa7b7 | 2014-10-30 16:45:02 -0700 | [diff] [blame] | 33 | namespace SkRecords { |
| 34 | class CollectLayers; |
| 35 | }; |
| 36 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | /** \class SkPicture |
| 38 | |
| 39 | The SkPicture class records the drawing commands made to a canvas, to |
| 40 | be played back at a later time. |
| 41 | */ |
mtklein | 08d1fcc | 2014-11-20 09:18:31 -0800 | [diff] [blame] | 42 | class SK_API SkPicture : public SkNVRefCnt<SkPicture> { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 43 | public: |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 44 | // AccelData provides a base class for device-specific acceleration |
robertphillips | 8236591 | 2014-11-12 09:32:34 -0800 | [diff] [blame] | 45 | // data. It is added to the picture via EXPERIMENTAL_addAccelData. |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 46 | class AccelData : public SkRefCnt { |
| 47 | public: |
| 48 | typedef uint8_t Domain; |
| 49 | typedef uint32_t Key; |
| 50 | |
| 51 | AccelData(Key key) : fKey(key) { } |
| 52 | |
| 53 | const Key& getKey() const { return fKey; } |
| 54 | |
| 55 | // This entry point allows user's to get a unique domain prefix |
| 56 | // for their keys |
| 57 | static Domain GenerateDomain(); |
| 58 | private: |
| 59 | Key fKey; |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 62 | /** PRIVATE / EXPERIMENTAL -- do not call */ |
Mike Klein | 744fb73 | 2014-06-23 15:13:26 -0400 | [diff] [blame] | 63 | void EXPERIMENTAL_addAccelData(const AccelData*) const; |
| 64 | |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 65 | /** PRIVATE / EXPERIMENTAL -- do not call */ |
Mike Klein | 744fb73 | 2014-06-23 15:13:26 -0400 | [diff] [blame] | 66 | const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key) const; |
commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 67 | |
reed@google.com | 34342f6 | 2012-06-25 14:36:28 +0000 | [diff] [blame] | 68 | /** |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 69 | * Function signature defining a function that sets up an SkBitmap from encoded data. On |
| 70 | * success, the SkBitmap should have its Config, width, height, rowBytes and pixelref set. |
| 71 | * If the installed pixelref has decoded the data into pixels, then the src buffer need not be |
| 72 | * copied. If the pixelref defers the actual decode until its lockPixels() is called, then it |
| 73 | * must make a copy of the src buffer. |
| 74 | * @param src Encoded data. |
| 75 | * @param length Size of the encoded data, in bytes. |
| 76 | * @param dst SkBitmap to install the pixel ref on. |
| 77 | * @param bool Whether or not a pixel ref was successfully installed. |
| 78 | */ |
| 79 | typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap* dst); |
| 80 | |
| 81 | /** |
| 82 | * Recreate a picture that was serialized into a stream. |
scroggo | a1193e4 | 2015-01-21 12:09:53 -0800 | [diff] [blame] | 83 | * @param SkStream Serialized picture data. Ownership is unchanged by this call. |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 84 | * @param proc Function pointer for installing pixelrefs on SkBitmaps representing the |
| 85 | * encoded bitmap data from the stream. |
scroggo@google.com | f1754ec | 2013-06-28 21:32:00 +0000 | [diff] [blame] | 86 | * @return A new SkPicture representing the serialized data, or NULL if the stream is |
| 87 | * invalid. |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 88 | */ |
scroggo@google.com | f1754ec | 2013-06-28 21:32:00 +0000 | [diff] [blame] | 89 | static SkPicture* CreateFromStream(SkStream*, |
| 90 | InstallPixelRefProc proc = &SkImageDecoder::DecodeMemory); |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 91 | |
commit-bot@chromium.org | 5e0995e | 2014-02-07 12:20:04 +0000 | [diff] [blame] | 92 | /** |
| 93 | * Recreate a picture that was serialized into a buffer. If the creation requires bitmap |
| 94 | * decoding, the decoder must be set on the SkReadBuffer parameter by calling |
| 95 | * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuffer(). |
| 96 | * @param SkReadBuffer Serialized picture data. |
| 97 | * @return A new SkPicture representing the serialized data, or NULL if the buffer is |
| 98 | * invalid. |
| 99 | */ |
| 100 | static SkPicture* CreateFromBuffer(SkReadBuffer&); |
| 101 | |
mtklein | 08d1fcc | 2014-11-20 09:18:31 -0800 | [diff] [blame] | 102 | ~SkPicture(); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 103 | |
robertphillips | 783fe16 | 2015-01-07 07:28:41 -0800 | [diff] [blame] | 104 | /** |
| 105 | * Subclasses of this can be passed to playback(). During the playback |
| 106 | * of the picture, this callback will periodically be invoked. If its |
| 107 | * abort() returns true, then picture playback will be interrupted. |
| 108 | * |
| 109 | * The resulting drawing is undefined, as there is no guarantee how often the |
| 110 | * callback will be invoked. If the abort happens inside some level of nested |
| 111 | * calls to save(), restore will automatically be called to return the state |
| 112 | * to the same level it was before the playback call was made. |
| 113 | */ |
| 114 | class SK_API AbortCallback { |
| 115 | public: |
| 116 | AbortCallback() {} |
| 117 | virtual ~AbortCallback() {} |
| 118 | |
| 119 | virtual bool abort() = 0; |
| 120 | }; |
| 121 | |
robertphillips | c5ba71d | 2014-09-04 08:42:50 -0700 | [diff] [blame] | 122 | /** Replays the drawing commands on the specified canvas. Note that |
| 123 | this has the effect of unfurling this picture into the destination |
| 124 | canvas. Using the SkCanvas::drawPicture entry point gives the destination |
| 125 | canvas the option of just taking a ref. |
reed@google.com | 74babdf | 2013-05-20 17:02:41 +0000 | [diff] [blame] | 126 | @param canvas the canvas receiving the drawing commands. |
robertphillips | c5ba71d | 2014-09-04 08:42:50 -0700 | [diff] [blame] | 127 | @param callback a callback that allows interruption of playback |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 128 | */ |
robertphillips | 783fe16 | 2015-01-07 07:28:41 -0800 | [diff] [blame] | 129 | void playback(SkCanvas* canvas, AbortCallback* = NULL) const; |
robertphillips | c5ba71d | 2014-09-04 08:42:50 -0700 | [diff] [blame] | 130 | |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 131 | /** Return the cull rect used when creating this picture: { 0, 0, cullWidth, cullHeight }. |
| 132 | It does not necessarily reflect the bounds of what has been recorded into the picture. |
| 133 | @return the cull rect used to create this picture |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 134 | */ |
reed | 78e2768 | 2014-11-19 08:04:34 -0800 | [diff] [blame] | 135 | SkRect cullRect() const { return fCullRect; } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 136 | |
reed | 41d2c2e | 2014-11-21 08:07:41 -0800 | [diff] [blame] | 137 | /** Return a non-zero, unique value representing the picture. |
| 138 | */ |
mtklein | e35268e | 2015-04-07 06:34:05 -0700 | [diff] [blame] | 139 | uint32_t uniqueID() const; |
robertphillips@google.com | d550088 | 2014-04-02 23:51:13 +0000 | [diff] [blame] | 140 | |
scroggo@google.com | 5a7c6be | 2012-10-04 21:46:08 +0000 | [diff] [blame] | 141 | /** |
scroggo | 895c43b | 2014-12-11 10:53:58 -0800 | [diff] [blame] | 142 | * Serialize to a stream. If non NULL, serializer will be used to serialize |
| 143 | * any bitmaps in the picture. |
| 144 | * |
| 145 | * TODO: Use serializer to serialize SkImages as well. |
| 146 | */ |
| 147 | void serialize(SkWStream*, SkPixelSerializer* serializer = NULL) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 148 | |
tomhudson@google.com | 381010e | 2013-10-24 11:12:47 +0000 | [diff] [blame] | 149 | /** |
commit-bot@chromium.org | 5e0995e | 2014-02-07 12:20:04 +0000 | [diff] [blame] | 150 | * Serialize to a buffer. |
| 151 | */ |
| 152 | void flatten(SkWriteBuffer&) const; |
| 153 | |
| 154 | /** |
tomhudson@google.com | 381010e | 2013-10-24 11:12:47 +0000 | [diff] [blame] | 155 | * Returns true if any bitmaps may be produced when this SkPicture |
| 156 | * is replayed. |
tomhudson@google.com | 381010e | 2013-10-24 11:12:47 +0000 | [diff] [blame] | 157 | */ |
| 158 | bool willPlayBackBitmaps() const; |
| 159 | |
commit-bot@chromium.org | 6f4fb0f | 2014-03-03 19:18:39 +0000 | [diff] [blame] | 160 | /** Return true if the SkStream/Buffer represents a serialized picture, and |
| 161 | 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] | 162 | 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] | 163 | CreateFromStream or CreateFromBuffer. Note, CreateFromStream and |
| 164 | CreateFromBuffer perform this check internally so these entry points are |
| 165 | intended for stand alone tools. |
| 166 | If false is returned, SkPictInfo is unmodified. |
| 167 | */ |
| 168 | static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*); |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 169 | static bool InternalOnly_BufferIsSKP(SkReadBuffer*, SkPictInfo*); |
commit-bot@chromium.org | 6f4fb0f | 2014-03-03 19:18:39 +0000 | [diff] [blame] | 170 | |
commit-bot@chromium.org | eb9547c | 2014-03-19 21:24:25 +0000 | [diff] [blame] | 171 | /** Return true if the picture is suitable for rendering on the GPU. |
| 172 | */ |
| 173 | |
| 174 | #if SK_SUPPORT_GPU |
commit-bot@chromium.org | a1ff26a | 2014-05-30 21:52:52 +0000 | [diff] [blame] | 175 | bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const; |
commit-bot@chromium.org | eb9547c | 2014-03-19 21:24:25 +0000 | [diff] [blame] | 176 | #endif |
| 177 | |
mtklein | 5a246bb | 2014-08-14 19:17:18 -0700 | [diff] [blame] | 178 | /** Return the approximate number of operations in this picture. This |
| 179 | * number may be greater or less than the number of SkCanvas calls |
| 180 | * recorded: some calls may be recorded as more than one operation, or some |
| 181 | * calls may be optimized away. |
| 182 | */ |
| 183 | int approximateOpCount() const; |
| 184 | |
ajuma | 750ae26 | 2014-08-18 12:59:55 -0700 | [diff] [blame] | 185 | /** Return true if this picture contains text. |
| 186 | */ |
| 187 | bool hasText() const; |
| 188 | |
mtklein | 19ac767 | 2014-11-21 12:20:35 -0800 | [diff] [blame] | 189 | // An array of refcounted const SkPicture pointers. |
| 190 | class SnapshotArray : ::SkNoncopyable { |
| 191 | public: |
reed | 735f548 | 2014-11-23 18:37:14 -0800 | [diff] [blame] | 192 | SnapshotArray(const SkPicture* pics[], int count) : fPics(pics), fCount(count) {} |
| 193 | ~SnapshotArray() { for (int i = 0; i < fCount; i++) { fPics[i]->unref(); } } |
mtklein | b7ee349 | 2014-11-21 11:06:04 -0800 | [diff] [blame] | 194 | |
| 195 | const SkPicture* const* begin() const { return fPics; } |
reed | 735f548 | 2014-11-23 18:37:14 -0800 | [diff] [blame] | 196 | int count() const { return fCount; } |
mtklein | b7ee349 | 2014-11-21 11:06:04 -0800 | [diff] [blame] | 197 | private: |
| 198 | SkAutoTMalloc<const SkPicture*> fPics; |
reed | 735f548 | 2014-11-23 18:37:14 -0800 | [diff] [blame] | 199 | int fCount; |
mtklein | b7ee349 | 2014-11-21 11:06:04 -0800 | [diff] [blame] | 200 | }; |
| 201 | |
mtklein | 04c9695 | 2014-11-24 08:20:57 -0800 | [diff] [blame] | 202 | // Sent via SkMessageBus from destructor. |
| 203 | struct DeletionMessage { int32_t fUniqueID; }; |
| 204 | |
robertphillips | 6daadc7 | 2014-07-08 08:38:18 -0700 | [diff] [blame] | 205 | private: |
robertphillips@google.com | 9a5b570 | 2012-11-13 20:41:18 +0000 | [diff] [blame] | 206 | // V2 : adds SkPixelRef's generation ID. |
| 207 | // V3 : PictInfo tag at beginning, and EOF tag at the end |
| 208 | // V4 : move SkPictInfo to be the header |
| 209 | // V5 : don't read/write FunctionPtr on cross-process (we can detect that) |
| 210 | // V6 : added serialization of SkPath's bounds (and packed its flags tighter) |
| 211 | // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) |
| 212 | // V8 : Add an option for encoding bitmaps |
| 213 | // V9 : Allow the reader and writer of an SKP disagree on whether to support |
| 214 | // SK_SUPPORT_HINTING_SCALE_FACTOR |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 215 | // V10: add drawRRect, drawOval, clipRRect |
scroggo@google.com | 74b7ffd | 2013-04-30 02:32:41 +0000 | [diff] [blame] | 216 | // V11: modify how readBitmap and writeBitmap store their info. |
reed@google.com | 277c3f8 | 2013-05-31 15:17:50 +0000 | [diff] [blame] | 217 | // V12: add conics to SkPath, use new SkPathRef flattening |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 218 | // V13: add flag to drawBitmapRectToRect |
robertphillips@google.com | 7ce661d | 2013-08-27 16:14:03 +0000 | [diff] [blame] | 219 | // parameterize blurs by sigma rather than radius |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 220 | // V14: Add flags word to PathRef serialization |
robertphillips@google.com | d550088 | 2014-04-02 23:51:13 +0000 | [diff] [blame] | 221 | // V15: Remove A1 bitmap config (and renumber remaining configs) |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 222 | // V16: Move SkPath's isOval flag to SkPathRef |
reed@google.com | e132f50 | 2013-12-13 19:58:46 +0000 | [diff] [blame] | 223 | // V17: SkPixelRef now writes SkImageInfo |
reed@google.com | 672588b | 2014-01-08 15:42:01 +0000 | [diff] [blame] | 224 | // 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] | 225 | // V19: encode matrices and regions into the ops stream |
commit-bot@chromium.org | 5e0995e | 2014-02-07 12:20:04 +0000 | [diff] [blame] | 226 | // 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] | 227 | // V21: add pushCull, popCull |
commit-bot@chromium.org | dcb8e54 | 2014-03-05 18:25:20 +0000 | [diff] [blame] | 228 | // 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] | 229 | // V23: SkPaint::FilterLevel became a real enum |
commit-bot@chromium.org | 44d83c1 | 2014-04-21 13:10:25 +0000 | [diff] [blame] | 230 | // V24: SkTwoPointConicalGradient now has fFlipped flag for gradient flipping |
commit-bot@chromium.org | aec1438 | 2014-04-22 15:21:18 +0000 | [diff] [blame] | 231 | // 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] | 232 | // V26: Removed boolean from SkColorShader for inheriting color from SkPaint. |
commit-bot@chromium.org | 83f23d8 | 2014-05-22 12:27:41 +0000 | [diff] [blame] | 233 | // V27: Remove SkUnitMapper from gradients (and skia). |
commit-bot@chromium.org | 968edca | 2014-05-23 13:21:55 +0000 | [diff] [blame] | 234 | // V28: No longer call bitmap::flatten inside SkWriteBuffer::writeBitmap. |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 235 | // V29: Removed SaveFlags parameter from save(). |
scroggo | c870d49 | 2014-07-11 10:42:12 -0700 | [diff] [blame] | 236 | // V30: Remove redundant SkMatrix from SkLocalMatrixShader. |
senorblanco | 55b6d8b | 2014-07-30 11:26:46 -0700 | [diff] [blame] | 237 | // V31: Add a serialized UniqueID to SkImageFilter. |
djsollen | 3b62554 | 2014-08-14 06:29:02 -0700 | [diff] [blame] | 238 | // V32: Removed SkPaintOptionsAndroid from SkPaint |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 239 | // V33: Serialize only public API of effects. |
| 240 | // V34: Add SkTextBlob serialization. |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 241 | // V35: Store SkRect (rather then width & height) in header |
reed | c5e15a1 | 2014-09-29 12:10:27 -0700 | [diff] [blame] | 242 | // V36: Remove (obsolete) alphatype from SkColorTable |
reed | 8eddfb5 | 2014-12-04 07:50:14 -0800 | [diff] [blame] | 243 | // V37: Added shadow only option to SkDropShadowImageFilter (last version to record CLEAR) |
junov | f3c78cc | 2014-12-09 13:07:22 -0800 | [diff] [blame] | 244 | // V38: Added PictureResolution option to SkPictureImageFilter |
| 245 | // V39: Added FilterLevel option to SkPictureImageFilter |
senorblanco | 4a22a43 | 2015-03-18 13:14:54 -0700 | [diff] [blame] | 246 | // V40: Remove UniqueID serialization from SkImageFilter. |
robertphillips | 25c40d2 | 2015-04-10 08:39:58 -0700 | [diff] [blame] | 247 | // V41: Added serialization of SkBitmapSource's filterQuality parameter |
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. |
mtklein | 88fd0fb | 2014-12-01 06:56:38 -0800 | [diff] [blame] | 253 | static const uint32_t MIN_PICTURE_VERSION = 35; // Produced by Chrome M39. |
robertphillips | 25c40d2 | 2015-04-10 08:39:58 -0700 | [diff] [blame] | 254 | static const uint32_t CURRENT_PICTURE_VERSION = 41; |
robertphillips@google.com | 9a5b570 | 2012-11-13 20:41:18 +0000 | [diff] [blame] | 255 | |
bungeman | 9d911d5 | 2015-04-17 11:00:06 -0700 | [diff] [blame^] | 256 | static_assert(MIN_PICTURE_VERSION <= 41, |
| 257 | "Remove kFontFileName and related code from SkFontDescriptor.cpp."); |
| 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 | 19ac767 | 2014-11-21 12:20:35 -0800 | [diff] [blame] | 262 | // Takes ownership of the SkRecord and (optional) SnapshotArray, refs the (optional) BBH. |
mtklein | b7ee349 | 2014-11-21 11:06:04 -0800 | [diff] [blame] | 263 | SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, 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*); |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 266 | static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, |
| 267 | SkPicture const* const drawablePics[], int drawableCount); |
mtklein | c6ad9ee | 2014-11-17 06:45:18 -0800 | [diff] [blame] | 268 | |
mtklein | 08d1fcc | 2014-11-20 09:18:31 -0800 | [diff] [blame] | 269 | // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> |
mtklein | e35268e | 2015-04-07 06:34:05 -0700 | [diff] [blame] | 270 | mutable uint32_t fUniqueID; |
reed | 78e2768 | 2014-11-19 08:04:34 -0800 | [diff] [blame] | 271 | const SkRect fCullRect; |
mtklein | c6ad9ee | 2014-11-17 06:45:18 -0800 | [diff] [blame] | 272 | mutable SkAutoTUnref<const AccelData> fAccelData; |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 273 | SkAutoTUnref<const SkRecord> fRecord; |
| 274 | SkAutoTUnref<const SkBBoxHierarchy> fBBH; |
| 275 | SkAutoTDelete<const SnapshotArray> fDrawablePicts; |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 276 | |
| 277 | // helpers for fDrawablePicts |
| 278 | int drawableCount() const; |
| 279 | // will return NULL if drawableCount() returns 0 |
| 280 | SkPicture const* const* drawablePicts() const; |
| 281 | |
| 282 | struct PathCounter; |
| 283 | |
tomhudson | 3a0f279 | 2014-08-20 05:29:41 -0700 | [diff] [blame] | 284 | struct Analysis { |
mtklein | c551d9f | 2014-08-20 08:09:46 -0700 | [diff] [blame] | 285 | Analysis() {} // Only used by SkPictureData codepath. |
| 286 | explicit Analysis(const SkRecord&); |
tomhudson | 3a0f279 | 2014-08-20 05:29:41 -0700 | [diff] [blame] | 287 | |
| 288 | bool suitableForGpuRasterization(const char** reason, int sampleCount) const; |
| 289 | |
| 290 | bool fWillPlaybackBitmaps; |
mtklein | c551d9f | 2014-08-20 08:09:46 -0700 | [diff] [blame] | 291 | bool fHasText; |
tomhudson | 3a0f279 | 2014-08-20 05:29:41 -0700 | [diff] [blame] | 292 | int fNumPaintWithPathEffectUses; |
| 293 | int fNumFastPathDashEffects; |
| 294 | int fNumAAConcavePaths; |
| 295 | int fNumAAHairlineConcavePaths; |
jvanverth | f7007b0 | 2014-11-04 07:59:01 -0800 | [diff] [blame] | 296 | int fNumAADFEligibleConcavePaths; |
mtklein | c551d9f | 2014-08-20 08:09:46 -0700 | [diff] [blame] | 297 | } fAnalysis; |
mtklein | c6ad9ee | 2014-11-17 06:45:18 -0800 | [diff] [blame] | 298 | |
mtklein | c6ad9ee | 2014-11-17 06:45:18 -0800 | [diff] [blame] | 299 | friend class SkPictureRecorder; // SkRecord-based constructor. |
| 300 | friend class GrLayerHoister; // access to fRecord |
| 301 | friend class ReplaceDraw; |
tomhudson | 158fcaa | 2014-11-19 10:41:14 -0800 | [diff] [blame] | 302 | friend class SkPictureUtils; |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 303 | friend class SkRecordedDrawable; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 304 | }; |
mtklein | 08d1fcc | 2014-11-20 09:18:31 -0800 | [diff] [blame] | 305 | SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 306 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 307 | #endif |