chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 | */ |
| 7 | |
| 8 | |
| 9 | #ifndef SKDEBUGCANVAS_H_ |
| 10 | #define SKDEBUGCANVAS_H_ |
| 11 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 12 | #include "SkCanvas.h" |
| 13 | #include "SkDrawCommand.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 14 | #include "SkPath.h" |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 15 | #include "SkPathOps.h" |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 16 | #include "SkPicture.h" |
reed | fb8c1fc | 2015-08-04 18:44:56 -0700 | [diff] [blame] | 17 | #include "SkString.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 18 | #include "SkTArray.h" |
ethannicholas | 402cd91 | 2016-02-10 12:57:30 -0800 | [diff] [blame] | 19 | #include "UrlDataManager.h" |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 20 | |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 21 | class GrAuditTrail; |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 22 | class SkNWayCanvas; |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 23 | |
fmalita@google.com | 86681b3 | 2013-06-13 20:59:14 +0000 | [diff] [blame] | 24 | class SK_API SkDebugCanvas : public SkCanvas { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 25 | public: |
chudy@google.com | 80a4a60 | 2012-07-30 18:54:07 +0000 | [diff] [blame] | 26 | SkDebugCanvas(int width, int height); |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 27 | |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 28 | virtual ~SkDebugCanvas(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 29 | |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 30 | void toggleFilter(bool toggle) { fFilter = toggle; } |
| 31 | |
| 32 | void setMegaVizMode(bool megaVizMode) { fMegaVizMode = megaVizMode; } |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 33 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 34 | bool getMegaVizMode() const { return fMegaVizMode; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 35 | |
| 36 | /** |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 37 | * Enable or disable overdraw visualization |
| 38 | */ |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 39 | void setOverdrawViz(bool overdrawViz); |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 40 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 41 | bool getOverdrawViz() const { return fOverdrawViz; } |
| 42 | |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 43 | /** |
| 44 | * Set the color of the clip visualization. An alpha of zero renders the clip invisible. |
| 45 | */ |
| 46 | void setClipVizColor(SkColor clipVizColor) { this->fClipVizColor = clipVizColor; } |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 47 | |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 48 | SkColor getClipVizColor() const { return fClipVizColor; } |
| 49 | |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 50 | void setDrawGpuBatchBounds(bool drawGpuBatchBounds) { |
| 51 | fDrawGpuBatchBounds = drawGpuBatchBounds; |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 52 | } |
| 53 | |
joshualitt | 5d5207a | 2016-02-29 12:46:04 -0800 | [diff] [blame] | 54 | bool getDrawGpuBatchBounds() const { return fDrawGpuBatchBounds; } |
| 55 | |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 56 | bool getAllowSimplifyClip() const { return fAllowSimplifyClip; } |
| 57 | |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 58 | void setPicture(SkPicture *picture) { fPicture = picture; } |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 59 | |
| 60 | /** |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 61 | * Enable or disable texure filtering override |
| 62 | */ |
reed | 93a1215 | 2015-03-16 10:08:34 -0700 | [diff] [blame] | 63 | void overrideTexFiltering(bool overrideTexFiltering, SkFilterQuality); |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 64 | |
| 65 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 66 | Executes all draw calls to the canvas. |
| 67 | @param canvas The canvas being drawn to |
| 68 | */ |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 69 | void draw(SkCanvas *canvas); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 70 | |
| 71 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 72 | Executes the draw calls up to the specified index. |
| 73 | @param canvas The canvas being drawn to |
| 74 | @param index The index of the final command being executed |
joshualitt | 46b301d | 2016-03-02 08:32:37 -0800 | [diff] [blame] | 75 | @param m an optional Mth gpu batch to highlight, or -1 |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 76 | */ |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 77 | void drawTo(SkCanvas *canvas, int index, int m = -1); |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 78 | |
| 79 | /** |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 80 | Returns the most recently calculated transformation matrix |
| 81 | */ |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 82 | const SkMatrix &getCurrentMatrix() { |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 83 | return fMatrix; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | Returns the most recently calculated clip |
| 88 | */ |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 89 | const SkIRect &getCurrentClip() { |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 90 | return fClip; |
| 91 | } |
| 92 | |
| 93 | /** |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 94 | Returns the index of the last draw command to write to the pixel at (x,y) |
| 95 | */ |
chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 96 | int getCommandAtPoint(int x, int y, int index); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 97 | |
| 98 | /** |
robertphillips@google.com | 50c84da | 2013-04-01 18:18:49 +0000 | [diff] [blame] | 99 | Removes the command at the specified index |
| 100 | @param index The index of the command to delete |
| 101 | */ |
| 102 | void deleteDrawCommandAt(int index); |
| 103 | |
| 104 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 105 | Returns the draw command at the given index. |
| 106 | @param index The index of the command |
| 107 | */ |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 108 | SkDrawCommand *getDrawCommandAt(int index); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 109 | |
| 110 | /** |
robertphillips@google.com | 50c84da | 2013-04-01 18:18:49 +0000 | [diff] [blame] | 111 | Sets the draw command for a given index. |
| 112 | @param index The index to overwrite |
| 113 | @param command The new command |
| 114 | */ |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 115 | void setDrawCommandAt(int index, SkDrawCommand *command); |
robertphillips@google.com | 50c84da | 2013-04-01 18:18:49 +0000 | [diff] [blame] | 116 | |
| 117 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 118 | Returns information about the command at the given index. |
| 119 | @param index The index of the command |
| 120 | */ |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 121 | const SkTDArray<SkString *> *getCommandInfo(int index) const; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 122 | |
| 123 | /** |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 124 | Returns the visibility of the command at the given index. |
| 125 | @param index The index of the command |
| 126 | */ |
| 127 | bool getDrawCommandVisibilityAt(int index); |
| 128 | |
| 129 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 130 | Returns the vector of draw commands |
| 131 | */ |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 132 | SK_ATTR_DEPRECATED("please use getDrawCommandAt and getSize instead") |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 133 | const SkTDArray<SkDrawCommand *> &getDrawCommands() const; |
skia.committer@gmail.com | 2e71f16 | 2013-03-12 07:12:32 +0000 | [diff] [blame] | 134 | |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 135 | /** |
| 136 | Returns the vector of draw commands. Do not use this entry |
| 137 | point - it is going away! |
| 138 | */ |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 139 | SkTDArray<SkDrawCommand *> &getDrawCommands(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 140 | |
| 141 | /** |
chudy@google.com | f141432 | 2012-07-03 20:28:14 +0000 | [diff] [blame] | 142 | Returns length of draw command vector. |
| 143 | */ |
commit-bot@chromium.org | 0d4fe14 | 2013-07-15 22:47:14 +0000 | [diff] [blame] | 144 | int getSize() const { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 145 | return fCommandVector.count(); |
chudy@google.com | f141432 | 2012-07-03 20:28:14 +0000 | [diff] [blame] | 146 | } |
| 147 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 148 | /** |
| 149 | Toggles the visibility / execution of the draw command at index i with |
| 150 | the value of toggle. |
| 151 | */ |
| 152 | void toggleCommand(int index, bool toggle); |
| 153 | |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 154 | void setUserMatrix(SkMatrix matrix) { |
| 155 | fUserMatrix = matrix; |
chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 156 | } |
| 157 | |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 158 | SkString clipStackData() const { return fClipStackData; } |
| 159 | |
ethannicholas | 402cd91 | 2016-02-10 12:57:30 -0800 | [diff] [blame] | 160 | /** |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 161 | Returns a JSON object representing up to the Nth draw, where N is less than |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 162 | SkDebugCanvas::getSize(). The encoder may use the UrlDataManager to store binary data such |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 163 | as images, referring to them via URLs embedded in the JSON. |
ethannicholas | 402cd91 | 2016-02-10 12:57:30 -0800 | [diff] [blame] | 164 | */ |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 165 | Json::Value toJSON(UrlDataManager &urlDataManager, int n, SkCanvas *); |
ethannicholas | 402cd91 | 2016-02-10 12:57:30 -0800 | [diff] [blame] | 166 | |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 167 | Json::Value toJSONBatchList(int n, SkCanvas *); |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 168 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 169 | //////////////////////////////////////////////////////////////////////////////// |
| 170 | // Inherited from SkCanvas |
| 171 | //////////////////////////////////////////////////////////////////////////////// |
| 172 | |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 173 | static const int kVizImageHeight = 256; |
| 174 | static const int kVizImageWidth = 256; |
| 175 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 176 | bool isClipEmpty() const override { return false; } |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 177 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 178 | bool isClipRect() const override { return true; } |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 179 | |
| 180 | bool getClipBounds(SkRect *bounds) const override { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 181 | if (bounds) { |
skia.committer@gmail.com | 370a899 | 2014-03-01 03:02:09 +0000 | [diff] [blame] | 182 | bounds->setXYWH(0, 0, |
reed | e5ea500 | 2014-09-03 11:54:58 -0700 | [diff] [blame] | 183 | SkIntToScalar(this->imageInfo().width()), |
| 184 | SkIntToScalar(this->imageInfo().height())); |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 185 | } |
| 186 | return true; |
| 187 | } |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 188 | |
| 189 | bool getClipDeviceBounds(SkIRect *bounds) const override { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 190 | if (bounds) { |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 191 | bounds->setLargest(); |
| 192 | } |
| 193 | return true; |
| 194 | } |
| 195 | |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 196 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 197 | void willSave() override; |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 198 | |
| 199 | SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &) override; |
| 200 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 201 | void willRestore() override; |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 202 | |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 203 | void didConcat(const SkMatrix &) override; |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 204 | |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 205 | void didSetMatrix(const SkMatrix &) override; |
| 206 | |
| 207 | #ifdef SK_EXPERIMENTAL_SHADOWING |
vjiaoblack | 5bfee98 | 2016-07-22 10:04:15 -0700 | [diff] [blame^] | 208 | void didTranslateZ(SkScalar) override; |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 209 | #else |
| 210 | void didTranslateZ(SkScalar); |
| 211 | #endif |
vjiaoblack | e5de130 | 2016-07-13 14:05:28 -0700 | [diff] [blame] | 212 | |
reed | 97660cc | 2016-06-28 18:54:19 -0700 | [diff] [blame] | 213 | void onDrawAnnotation(const SkRect&, const char[], SkData*) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 214 | void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 215 | void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 216 | const SkPaint&) override; |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 217 | void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 218 | const SkPaint&) override; |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 219 | void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 220 | SkScalar constY, const SkPaint&) override; |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 221 | void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 222 | const SkMatrix* matrix, const SkPaint&) override; |
reed | 45561a0 | 2016-07-07 12:47:17 -0700 | [diff] [blame] | 223 | void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[], const SkRect*, |
| 224 | const SkPaint&) override; |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 225 | void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 226 | const SkPaint& paint) override; |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 227 | |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 228 | void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 229 | const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 230 | void onDrawPaint(const SkPaint&) override; |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 231 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 232 | void onDrawRect(const SkRect&, const SkPaint&) override; |
| 233 | void onDrawOval(const SkRect&, const SkPaint&) override; |
| 234 | void onDrawRRect(const SkRRect&, const SkPaint&) override; |
| 235 | void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override; |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 236 | void onDrawVertices(VertexMode vmode, int vertexCount, |
| 237 | const SkPoint vertices[], const SkPoint texs[], |
| 238 | const SkColor colors[], SkXfermode* xmode, |
| 239 | const uint16_t indices[], int indexCount, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 240 | const SkPaint&) override; |
| 241 | void onDrawPath(const SkPath&, const SkPaint&) override; |
| 242 | void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 243 | void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 244 | SrcRectConstraint) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 245 | void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 246 | void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 247 | const SkPaint*, SrcRectConstraint) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 248 | void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 249 | const SkPaint*) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 250 | void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; |
| 251 | void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; |
| 252 | void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; |
| 253 | void onClipRegion(const SkRegion& region, SkRegion::Op) override; |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 254 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 255 | void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override; |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 256 | |
vjiaoblack | 95302da | 2016-07-21 10:25:54 -0700 | [diff] [blame] | 257 | #ifdef SK_EXPERIMENTAL_SHADOWING |
| 258 | void onDrawShadowedPicture(const SkPicture*, |
| 259 | const SkMatrix*, |
| 260 | const SkPaint*) override; |
| 261 | #else |
| 262 | void onDrawShadowedPicture(const SkPicture*, |
| 263 | const SkMatrix*, |
| 264 | const SkPaint*); |
| 265 | #endif |
| 266 | |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 267 | void markActiveCommands(int index); |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 268 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 269 | private: |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 270 | SkTDArray<SkDrawCommand*> fCommandVector; |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 271 | SkPicture* fPicture; |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 272 | bool fFilter; |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 273 | bool fMegaVizMode; |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 274 | SkMatrix fUserMatrix; |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 275 | SkMatrix fMatrix; |
| 276 | SkIRect fClip; |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 277 | |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 278 | SkString fClipStackData; |
| 279 | bool fCalledAddStackData; |
| 280 | SkPath fSaveDevPath; |
| 281 | |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 282 | bool fOverdrawViz; |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 283 | bool fOverrideFilterQuality; |
| 284 | SkFilterQuality fFilterQuality; |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 285 | SkColor fClipVizColor; |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 286 | bool fDrawGpuBatchBounds; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 287 | |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 288 | SkAutoTUnref<SkNWayCanvas> fPaintFilterCanvas; |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 289 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 290 | /** |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 291 | The active saveLayer commands at a given point in the renderering. |
| 292 | Only used when "mega" visualization is enabled. |
| 293 | */ |
| 294 | SkTDArray<SkDrawCommand*> fActiveLayers; |
| 295 | |
skia.committer@gmail.com | ade9a34 | 2014-03-04 03:02:32 +0000 | [diff] [blame] | 296 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 297 | Adds the command to the classes vector of commands. |
| 298 | @param command The draw command for execution |
| 299 | */ |
| 300 | void addDrawCommand(SkDrawCommand* command); |
chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 301 | |
| 302 | /** |
| 303 | Applies any panning and zooming the user has specified before |
| 304 | drawing anything else into the canvas. |
| 305 | */ |
| 306 | void applyUserTransform(SkCanvas* canvas); |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 307 | |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 308 | void resetClipStackData() { fClipStackData.reset(); fCalledAddStackData = false; } |
| 309 | |
| 310 | void addClipStackData(const SkPath& devPath, const SkPath& operand, SkRegion::Op elementOp); |
| 311 | void addPathData(const SkPath& path, const char* pathName); |
| 312 | bool lastClipStackData(const SkPath& devPath); |
| 313 | void outputConicPoints(const SkPoint* pts, SkScalar weight); |
| 314 | void outputPoints(const SkPoint* pts, int count); |
| 315 | void outputPointsCommon(const SkPoint* pts, int count); |
| 316 | void outputScalar(SkScalar num); |
skia.committer@gmail.com | 3b9e8be | 2014-05-20 03:05:34 +0000 | [diff] [blame] | 317 | |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 318 | GrAuditTrail* getAuditTrail(SkCanvas*); |
| 319 | |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 320 | void updatePaintFilterCanvas(); |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 321 | void drawAndCollectBatches(int n, SkCanvas*); |
| 322 | void cleanupAuditTrail(SkCanvas*); |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 323 | |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 324 | typedef SkCanvas INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | #endif |