epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
reed@google.com | 76f10a3 | 2014-02-05 15:32:21 +0000 | [diff] [blame] | 7 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #include "SkPictureRecord.h" |
reed | a85d4d0 | 2015-05-06 12:56:48 -0700 | [diff] [blame] | 9 | #include "SkImage_Base.h" |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 10 | #include "SkPatchUtils.h" |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 11 | #include "SkPixelRef.h" |
| 12 | #include "SkRRect.h" |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 13 | #include "SkRSXform.h" |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 14 | #include "SkTextBlob.h" |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 15 | #include "SkTSearch.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 16 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 17 | #define HEAP_BLOCK_SIZE 4096 |
| 18 | |
junov@chromium.org | 4e6dfa5 | 2012-07-16 14:04:59 +0000 | [diff] [blame] | 19 | enum { |
reed@google.com | d86e7ab | 2012-09-27 20:31:31 +0000 | [diff] [blame] | 20 | // just need a value that save or getSaveCount would never return |
junov@chromium.org | 4e6dfa5 | 2012-07-16 14:04:59 +0000 | [diff] [blame] | 21 | kNoInitialSave = -1, |
| 22 | }; |
| 23 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 24 | // A lot of basic types get stored as a uint32_t: bools, ints, paint indices, etc. |
| 25 | static int const kUInt32Size = 4; |
| 26 | |
robertphillips | 0bdbea7 | 2014-06-11 11:37:55 -0700 | [diff] [blame] | 27 | SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags) |
commit-bot@chromium.org | 19fafef | 2014-02-17 15:28:00 +0000 | [diff] [blame] | 28 | : INHERITED(dimensions.width(), dimensions.height()) |
mtklein | 71a2363 | 2014-11-12 10:24:55 -0800 | [diff] [blame] | 29 | , fRecordFlags(flags) |
| 30 | , fInitialSaveCount(kNoInitialSave) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | SkPictureRecord::~SkPictureRecord() { |
robertphillips | 5351aad | 2015-06-23 06:54:56 -0700 | [diff] [blame] | 34 | fImageRefs.unrefAll(); |
djsollen@google.com | 21830d9 | 2012-08-07 19:49:41 +0000 | [diff] [blame] | 35 | fPictureRefs.unrefAll(); |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 36 | fDrawableRefs.unrefAll(); |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 37 | fTextBlobRefs.unrefAll(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | /////////////////////////////////////////////////////////////////////////////// |
| 41 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 42 | void SkPictureRecord::willSave() { |
reed@google.com | ffacd3c | 2012-08-30 15:31:23 +0000 | [diff] [blame] | 43 | // record the offset to us, making it non-positive to distinguish a save |
| 44 | // from a clip entry. |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 45 | fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten()); |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 46 | this->recordSave(); |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 47 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 48 | this->INHERITED::willSave(); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 49 | } |
skia.committer@gmail.com | 11f8692 | 2012-08-31 17:14:46 +0000 | [diff] [blame] | 50 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 51 | void SkPictureRecord::recordSave() { |
robertphillips | c019ec4 | 2014-08-12 05:35:58 -0700 | [diff] [blame] | 52 | fContentInfo.onSave(); |
| 53 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 54 | // op only |
reed | 512f3e3 | 2016-01-04 14:11:31 -0800 | [diff] [blame] | 55 | size_t size = sizeof(kUInt32Size); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 56 | size_t initialOffset = this->addDraw(SAVE, &size); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 57 | |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 58 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 59 | } |
| 60 | |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 61 | SkCanvas::SaveLayerStrategy SkPictureRecord::getSaveLayerStrategy(const SaveLayerRec& rec) { |
reed@google.com | ffacd3c | 2012-08-30 15:31:23 +0000 | [diff] [blame] | 62 | // record the offset to us, making it non-positive to distinguish a save |
| 63 | // from a clip entry. |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 64 | fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten()); |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 65 | this->recordSaveLayer(rec); |
skia.committer@gmail.com | 11f8692 | 2012-08-31 17:14:46 +0000 | [diff] [blame] | 66 | |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 67 | (void)this->INHERITED::getSaveLayerStrategy(rec); |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 68 | /* No need for a (potentially very big) layer which we don't actually need |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 69 | at this time (and may not be able to afford since during record our |
| 70 | clip starts out the size of the picture, which is often much larger |
| 71 | than the size of the actual device we'll use during playback). |
| 72 | */ |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 73 | return kNoLayer_SaveLayerStrategy; |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 74 | } |
| 75 | |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 76 | void SkPictureRecord::recordSaveLayer(const SaveLayerRec& rec) { |
robertphillips | c019ec4 | 2014-08-12 05:35:58 -0700 | [diff] [blame] | 77 | fContentInfo.onSaveLayer(); |
| 78 | |
reed | bfd5f17 | 2016-01-07 11:28:08 -0800 | [diff] [blame] | 79 | // op + flatflags |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 80 | size_t size = 2 * kUInt32Size; |
reed | bfd5f17 | 2016-01-07 11:28:08 -0800 | [diff] [blame] | 81 | uint32_t flatFlags = 0; |
| 82 | |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 83 | if (rec.fBounds) { |
reed | bfd5f17 | 2016-01-07 11:28:08 -0800 | [diff] [blame] | 84 | flatFlags |= SAVELAYERREC_HAS_BOUNDS; |
| 85 | size += sizeof(*rec.fBounds); |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 86 | } |
reed | bfd5f17 | 2016-01-07 11:28:08 -0800 | [diff] [blame] | 87 | if (rec.fPaint) { |
| 88 | flatFlags |= SAVELAYERREC_HAS_PAINT; |
| 89 | size += sizeof(uint32_t); // index |
| 90 | } |
| 91 | if (rec.fBackdrop) { |
| 92 | flatFlags |= SAVELAYERREC_HAS_BACKDROP; |
| 93 | size += sizeof(uint32_t); // (paint) index |
| 94 | } |
| 95 | if (rec.fSaveLayerFlags) { |
| 96 | flatFlags |= SAVELAYERREC_HAS_FLAGS; |
| 97 | size += sizeof(uint32_t); |
| 98 | } |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 99 | |
reed | bfd5f17 | 2016-01-07 11:28:08 -0800 | [diff] [blame] | 100 | const size_t initialOffset = this->addDraw(SAVE_LAYER_SAVELAYERREC, &size); |
| 101 | this->addInt(flatFlags); |
| 102 | if (flatFlags & SAVELAYERREC_HAS_BOUNDS) { |
| 103 | this->addRect(*rec.fBounds); |
| 104 | } |
| 105 | if (flatFlags & SAVELAYERREC_HAS_PAINT) { |
| 106 | this->addPaintPtr(rec.fPaint); |
| 107 | } |
| 108 | if (flatFlags & SAVELAYERREC_HAS_BACKDROP) { |
| 109 | // overkill, but we didn't already track single flattenables, so using a paint for that |
| 110 | SkPaint paint; |
| 111 | paint.setImageFilter(const_cast<SkImageFilter*>(rec.fBackdrop)); |
| 112 | this->addPaint(paint); |
| 113 | } |
| 114 | if (flatFlags & SAVELAYERREC_HAS_FLAGS) { |
| 115 | this->addInt(rec.fSaveLayerFlags); |
| 116 | } |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 117 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 118 | } |
| 119 | |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 120 | #ifdef SK_DEBUG |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 121 | /* |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 122 | * Read the op code from 'offset' in 'writer' and extract the size too. |
| 123 | */ |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 124 | static DrawType peek_op_and_size(SkWriter32* writer, size_t offset, uint32_t* size) { |
commit-bot@chromium.org | 536ac5e | 2014-02-11 22:38:51 +0000 | [diff] [blame] | 125 | uint32_t peek = writer->readTAt<uint32_t>(offset); |
reed@google.com | ffacd3c | 2012-08-30 15:31:23 +0000 | [diff] [blame] | 126 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 127 | uint32_t op; |
commit-bot@chromium.org | c6d3c44 | 2014-01-31 16:22:57 +0000 | [diff] [blame] | 128 | UNPACK_8_24(peek, op, *size); |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 129 | if (MASK_24 == *size) { |
| 130 | // size required its own slot right after the op code |
commit-bot@chromium.org | 536ac5e | 2014-02-11 22:38:51 +0000 | [diff] [blame] | 131 | *size = writer->readTAt<uint32_t>(offset + kUInt32Size); |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 132 | } |
| 133 | return (DrawType) op; |
reed@google.com | ffacd3c | 2012-08-30 15:31:23 +0000 | [diff] [blame] | 134 | } |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 135 | #endif//SK_DEBUG |
commit-bot@chromium.org | 4b32bd5 | 2013-03-15 15:06:03 +0000 | [diff] [blame] | 136 | |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 137 | void SkPictureRecord::willRestore() { |
junov@chromium.org | 4e6dfa5 | 2012-07-16 14:04:59 +0000 | [diff] [blame] | 138 | #if 0 |
| 139 | SkASSERT(fRestoreOffsetStack.count() > 1); |
| 140 | #endif |
| 141 | |
reed@android.com | b4e22d6 | 2009-07-09 15:20:25 +0000 | [diff] [blame] | 142 | // check for underflow |
| 143 | if (fRestoreOffsetStack.count() == 0) { |
| 144 | return; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 145 | } |
reed@android.com | b4e22d6 | 2009-07-09 15:20:25 +0000 | [diff] [blame] | 146 | |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 147 | this->recordRestore(); |
reed@google.com | ffacd3c | 2012-08-30 15:31:23 +0000 | [diff] [blame] | 148 | |
reed@android.com | b4e22d6 | 2009-07-09 15:20:25 +0000 | [diff] [blame] | 149 | fRestoreOffsetStack.pop(); |
reed@android.com | 32a4249 | 2009-07-10 03:33:52 +0000 | [diff] [blame] | 150 | |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 151 | this->INHERITED::willRestore(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 152 | } |
| 153 | |
robertphillips@google.com | 105a4a5 | 2014-02-11 15:10:40 +0000 | [diff] [blame] | 154 | void SkPictureRecord::recordRestore(bool fillInSkips) { |
robertphillips | c019ec4 | 2014-08-12 05:35:58 -0700 | [diff] [blame] | 155 | fContentInfo.onRestore(); |
| 156 | |
robertphillips@google.com | 105a4a5 | 2014-02-11 15:10:40 +0000 | [diff] [blame] | 157 | if (fillInSkips) { |
| 158 | this->fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWriter.bytesWritten()); |
| 159 | } |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 160 | size_t size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code |
| 161 | size_t initialOffset = this->addDraw(RESTORE, &size); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 162 | this->validate(initialOffset, size); |
| 163 | } |
| 164 | |
commit-bot@chromium.org | d9ea09e | 2014-03-25 17:32:26 +0000 | [diff] [blame] | 165 | void SkPictureRecord::recordTranslate(const SkMatrix& m) { |
| 166 | SkASSERT(SkMatrix::kTranslate_Mask == m.getType()); |
| 167 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 168 | // op + dx + dy |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 169 | size_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 170 | size_t initialOffset = this->addDraw(TRANSLATE, &size); |
commit-bot@chromium.org | d9ea09e | 2014-03-25 17:32:26 +0000 | [diff] [blame] | 171 | this->addScalar(m.getTranslateX()); |
| 172 | this->addScalar(m.getTranslateY()); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 173 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 174 | } |
| 175 | |
commit-bot@chromium.org | d9ea09e | 2014-03-25 17:32:26 +0000 | [diff] [blame] | 176 | void SkPictureRecord::recordScale(const SkMatrix& m) { |
| 177 | SkASSERT(SkMatrix::kScale_Mask == m.getType()); |
robertphillips@google.com | 105a4a5 | 2014-02-11 15:10:40 +0000 | [diff] [blame] | 178 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 179 | // op + sx + sy |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 180 | size_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 181 | size_t initialOffset = this->addDraw(SCALE, &size); |
commit-bot@chromium.org | d9ea09e | 2014-03-25 17:32:26 +0000 | [diff] [blame] | 182 | this->addScalar(m.getScaleX()); |
| 183 | this->addScalar(m.getScaleY()); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 184 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 185 | } |
| 186 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 187 | void SkPictureRecord::didConcat(const SkMatrix& matrix) { |
commit-bot@chromium.org | d9ea09e | 2014-03-25 17:32:26 +0000 | [diff] [blame] | 188 | switch (matrix.getType()) { |
| 189 | case SkMatrix::kTranslate_Mask: |
| 190 | this->recordTranslate(matrix); |
| 191 | break; |
| 192 | case SkMatrix::kScale_Mask: |
| 193 | this->recordScale(matrix); |
| 194 | break; |
| 195 | default: |
| 196 | this->recordConcat(matrix); |
| 197 | break; |
| 198 | } |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 199 | this->INHERITED::didConcat(matrix); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | void SkPictureRecord::recordConcat(const SkMatrix& matrix) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 203 | this->validate(fWriter.bytesWritten(), 0); |
commit-bot@chromium.org | fed2ab6 | 2014-01-23 15:16:05 +0000 | [diff] [blame] | 204 | // op + matrix |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 205 | size_t size = kUInt32Size + matrix.writeToMemory(nullptr); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 206 | size_t initialOffset = this->addDraw(CONCAT, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 207 | this->addMatrix(matrix); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 208 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 209 | } |
| 210 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 211 | void SkPictureRecord::didSetMatrix(const SkMatrix& matrix) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 212 | this->validate(fWriter.bytesWritten(), 0); |
commit-bot@chromium.org | fed2ab6 | 2014-01-23 15:16:05 +0000 | [diff] [blame] | 213 | // op + matrix |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 214 | size_t size = kUInt32Size + matrix.writeToMemory(nullptr); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 215 | size_t initialOffset = this->addDraw(SET_MATRIX, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 216 | this->addMatrix(matrix); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 217 | this->validate(initialOffset, size); |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 218 | this->INHERITED::didSetMatrix(matrix); |
reed@android.com | 6e073b9 | 2009-01-06 15:03:30 +0000 | [diff] [blame] | 219 | } |
| 220 | |
vjiaoblack | e5de130 | 2016-07-13 14:05:28 -0700 | [diff] [blame] | 221 | void SkPictureRecord::didTranslateZ(SkScalar z) { |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 222 | #ifdef SK_EXPERIMENTAL_SHADOWING |
vjiaoblack | e5de130 | 2016-07-13 14:05:28 -0700 | [diff] [blame] | 223 | this->validate(fWriter.bytesWritten(), 0); |
| 224 | // op + scalar |
| 225 | size_t size = 1 * kUInt32Size + 1 * sizeof(SkScalar); |
| 226 | size_t initialOffset = this->addDraw(TRANSLATE_Z, &size); |
| 227 | this->addScalar(z); |
| 228 | this->validate(initialOffset, size); |
| 229 | this->INHERITED::didTranslateZ(z); |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 230 | #endif |
vjiaoblack | e5de130 | 2016-07-13 14:05:28 -0700 | [diff] [blame] | 231 | } |
| 232 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 233 | static bool clipOpExpands(SkCanvas::ClipOp op) { |
reed@google.com | 45482d1 | 2011-08-29 19:02:39 +0000 | [diff] [blame] | 234 | switch (op) { |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 235 | case SkCanvas::kUnion_Op: |
| 236 | case SkCanvas::kXOR_Op: |
| 237 | case SkCanvas::kReverseDifference_Op: |
| 238 | case SkCanvas::kReplace_Op: |
reed@google.com | 45482d1 | 2011-08-29 19:02:39 +0000 | [diff] [blame] | 239 | return true; |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 240 | case SkCanvas::kIntersect_Op: |
| 241 | case SkCanvas::kDifference_Op: |
reed@google.com | 45482d1 | 2011-08-29 19:02:39 +0000 | [diff] [blame] | 242 | return false; |
| 243 | default: |
tomhudson@google.com | 0c00f21 | 2011-12-28 14:59:50 +0000 | [diff] [blame] | 244 | SkDEBUGFAIL("unknown region op"); |
reed@google.com | 45482d1 | 2011-08-29 19:02:39 +0000 | [diff] [blame] | 245 | return false; |
| 246 | } |
| 247 | } |
| 248 | |
robertphillips@google.com | e37ad35 | 2013-03-01 19:44:30 +0000 | [diff] [blame] | 249 | void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffset) { |
reed@google.com | ffacd3c | 2012-08-30 15:31:23 +0000 | [diff] [blame] | 250 | int32_t offset = fRestoreOffsetStack.top(); |
| 251 | while (offset > 0) { |
commit-bot@chromium.org | 536ac5e | 2014-02-11 22:38:51 +0000 | [diff] [blame] | 252 | uint32_t peek = fWriter.readTAt<uint32_t>(offset); |
| 253 | fWriter.overwriteTAt(offset, restoreOffset); |
commit-bot@chromium.org | c6d3c44 | 2014-01-31 16:22:57 +0000 | [diff] [blame] | 254 | offset = peek; |
junov@chromium.org | e3dbedb | 2012-07-09 16:03:55 +0000 | [diff] [blame] | 255 | } |
skia.committer@gmail.com | 11f8692 | 2012-08-31 17:14:46 +0000 | [diff] [blame] | 256 | |
reed@google.com | ffacd3c | 2012-08-30 15:31:23 +0000 | [diff] [blame] | 257 | #ifdef SK_DEBUG |
reed | 2ff1fce | 2014-12-11 07:07:37 -0800 | [diff] [blame] | 258 | // offset of 0 has been disabled, so we skip it |
| 259 | if (offset > 0) { |
| 260 | // assert that the final offset value points to a save verb |
| 261 | uint32_t opSize; |
| 262 | DrawType drawOp = peek_op_and_size(&fWriter, -offset, &opSize); |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 263 | SkASSERT(SAVE_LAYER_SAVEFLAGS_DEPRECATED != drawOp); |
reed | bfd5f17 | 2016-01-07 11:28:08 -0800 | [diff] [blame] | 264 | SkASSERT(SAVE_LAYER_SAVELAYERFLAGS_DEPRECATED_JAN_2016 != drawOp); |
| 265 | SkASSERT(SAVE == drawOp || SAVE_LAYER_SAVELAYERREC == drawOp); |
reed | 2ff1fce | 2014-12-11 07:07:37 -0800 | [diff] [blame] | 266 | } |
reed@google.com | ffacd3c | 2012-08-30 15:31:23 +0000 | [diff] [blame] | 267 | #endif |
junov@chromium.org | e3dbedb | 2012-07-09 16:03:55 +0000 | [diff] [blame] | 268 | } |
| 269 | |
reed@google.com | d86e7ab | 2012-09-27 20:31:31 +0000 | [diff] [blame] | 270 | void SkPictureRecord::beginRecording() { |
| 271 | // we have to call this *after* our constructor, to ensure that it gets |
| 272 | // recorded. This is balanced by restoreToCount() call from endRecording, |
| 273 | // which in-turn calls our overridden restore(), so those get recorded too. |
commit-bot@chromium.org | 091a594 | 2014-04-18 14:19:31 +0000 | [diff] [blame] | 274 | fInitialSaveCount = this->save(); |
reed@google.com | d86e7ab | 2012-09-27 20:31:31 +0000 | [diff] [blame] | 275 | } |
| 276 | |
junov@chromium.org | a6c9e0e | 2012-07-12 17:47:34 +0000 | [diff] [blame] | 277 | void SkPictureRecord::endRecording() { |
junov@chromium.org | 4e6dfa5 | 2012-07-16 14:04:59 +0000 | [diff] [blame] | 278 | SkASSERT(kNoInitialSave != fInitialSaveCount); |
| 279 | this->restoreToCount(fInitialSaveCount); |
junov@chromium.org | a6c9e0e | 2012-07-12 17:47:34 +0000 | [diff] [blame] | 280 | } |
| 281 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 282 | size_t SkPictureRecord::recordRestoreOffsetPlaceholder(ClipOp op) { |
reed@google.com | 21b519d | 2012-10-02 17:42:15 +0000 | [diff] [blame] | 283 | if (fRestoreOffsetStack.isEmpty()) { |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 284 | return -1; |
reed@google.com | 21b519d | 2012-10-02 17:42:15 +0000 | [diff] [blame] | 285 | } |
| 286 | |
fmalita@google.com | d0f1a4f | 2013-08-27 15:50:19 +0000 | [diff] [blame] | 287 | // The RestoreOffset field is initially filled with a placeholder |
| 288 | // value that points to the offset of the previous RestoreOffset |
| 289 | // in the current stack level, thus forming a linked list so that |
| 290 | // the restore offsets can be filled in when the corresponding |
| 291 | // restore command is recorded. |
| 292 | int32_t prevOffset = fRestoreOffsetStack.top(); |
| 293 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 294 | if (clipOpExpands(op)) { |
reed@google.com | 45482d1 | 2011-08-29 19:02:39 +0000 | [diff] [blame] | 295 | // Run back through any previous clip ops, and mark their offset to |
| 296 | // be 0, disabling their ability to trigger a jump-to-restore, otherwise |
| 297 | // they could hide this clips ability to expand the clip (i.e. go from |
| 298 | // empty to non-empty). |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 299 | this->fillRestoreOffsetPlaceholdersForCurrentStackLevel(0); |
fmalita@google.com | d0f1a4f | 2013-08-27 15:50:19 +0000 | [diff] [blame] | 300 | |
| 301 | // Reset the pointer back to the previous clip so that subsequent |
| 302 | // restores don't overwrite the offsets we just cleared. |
| 303 | prevOffset = 0; |
reed@google.com | 45482d1 | 2011-08-29 19:02:39 +0000 | [diff] [blame] | 304 | } |
vandebo@chromium.org | 74b4619 | 2012-01-28 01:45:11 +0000 | [diff] [blame] | 305 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 306 | size_t offset = fWriter.bytesWritten(); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 307 | this->addInt(prevOffset); |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 308 | fRestoreOffsetStack.top() = SkToU32(offset); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 309 | return offset; |
reed@google.com | 45482d1 | 2011-08-29 19:02:39 +0000 | [diff] [blame] | 310 | } |
| 311 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 312 | void SkPictureRecord::onClipRect(const SkRect& rect, SkCanvas::ClipOp op, ClipEdgeStyle edgeStyle) { |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 313 | this->recordClipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 314 | this->INHERITED::onClipRect(rect, op, edgeStyle); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 315 | } |
| 316 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 317 | size_t SkPictureRecord::recordClipRect(const SkRect& rect, SkCanvas::ClipOp op, bool doAA) { |
robertphillips@google.com | f929150 | 2013-02-15 15:13:27 +0000 | [diff] [blame] | 318 | // id + rect + clip params |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 319 | size_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; |
robertphillips@google.com | 4310c66 | 2013-03-01 14:17:58 +0000 | [diff] [blame] | 320 | // recordRestoreOffsetPlaceholder doesn't always write an offset |
robertphillips@google.com | f929150 | 2013-02-15 15:13:27 +0000 | [diff] [blame] | 321 | if (!fRestoreOffsetStack.isEmpty()) { |
| 322 | // + restore offset |
| 323 | size += kUInt32Size; |
| 324 | } |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 325 | size_t initialOffset = this->addDraw(CLIP_RECT, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 326 | this->addRect(rect); |
| 327 | this->addInt(ClipParams_pack(op, doAA)); |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 328 | size_t offset = this->recordRestoreOffsetPlaceholder(op); |
skia.committer@gmail.com | 306ab9d | 2012-12-13 02:01:33 +0000 | [diff] [blame] | 329 | |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 330 | this->validate(initialOffset, size); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 331 | return offset; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 332 | } |
| 333 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 334 | void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkCanvas::ClipOp op, ClipEdgeStyle edgeStyle) { |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 335 | this->recordClipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); |
reed | d954498 | 2014-09-09 18:46:22 -0700 | [diff] [blame] | 336 | this->INHERITED::onClipRRect(rrect, op, edgeStyle); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 337 | } |
| 338 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 339 | size_t SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkCanvas::ClipOp op, bool doAA) { |
robertphillips@google.com | f929150 | 2013-02-15 15:13:27 +0000 | [diff] [blame] | 340 | // op + rrect + clip params |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 341 | size_t size = 1 * kUInt32Size + SkRRect::kSizeInMemory + 1 * kUInt32Size; |
robertphillips@google.com | 4310c66 | 2013-03-01 14:17:58 +0000 | [diff] [blame] | 342 | // recordRestoreOffsetPlaceholder doesn't always write an offset |
robertphillips@google.com | f929150 | 2013-02-15 15:13:27 +0000 | [diff] [blame] | 343 | if (!fRestoreOffsetStack.isEmpty()) { |
| 344 | // + restore offset |
| 345 | size += kUInt32Size; |
| 346 | } |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 347 | size_t initialOffset = this->addDraw(CLIP_RRECT, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 348 | this->addRRect(rrect); |
| 349 | this->addInt(ClipParams_pack(op, doAA)); |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 350 | size_t offset = recordRestoreOffsetPlaceholder(op); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 351 | this->validate(initialOffset, size); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 352 | return offset; |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 353 | } |
| 354 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 355 | void SkPictureRecord::onClipPath(const SkPath& path, SkCanvas::ClipOp op, ClipEdgeStyle edgeStyle) { |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 356 | int pathID = this->addPathToHeap(path); |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 357 | this->recordClipPath(pathID, op, kSoft_ClipEdgeStyle == edgeStyle); |
reed | d954498 | 2014-09-09 18:46:22 -0700 | [diff] [blame] | 358 | this->INHERITED::onClipPath(path, op, edgeStyle); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 359 | } |
| 360 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 361 | size_t SkPictureRecord::recordClipPath(int pathID, SkCanvas::ClipOp op, bool doAA) { |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 362 | // op + path index + clip params |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 363 | size_t size = 3 * kUInt32Size; |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 364 | // recordRestoreOffsetPlaceholder doesn't always write an offset |
| 365 | if (!fRestoreOffsetStack.isEmpty()) { |
| 366 | // + restore offset |
| 367 | size += kUInt32Size; |
| 368 | } |
| 369 | size_t initialOffset = this->addDraw(CLIP_PATH, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 370 | this->addInt(pathID); |
| 371 | this->addInt(ClipParams_pack(op, doAA)); |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 372 | size_t offset = recordRestoreOffsetPlaceholder(op); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 373 | this->validate(initialOffset, size); |
| 374 | return offset; |
| 375 | } |
| 376 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 377 | void SkPictureRecord::onClipRegion(const SkRegion& region, ClipOp op) { |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 378 | this->recordClipRegion(region, op); |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 379 | this->INHERITED::onClipRegion(region, op); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 380 | } |
| 381 | |
reed | 73603f3 | 2016-09-20 08:42:38 -0700 | [diff] [blame^] | 382 | size_t SkPictureRecord::recordClipRegion(const SkRegion& region, ClipOp op) { |
commit-bot@chromium.org | fed2ab6 | 2014-01-23 15:16:05 +0000 | [diff] [blame] | 383 | // op + clip params + region |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 384 | size_t size = 2 * kUInt32Size + region.writeToMemory(nullptr); |
robertphillips@google.com | 4310c66 | 2013-03-01 14:17:58 +0000 | [diff] [blame] | 385 | // recordRestoreOffsetPlaceholder doesn't always write an offset |
robertphillips@google.com | f929150 | 2013-02-15 15:13:27 +0000 | [diff] [blame] | 386 | if (!fRestoreOffsetStack.isEmpty()) { |
| 387 | // + restore offset |
| 388 | size += kUInt32Size; |
| 389 | } |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 390 | size_t initialOffset = this->addDraw(CLIP_REGION, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 391 | this->addRegion(region); |
| 392 | this->addInt(ClipParams_pack(op, false)); |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 393 | size_t offset = this->recordRestoreOffsetPlaceholder(op); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 394 | |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 395 | this->validate(initialOffset, size); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 396 | return offset; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 397 | } |
| 398 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 399 | void SkPictureRecord::onDrawPaint(const SkPaint& paint) { |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 400 | // op + paint index |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 401 | size_t size = 2 * kUInt32Size; |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 402 | size_t initialOffset = this->addDraw(DRAW_PAINT, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 403 | this->addPaint(paint); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 404 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 405 | } |
| 406 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 407 | void SkPictureRecord::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], |
| 408 | const SkPaint& paint) { |
hendrikw | afdada2 | 2014-08-08 10:44:33 -0700 | [diff] [blame] | 409 | fContentInfo.onDrawPoints(count, paint); |
robertphillips@google.com | 105a4a5 | 2014-02-11 15:10:40 +0000 | [diff] [blame] | 410 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 411 | // op + paint index + mode + count + point data |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 412 | size_t size = 4 * kUInt32Size + count * sizeof(SkPoint); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 413 | size_t initialOffset = this->addDraw(DRAW_POINTS, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 414 | this->addPaint(paint); |
hendrikw | afdada2 | 2014-08-08 10:44:33 -0700 | [diff] [blame] | 415 | |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 416 | this->addInt(mode); |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 417 | this->addInt(SkToInt(count)); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 418 | fWriter.writeMul4(pts, count * sizeof(SkPoint)); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 419 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 420 | } |
| 421 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 422 | void SkPictureRecord::onDrawOval(const SkRect& oval, const SkPaint& paint) { |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 423 | // op + paint index + rect |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 424 | size_t size = 2 * kUInt32Size + sizeof(oval); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 425 | size_t initialOffset = this->addDraw(DRAW_OVAL, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 426 | this->addPaint(paint); |
| 427 | this->addRect(oval); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 428 | this->validate(initialOffset, size); |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 429 | } |
| 430 | |
bsalomon | ac3aa24 | 2016-08-19 11:25:19 -0700 | [diff] [blame] | 431 | void SkPictureRecord::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, |
| 432 | bool useCenter, const SkPaint& paint) { |
| 433 | // op + paint index + rect + start + sweep + bool (as int) |
| 434 | size_t size = 2 * kUInt32Size + sizeof(oval) + sizeof(startAngle) + sizeof(sweepAngle) + |
| 435 | sizeof(int); |
| 436 | size_t initialOffset = this->addDraw(DRAW_ARC, &size); |
| 437 | this->addPaint(paint); |
| 438 | this->addRect(oval); |
| 439 | this->addScalar(startAngle); |
| 440 | this->addScalar(sweepAngle); |
| 441 | this->addInt(useCenter); |
| 442 | this->validate(initialOffset, size); |
| 443 | } |
| 444 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 445 | void SkPictureRecord::onDrawRect(const SkRect& rect, const SkPaint& paint) { |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 446 | // op + paint index + rect |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 447 | size_t size = 2 * kUInt32Size + sizeof(rect); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 448 | size_t initialOffset = this->addDraw(DRAW_RECT, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 449 | this->addPaint(paint); |
| 450 | this->addRect(rect); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 451 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 452 | } |
| 453 | |
msarett | 44df651 | 2016-08-25 13:54:30 -0700 | [diff] [blame] | 454 | void SkPictureRecord::onDrawRegion(const SkRegion& region, const SkPaint& paint) { |
| 455 | // op + paint index + region |
| 456 | size_t regionBytes = region.writeToMemory(nullptr); |
| 457 | size_t size = 2 * kUInt32Size + regionBytes; |
| 458 | size_t initialOffset = this->addDraw(DRAW_REGION, &size); |
| 459 | this->addPaint(paint); |
| 460 | fWriter.writeRegion(region); |
| 461 | this->validate(initialOffset, size); |
| 462 | } |
| 463 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 464 | void SkPictureRecord::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 465 | // op + paint index + rrect |
| 466 | size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory; |
| 467 | size_t initialOffset = this->addDraw(DRAW_RRECT, &size); |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 468 | this->addPaint(paint); |
| 469 | this->addRRect(rrect); |
| 470 | this->validate(initialOffset, size); |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 471 | } |
| 472 | |
commit-bot@chromium.org | ed9806f | 2014-02-21 02:32:36 +0000 | [diff] [blame] | 473 | void SkPictureRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
| 474 | const SkPaint& paint) { |
commit-bot@chromium.org | ed9806f | 2014-02-21 02:32:36 +0000 | [diff] [blame] | 475 | // op + paint index + rrects |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 476 | size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory * 2; |
| 477 | size_t initialOffset = this->addDraw(DRAW_DRRECT, &size); |
commit-bot@chromium.org | ed9806f | 2014-02-21 02:32:36 +0000 | [diff] [blame] | 478 | this->addPaint(paint); |
| 479 | this->addRRect(outer); |
| 480 | this->addRRect(inner); |
| 481 | this->validate(initialOffset, size); |
| 482 | } |
| 483 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 484 | void SkPictureRecord::onDrawPath(const SkPath& path, const SkPaint& paint) { |
hendrikw | afdada2 | 2014-08-08 10:44:33 -0700 | [diff] [blame] | 485 | fContentInfo.onDrawPath(path, paint); |
commit-bot@chromium.org | e2cb12a | 2014-04-24 21:53:13 +0000 | [diff] [blame] | 486 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 487 | // op + paint index + path index |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 488 | size_t size = 3 * kUInt32Size; |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 489 | size_t initialOffset = this->addDraw(DRAW_PATH, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 490 | this->addPaint(paint); |
| 491 | this->addPath(path); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 492 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 493 | } |
| 494 | |
reed | a85d4d0 | 2015-05-06 12:56:48 -0700 | [diff] [blame] | 495 | void SkPictureRecord::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, |
| 496 | const SkPaint* paint) { |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 497 | // op + paint_index + image_index + x + y |
| 498 | size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); |
| 499 | size_t initialOffset = this->addDraw(DRAW_IMAGE, &size); |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 500 | this->addPaintPtr(paint); |
| 501 | this->addImage(image); |
| 502 | this->addScalar(x); |
| 503 | this->addScalar(y); |
| 504 | this->validate(initialOffset, size); |
reed | a85d4d0 | 2015-05-06 12:56:48 -0700 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 508 | const SkPaint* paint, SrcRectConstraint constraint) { |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 509 | // id + paint_index + image_index + bool_for_src + constraint |
| 510 | size_t size = 5 * kUInt32Size; |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 511 | if (src) { |
| 512 | size += sizeof(*src); // + rect |
reed | a85d4d0 | 2015-05-06 12:56:48 -0700 | [diff] [blame] | 513 | } |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 514 | size += sizeof(dst); // + rect |
mtklein | c2e2977 | 2015-10-30 05:24:58 -0700 | [diff] [blame] | 515 | |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 516 | size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size); |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 517 | this->addPaintPtr(paint); |
| 518 | this->addImage(image); |
| 519 | this->addRectPtr(src); // may be null |
| 520 | this->addRect(dst); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 521 | this->addInt(constraint); |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 522 | this->validate(initialOffset, size); |
reed | a85d4d0 | 2015-05-06 12:56:48 -0700 | [diff] [blame] | 523 | } |
| 524 | |
reed | 4c21dc5 | 2015-06-25 12:32:03 -0700 | [diff] [blame] | 525 | void SkPictureRecord::onDrawImageNine(const SkImage* img, const SkIRect& center, const SkRect& dst, |
| 526 | const SkPaint* paint) { |
| 527 | // id + paint_index + image_index + center + dst |
| 528 | size_t size = 3 * kUInt32Size + sizeof(SkIRect) + sizeof(SkRect); |
mtklein | c2e2977 | 2015-10-30 05:24:58 -0700 | [diff] [blame] | 529 | |
reed | 4c21dc5 | 2015-06-25 12:32:03 -0700 | [diff] [blame] | 530 | size_t initialOffset = this->addDraw(DRAW_IMAGE_NINE, &size); |
reed | 4c21dc5 | 2015-06-25 12:32:03 -0700 | [diff] [blame] | 531 | this->addPaintPtr(paint); |
| 532 | this->addImage(img); |
| 533 | this->addIRect(center); |
| 534 | this->addRect(dst); |
| 535 | this->validate(initialOffset, size); |
| 536 | } |
| 537 | |
msarett | 1688206 | 2016-08-16 09:31:08 -0700 | [diff] [blame] | 538 | void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& lattice, |
| 539 | const SkRect& dst, const SkPaint* paint) { |
| 540 | // xCount + xDivs + yCount+ yDivs |
msarett | 0764efe | 2016-09-02 11:24:30 -0700 | [diff] [blame] | 541 | int flagCount = (nullptr == lattice.fFlags) ? 0 : (lattice.fXCount + 1) * (lattice.fYCount + 1); |
| 542 | size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount + 1) * kUInt32Size + |
| 543 | SkAlign4(flagCount * sizeof(SkCanvas::Lattice::Flags)); |
msarett | 1688206 | 2016-08-16 09:31:08 -0700 | [diff] [blame] | 544 | |
| 545 | // op + paint index + image index + lattice + dst rect |
| 546 | size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst); |
| 547 | size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size); |
| 548 | this->addPaintPtr(paint); |
| 549 | this->addImage(image); |
| 550 | this->addInt(lattice.fXCount); |
| 551 | fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size); |
| 552 | this->addInt(lattice.fYCount); |
| 553 | fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size); |
msarett | 0764efe | 2016-09-02 11:24:30 -0700 | [diff] [blame] | 554 | this->addInt(flagCount); |
| 555 | fWriter.writePad(lattice.fFlags, flagCount * sizeof(SkCanvas::Lattice::Flags)); |
msarett | 1688206 | 2016-08-16 09:31:08 -0700 | [diff] [blame] | 556 | this->addRect(dst); |
| 557 | this->validate(initialOffset, size); |
| 558 | } |
| 559 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 560 | void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
| 561 | const SkPaint& paint) { |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 562 | // op + paint index + length + 'length' worth of chars + x + y |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 563 | size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 564 | |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 565 | DrawType op = DRAW_TEXT; |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 566 | size_t initialOffset = this->addDraw(op, &size); |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 567 | this->addPaint(paint); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 568 | this->addText(text, byteLength); |
| 569 | this->addScalar(x); |
| 570 | this->addScalar(y); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 571 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 572 | } |
| 573 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 574 | void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
| 575 | const SkPaint& paint) { |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 576 | int points = paint.countText(text, byteLength); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 577 | |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 578 | // op + paint index + length + 'length' worth of data + num points + x&y point data |
| 579 | size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + points * sizeof(SkPoint); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 580 | |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 581 | DrawType op = DRAW_POS_TEXT; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 582 | |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 583 | size_t initialOffset = this->addDraw(op, &size); |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 584 | this->addPaint(paint); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 585 | this->addText(text, byteLength); |
| 586 | this->addInt(points); |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 587 | fWriter.writeMul4(pos, points * sizeof(SkPoint)); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 588 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 589 | } |
| 590 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 591 | void SkPictureRecord::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], |
| 592 | SkScalar constY, const SkPaint& paint) { |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 593 | int points = paint.countText(text, byteLength); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 594 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 595 | // op + paint index + length + 'length' worth of data + num points |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 596 | size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size; |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 597 | // + y + the actual points |
| 598 | size += 1 * kUInt32Size + points * sizeof(SkScalar); |
commit-bot@chromium.org | cf7be95 | 2013-08-22 17:19:52 +0000 | [diff] [blame] | 599 | |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 600 | size_t initialOffset = this->addDraw(DRAW_POS_TEXT_H, &size); |
| 601 | this->addPaint(paint); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 602 | this->addText(text, byteLength); |
| 603 | this->addInt(points); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 604 | this->addScalar(constY); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 605 | fWriter.writeMul4(xpos, points * sizeof(SkScalar)); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 606 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 607 | } |
| 608 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 609 | void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
| 610 | const SkMatrix* matrix, const SkPaint& paint) { |
commit-bot@chromium.org | fed2ab6 | 2014-01-23 15:16:05 +0000 | [diff] [blame] | 611 | // op + paint index + length + 'length' worth of data + path index + matrix |
| 612 | const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 613 | size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.writeToMemory(nullptr); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 614 | size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 615 | this->addPaint(paint); |
| 616 | this->addText(text, byteLength); |
| 617 | this->addPath(path); |
| 618 | this->addMatrix(m); |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 619 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 620 | } |
| 621 | |
reed | 45561a0 | 2016-07-07 12:47:17 -0700 | [diff] [blame] | 622 | void SkPictureRecord::onDrawTextRSXform(const void* text, size_t byteLength, |
| 623 | const SkRSXform xform[], const SkRect* cull, |
| 624 | const SkPaint& paint) { |
| 625 | const int count = paint.countText(text, byteLength); |
| 626 | // [op + paint-index + count + flags + length] + [text] + [xform] + cull |
| 627 | size_t size = 5 * kUInt32Size + SkAlign4(byteLength) + count * sizeof(SkRSXform); |
| 628 | uint32_t flags = 0; |
| 629 | if (cull) { |
| 630 | flags |= DRAW_TEXT_RSXFORM_HAS_CULL; |
| 631 | size += sizeof(SkRect); |
| 632 | } |
| 633 | |
| 634 | size_t initialOffset = this->addDraw(DRAW_TEXT_RSXFORM, &size); |
| 635 | this->addPaint(paint); |
| 636 | this->addInt(count); |
| 637 | this->addInt(flags); |
| 638 | this->addText(text, byteLength); |
| 639 | fWriter.write(xform, count * sizeof(SkRSXform)); |
| 640 | if (cull) { |
| 641 | fWriter.write(cull, sizeof(SkRect)); |
| 642 | } |
| 643 | this->validate(initialOffset, size); |
| 644 | } |
| 645 | |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 646 | void SkPictureRecord::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 647 | const SkPaint& paint) { |
| 648 | |
| 649 | // op + paint index + blob index + x/y |
| 650 | size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); |
| 651 | size_t initialOffset = this->addDraw(DRAW_TEXT_BLOB, &size); |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 652 | |
| 653 | this->addPaint(paint); |
| 654 | this->addTextBlob(blob); |
| 655 | this->addScalar(x); |
| 656 | this->addScalar(y); |
| 657 | |
| 658 | this->validate(initialOffset, size); |
| 659 | } |
| 660 | |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 661 | void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, |
| 662 | const SkPaint* paint) { |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 663 | // op + picture index |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 664 | size_t size = 2 * kUInt32Size; |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 665 | size_t initialOffset; |
| 666 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 667 | if (nullptr == matrix && nullptr == paint) { |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 668 | initialOffset = this->addDraw(DRAW_PICTURE, &size); |
| 669 | this->addPicture(picture); |
| 670 | } else { |
| 671 | const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 672 | size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 673 | initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 674 | this->addPaintPtr(paint); |
fmalita | 9f49cfd | 2014-08-12 12:24:17 -0700 | [diff] [blame] | 675 | this->addMatrix(m); |
| 676 | this->addPicture(picture); |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 677 | } |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 678 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 679 | } |
| 680 | |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 681 | void SkPictureRecord::onDrawShadowedPicture(const SkPicture* picture, |
| 682 | const SkMatrix* matrix, |
vjiaoblack | e6f5d56 | 2016-08-25 06:30:23 -0700 | [diff] [blame] | 683 | const SkPaint* paint, |
| 684 | const SkShadowParams& params) { |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 685 | // op + picture index |
| 686 | size_t size = 2 * kUInt32Size; |
| 687 | size_t initialOffset; |
| 688 | |
vjiaoblack | e6f5d56 | 2016-08-25 06:30:23 -0700 | [diff] [blame] | 689 | // TODO: handle recording params. |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 690 | if (nullptr == matrix && nullptr == paint) { |
| 691 | initialOffset = this->addDraw(DRAW_PICTURE, &size); |
| 692 | this->addPicture(picture); |
| 693 | } else { |
| 694 | const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); |
| 695 | size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint |
| 696 | initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); |
| 697 | this->addPaintPtr(paint); |
| 698 | this->addMatrix(m); |
| 699 | this->addPicture(picture); |
| 700 | } |
| 701 | this->validate(initialOffset, size); |
| 702 | } |
| 703 | |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 704 | void SkPictureRecord::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) { |
| 705 | // op + drawable index |
| 706 | size_t size = 2 * kUInt32Size; |
| 707 | size_t initialOffset; |
| 708 | |
| 709 | if (nullptr == matrix) { |
| 710 | initialOffset = this->addDraw(DRAW_DRAWABLE, &size); |
| 711 | this->addDrawable(drawable); |
| 712 | } else { |
| 713 | size += matrix->writeToMemory(nullptr); // matrix |
| 714 | initialOffset = this->addDraw(DRAW_DRAWABLE_MATRIX, &size); |
| 715 | this->addMatrix(*matrix); |
| 716 | this->addDrawable(drawable); |
| 717 | } |
| 718 | this->validate(initialOffset, size); |
| 719 | } |
| 720 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 721 | void SkPictureRecord::onDrawVertices(VertexMode vmode, int vertexCount, |
| 722 | const SkPoint vertices[], const SkPoint texs[], |
| 723 | const SkColor colors[], SkXfermode* xfer, |
| 724 | const uint16_t indices[], int indexCount, |
| 725 | const SkPaint& paint) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 726 | uint32_t flags = 0; |
| 727 | if (texs) { |
| 728 | flags |= DRAW_VERTICES_HAS_TEXS; |
| 729 | } |
| 730 | if (colors) { |
| 731 | flags |= DRAW_VERTICES_HAS_COLORS; |
| 732 | } |
| 733 | if (indexCount > 0) { |
| 734 | flags |= DRAW_VERTICES_HAS_INDICES; |
| 735 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 736 | if (xfer) { |
reed@google.com | 85e143c | 2013-12-30 15:51:25 +0000 | [diff] [blame] | 737 | SkXfermode::Mode mode; |
| 738 | if (xfer->asMode(&mode) && SkXfermode::kModulate_Mode != mode) { |
| 739 | flags |= DRAW_VERTICES_HAS_XFER; |
| 740 | } |
| 741 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 742 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 743 | // op + paint index + flags + vmode + vCount + vertices |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 744 | size_t size = 5 * kUInt32Size + vertexCount * sizeof(SkPoint); |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 745 | if (flags & DRAW_VERTICES_HAS_TEXS) { |
| 746 | size += vertexCount * sizeof(SkPoint); // + uvs |
| 747 | } |
| 748 | if (flags & DRAW_VERTICES_HAS_COLORS) { |
| 749 | size += vertexCount * sizeof(SkColor); // + vert colors |
| 750 | } |
| 751 | if (flags & DRAW_VERTICES_HAS_INDICES) { |
| 752 | // + num indices + indices |
| 753 | size += 1 * kUInt32Size + SkAlign4(indexCount * sizeof(uint16_t)); |
| 754 | } |
reed@google.com | 85e143c | 2013-12-30 15:51:25 +0000 | [diff] [blame] | 755 | if (flags & DRAW_VERTICES_HAS_XFER) { |
| 756 | size += kUInt32Size; // mode enum |
| 757 | } |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 758 | |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 759 | size_t initialOffset = this->addDraw(DRAW_VERTICES, &size); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 760 | this->addPaint(paint); |
| 761 | this->addInt(flags); |
| 762 | this->addInt(vmode); |
| 763 | this->addInt(vertexCount); |
| 764 | this->addPoints(vertices, vertexCount); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 765 | if (flags & DRAW_VERTICES_HAS_TEXS) { |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 766 | this->addPoints(texs, vertexCount); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 767 | } |
| 768 | if (flags & DRAW_VERTICES_HAS_COLORS) { |
| 769 | fWriter.writeMul4(colors, vertexCount * sizeof(SkColor)); |
| 770 | } |
| 771 | if (flags & DRAW_VERTICES_HAS_INDICES) { |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 772 | this->addInt(indexCount); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 773 | fWriter.writePad(indices, indexCount * sizeof(uint16_t)); |
| 774 | } |
reed@google.com | 85e143c | 2013-12-30 15:51:25 +0000 | [diff] [blame] | 775 | if (flags & DRAW_VERTICES_HAS_XFER) { |
| 776 | SkXfermode::Mode mode = SkXfermode::kModulate_Mode; |
| 777 | (void)xfer->asMode(&mode); |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 778 | this->addInt(mode); |
reed@google.com | 85e143c | 2013-12-30 15:51:25 +0000 | [diff] [blame] | 779 | } |
robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 780 | this->validate(initialOffset, size); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 781 | } |
| 782 | |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 783 | void SkPictureRecord::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
| 784 | const SkPoint texCoords[4], SkXfermode* xmode, |
| 785 | const SkPaint& paint) { |
| 786 | // op + paint index + patch 12 control points + flag + patch 4 colors + 4 texture coordinates |
| 787 | size_t size = 2 * kUInt32Size + SkPatchUtils::kNumCtrlPts * sizeof(SkPoint) + kUInt32Size; |
| 788 | uint32_t flag = 0; |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 789 | if (colors) { |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 790 | flag |= DRAW_VERTICES_HAS_COLORS; |
| 791 | size += SkPatchUtils::kNumCorners * sizeof(SkColor); |
| 792 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 793 | if (texCoords) { |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 794 | flag |= DRAW_VERTICES_HAS_TEXS; |
| 795 | size += SkPatchUtils::kNumCorners * sizeof(SkPoint); |
| 796 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 797 | if (xmode) { |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 798 | SkXfermode::Mode mode; |
| 799 | if (xmode->asMode(&mode) && SkXfermode::kModulate_Mode != mode) { |
| 800 | flag |= DRAW_VERTICES_HAS_XFER; |
| 801 | size += kUInt32Size; |
| 802 | } |
| 803 | } |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 804 | |
dandov | 963137b | 2014-08-07 07:49:53 -0700 | [diff] [blame] | 805 | size_t initialOffset = this->addDraw(DRAW_PATCH, &size); |
dandov | 963137b | 2014-08-07 07:49:53 -0700 | [diff] [blame] | 806 | this->addPaint(paint); |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 807 | this->addPatch(cubics); |
| 808 | this->addInt(flag); |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 809 | |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 810 | // write optional parameters |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 811 | if (colors) { |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 812 | fWriter.write(colors, SkPatchUtils::kNumCorners * sizeof(SkColor)); |
| 813 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 814 | if (texCoords) { |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 815 | fWriter.write(texCoords, SkPatchUtils::kNumCorners * sizeof(SkPoint)); |
| 816 | } |
| 817 | if (flag & DRAW_VERTICES_HAS_XFER) { |
| 818 | SkXfermode::Mode mode = SkXfermode::kModulate_Mode; |
| 819 | xmode->asMode(&mode); |
| 820 | this->addInt(mode); |
| 821 | } |
dandov | 963137b | 2014-08-07 07:49:53 -0700 | [diff] [blame] | 822 | this->validate(initialOffset, size); |
| 823 | } |
| 824 | |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 825 | void SkPictureRecord::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], |
| 826 | const SkColor colors[], int count, SkXfermode::Mode mode, |
| 827 | const SkRect* cull, const SkPaint* paint) { |
| 828 | // [op + paint-index + atlas-index + flags + count] + [xform] + [tex] + [*colors + mode] + cull |
| 829 | size_t size = 5 * kUInt32Size + count * sizeof(SkRSXform) + count * sizeof(SkRect); |
| 830 | uint32_t flags = 0; |
| 831 | if (colors) { |
| 832 | flags |= DRAW_ATLAS_HAS_COLORS; |
| 833 | size += count * sizeof(SkColor); |
| 834 | size += sizeof(uint32_t); // xfermode::mode |
| 835 | } |
| 836 | if (cull) { |
| 837 | flags |= DRAW_ATLAS_HAS_CULL; |
| 838 | size += sizeof(SkRect); |
| 839 | } |
mtklein | c2e2977 | 2015-10-30 05:24:58 -0700 | [diff] [blame] | 840 | |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 841 | size_t initialOffset = this->addDraw(DRAW_ATLAS, &size); |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 842 | this->addPaintPtr(paint); |
| 843 | this->addImage(atlas); |
| 844 | this->addInt(flags); |
| 845 | this->addInt(count); |
| 846 | fWriter.write(xform, count * sizeof(SkRSXform)); |
| 847 | fWriter.write(tex, count * sizeof(SkRect)); |
| 848 | |
| 849 | // write optional parameters |
| 850 | if (colors) { |
| 851 | fWriter.write(colors, count * sizeof(SkColor)); |
| 852 | this->addInt(mode); |
| 853 | } |
| 854 | if (cull) { |
| 855 | fWriter.write(cull, sizeof(SkRect)); |
| 856 | } |
| 857 | this->validate(initialOffset, size); |
| 858 | } |
| 859 | |
reed | f70b531 | 2016-03-04 16:36:20 -0800 | [diff] [blame] | 860 | void SkPictureRecord::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) { |
| 861 | size_t keyLen = fWriter.WriteStringSize(key); |
| 862 | size_t valueLen = fWriter.WriteDataSize(value); |
| 863 | size_t size = 4 + sizeof(SkRect) + keyLen + valueLen; |
| 864 | |
| 865 | size_t initialOffset = this->addDraw(DRAW_ANNOTATION, &size); |
| 866 | this->addRect(rect); |
| 867 | fWriter.writeString(key); |
| 868 | fWriter.writeData(value); |
| 869 | this->validate(initialOffset, size); |
| 870 | } |
| 871 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 872 | /////////////////////////////////////////////////////////////////////////////// |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 873 | |
reed | 22b2af1 | 2016-08-29 07:52:13 -0700 | [diff] [blame] | 874 | template <typename T> int find_or_append_uniqueID(SkTDArray<const T*>& array, const T* obj) { |
| 875 | int index = array.select([&](const T* elem) { |
| 876 | return elem->uniqueID() == obj->uniqueID(); |
| 877 | }); |
| 878 | if (index < 0) { |
| 879 | index = array.count(); |
| 880 | *array.append() = SkRef(obj); |
| 881 | } |
| 882 | return index; |
| 883 | } |
| 884 | |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 885 | sk_sp<SkSurface> SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfaceProps&) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 886 | return nullptr; |
reed@google.com | 76f10a3 | 2014-02-05 15:32:21 +0000 | [diff] [blame] | 887 | } |
| 888 | |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 889 | void SkPictureRecord::addImage(const SkImage* image) { |
reed | 22b2af1 | 2016-08-29 07:52:13 -0700 | [diff] [blame] | 890 | // convention for images is 0-based index |
| 891 | this->addInt(find_or_append_uniqueID(fImageRefs, image)); |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 892 | } |
| 893 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 894 | void SkPictureRecord::addMatrix(const SkMatrix& matrix) { |
commit-bot@chromium.org | fed2ab6 | 2014-01-23 15:16:05 +0000 | [diff] [blame] | 895 | fWriter.writeMatrix(matrix); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 896 | } |
| 897 | |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 898 | void SkPictureRecord::addPaintPtr(const SkPaint* paint) { |
hendrikw | afdada2 | 2014-08-08 10:44:33 -0700 | [diff] [blame] | 899 | fContentInfo.onAddPaintPtr(paint); |
commit-bot@chromium.org | e2cb12a | 2014-04-24 21:53:13 +0000 | [diff] [blame] | 900 | |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 901 | if (paint) { |
mtklein | a74ce85 | 2014-11-12 09:19:02 -0800 | [diff] [blame] | 902 | fPaints.push_back(*paint); |
| 903 | this->addInt(fPaints.count()); |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 904 | } else { |
| 905 | this->addInt(0); |
| 906 | } |
commit-bot@chromium.org | cf7be95 | 2013-08-22 17:19:52 +0000 | [diff] [blame] | 907 | } |
| 908 | |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 909 | int SkPictureRecord::addPathToHeap(const SkPath& path) { |
mtklein | c2e2977 | 2015-10-30 05:24:58 -0700 | [diff] [blame] | 910 | if (int* n = fPaths.find(path)) { |
| 911 | return *n; |
| 912 | } |
| 913 | int n = fPaths.count() + 1; // 0 is reserved for null / error. |
| 914 | fPaths.set(path, n); |
| 915 | return n; |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 916 | } |
| 917 | |
| 918 | void SkPictureRecord::addPath(const SkPath& path) { |
robertphillips@google.com | cb6adec | 2014-02-05 14:05:38 +0000 | [diff] [blame] | 919 | this->addInt(this->addPathToHeap(path)); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 920 | } |
| 921 | |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 922 | void SkPictureRecord::addPatch(const SkPoint cubics[12]) { |
| 923 | fWriter.write(cubics, SkPatchUtils::kNumCtrlPts * sizeof(SkPoint)); |
dandov | 963137b | 2014-08-07 07:49:53 -0700 | [diff] [blame] | 924 | } |
| 925 | |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 926 | void SkPictureRecord::addPicture(const SkPicture* picture) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 927 | // follow the convention of recording a 1-based index |
reed | 22b2af1 | 2016-08-29 07:52:13 -0700 | [diff] [blame] | 928 | this->addInt(find_or_append_uniqueID(fPictureRefs, picture) + 1); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 929 | } |
| 930 | |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 931 | void SkPictureRecord::addDrawable(SkDrawable* drawable) { |
| 932 | int index = fDrawableRefs.find(drawable); |
| 933 | if (index < 0) { // not found |
| 934 | index = fDrawableRefs.count(); |
| 935 | *fDrawableRefs.append() = drawable; |
| 936 | drawable->ref(); |
| 937 | } |
| 938 | // follow the convention of recording a 1-based index |
| 939 | this->addInt(index + 1); |
| 940 | } |
| 941 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 942 | void SkPictureRecord::addPoint(const SkPoint& point) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 943 | fWriter.writePoint(point); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 944 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 945 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 946 | void SkPictureRecord::addPoints(const SkPoint pts[], int count) { |
| 947 | fWriter.writeMul4(pts, count * sizeof(SkPoint)); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 948 | } |
| 949 | |
senorblanco@chromium.org | 68250c8 | 2014-05-06 22:52:55 +0000 | [diff] [blame] | 950 | void SkPictureRecord::addNoOp() { |
| 951 | size_t size = kUInt32Size; // op |
| 952 | this->addDraw(NOOP, &size); |
| 953 | } |
| 954 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 955 | void SkPictureRecord::addRect(const SkRect& rect) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 956 | fWriter.writeRect(rect); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | void SkPictureRecord::addRectPtr(const SkRect* rect) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 960 | if (fWriter.writeBool(rect != nullptr)) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 961 | fWriter.writeRect(*rect); |
| 962 | } |
| 963 | } |
| 964 | |
reed@google.com | f0b5e11 | 2011-09-07 11:57:34 +0000 | [diff] [blame] | 965 | void SkPictureRecord::addIRect(const SkIRect& rect) { |
| 966 | fWriter.write(&rect, sizeof(rect)); |
| 967 | } |
| 968 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 969 | void SkPictureRecord::addIRectPtr(const SkIRect* rect) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 970 | if (fWriter.writeBool(rect != nullptr)) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 971 | *(SkIRect*)fWriter.reserve(sizeof(SkIRect)) = *rect; |
| 972 | } |
| 973 | } |
| 974 | |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 975 | void SkPictureRecord::addRRect(const SkRRect& rrect) { |
| 976 | fWriter.writeRRect(rrect); |
| 977 | } |
| 978 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 979 | void SkPictureRecord::addRegion(const SkRegion& region) { |
commit-bot@chromium.org | fed2ab6 | 2014-01-23 15:16:05 +0000 | [diff] [blame] | 980 | fWriter.writeRegion(region); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | void SkPictureRecord::addText(const void* text, size_t byteLength) { |
hendrikw | afdada2 | 2014-08-08 10:44:33 -0700 | [diff] [blame] | 984 | fContentInfo.onDrawText(); |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 985 | addInt(SkToInt(byteLength)); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 986 | fWriter.writePad(text, byteLength); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 987 | } |
| 988 | |
reed | 22b2af1 | 2016-08-29 07:52:13 -0700 | [diff] [blame] | 989 | void SkPictureRecord::addTextBlob(const SkTextBlob* blob) { |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 990 | // follow the convention of recording a 1-based index |
reed | 22b2af1 | 2016-08-29 07:52:13 -0700 | [diff] [blame] | 991 | this->addInt(find_or_append_uniqueID(fTextBlobRefs, blob) + 1); |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 992 | } |
| 993 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 994 | /////////////////////////////////////////////////////////////////////////////// |