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