| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 10 | #include "SkColorPriv.h" |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 11 | #include "SkDebugCanvas.h" |
| 12 | #include "SkDrawCommand.h" |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 13 | #include "SkDrawFilter.h" |
| robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 14 | #include "SkDevice.h" |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 15 | #include "SkXfermode.h" |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 16 | |
| reed@google.com | 6ae24e0 | 2012-09-26 13:44:13 +0000 | [diff] [blame] | 17 | SkDebugCanvas::SkDebugCanvas(int width, int height) |
| commit-bot@chromium.org | e254310 | 2014-01-31 19:42:58 +0000 | [diff] [blame] | 18 | : INHERITED(width, height) |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 19 | , fPicture(NULL) |
| commit-bot@chromium.org | 1735d66 | 2013-12-04 13:42:46 +0000 | [diff] [blame] | 20 | , fWidth(width) |
| 21 | , fHeight(height) |
| 22 | , fFilter(false) |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 23 | , fMegaVizMode(false) |
| commit-bot@chromium.org | 1735d66 | 2013-12-04 13:42:46 +0000 | [diff] [blame] | 24 | , fIndex(0) |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 25 | , fOverdrawViz(false) |
| scroggo@google.com | 06d6ac6 | 2013-02-08 21:16:19 +0000 | [diff] [blame] | 26 | , fOverdrawFilter(NULL) |
| robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 27 | , fOverrideTexFiltering(false) |
| 28 | , fTexOverrideFilter(NULL) |
| scroggo@google.com | 06d6ac6 | 2013-02-08 21:16:19 +0000 | [diff] [blame] | 29 | , fOutstandingSaveCount(0) { |
| bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 30 | fUserMatrix.reset(); |
| robertphillips@google.com | 8b15717 | 2013-11-07 22:20:31 +0000 | [diff] [blame] | 31 | |
| 32 | // SkPicturePlayback uses the base-class' quickReject calls to cull clipped |
| 33 | // operations. This can lead to problems in the debugger which expects all |
| 34 | // the operations in the captured skp to appear in the debug canvas. To |
| 35 | // circumvent this we create a wide open clip here (an empty clip rect |
| 36 | // is not sufficient). |
| 37 | // Internally, the SkRect passed to clipRect is converted to an SkIRect and |
| 38 | // rounded out. The following code creates a nearly maximal rect that will |
| 39 | // not get collapsed by the coming conversions (Due to precision loss the |
| 40 | // inset has to be surprisingly large). |
| 41 | SkIRect largeIRect = SkIRect::MakeLargest(); |
| 42 | largeIRect.inset(1024, 1024); |
| robertphillips@google.com | 6c1e49a | 2013-11-10 15:08:45 +0000 | [diff] [blame] | 43 | SkRect large = SkRect::Make(largeIRect); |
| robertphillips@google.com | 8b15717 | 2013-11-07 22:20:31 +0000 | [diff] [blame] | 44 | #ifdef SK_DEBUG |
| 45 | large.roundOut(&largeIRect); |
| 46 | SkASSERT(!largeIRect.isEmpty()); |
| 47 | #endif |
| robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 48 | // call the base class' version to avoid adding a draw command |
| 49 | this->INHERITED::onClipRect(large, SkRegion::kReplace_Op, kHard_ClipEdgeStyle); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| chudy@google.com | 9cda6f7 | 2012-08-07 15:08:33 +0000 | [diff] [blame] | 52 | SkDebugCanvas::~SkDebugCanvas() { |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 53 | fCommandVector.deleteAll(); |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 54 | SkSafeUnref(fOverdrawFilter); |
| commit-bot@chromium.org | 1735d66 | 2013-12-04 13:42:46 +0000 | [diff] [blame] | 55 | SkSafeUnref(fTexOverrideFilter); |
| chudy@google.com | 9cda6f7 | 2012-08-07 15:08:33 +0000 | [diff] [blame] | 56 | } |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 57 | |
| 58 | void SkDebugCanvas::addDrawCommand(SkDrawCommand* command) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 59 | command->setOffset(this->getOpID()); |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 60 | fCommandVector.push(command); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | void SkDebugCanvas::draw(SkCanvas* canvas) { |
| commit-bot@chromium.org | 1735d66 | 2013-12-04 13:42:46 +0000 | [diff] [blame] | 64 | if (!fCommandVector.isEmpty()) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 65 | this->drawTo(canvas, fCommandVector.count() - 1); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 66 | } |
| 67 | } |
| 68 | |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 69 | void SkDebugCanvas::applyUserTransform(SkCanvas* canvas) { |
| bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 70 | canvas->concat(fUserMatrix); |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | int SkDebugCanvas::getCommandAtPoint(int x, int y, int index) { |
| chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 74 | SkBitmap bitmap; |
| reed@google.com | 9ebcac5 | 2014-01-24 18:53:42 +0000 | [diff] [blame] | 75 | bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 76 | |
| chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 77 | SkCanvas canvas(bitmap); |
| robertphillips@google.com | 94acc70 | 2012-09-06 18:43:21 +0000 | [diff] [blame] | 78 | canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y)); |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 79 | applyUserTransform(&canvas); |
| chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 80 | |
| 81 | int layer = 0; |
| chudy@google.com | 751961d | 2012-07-31 20:07:42 +0000 | [diff] [blame] | 82 | SkColor prev = bitmap.getColor(0,0); |
| chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 83 | for (int i = 0; i < index; i++) { |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 84 | if (fCommandVector[i]->isVisible()) { |
| 85 | fCommandVector[i]->execute(&canvas); |
| chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 86 | } |
| 87 | if (prev != bitmap.getColor(0,0)) { |
| 88 | layer = i; |
| 89 | } |
| 90 | prev = bitmap.getColor(0,0); |
| 91 | } |
| 92 | return layer; |
| 93 | } |
| 94 | |
| bsalomon@google.com | 383e234 | 2013-02-06 21:44:21 +0000 | [diff] [blame] | 95 | static SkPMColor OverdrawXferModeProc(SkPMColor src, SkPMColor dst) { |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 96 | // This table encodes the color progression of the overdraw visualization |
| 97 | static const SkPMColor gTable[] = { |
| 98 | SkPackARGB32(0x00, 0x00, 0x00, 0x00), |
| 99 | SkPackARGB32(0xFF, 128, 158, 255), |
| 100 | SkPackARGB32(0xFF, 170, 185, 212), |
| 101 | SkPackARGB32(0xFF, 213, 195, 170), |
| 102 | SkPackARGB32(0xFF, 255, 192, 127), |
| 103 | SkPackARGB32(0xFF, 255, 185, 85), |
| 104 | SkPackARGB32(0xFF, 255, 165, 42), |
| 105 | SkPackARGB32(0xFF, 255, 135, 0), |
| 106 | SkPackARGB32(0xFF, 255, 95, 0), |
| 107 | SkPackARGB32(0xFF, 255, 50, 0), |
| 108 | SkPackARGB32(0xFF, 255, 0, 0) |
| 109 | }; |
| 110 | |
| robertphillips@google.com | 0b256e1 | 2013-02-06 20:42:14 +0000 | [diff] [blame] | 111 | for (size_t i = 0; i < SK_ARRAY_COUNT(gTable)-1; ++i) { |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 112 | if (gTable[i] == dst) { |
| 113 | return gTable[i+1]; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | return gTable[SK_ARRAY_COUNT(gTable)-1]; |
| 118 | } |
| 119 | |
| 120 | // The OverdrawFilter modifies every paint to use an SkProcXfermode which |
| 121 | // in turn invokes OverdrawXferModeProc |
| robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 122 | class SkOverdrawFilter : public SkDrawFilter { |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 123 | public: |
| robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 124 | SkOverdrawFilter() { |
| commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame] | 125 | fXferMode = SkProcXfermode::Create(OverdrawXferModeProc); |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 126 | } |
| 127 | |
| robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 128 | virtual ~SkOverdrawFilter() { |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 129 | delete fXferMode; |
| 130 | } |
| 131 | |
| 132 | virtual bool filter(SkPaint* p, Type) SK_OVERRIDE { |
| 133 | p->setXfermode(fXferMode); |
| 134 | return true; |
| 135 | } |
| 136 | |
| 137 | protected: |
| 138 | SkXfermode* fXferMode; |
| 139 | |
| 140 | private: |
| 141 | typedef SkDrawFilter INHERITED; |
| 142 | }; |
| 143 | |
| skia.committer@gmail.com | f84ad8f | 2013-10-18 07:01:59 +0000 | [diff] [blame] | 144 | // SkTexOverrideFilter modifies every paint to use the specified |
| robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 145 | // texture filtering mode |
| 146 | class SkTexOverrideFilter : public SkDrawFilter { |
| 147 | public: |
| 148 | SkTexOverrideFilter() : fFilterLevel(SkPaint::kNone_FilterLevel) { |
| 149 | } |
| 150 | |
| 151 | void setFilterLevel(SkPaint::FilterLevel filterLevel) { |
| 152 | fFilterLevel = filterLevel; |
| 153 | } |
| 154 | |
| 155 | virtual bool filter(SkPaint* p, Type) SK_OVERRIDE { |
| 156 | p->setFilterLevel(fFilterLevel); |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | protected: |
| 161 | SkPaint::FilterLevel fFilterLevel; |
| 162 | |
| 163 | private: |
| 164 | typedef SkDrawFilter INHERITED; |
| 165 | }; |
| 166 | |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 167 | class SkDebugClipVisitor : public SkCanvas::ClipVisitor { |
| 168 | public: |
| 169 | SkDebugClipVisitor(SkCanvas* canvas) : fCanvas(canvas) {} |
| 170 | |
| 171 | virtual void clipRect(const SkRect& r, SkRegion::Op, bool doAA) SK_OVERRIDE { |
| 172 | SkPaint p; |
| 173 | p.setColor(SK_ColorRED); |
| 174 | p.setStyle(SkPaint::kStroke_Style); |
| 175 | p.setAntiAlias(doAA); |
| 176 | fCanvas->drawRect(r, p); |
| 177 | } |
| 178 | virtual void clipRRect(const SkRRect& rr, SkRegion::Op, bool doAA) SK_OVERRIDE { |
| 179 | SkPaint p; |
| 180 | p.setColor(SK_ColorGREEN); |
| 181 | p.setStyle(SkPaint::kStroke_Style); |
| 182 | p.setAntiAlias(doAA); |
| 183 | fCanvas->drawRRect(rr, p); |
| 184 | } |
| 185 | virtual void clipPath(const SkPath& path, SkRegion::Op, bool doAA) SK_OVERRIDE { |
| 186 | SkPaint p; |
| 187 | p.setColor(SK_ColorBLUE); |
| 188 | p.setStyle(SkPaint::kStroke_Style); |
| 189 | p.setAntiAlias(doAA); |
| 190 | fCanvas->drawPath(path, p); |
| 191 | } |
| 192 | |
| 193 | protected: |
| 194 | SkCanvas* fCanvas; |
| 195 | |
| 196 | private: |
| 197 | typedef SkCanvas::ClipVisitor INHERITED; |
| 198 | }; |
| 199 | |
| 200 | // set up the saveLayer commands so that the active ones |
| 201 | // return true in their 'active' method |
| commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 202 | void SkDebugCanvas::markActiveCommands(int index) { |
| 203 | fActiveLayers.rewind(); |
| 204 | fActiveCulls.rewind(); |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 205 | |
| 206 | for (int i = 0; i < fCommandVector.count(); ++i) { |
| 207 | fCommandVector[i]->setActive(false); |
| 208 | } |
| 209 | |
| 210 | for (int i = 0; i < index; ++i) { |
| 211 | SkDrawCommand::Action result = fCommandVector[i]->action(); |
| commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 212 | if (SkDrawCommand::kPushLayer_Action == result) { |
| 213 | fActiveLayers.push(fCommandVector[i]); |
| 214 | } else if (SkDrawCommand::kPopLayer_Action == result) { |
| 215 | fActiveLayers.pop(); |
| 216 | } else if (SkDrawCommand::kPushCull_Action == result) { |
| 217 | fActiveCulls.push(fCommandVector[i]); |
| 218 | } else if (SkDrawCommand::kPopCull_Action == result) { |
| 219 | fActiveCulls.pop(); |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 220 | } |
| 221 | } |
| 222 | |
| commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 223 | for (int i = 0; i < fActiveLayers.count(); ++i) { |
| 224 | fActiveLayers[i]->setActive(true); |
| 225 | } |
| 226 | |
| 227 | for (int i = 0; i < fActiveCulls.count(); ++i) { |
| 228 | fActiveCulls[i]->setActive(true); |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | |
| chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 232 | void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) { |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 233 | SkASSERT(!fCommandVector.isEmpty()); |
| 234 | SkASSERT(index < fCommandVector.count()); |
| commit-bot@chromium.org | 1735d66 | 2013-12-04 13:42:46 +0000 | [diff] [blame] | 235 | int i = 0; |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 236 | |
| 237 | // This only works assuming the canvas and device are the same ones that |
| 238 | // were previously drawn into because they need to preserve all saves |
| 239 | // and restores. |
| commit-bot@chromium.org | 1735d66 | 2013-12-04 13:42:46 +0000 | [diff] [blame] | 240 | // The visibility filter also requires a full re-draw - otherwise we can |
| 241 | // end up drawing the filter repeatedly. |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 242 | if (fIndex < index && !fFilter && !fMegaVizMode) { |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 243 | i = fIndex + 1; |
| 244 | } else { |
| tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 245 | for (int j = 0; j < fOutstandingSaveCount; j++) { |
| 246 | canvas->restore(); |
| 247 | } |
| junov@google.com | dbfac8a | 2012-12-06 21:47:40 +0000 | [diff] [blame] | 248 | canvas->clear(SK_ColorTRANSPARENT); |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 249 | canvas->resetMatrix(); |
| skia.committer@gmail.com | 04ba448 | 2012-09-07 02:01:30 +0000 | [diff] [blame] | 250 | SkRect rect = SkRect::MakeWH(SkIntToScalar(fWidth), |
| robertphillips@google.com | 94acc70 | 2012-09-06 18:43:21 +0000 | [diff] [blame] | 251 | SkIntToScalar(fHeight)); |
| chudy@google.com | 4c7962e | 2012-08-14 19:38:31 +0000 | [diff] [blame] | 252 | canvas->clipRect(rect, SkRegion::kReplace_Op ); |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 253 | applyUserTransform(canvas); |
| tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 254 | fOutstandingSaveCount = 0; |
| commit-bot@chromium.org | a27622c | 2013-08-05 16:31:27 +0000 | [diff] [blame] | 255 | } |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 256 | |
| commit-bot@chromium.org | a27622c | 2013-08-05 16:31:27 +0000 | [diff] [blame] | 257 | // The setting of the draw filter has to go here (rather than in |
| 258 | // SkRasterWidget) due to the canvas restores this class performs. |
| 259 | // Since the draw filter is stored in the layer stack if we |
| 260 | // call setDrawFilter on anything but the root layer odd things happen. |
| 261 | if (fOverdrawViz) { |
| 262 | if (NULL == fOverdrawFilter) { |
| robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 263 | fOverdrawFilter = new SkOverdrawFilter; |
| robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 264 | } |
| commit-bot@chromium.org | a27622c | 2013-08-05 16:31:27 +0000 | [diff] [blame] | 265 | |
| 266 | if (fOverdrawFilter != canvas->getDrawFilter()) { |
| 267 | canvas->setDrawFilter(fOverdrawFilter); |
| 268 | } |
| robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 269 | } else if (fOverrideTexFiltering) { |
| 270 | if (NULL == fTexOverrideFilter) { |
| 271 | fTexOverrideFilter = new SkTexOverrideFilter; |
| 272 | } |
| 273 | |
| 274 | if (fTexOverrideFilter != canvas->getDrawFilter()) { |
| 275 | canvas->setDrawFilter(fTexOverrideFilter); |
| 276 | } |
| commit-bot@chromium.org | a27622c | 2013-08-05 16:31:27 +0000 | [diff] [blame] | 277 | } else { |
| 278 | canvas->setDrawFilter(NULL); |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 281 | if (fMegaVizMode) { |
| commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 282 | this->markActiveCommands(index); |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 285 | for (; i <= index; i++) { |
| chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 286 | if (i == index && fFilter) { |
| 287 | SkPaint p; |
| 288 | p.setColor(0xAAFFFFFF); |
| 289 | canvas->save(); |
| 290 | canvas->resetMatrix(); |
| 291 | SkRect mask; |
| 292 | mask.set(SkIntToScalar(0), SkIntToScalar(0), |
| 293 | SkIntToScalar(fWidth), SkIntToScalar(fHeight)); |
| 294 | canvas->clipRect(mask, SkRegion::kReplace_Op, false); |
| 295 | canvas->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), |
| 296 | SkIntToScalar(fWidth), SkIntToScalar(fHeight), p); |
| 297 | canvas->restore(); |
| 298 | } |
| 299 | |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 300 | if (fCommandVector[i]->isVisible()) { |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 301 | if (fMegaVizMode && fCommandVector[i]->active()) { |
| commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 302 | // "active" commands execute their visualization behaviors: |
| 303 | // All active saveLayers get replaced with saves so all draws go to the |
| 304 | // visible canvas. |
| 305 | // All active culls draw their cull box |
| 306 | fCommandVector[i]->vizExecute(canvas); |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 307 | } else { |
| 308 | fCommandVector[i]->execute(canvas); |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 309 | } |
| commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 310 | |
| 311 | fCommandVector[i]->trackSaveState(&fOutstandingSaveCount); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 312 | } |
| 313 | } |
| commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 314 | |
| 315 | if (fMegaVizMode) { |
| 316 | SkRect r = SkRect::MakeWH(SkIntToScalar(fWidth), SkIntToScalar(fHeight)); |
| 317 | r.outset(SK_Scalar1, SK_Scalar1); |
| 318 | |
| 319 | canvas->save(); |
| 320 | // nuke the CTM |
| 321 | canvas->setMatrix(SkMatrix::I()); |
| 322 | // turn off clipping |
| 323 | canvas->clipRect(r, SkRegion::kReplace_Op); |
| 324 | |
| 325 | // visualize existing clips |
| 326 | SkDebugClipVisitor visitor(canvas); |
| 327 | |
| 328 | canvas->replayClips(&visitor); |
| 329 | |
| 330 | canvas->restore(); |
| 331 | } |
| chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 332 | fMatrix = canvas->getTotalMatrix(); |
| commit-bot@chromium.org | 5c70cdc | 2014-03-08 03:57:19 +0000 | [diff] [blame] | 333 | if (!canvas->getClipDeviceBounds(&fClip)) { |
| 334 | fClip.setEmpty(); |
| 335 | } |
| chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 336 | fIndex = index; |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 337 | } |
| 338 | |
| robertphillips@google.com | 50c84da | 2013-04-01 18:18:49 +0000 | [diff] [blame] | 339 | void SkDebugCanvas::deleteDrawCommandAt(int index) { |
| 340 | SkASSERT(index < fCommandVector.count()); |
| 341 | delete fCommandVector[index]; |
| 342 | fCommandVector.remove(index); |
| 343 | } |
| 344 | |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 345 | SkDrawCommand* SkDebugCanvas::getDrawCommandAt(int index) { |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 346 | SkASSERT(index < fCommandVector.count()); |
| 347 | return fCommandVector[index]; |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 348 | } |
| 349 | |
| robertphillips@google.com | 50c84da | 2013-04-01 18:18:49 +0000 | [diff] [blame] | 350 | void SkDebugCanvas::setDrawCommandAt(int index, SkDrawCommand* command) { |
| 351 | SkASSERT(index < fCommandVector.count()); |
| 352 | delete fCommandVector[index]; |
| 353 | fCommandVector[index] = command; |
| 354 | } |
| 355 | |
| chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 356 | SkTDArray<SkString*>* SkDebugCanvas::getCommandInfo(int index) { |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 357 | SkASSERT(index < fCommandVector.count()); |
| 358 | return fCommandVector[index]->Info(); |
| chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 359 | } |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 360 | |
| chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 361 | bool SkDebugCanvas::getDrawCommandVisibilityAt(int index) { |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 362 | SkASSERT(index < fCommandVector.count()); |
| 363 | return fCommandVector[index]->isVisible(); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 366 | const SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() const { |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 367 | return fCommandVector; |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 368 | } |
| 369 | |
| robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 370 | SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() { |
| 371 | return fCommandVector; |
| 372 | } |
| 373 | |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 374 | // TODO(chudy): Free command string memory. |
| robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 375 | SkTArray<SkString>* SkDebugCanvas::getDrawCommandsAsStrings() const { |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 376 | SkTArray<SkString>* commandString = new SkTArray<SkString>(fCommandVector.count()); |
| 377 | if (!fCommandVector.isEmpty()) { |
| 378 | for (int i = 0; i < fCommandVector.count(); i ++) { |
| 379 | commandString->push_back() = fCommandVector[i]->toString(); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 380 | } |
| 381 | } |
| 382 | return commandString; |
| 383 | } |
| 384 | |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 385 | SkTDArray<size_t>* SkDebugCanvas::getDrawCommandOffsets() const { |
| 386 | SkTDArray<size_t>* commandOffsets = new SkTDArray<size_t>; |
| 387 | if (!fCommandVector.isEmpty()) { |
| 388 | for (int i = 0; i < fCommandVector.count(); i ++) { |
| 389 | *commandOffsets->push() = fCommandVector[i]->offset(); |
| 390 | } |
| 391 | } |
| 392 | return commandOffsets; |
| 393 | } |
| 394 | |
| skia.committer@gmail.com | f84ad8f | 2013-10-18 07:01:59 +0000 | [diff] [blame] | 395 | void SkDebugCanvas::overrideTexFiltering(bool overrideTexFiltering, SkPaint::FilterLevel level) { |
| robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 396 | if (NULL == fTexOverrideFilter) { |
| 397 | fTexOverrideFilter = new SkTexOverrideFilter; |
| 398 | } |
| 399 | |
| skia.committer@gmail.com | f84ad8f | 2013-10-18 07:01:59 +0000 | [diff] [blame] | 400 | fOverrideTexFiltering = overrideTexFiltering; |
| robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 401 | fTexOverrideFilter->setFilterLevel(level); |
| 402 | } |
| 403 | |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 404 | void SkDebugCanvas::clear(SkColor color) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 405 | this->addDrawCommand(new SkClearCommand(color)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 406 | } |
| 407 | |
| robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 408 | void SkDebugCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
| 409 | this->addDrawCommand(new SkClipPathCommand(path, op, kSoft_ClipEdgeStyle == edgeStyle)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 410 | } |
| 411 | |
| robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 412 | void SkDebugCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
| 413 | this->addDrawCommand(new SkClipRectCommand(rect, op, kSoft_ClipEdgeStyle == edgeStyle)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 414 | } |
| 415 | |
| robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 416 | void SkDebugCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
| 417 | this->addDrawCommand(new SkClipRRectCommand(rrect, op, kSoft_ClipEdgeStyle == edgeStyle)); |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 418 | } |
| 419 | |
| robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 420 | void SkDebugCanvas::onClipRegion(const SkRegion& region, SkRegion::Op op) { |
| 421 | this->addDrawCommand(new SkClipRegionCommand(region, op)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 422 | } |
| 423 | |
| commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 424 | void SkDebugCanvas::didConcat(const SkMatrix& matrix) { |
| commit-bot@chromium.org | d9ea09e | 2014-03-25 17:32:26 +0000 | [diff] [blame] | 425 | switch (matrix.getType()) { |
| 426 | case SkMatrix::kTranslate_Mask: |
| 427 | this->addDrawCommand(new SkTranslateCommand(matrix.getTranslateX(), |
| 428 | matrix.getTranslateY())); |
| 429 | break; |
| 430 | case SkMatrix::kScale_Mask: |
| 431 | this->addDrawCommand(new SkScaleCommand(matrix.getScaleX(), |
| 432 | matrix.getScaleY())); |
| 433 | break; |
| 434 | default: |
| 435 | this->addDrawCommand(new SkConcatCommand(matrix)); |
| 436 | break; |
| 437 | } |
| 438 | |
| commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 439 | this->INHERITED::didConcat(matrix); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | void SkDebugCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar left, |
| commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 443 | SkScalar top, const SkPaint* paint = NULL) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 444 | this->addDrawCommand(new SkDrawBitmapCommand(bitmap, left, top, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 445 | } |
| 446 | |
| reed@google.com | 7112173 | 2012-09-18 15:14:33 +0000 | [diff] [blame] | 447 | void SkDebugCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, |
| skia.committer@gmail.com | 7475811 | 2013-08-17 07:01:54 +0000 | [diff] [blame] | 448 | const SkRect* src, const SkRect& dst, |
| commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 449 | const SkPaint* paint, |
| 450 | SkCanvas::DrawBitmapRectFlags flags) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 451 | this->addDrawCommand(new SkDrawBitmapRectCommand(bitmap, src, dst, paint, flags)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | void SkDebugCanvas::drawBitmapMatrix(const SkBitmap& bitmap, |
| commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 455 | const SkMatrix& matrix, const SkPaint* paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 456 | this->addDrawCommand(new SkDrawBitmapMatrixCommand(bitmap, matrix, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | void SkDebugCanvas::drawBitmapNine(const SkBitmap& bitmap, |
| 460 | const SkIRect& center, const SkRect& dst, const SkPaint* paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 461 | this->addDrawCommand(new SkDrawBitmapNineCommand(bitmap, center, dst, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | void SkDebugCanvas::drawData(const void* data, size_t length) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 465 | this->addDrawCommand(new SkDrawDataCommand(data, length)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 466 | } |
| 467 | |
| robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 468 | void SkDebugCanvas::beginCommentGroup(const char* description) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 469 | this->addDrawCommand(new SkBeginCommentGroupCommand(description)); |
| robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | void SkDebugCanvas::addComment(const char* kywd, const char* value) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 473 | this->addDrawCommand(new SkCommentCommand(kywd, value)); |
| robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | void SkDebugCanvas::endCommentGroup() { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 477 | this->addDrawCommand(new SkEndCommentGroupCommand()); |
| robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 478 | } |
| 479 | |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 480 | void SkDebugCanvas::drawOval(const SkRect& oval, const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 481 | this->addDrawCommand(new SkDrawOvalCommand(oval, paint)); |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 482 | } |
| 483 | |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 484 | void SkDebugCanvas::drawPaint(const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 485 | this->addDrawCommand(new SkDrawPaintCommand(paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 486 | } |
| 487 | |
| bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 488 | void SkDebugCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 489 | this->addDrawCommand(new SkDrawPathCommand(path, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | void SkDebugCanvas::drawPicture(SkPicture& picture) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 493 | this->addDrawCommand(new SkDrawPictureCommand(picture)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | void SkDebugCanvas::drawPoints(PointMode mode, size_t count, |
| robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 497 | const SkPoint pts[], const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 498 | this->addDrawCommand(new SkDrawPointsCommand(mode, count, pts, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | void SkDebugCanvas::drawPosText(const void* text, size_t byteLength, |
| 502 | const SkPoint pos[], const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 503 | this->addDrawCommand(new SkDrawPosTextCommand(text, byteLength, pos, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | void SkDebugCanvas::drawPosTextH(const void* text, size_t byteLength, |
| 507 | const SkScalar xpos[], SkScalar constY, const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 508 | this->addDrawCommand( |
| commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 509 | new SkDrawPosTextHCommand(text, byteLength, xpos, constY, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 510 | } |
| 511 | |
| bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 512 | void SkDebugCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 513 | // NOTE(chudy): Messing up when renamed to DrawRect... Why? |
| commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 514 | addDrawCommand(new SkDrawRectCommand(rect, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 515 | } |
| 516 | |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 517 | void SkDebugCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 518 | this->addDrawCommand(new SkDrawRRectCommand(rrect, paint)); |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 519 | } |
| 520 | |
| commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 521 | void SkDebugCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
| 522 | const SkPaint& paint) { |
| commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 523 | this->addDrawCommand(new SkDrawDRRectCommand(outer, inner, paint)); |
| commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 524 | } |
| 525 | |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 526 | void SkDebugCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, |
| robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 527 | const SkPaint* paint = NULL) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 528 | this->addDrawCommand(new SkDrawSpriteCommand(bitmap, left, top, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | void SkDebugCanvas::drawText(const void* text, size_t byteLength, SkScalar x, |
| 532 | SkScalar y, const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 533 | this->addDrawCommand(new SkDrawTextCommand(text, byteLength, x, y, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | void SkDebugCanvas::drawTextOnPath(const void* text, size_t byteLength, |
| 537 | const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 538 | this->addDrawCommand( |
| commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 539 | new SkDrawTextOnPathCommand(text, byteLength, path, matrix, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | void SkDebugCanvas::drawVertices(VertexMode vmode, int vertexCount, |
| 543 | const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], |
| 544 | SkXfermode*, const uint16_t indices[], int indexCount, |
| 545 | const SkPaint& paint) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 546 | this->addDrawCommand(new SkDrawVerticesCommand(vmode, vertexCount, vertices, |
| 547 | texs, colors, NULL, indices, indexCount, paint)); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 548 | } |
| 549 | |
| commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 550 | void SkDebugCanvas::onPushCull(const SkRect& cullRect) { |
| 551 | this->addDrawCommand(new SkPushCullCommand(cullRect)); |
| 552 | } |
| 553 | |
| 554 | void SkDebugCanvas::onPopCull() { |
| 555 | this->addDrawCommand(new SkPopCullCommand()); |
| 556 | } |
| 557 | |
| commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 558 | void SkDebugCanvas::willRestore() { |
| 559 | this->addDrawCommand(new SkRestoreCommand()); |
| 560 | this->INHERITED::willRestore(); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 561 | } |
| 562 | |
| commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 563 | void SkDebugCanvas::willSave(SaveFlags flags) { |
| 564 | this->addDrawCommand(new SkSaveCommand(flags)); |
| 565 | this->INHERITED::willSave(flags); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 566 | } |
| 567 | |
| commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 568 | SkCanvas::SaveLayerStrategy SkDebugCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, |
| 569 | SaveFlags flags) { |
| 570 | this->addDrawCommand(new SkSaveLayerCommand(bounds, paint, flags)); |
| 571 | this->INHERITED::willSaveLayer(bounds, paint, flags); |
| 572 | // No need for a full layer. |
| 573 | return kNoLayer_SaveLayerStrategy; |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 574 | } |
| 575 | |
| commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 576 | void SkDebugCanvas::didSetMatrix(const SkMatrix& matrix) { |
| commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame^] | 577 | this->addDrawCommand(new SkSetMatrixCommand(matrix)); |
| commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 578 | this->INHERITED::didSetMatrix(matrix); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 579 | } |
| 580 | |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 581 | void SkDebugCanvas::toggleCommand(int index, bool toggle) { |
| robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 582 | SkASSERT(index < fCommandVector.count()); |
| 583 | fCommandVector[index]->setVisible(toggle); |
| chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 584 | } |