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 | #ifndef SkPictureRecord_DEFINED |
| 9 | #define SkPictureRecord_DEFINED |
| 10 | |
| 11 | #include "SkCanvas.h" |
Brian Osman | 37886ce | 2018-03-09 13:40:31 -0500 | [diff] [blame] | 12 | #include "SkCanvasVirtualEnforcer.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 13 | #include "SkFlattenable.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 14 | #include "SkPicture.h" |
robertphillips | db53990 | 2014-07-01 08:47:04 -0700 | [diff] [blame] | 15 | #include "SkPictureData.h" |
bungeman | f3c15b7 | 2015-08-19 11:56:48 -0700 | [diff] [blame] | 16 | #include "SkTArray.h" |
| 17 | #include "SkTDArray.h" |
mtklein | c2e2977 | 2015-10-30 05:24:58 -0700 | [diff] [blame] | 18 | #include "SkTHash.h" |
Brian Salomon | 199fb87 | 2017-02-06 09:41:10 -0500 | [diff] [blame] | 19 | #include "SkVertices.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 20 | #include "SkWriter32.h" |
| 21 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 22 | // These macros help with packing and unpacking a single byte value and |
| 23 | // a 3 byte value into/out of a uint32_t |
| 24 | #define MASK_24 0x00FFFFFF |
| 25 | #define UNPACK_8_24(combined, small, large) \ |
| 26 | small = (combined >> 24) & 0xFF; \ |
| 27 | large = combined & MASK_24; |
| 28 | #define PACK_8_24(small, large) ((small << 24) | large) |
| 29 | |
| 30 | |
Brian Osman | 37886ce | 2018-03-09 13:40:31 -0500 | [diff] [blame] | 31 | class SkPictureRecord : public SkCanvasVirtualEnforcer<SkCanvas> { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 32 | public: |
robertphillips | 0bdbea7 | 2014-06-11 11:37:55 -0700 | [diff] [blame] | 33 | SkPictureRecord(const SkISize& dimensions, uint32_t recordFlags); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 34 | |
Florin Malita | 8fd15d8 | 2018-05-15 14:57:12 -0400 | [diff] [blame^] | 35 | const SkTArray<sk_sp<const SkPicture>>& getPictures() const { |
| 36 | return fPictures; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | } |
vandebo@chromium.org | 74b4619 | 2012-01-28 01:45:11 +0000 | [diff] [blame] | 38 | |
Florin Malita | 8fd15d8 | 2018-05-15 14:57:12 -0400 | [diff] [blame^] | 39 | const SkTArray<sk_sp<SkDrawable>>& getDrawables() const { |
| 40 | return fDrawables; |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 41 | } |
| 42 | |
Florin Malita | 8fd15d8 | 2018-05-15 14:57:12 -0400 | [diff] [blame^] | 43 | const SkTArray<sk_sp<const SkTextBlob>>& getTextBlobs() const { |
| 44 | return fTextBlobs; |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Florin Malita | 8fd15d8 | 2018-05-15 14:57:12 -0400 | [diff] [blame^] | 47 | const SkTArray<sk_sp<const SkVertices>>& getVertices() const { |
| 48 | return fVertices; |
Mike Reed | e88a1cb | 2017-03-17 09:50:46 -0400 | [diff] [blame] | 49 | } |
| 50 | |
Florin Malita | 8fd15d8 | 2018-05-15 14:57:12 -0400 | [diff] [blame^] | 51 | const SkTArray<sk_sp<const SkImage>>& getImages() const { |
| 52 | return fImages; |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 53 | } |
bungeman | f3c15b7 | 2015-08-19 11:56:48 -0700 | [diff] [blame] | 54 | |
mtklein | 4d9ff62 | 2016-04-29 14:45:36 -0700 | [diff] [blame] | 55 | sk_sp<SkData> opData() const { |
robertphillips | 0bdbea7 | 2014-06-11 11:37:55 -0700 | [diff] [blame] | 56 | this->validate(fWriter.bytesWritten(), 0); |
| 57 | |
| 58 | if (fWriter.bytesWritten() == 0) { |
reed | fde0511 | 2016-03-11 13:02:28 -0800 | [diff] [blame] | 59 | return SkData::MakeEmpty(); |
robertphillips | 0bdbea7 | 2014-06-11 11:37:55 -0700 | [diff] [blame] | 60 | } |
robertphillips | 0bdbea7 | 2014-06-11 11:37:55 -0700 | [diff] [blame] | 61 | return fWriter.snapshotAsData(); |
| 62 | } |
| 63 | |
junov@chromium.org | 4866cc0 | 2012-06-01 21:23:07 +0000 | [diff] [blame] | 64 | void setFlags(uint32_t recordFlags) { |
| 65 | fRecordFlags = recordFlags; |
| 66 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 67 | |
| 68 | const SkWriter32& writeStream() const { |
| 69 | return fWriter; |
| 70 | } |
| 71 | |
reed@google.com | d86e7ab | 2012-09-27 20:31:31 +0000 | [diff] [blame] | 72 | void beginRecording(); |
junov@chromium.org | a6c9e0e | 2012-07-12 17:47:34 +0000 | [diff] [blame] | 73 | void endRecording(); |
reed@google.com | d86e7ab | 2012-09-27 20:31:31 +0000 | [diff] [blame] | 74 | |
senorblanco@chromium.org | 68250c8 | 2014-05-06 22:52:55 +0000 | [diff] [blame] | 75 | protected: |
| 76 | void addNoOp(); |
| 77 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 78 | private: |
commit-bot@chromium.org | 4b32bd5 | 2013-03-15 15:06:03 +0000 | [diff] [blame] | 79 | void handleOptimization(int opt); |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 80 | size_t recordRestoreOffsetPlaceholder(SkClipOp); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 81 | void fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffset); |
junov@chromium.org | e3dbedb | 2012-07-09 16:03:55 +0000 | [diff] [blame] | 82 | |
reed@google.com | ffacd3c | 2012-08-30 15:31:23 +0000 | [diff] [blame] | 83 | SkTDArray<int32_t> fRestoreOffsetStack; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 84 | |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 85 | SkTDArray<uint32_t> fCullOffsetStack; |
| 86 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 87 | /* |
| 88 | * Write the 'drawType' operation and chunk size to the skp. 'size' |
skia.committer@gmail.com | ce8343d | 2013-02-16 07:01:31 +0000 | [diff] [blame] | 89 | * can potentially be increased if the chunk size needs its own storage |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 90 | * location (i.e., it overflows 24 bits). |
| 91 | * Returns the start offset of the chunk. This is the location at which |
| 92 | * the opcode & size are stored. |
skia.committer@gmail.com | ce8343d | 2013-02-16 07:01:31 +0000 | [diff] [blame] | 93 | * TODO: since we are handing the size into here we could call reserve |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 94 | * and then return a pointer to the memory storage. This could decrease |
| 95 | * allocation overhead but could lead to more wasted space (the tail |
| 96 | * end of blocks could go unused). Possibly add a second addDraw that |
| 97 | * operates in this manner. |
| 98 | */ |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 99 | size_t addDraw(DrawType drawType, size_t* size) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 100 | size_t offset = fWriter.bytesWritten(); |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 101 | |
reed@google.com | 97af1a6 | 2012-08-28 12:19:02 +0000 | [diff] [blame] | 102 | this->predrawNotify(); |
| 103 | |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 104 | SkASSERT(0 != *size); |
| 105 | SkASSERT(((uint8_t) drawType) == drawType); |
| 106 | |
| 107 | if (0 != (*size & ~MASK_24) || *size == MASK_24) { |
| 108 | fWriter.writeInt(PACK_8_24(drawType, MASK_24)); |
| 109 | *size += 1; |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 110 | fWriter.writeInt(SkToU32(*size)); |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 111 | } else { |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 112 | fWriter.writeInt(PACK_8_24(drawType, SkToU32(*size))); |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | return offset; |
vandebo@chromium.org | 74b4619 | 2012-01-28 01:45:11 +0000 | [diff] [blame] | 116 | } |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 117 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 118 | void addInt(int value) { |
| 119 | fWriter.writeInt(value); |
| 120 | } |
| 121 | void addScalar(SkScalar scalar) { |
| 122 | fWriter.writeScalar(scalar); |
| 123 | } |
vandebo@chromium.org | 74b4619 | 2012-01-28 01:45:11 +0000 | [diff] [blame] | 124 | |
reed | 871872f | 2015-06-22 12:48:26 -0700 | [diff] [blame] | 125 | void addImage(const SkImage*); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 126 | void addMatrix(const SkMatrix& matrix); |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 127 | void addPaint(const SkPaint& paint) { this->addPaintPtr(&paint); } |
| 128 | void addPaintPtr(const SkPaint* paint); |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 129 | void addPatch(const SkPoint cubics[12]); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 130 | void addPath(const SkPath& path); |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 131 | void addPicture(const SkPicture* picture); |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 132 | void addDrawable(SkDrawable* picture); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 133 | void addPoint(const SkPoint& point); |
| 134 | void addPoints(const SkPoint pts[], int count); |
| 135 | void addRect(const SkRect& rect); |
| 136 | void addRectPtr(const SkRect* rect); |
reed@google.com | f0b5e11 | 2011-09-07 11:57:34 +0000 | [diff] [blame] | 137 | void addIRect(const SkIRect& rect); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 138 | void addIRectPtr(const SkIRect* rect); |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 139 | void addRRect(const SkRRect&); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 140 | void addRegion(const SkRegion& region); |
| 141 | void addText(const void* text, size_t byteLength); |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 142 | void addTextBlob(const SkTextBlob* blob); |
Mike Reed | e88a1cb | 2017-03-17 09:50:46 -0400 | [diff] [blame] | 143 | void addVertices(const SkVertices*); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 144 | |
junov@chromium.org | 4866cc0 | 2012-06-01 21:23:07 +0000 | [diff] [blame] | 145 | int find(const SkBitmap& bitmap); |
| 146 | |
robertphillips | 6162af8 | 2014-08-11 09:50:11 -0700 | [diff] [blame] | 147 | protected: |
commit-bot@chromium.org | dcecb16 | 2014-04-22 17:54:29 +0000 | [diff] [blame] | 148 | void validate(size_t initialOffset, size_t size) const { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 149 | SkASSERT(fWriter.bytesWritten() == initialOffset + size); |
robertphillips@google.com | 2ca1aaa | 2013-02-15 13:47:37 +0000 | [diff] [blame] | 150 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 151 | |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 152 | sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
reed | 884e97c | 2015-05-26 11:31:54 -0700 | [diff] [blame] | 153 | bool onPeekPixels(SkPixmap*) override { return false; } |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 154 | |
Mike Klein | 7cc49d6 | 2017-08-14 10:39:28 -0400 | [diff] [blame] | 155 | void onFlush() override; |
| 156 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 157 | void willSave() override; |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 158 | SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 159 | void willRestore() override; |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 160 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 161 | void didConcat(const SkMatrix&) override; |
| 162 | void didSetMatrix(const SkMatrix&) override; |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 163 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 164 | void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; |
reed@google.com | 76f10a3 | 2014-02-05 15:32:21 +0000 | [diff] [blame] | 165 | |
reed | 3dfd133 | 2015-06-25 14:26:11 -0700 | [diff] [blame] | 166 | void onDrawText(const void* text, size_t, SkScalar x, SkScalar y, const SkPaint&) override; |
| 167 | void onDrawPosText(const void* text, size_t, const SkPoint pos[], const SkPaint&) override; |
| 168 | void onDrawPosTextH(const void* text, size_t, const SkScalar xpos[], SkScalar constY, |
| 169 | const SkPaint&) override; |
| 170 | void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 171 | const SkMatrix* matrix, const SkPaint&) override; |
reed | 45561a0 | 2016-07-07 12:47:17 -0700 | [diff] [blame] | 172 | void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[], |
| 173 | const SkRect* cull, const SkPaint&) override; |
reed | 3dfd133 | 2015-06-25 14:26:11 -0700 | [diff] [blame] | 174 | void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 175 | const SkPaint& paint) override; |
mtklein | 46616af | 2014-09-30 14:47:10 -0700 | [diff] [blame] | 176 | |
reed | 3dfd133 | 2015-06-25 14:26:11 -0700 | [diff] [blame] | 177 | void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
Mike Reed | faba371 | 2016-11-03 14:45:31 -0400 | [diff] [blame] | 178 | const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint) override; |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 179 | void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int, |
Mike Reed | faba371 | 2016-11-03 14:45:31 -0400 | [diff] [blame] | 180 | SkBlendMode, const SkRect*, const SkPaint*) override; |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 181 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 182 | void onDrawPaint(const SkPaint&) override; |
| 183 | void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override; |
| 184 | void onDrawRect(const SkRect&, const SkPaint&) override; |
msarett | 44df651 | 2016-08-25 13:54:30 -0700 | [diff] [blame] | 185 | void onDrawRegion(const SkRegion&, const SkPaint&) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 186 | void onDrawOval(const SkRect&, const SkPaint&) override; |
bsalomon | ac3aa24 | 2016-08-19 11:25:19 -0700 | [diff] [blame] | 187 | void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 188 | void onDrawRRect(const SkRRect&, const SkPaint&) override; |
| 189 | void onDrawPath(const SkPath&, const SkPaint&) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 190 | void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 191 | void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 192 | const SkPaint*, SrcRectConstraint) override; |
reed | 4c21dc5 | 2015-06-25 12:32:03 -0700 | [diff] [blame] | 193 | void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, |
| 194 | const SkPaint*) override; |
msarett | 1688206 | 2016-08-16 09:31:08 -0700 | [diff] [blame] | 195 | void onDrawImageLattice(const SkImage*, const SkCanvas::Lattice& lattice, const SkRect& dst, |
| 196 | const SkPaint*) override; |
Jim Van Verth | 4123d0f | 2017-05-22 12:02:21 -0400 | [diff] [blame] | 197 | void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override; |
Mike Reed | e88a1cb | 2017-03-17 09:50:46 -0400 | [diff] [blame] | 198 | void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 199 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 200 | void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override; |
| 201 | void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override; |
| 202 | void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override; |
| 203 | void onClipRegion(const SkRegion&, SkClipOp) override; |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 204 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 205 | void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override; |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 206 | |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 207 | void onDrawDrawable(SkDrawable*, const SkMatrix*) override; |
reed | f70b531 | 2016-03-04 16:36:20 -0800 | [diff] [blame] | 208 | void onDrawAnnotation(const SkRect&, const char[], SkData*) override; |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 209 | |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 210 | int addPathToHeap(const SkPath& path); // does not write to ops stream |
| 211 | |
skia.committer@gmail.com | 1dab403 | 2014-02-05 03:01:48 +0000 | [diff] [blame] | 212 | // These entry points allow the writing of matrices, clips, saves & |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 213 | // restores to be deferred (e.g., if the MC state is being collapsed and |
| 214 | // only written out as needed). |
| 215 | void recordConcat(const SkMatrix& matrix); |
commit-bot@chromium.org | d9ea09e | 2014-03-25 17:32:26 +0000 | [diff] [blame] | 216 | void recordTranslate(const SkMatrix& matrix); |
| 217 | void recordScale(const SkMatrix& matrix); |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 218 | size_t recordClipRect(const SkRect& rect, SkClipOp op, bool doAA); |
| 219 | size_t recordClipRRect(const SkRRect& rrect, SkClipOp op, bool doAA); |
| 220 | size_t recordClipPath(int pathID, SkClipOp op, bool doAA); |
| 221 | size_t recordClipRegion(const SkRegion& region, SkClipOp op); |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 222 | void recordSave(); |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 223 | void recordSaveLayer(const SaveLayerRec&); |
robertphillips@google.com | 105a4a5 | 2014-02-11 15:10:40 +0000 | [diff] [blame] | 224 | void recordRestore(bool fillInSkips = true); |
robertphillips@google.com | 5a63f24 | 2014-02-04 20:07:50 +0000 | [diff] [blame] | 225 | |
reed | a9ca05c | 2016-08-11 03:55:15 -0700 | [diff] [blame] | 226 | // SHOULD NEVER BE CALLED |
| 227 | void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override { |
Ben Wagner | 7ca9a74 | 2017-08-17 14:05:04 -0400 | [diff] [blame] | 228 | SK_ABORT("not reached"); |
reed | a9ca05c | 2016-08-11 03:55:15 -0700 | [diff] [blame] | 229 | } |
| 230 | void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, |
| 231 | SrcRectConstraint) override { |
Ben Wagner | 7ca9a74 | 2017-08-17 14:05:04 -0400 | [diff] [blame] | 232 | SK_ABORT("not reached"); |
reed | a9ca05c | 2016-08-11 03:55:15 -0700 | [diff] [blame] | 233 | } |
| 234 | void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, |
| 235 | const SkPaint*) override { |
Ben Wagner | 7ca9a74 | 2017-08-17 14:05:04 -0400 | [diff] [blame] | 236 | SK_ABORT("not reached"); |
reed | a9ca05c | 2016-08-11 03:55:15 -0700 | [diff] [blame] | 237 | } |
msarett | 1688206 | 2016-08-16 09:31:08 -0700 | [diff] [blame] | 238 | void onDrawBitmapLattice(const SkBitmap&, const SkCanvas::Lattice& lattice, const SkRect& dst, |
| 239 | const SkPaint*) override { |
Ben Wagner | 7ca9a74 | 2017-08-17 14:05:04 -0400 | [diff] [blame] | 240 | SK_ABORT("not reached"); |
msarett | 1688206 | 2016-08-16 09:31:08 -0700 | [diff] [blame] | 241 | } |
reed | a9ca05c | 2016-08-11 03:55:15 -0700 | [diff] [blame] | 242 | |
robertphillips@google.com | 801cee1 | 2012-10-19 19:06:11 +0000 | [diff] [blame] | 243 | private: |
mtklein | 71a2363 | 2014-11-12 10:24:55 -0800 | [diff] [blame] | 244 | SkTArray<SkPaint> fPaints; |
mtklein | c2e2977 | 2015-10-30 05:24:58 -0700 | [diff] [blame] | 245 | |
| 246 | struct PathHash { |
| 247 | uint32_t operator()(const SkPath& p) { return p.getGenerationID(); } |
| 248 | }; |
| 249 | SkTHashMap<SkPath, int, PathHash> fPaths; |
djsollen@google.com | d2700ee | 2012-05-30 16:54:13 +0000 | [diff] [blame] | 250 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 251 | SkWriter32 fWriter; |
| 252 | |
Florin Malita | 8fd15d8 | 2018-05-15 14:57:12 -0400 | [diff] [blame^] | 253 | SkTArray<sk_sp<const SkImage>> fImages; |
| 254 | SkTArray<sk_sp<const SkPicture>> fPictures; |
| 255 | SkTArray<sk_sp<SkDrawable>> fDrawables; |
| 256 | SkTArray<sk_sp<const SkTextBlob>> fTextBlobs; |
| 257 | SkTArray<sk_sp<const SkVertices>> fVertices; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 258 | |
reed@android.com | ae814c8 | 2009-02-13 14:56:09 +0000 | [diff] [blame] | 259 | uint32_t fRecordFlags; |
commit-bot@chromium.org | e494dbd | 2014-03-04 19:08:57 +0000 | [diff] [blame] | 260 | int fInitialSaveCount; |
reed@android.com | ae814c8 | 2009-02-13 14:56:09 +0000 | [diff] [blame] | 261 | |
robertphillips | 6142609 | 2014-07-10 09:35:12 -0700 | [diff] [blame] | 262 | friend class SkPictureData; // for SkPictureData's SkPictureRecord-based constructor |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 263 | |
Brian Osman | 37886ce | 2018-03-09 13:40:31 -0500 | [diff] [blame] | 264 | typedef SkCanvasVirtualEnforcer<SkCanvas> INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 265 | }; |
vjiaoblack | 5bfee98 | 2016-07-22 10:04:15 -0700 | [diff] [blame] | 266 | |
| 267 | #endif |