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 | |
ethannicholas | 891ad66 | 2016-02-12 07:15:45 -0800 | [diff] [blame] | 8 | #include "SkCanvasPriv.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 9 | #include "SkClipStack.h" |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 10 | #include "SkDebugCanvas.h" |
| 11 | #include "SkDrawCommand.h" |
fmalita | 37283c2 | 2016-09-13 10:00:23 -0700 | [diff] [blame] | 12 | #include "SkPaintFilterCanvas.h" |
Mike Reed | 274218e | 2018-01-08 15:05:02 -0500 | [diff] [blame] | 13 | #include "SkRectPriv.h" |
fmalita | 37283c2 | 2016-09-13 10:00:23 -0700 | [diff] [blame] | 14 | #include "SkTextBlob.h" |
Mike Reed | ebfce6d | 2016-12-12 10:02:12 -0500 | [diff] [blame] | 15 | #include "SkClipOpPriv.h" |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 16 | |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 17 | #if SK_SUPPORT_GPU |
| 18 | #include "GrAuditTrail.h" |
| 19 | #include "GrContext.h" |
Robert Phillips | 22f4a1f | 2016-12-20 08:57:26 -0500 | [diff] [blame] | 20 | #include "GrRenderTargetContext.h" |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 21 | #endif |
| 22 | |
joshualitt | e43f7e6 | 2016-03-04 10:45:05 -0800 | [diff] [blame] | 23 | #define SKDEBUGCANVAS_VERSION 1 |
| 24 | #define SKDEBUGCANVAS_ATTRIBUTE_VERSION "version" |
| 25 | #define SKDEBUGCANVAS_ATTRIBUTE_COMMANDS "commands" |
| 26 | #define SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL "auditTrail" |
ethannicholas | 402cd91 | 2016-02-10 12:57:30 -0800 | [diff] [blame] | 27 | |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 28 | class DebugPaintFilterCanvas : public SkPaintFilterCanvas { |
| 29 | public: |
Ben Wagner | c03e1c5 | 2016-10-17 15:20:02 -0400 | [diff] [blame] | 30 | DebugPaintFilterCanvas(SkCanvas* canvas, |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 31 | bool overdrawViz, |
| 32 | bool overrideFilterQuality, |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 33 | SkFilterQuality quality) |
Ben Wagner | c03e1c5 | 2016-10-17 15:20:02 -0400 | [diff] [blame] | 34 | : INHERITED(canvas) |
| 35 | , fOverdrawViz(overdrawViz) |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 36 | , fOverrideFilterQuality(overrideFilterQuality) |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 37 | , fFilterQuality(quality) {} |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 38 | |
| 39 | protected: |
fmalita | 32cdc32 | 2016-01-12 07:21:11 -0800 | [diff] [blame] | 40 | bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) const override { |
| 41 | if (*paint) { |
Ben Wagner | c03e1c5 | 2016-10-17 15:20:02 -0400 | [diff] [blame] | 42 | if (fOverdrawViz) { |
| 43 | paint->writable()->setColor(SK_ColorRED); |
| 44 | paint->writable()->setAlpha(0x08); |
| 45 | paint->writable()->setBlendMode(SkBlendMode::kSrcOver); |
fmalita | bad23dc | 2016-01-11 13:58:29 -0800 | [diff] [blame] | 46 | } |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 47 | |
fmalita | bad23dc | 2016-01-11 13:58:29 -0800 | [diff] [blame] | 48 | if (fOverrideFilterQuality) { |
fmalita | 32cdc32 | 2016-01-12 07:21:11 -0800 | [diff] [blame] | 49 | paint->writable()->setFilterQuality(fFilterQuality); |
fmalita | bad23dc | 2016-01-11 13:58:29 -0800 | [diff] [blame] | 50 | } |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 51 | } |
fmalita | bad23dc | 2016-01-11 13:58:29 -0800 | [diff] [blame] | 52 | return true; |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 53 | } |
| 54 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 55 | void onDrawPicture(const SkPicture* picture, |
| 56 | const SkMatrix* matrix, |
| 57 | const SkPaint* paint) override { |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 58 | // We need to replay the picture onto this canvas in order to filter its internal paints. |
| 59 | this->SkCanvas::onDrawPicture(picture, matrix, paint); |
| 60 | } |
| 61 | |
| 62 | private: |
Ben Wagner | c03e1c5 | 2016-10-17 15:20:02 -0400 | [diff] [blame] | 63 | bool fOverdrawViz; |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 64 | bool fOverrideFilterQuality; |
| 65 | SkFilterQuality fFilterQuality; |
| 66 | |
| 67 | typedef SkPaintFilterCanvas INHERITED; |
| 68 | }; |
| 69 | |
kkinnunen | 26e5400 | 2015-01-05 12:58:56 -0800 | [diff] [blame] | 70 | SkDebugCanvas::SkDebugCanvas(int width, int height) |
| 71 | : INHERITED(width, height) |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 72 | , fPicture(nullptr) |
commit-bot@chromium.org | 1735d66 | 2013-12-04 13:42:46 +0000 | [diff] [blame] | 73 | , fFilter(false) |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 74 | , fMegaVizMode(false) |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 75 | , fOverdrawViz(false) |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 76 | , fOverrideFilterQuality(false) |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 77 | , fFilterQuality(kNone_SkFilterQuality) |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 78 | , fClipVizColor(SK_ColorTRANSPARENT) |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 79 | , fDrawGpuOpBounds(false) { |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 80 | fUserMatrix.reset(); |
robertphillips@google.com | 8b15717 | 2013-11-07 22:20:31 +0000 | [diff] [blame] | 81 | |
| 82 | // SkPicturePlayback uses the base-class' quickReject calls to cull clipped |
| 83 | // operations. This can lead to problems in the debugger which expects all |
| 84 | // the operations in the captured skp to appear in the debug canvas. To |
| 85 | // circumvent this we create a wide open clip here (an empty clip rect |
| 86 | // is not sufficient). |
| 87 | // Internally, the SkRect passed to clipRect is converted to an SkIRect and |
| 88 | // rounded out. The following code creates a nearly maximal rect that will |
| 89 | // not get collapsed by the coming conversions (Due to precision loss the |
| 90 | // inset has to be surprisingly large). |
Mike Reed | 8008df1 | 2018-01-17 12:20:04 -0500 | [diff] [blame^] | 91 | SkIRect largeIRect = SkRectPriv::MakeILarge(); |
robertphillips@google.com | 8b15717 | 2013-11-07 22:20:31 +0000 | [diff] [blame] | 92 | largeIRect.inset(1024, 1024); |
robertphillips@google.com | 6c1e49a | 2013-11-10 15:08:45 +0000 | [diff] [blame] | 93 | SkRect large = SkRect::Make(largeIRect); |
robertphillips@google.com | 8b15717 | 2013-11-07 22:20:31 +0000 | [diff] [blame] | 94 | #ifdef SK_DEBUG |
reed | b07a94f | 2014-11-19 05:03:18 -0800 | [diff] [blame] | 95 | SkASSERT(!large.roundOut().isEmpty()); |
robertphillips@google.com | 8b15717 | 2013-11-07 22:20:31 +0000 | [diff] [blame] | 96 | #endif |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 97 | // call the base class' version to avoid adding a draw command |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 98 | this->INHERITED::onClipRect(large, kReplace_SkClipOp, kHard_ClipEdgeStyle); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 99 | } |
| 100 | |
chudy@google.com | 9cda6f7 | 2012-08-07 15:08:33 +0000 | [diff] [blame] | 101 | SkDebugCanvas::~SkDebugCanvas() { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 102 | fCommandVector.deleteAll(); |
chudy@google.com | 9cda6f7 | 2012-08-07 15:08:33 +0000 | [diff] [blame] | 103 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 104 | |
| 105 | void SkDebugCanvas::addDrawCommand(SkDrawCommand* command) { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 106 | fCommandVector.push(command); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | void SkDebugCanvas::draw(SkCanvas* canvas) { |
commit-bot@chromium.org | 1735d66 | 2013-12-04 13:42:46 +0000 | [diff] [blame] | 110 | if (!fCommandVector.isEmpty()) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 111 | this->drawTo(canvas, fCommandVector.count() - 1); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 112 | } |
| 113 | } |
| 114 | |
chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 115 | void SkDebugCanvas::applyUserTransform(SkCanvas* canvas) { |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 116 | canvas->concat(fUserMatrix); |
chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | int SkDebugCanvas::getCommandAtPoint(int x, int y, int index) { |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 120 | SkBitmap bitmap; |
reed@google.com | 9ebcac5 | 2014-01-24 18:53:42 +0000 | [diff] [blame] | 121 | bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 122 | |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 123 | SkCanvas canvas(bitmap); |
robertphillips@google.com | 94acc70 | 2012-09-06 18:43:21 +0000 | [diff] [blame] | 124 | canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y)); |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 125 | this->applyUserTransform(&canvas); |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 126 | |
| 127 | int layer = 0; |
chudy@google.com | 751961d | 2012-07-31 20:07:42 +0000 | [diff] [blame] | 128 | SkColor prev = bitmap.getColor(0,0); |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 129 | for (int i = 0; i < index; i++) { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 130 | if (fCommandVector[i]->isVisible()) { |
robertphillips | 7017168 | 2014-10-16 14:28:28 -0700 | [diff] [blame] | 131 | fCommandVector[i]->setUserMatrix(fUserMatrix); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 132 | fCommandVector[i]->execute(&canvas); |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 133 | } |
| 134 | if (prev != bitmap.getColor(0,0)) { |
| 135 | layer = i; |
| 136 | } |
| 137 | prev = bitmap.getColor(0,0); |
| 138 | } |
| 139 | return layer; |
| 140 | } |
| 141 | |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 142 | // set up the saveLayer commands so that the active ones |
| 143 | // return true in their 'active' method |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 144 | void SkDebugCanvas::markActiveCommands(int index) { |
| 145 | fActiveLayers.rewind(); |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 146 | |
| 147 | for (int i = 0; i < fCommandVector.count(); ++i) { |
| 148 | fCommandVector[i]->setActive(false); |
| 149 | } |
| 150 | |
| 151 | for (int i = 0; i < index; ++i) { |
| 152 | SkDrawCommand::Action result = fCommandVector[i]->action(); |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 153 | if (SkDrawCommand::kPushLayer_Action == result) { |
| 154 | fActiveLayers.push(fCommandVector[i]); |
| 155 | } else if (SkDrawCommand::kPopLayer_Action == result) { |
| 156 | fActiveLayers.pop(); |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 160 | for (int i = 0; i < fActiveLayers.count(); ++i) { |
| 161 | fActiveLayers[i]->setActive(true); |
| 162 | } |
| 163 | |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 166 | void SkDebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 167 | SkASSERT(!fCommandVector.isEmpty()); |
| 168 | SkASSERT(index < fCommandVector.count()); |
kkinnunen | 26a00de | 2015-01-13 23:09:19 -0800 | [diff] [blame] | 169 | |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 170 | int saveCount = originalCanvas->save(); |
kkinnunen | 26a00de | 2015-01-13 23:09:19 -0800 | [diff] [blame] | 171 | |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 172 | SkRect windowRect = SkRect::MakeWH(SkIntToScalar(originalCanvas->getBaseLayerSize().width()), |
| 173 | SkIntToScalar(originalCanvas->getBaseLayerSize().height())); |
chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 174 | |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 175 | bool pathOpsMode = getAllowSimplifyClip(); |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 176 | originalCanvas->setAllowSimplifyClip(pathOpsMode); |
| 177 | originalCanvas->clear(SK_ColorWHITE); |
| 178 | originalCanvas->resetMatrix(); |
kkinnunen | 26a00de | 2015-01-13 23:09:19 -0800 | [diff] [blame] | 179 | if (!windowRect.isEmpty()) { |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 180 | originalCanvas->clipRect(windowRect, kReplace_SkClipOp); |
commit-bot@chromium.org | a27622c | 2013-08-05 16:31:27 +0000 | [diff] [blame] | 181 | } |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 182 | this->applyUserTransform(originalCanvas); |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 183 | |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 184 | DebugPaintFilterCanvas filterCanvas(originalCanvas, fOverdrawViz, fOverrideFilterQuality, |
| 185 | fFilterQuality); |
chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 186 | |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 187 | if (fMegaVizMode) { |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 188 | this->markActiveCommands(index); |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 189 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 190 | |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame] | 191 | #if SK_SUPPORT_GPU |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 192 | // If we have a GPU backend we can also visualize the op information |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 193 | GrAuditTrail* at = nullptr; |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 194 | if (fDrawGpuOpBounds || m != -1) { |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 195 | // The audit trail must be obtained from the original canvas. |
| 196 | at = this->getAuditTrail(originalCanvas); |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 197 | } |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame] | 198 | #endif |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 199 | |
kkinnunen | 26a00de | 2015-01-13 23:09:19 -0800 | [diff] [blame] | 200 | for (int i = 0; i <= index; i++) { |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 201 | if (i == index && fFilter) { |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 202 | filterCanvas.clear(0xAAFFFFFF); |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 203 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 204 | |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 205 | #if SK_SUPPORT_GPU |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 206 | // We need to flush any pending operations, or they might combine with commands below. |
brianosman | 1c9f922 | 2016-04-15 11:00:51 -0700 | [diff] [blame] | 207 | // Previous operations were not registered with the audit trail when they were |
| 208 | // created, so if we allow them to combine, the audit trail will fail to find them. |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 209 | filterCanvas.flush(); |
brianosman | 1c9f922 | 2016-04-15 11:00:51 -0700 | [diff] [blame] | 210 | |
Brian Salomon | 42ad83a | 2016-12-20 16:14:45 -0500 | [diff] [blame] | 211 | GrAuditTrail::AutoCollectOps* acb = nullptr; |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 212 | if (at) { |
Brian Salomon | 42ad83a | 2016-12-20 16:14:45 -0500 | [diff] [blame] | 213 | acb = new GrAuditTrail::AutoCollectOps(at, i); |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 214 | } |
| 215 | #endif |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 216 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 217 | if (fCommandVector[i]->isVisible()) { |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 218 | if (fMegaVizMode && fCommandVector[i]->active()) { |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 219 | // "active" commands execute their visualization behaviors: |
| 220 | // All active saveLayers get replaced with saves so all draws go to the |
| 221 | // visible canvas. |
| 222 | // All active culls draw their cull box |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 223 | fCommandVector[i]->vizExecute(&filterCanvas); |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 224 | } else { |
robertphillips | 7017168 | 2014-10-16 14:28:28 -0700 | [diff] [blame] | 225 | fCommandVector[i]->setUserMatrix(fUserMatrix); |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 226 | fCommandVector[i]->execute(&filterCanvas); |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 227 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 228 | } |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 229 | #if SK_SUPPORT_GPU |
| 230 | if (at && acb) { |
| 231 | delete acb; |
| 232 | } |
| 233 | #endif |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 234 | } |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 235 | |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 236 | if (SkColorGetA(fClipVizColor) != 0) { |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 237 | filterCanvas.save(); |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 238 | #define LARGE_COORD 1000000000 |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 239 | filterCanvas.clipRect( |
| 240 | SkRect::MakeLTRB(-LARGE_COORD, -LARGE_COORD, LARGE_COORD, LARGE_COORD), |
| 241 | kReverseDifference_SkClipOp); |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 242 | SkPaint clipPaint; |
| 243 | clipPaint.setColor(fClipVizColor); |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 244 | filterCanvas.drawPaint(clipPaint); |
| 245 | filterCanvas.restore(); |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 246 | } |
| 247 | |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 248 | if (pathOpsMode) { |
| 249 | this->resetClipStackData(); |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 250 | const SkClipStack* clipStack = nullptr;//HACK filterCanvas.getClipStack(); |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 251 | SkClipStack::Iter iter(*clipStack, SkClipStack::Iter::kBottom_IterStart); |
| 252 | const SkClipStack::Element* element; |
| 253 | SkPath devPath; |
| 254 | while ((element = iter.next())) { |
Brian Salomon | f3b46e5 | 2017-08-30 11:37:57 -0400 | [diff] [blame] | 255 | SkClipStack::Element::DeviceSpaceType type = element->getDeviceSpaceType(); |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 256 | SkPath operand; |
Brian Salomon | f3b46e5 | 2017-08-30 11:37:57 -0400 | [diff] [blame] | 257 | if (type != SkClipStack::Element::DeviceSpaceType::kEmpty) { |
| 258 | element->asDeviceSpacePath(&operand); |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 259 | } |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 260 | SkClipOp elementOp = element->getOp(); |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 261 | this->addClipStackData(devPath, operand, elementOp); |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 262 | if (elementOp == kReplace_SkClipOp) { |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 263 | devPath = operand; |
| 264 | } else { |
| 265 | Op(devPath, operand, (SkPathOp) elementOp, &devPath); |
| 266 | } |
| 267 | } |
| 268 | this->lastClipStackData(devPath); |
| 269 | } |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 270 | fMatrix = filterCanvas.getTotalMatrix(); |
Mike Reed | 918e144 | 2017-01-23 11:39:45 -0500 | [diff] [blame] | 271 | fClip = filterCanvas.getDeviceClipBounds(); |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 272 | filterCanvas.restoreToCount(saveCount); |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 273 | |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 274 | #if SK_SUPPORT_GPU |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 275 | // draw any ops if required and issue a full reset onto GrAuditTrail |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 276 | if (at) { |
joshualitt | e43f7e6 | 2016-03-04 10:45:05 -0800 | [diff] [blame] | 277 | // just in case there is global reordering, we flush the canvas before querying |
| 278 | // GrAuditTrail |
joshualitt | b0666ad | 2016-03-08 10:43:41 -0800 | [diff] [blame] | 279 | GrAuditTrail::AutoEnable ae(at); |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 280 | filterCanvas.flush(); |
joshualitt | e43f7e6 | 2016-03-04 10:45:05 -0800 | [diff] [blame] | 281 | |
joshualitt | bdc6b2b | 2016-03-01 14:22:02 -0800 | [diff] [blame] | 282 | // we pick three colorblind-safe colors, 75% alpha |
| 283 | static const SkColor kTotalBounds = SkColorSetARGB(0xC0, 0x6A, 0x3D, 0x9A); |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 284 | static const SkColor kCommandOpBounds = SkColorSetARGB(0xC0, 0xE3, 0x1A, 0x1C); |
| 285 | static const SkColor kOtherOpBounds = SkColorSetARGB(0xC0, 0xFF, 0x7F, 0x00); |
joshualitt | bdc6b2b | 2016-03-01 14:22:02 -0800 | [diff] [blame] | 286 | |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 287 | // get the render target of the top device (from the original canvas) so we can ignore ops |
| 288 | // drawn offscreen |
| 289 | GrRenderTargetContext* rtc = |
| 290 | originalCanvas->internal_private_accessTopLayerRenderTargetContext(); |
Robert Phillips | 318c419 | 2017-05-17 09:36:38 -0400 | [diff] [blame] | 291 | GrSurfaceProxy::UniqueID proxyID = rtc->asSurfaceProxy()->uniqueID(); |
joshualitt | 1d7decf | 2016-03-01 07:15:52 -0800 | [diff] [blame] | 292 | |
| 293 | // get the bounding boxes to draw |
Brian Salomon | 42ad83a | 2016-12-20 16:14:45 -0500 | [diff] [blame] | 294 | SkTArray<GrAuditTrail::OpInfo> childrenBounds; |
joshualitt | 46b301d | 2016-03-02 08:32:37 -0800 | [diff] [blame] | 295 | if (m == -1) { |
| 296 | at->getBoundsByClientID(&childrenBounds, index); |
| 297 | } else { |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 298 | // the client wants us to draw the mth op |
Brian Salomon | 42ad83a | 2016-12-20 16:14:45 -0500 | [diff] [blame] | 299 | at->getBoundsByOpListID(&childrenBounds.push_back(), m); |
joshualitt | 46b301d | 2016-03-02 08:32:37 -0800 | [diff] [blame] | 300 | } |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 301 | SkPaint paint; |
| 302 | paint.setStyle(SkPaint::kStroke_Style); |
| 303 | paint.setStrokeWidth(1); |
| 304 | for (int i = 0; i < childrenBounds.count(); i++) { |
Robert Phillips | 318c419 | 2017-05-17 09:36:38 -0400 | [diff] [blame] | 305 | if (childrenBounds[i].fProxyUniqueID != proxyID) { |
joshualitt | 1d7decf | 2016-03-01 07:15:52 -0800 | [diff] [blame] | 306 | // offscreen draw, ignore for now |
| 307 | continue; |
| 308 | } |
joshualitt | bdc6b2b | 2016-03-01 14:22:02 -0800 | [diff] [blame] | 309 | paint.setColor(kTotalBounds); |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 310 | filterCanvas.drawRect(childrenBounds[i].fBounds, paint); |
Brian Salomon | 42ad83a | 2016-12-20 16:14:45 -0500 | [diff] [blame] | 311 | for (int j = 0; j < childrenBounds[i].fOps.count(); j++) { |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 312 | const GrAuditTrail::OpInfo::Op& op = childrenBounds[i].fOps[j]; |
| 313 | if (op.fClientID != index) { |
| 314 | paint.setColor(kOtherOpBounds); |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 315 | } else { |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 316 | paint.setColor(kCommandOpBounds); |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 317 | } |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 318 | filterCanvas.drawRect(op.fBounds, paint); |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 319 | } |
| 320 | } |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 321 | } |
joshualitt | 10d8fc2 | 2016-02-29 11:15:06 -0800 | [diff] [blame] | 322 | #endif |
Ravi Mistry | 99c9796 | 2016-12-21 22:41:03 +0000 | [diff] [blame] | 323 | this->cleanupAuditTrail(originalCanvas); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 324 | } |
| 325 | |
robertphillips@google.com | 50c84da | 2013-04-01 18:18:49 +0000 | [diff] [blame] | 326 | void SkDebugCanvas::deleteDrawCommandAt(int index) { |
| 327 | SkASSERT(index < fCommandVector.count()); |
| 328 | delete fCommandVector[index]; |
| 329 | fCommandVector.remove(index); |
| 330 | } |
| 331 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 332 | SkDrawCommand* SkDebugCanvas::getDrawCommandAt(int index) { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 333 | SkASSERT(index < fCommandVector.count()); |
| 334 | return fCommandVector[index]; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 335 | } |
| 336 | |
robertphillips@google.com | 50c84da | 2013-04-01 18:18:49 +0000 | [diff] [blame] | 337 | void SkDebugCanvas::setDrawCommandAt(int index, SkDrawCommand* command) { |
| 338 | SkASSERT(index < fCommandVector.count()); |
| 339 | delete fCommandVector[index]; |
| 340 | fCommandVector[index] = command; |
| 341 | } |
| 342 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame] | 343 | const SkTDArray<SkString*>* SkDebugCanvas::getCommandInfo(int index) const { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 344 | SkASSERT(index < fCommandVector.count()); |
| 345 | return fCommandVector[index]->Info(); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 346 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 347 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 348 | bool SkDebugCanvas::getDrawCommandVisibilityAt(int index) { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 349 | SkASSERT(index < fCommandVector.count()); |
| 350 | return fCommandVector[index]->isVisible(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 351 | } |
| 352 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 353 | const SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() const { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 354 | return fCommandVector; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 355 | } |
| 356 | |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 357 | SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() { |
| 358 | return fCommandVector; |
| 359 | } |
| 360 | |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 361 | GrAuditTrail* SkDebugCanvas::getAuditTrail(SkCanvas* canvas) { |
| 362 | GrAuditTrail* at = nullptr; |
joshualitt | e43f7e6 | 2016-03-04 10:45:05 -0800 | [diff] [blame] | 363 | #if SK_SUPPORT_GPU |
robertphillips | 175dd9b | 2016-04-28 14:32:04 -0700 | [diff] [blame] | 364 | GrContext* ctx = canvas->getGrContext(); |
| 365 | if (ctx) { |
| 366 | at = ctx->getAuditTrail(); |
joshualitt | e43f7e6 | 2016-03-04 10:45:05 -0800 | [diff] [blame] | 367 | } |
| 368 | #endif |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 369 | return at; |
| 370 | } |
| 371 | |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 372 | void SkDebugCanvas::drawAndCollectOps(int n, SkCanvas* canvas) { |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame] | 373 | #if SK_SUPPORT_GPU |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 374 | GrAuditTrail* at = this->getAuditTrail(canvas); |
| 375 | if (at) { |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 376 | // loop over all of the commands and draw them, this is to collect reordering |
| 377 | // information |
| 378 | for (int i = 0; i < this->getSize() && i <= n; i++) { |
Brian Salomon | 42ad83a | 2016-12-20 16:14:45 -0500 | [diff] [blame] | 379 | GrAuditTrail::AutoCollectOps enable(at, i); |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 380 | fCommandVector[i]->execute(canvas); |
| 381 | } |
| 382 | |
| 383 | // in case there is some kind of global reordering |
| 384 | { |
| 385 | GrAuditTrail::AutoEnable ae(at); |
| 386 | canvas->flush(); |
| 387 | } |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 388 | } |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame] | 389 | #endif |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | void SkDebugCanvas::cleanupAuditTrail(SkCanvas* canvas) { |
| 393 | GrAuditTrail* at = this->getAuditTrail(canvas); |
| 394 | if (at) { |
| 395 | #if SK_SUPPORT_GPU |
| 396 | GrAuditTrail::AutoEnable ae(at); |
| 397 | at->fullReset(); |
| 398 | #endif |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager, int n, SkCanvas* canvas) { |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 403 | this->drawAndCollectOps(n, canvas); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 404 | |
joshualitt | e43f7e6 | 2016-03-04 10:45:05 -0800 | [diff] [blame] | 405 | // now collect json |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame] | 406 | #if SK_SUPPORT_GPU |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 407 | GrAuditTrail* at = this->getAuditTrail(canvas); |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame] | 408 | #endif |
ethannicholas | 402cd91 | 2016-02-10 12:57:30 -0800 | [diff] [blame] | 409 | Json::Value result = Json::Value(Json::objectValue); |
| 410 | result[SKDEBUGCANVAS_ATTRIBUTE_VERSION] = Json::Value(SKDEBUGCANVAS_VERSION); |
| 411 | Json::Value commands = Json::Value(Json::arrayValue); |
ethannicholas | 0a0520a | 2016-02-12 12:06:53 -0800 | [diff] [blame] | 412 | for (int i = 0; i < this->getSize() && i <= n; i++) { |
joshualitt | e43f7e6 | 2016-03-04 10:45:05 -0800 | [diff] [blame] | 413 | commands[i] = this->getDrawCommandAt(i)->toJSON(urlDataManager); |
| 414 | #if SK_SUPPORT_GPU |
| 415 | if (at) { |
| 416 | // TODO if this is inefficient we could add a method to GrAuditTrail which takes |
| 417 | // a Json::Value and is only compiled in this file |
| 418 | Json::Value parsedFromString; |
| 419 | Json::Reader reader; |
| 420 | SkAssertResult(reader.parse(at->toJson(i).c_str(), parsedFromString)); |
| 421 | |
| 422 | commands[i][SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL] = parsedFromString; |
| 423 | } |
| 424 | #endif |
ethannicholas | 402cd91 | 2016-02-10 12:57:30 -0800 | [diff] [blame] | 425 | } |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 426 | this->cleanupAuditTrail(canvas); |
ethannicholas | 402cd91 | 2016-02-10 12:57:30 -0800 | [diff] [blame] | 427 | result[SKDEBUGCANVAS_ATTRIBUTE_COMMANDS] = commands; |
| 428 | return result; |
| 429 | } |
| 430 | |
Brian Salomon | 144a5c5 | 2016-12-20 16:48:59 -0500 | [diff] [blame] | 431 | Json::Value SkDebugCanvas::toJSONOpList(int n, SkCanvas* canvas) { |
| 432 | this->drawAndCollectOps(n, canvas); |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 433 | |
| 434 | Json::Value parsedFromString; |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 435 | #if SK_SUPPORT_GPU |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame] | 436 | GrAuditTrail* at = this->getAuditTrail(canvas); |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 437 | if (at) { |
Brian Salomon | 42ad83a | 2016-12-20 16:14:45 -0500 | [diff] [blame] | 438 | GrAuditTrail::AutoManageOpList enable(at); |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 439 | Json::Reader reader; |
| 440 | SkAssertResult(reader.parse(at->toJson().c_str(), parsedFromString)); |
| 441 | } |
| 442 | #endif |
| 443 | this->cleanupAuditTrail(canvas); |
| 444 | return parsedFromString; |
| 445 | } |
| 446 | |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 447 | void SkDebugCanvas::setOverdrawViz(bool overdrawViz) { |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 448 | fOverdrawViz = overdrawViz; |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | void SkDebugCanvas::overrideTexFiltering(bool overrideTexFiltering, SkFilterQuality quality) { |
fmalita | 65cdb57 | 2015-03-26 07:24:48 -0700 | [diff] [blame] | 452 | fOverrideFilterQuality = overrideTexFiltering; |
| 453 | fFilterQuality = quality; |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 456 | void SkDebugCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) { |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 457 | this->addDrawCommand(new SkClipPathCommand(path, op, kSoft_ClipEdgeStyle == edgeStyle)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 458 | } |
| 459 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 460 | void SkDebugCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) { |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 461 | this->addDrawCommand(new SkClipRectCommand(rect, op, kSoft_ClipEdgeStyle == edgeStyle)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 462 | } |
| 463 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 464 | void SkDebugCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) { |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 465 | this->addDrawCommand(new SkClipRRectCommand(rrect, op, kSoft_ClipEdgeStyle == edgeStyle)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 466 | } |
| 467 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 468 | void SkDebugCanvas::onClipRegion(const SkRegion& region, SkClipOp op) { |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 469 | this->addDrawCommand(new SkClipRegionCommand(region, op)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 470 | } |
| 471 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 472 | void SkDebugCanvas::didConcat(const SkMatrix& matrix) { |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 473 | this->addDrawCommand(new SkConcatCommand(matrix)); |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 474 | this->INHERITED::didConcat(matrix); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 475 | } |
| 476 | |
reed | 97660cc | 2016-06-28 18:54:19 -0700 | [diff] [blame] | 477 | void SkDebugCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) { |
| 478 | this->addDrawCommand(new SkDrawAnnotationCommand(rect, key, sk_ref_sp(value))); |
| 479 | } |
| 480 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 481 | void SkDebugCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left, |
| 482 | SkScalar top, const SkPaint* paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 483 | this->addDrawCommand(new SkDrawBitmapCommand(bitmap, left, top, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 484 | } |
| 485 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 486 | void SkDebugCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 487 | const SkPaint* paint, SrcRectConstraint constraint) { |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 488 | this->addDrawCommand(new SkDrawBitmapRectCommand(bitmap, src, dst, paint, |
| 489 | (SrcRectConstraint)constraint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 490 | } |
| 491 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 492 | void SkDebugCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
| 493 | const SkRect& dst, const SkPaint* paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 494 | this->addDrawCommand(new SkDrawBitmapNineCommand(bitmap, center, dst, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 495 | } |
| 496 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 497 | void SkDebugCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, |
| 498 | const SkPaint* paint) { |
fmalita | 651c920 | 2015-07-22 10:23:01 -0700 | [diff] [blame] | 499 | this->addDrawCommand(new SkDrawImageCommand(image, left, top, paint)); |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 500 | } |
| 501 | |
Stan Iliev | ac42aeb | 2017-01-12 16:20:50 -0500 | [diff] [blame] | 502 | void SkDebugCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice, |
| 503 | const SkRect& dst, const SkPaint* paint) { |
| 504 | this->addDrawCommand(new SkDrawImageLatticeCommand(image, lattice, dst, paint)); |
| 505 | } |
| 506 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 507 | void SkDebugCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 508 | const SkPaint* paint, SrcRectConstraint constraint) { |
fmalita | 651c920 | 2015-07-22 10:23:01 -0700 | [diff] [blame] | 509 | this->addDrawCommand(new SkDrawImageRectCommand(image, src, dst, paint, constraint)); |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 510 | } |
| 511 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 512 | void SkDebugCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 513 | this->addDrawCommand(new SkDrawOvalCommand(oval, paint)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 514 | } |
| 515 | |
bsalomon | ac3aa24 | 2016-08-19 11:25:19 -0700 | [diff] [blame] | 516 | void SkDebugCanvas::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, |
| 517 | bool useCenter, const SkPaint& paint) { |
| 518 | this->addDrawCommand(new SkDrawArcCommand(oval, startAngle, sweepAngle, useCenter, paint)); |
| 519 | } |
| 520 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 521 | void SkDebugCanvas::onDrawPaint(const SkPaint& paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 522 | this->addDrawCommand(new SkDrawPaintCommand(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 523 | } |
| 524 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 525 | void SkDebugCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 526 | this->addDrawCommand(new SkDrawPathCommand(path, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 527 | } |
| 528 | |
mtklein | f0f1411 | 2014-12-12 08:46:25 -0800 | [diff] [blame] | 529 | void SkDebugCanvas::onDrawPicture(const SkPicture* picture, |
| 530 | const SkMatrix* matrix, |
robertphillips | b3f319f | 2014-08-13 10:46:23 -0700 | [diff] [blame] | 531 | const SkPaint* paint) { |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 532 | this->addDrawCommand(new SkBeginDrawPictureCommand(picture, matrix, paint)); |
ethannicholas | 891ad66 | 2016-02-12 07:15:45 -0800 | [diff] [blame] | 533 | SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect()); |
| 534 | picture->playback(this); |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 535 | this->addDrawCommand(new SkEndDrawPictureCommand(SkToBool(matrix) || SkToBool(paint))); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 536 | } |
| 537 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 538 | void SkDebugCanvas::onDrawPoints(PointMode mode, size_t count, |
| 539 | const SkPoint pts[], const SkPaint& paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 540 | this->addDrawCommand(new SkDrawPointsCommand(mode, count, pts, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 541 | } |
| 542 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 543 | void SkDebugCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
| 544 | const SkPaint& paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 545 | this->addDrawCommand(new SkDrawPosTextCommand(text, byteLength, pos, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 546 | } |
| 547 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 548 | void SkDebugCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], |
| 549 | SkScalar constY, const SkPaint& paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 550 | this->addDrawCommand( |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 551 | new SkDrawPosTextHCommand(text, byteLength, xpos, constY, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 552 | } |
| 553 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 554 | void SkDebugCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 555 | // NOTE(chudy): Messing up when renamed to DrawRect... Why? |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 556 | addDrawCommand(new SkDrawRectCommand(rect, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 557 | } |
| 558 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 559 | void SkDebugCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 560 | this->addDrawCommand(new SkDrawRRectCommand(rrect, paint)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 561 | } |
| 562 | |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 563 | void SkDebugCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
| 564 | const SkPaint& paint) { |
commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 565 | this->addDrawCommand(new SkDrawDRRectCommand(outer, inner, paint)); |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 566 | } |
| 567 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 568 | void SkDebugCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
| 569 | const SkPaint& paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 570 | this->addDrawCommand(new SkDrawTextCommand(text, byteLength, x, y, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 571 | } |
| 572 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 573 | void SkDebugCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
| 574 | const SkMatrix* matrix, const SkPaint& paint) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 575 | this->addDrawCommand( |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 576 | new SkDrawTextOnPathCommand(text, byteLength, path, matrix, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 577 | } |
| 578 | |
reed | 45561a0 | 2016-07-07 12:47:17 -0700 | [diff] [blame] | 579 | void SkDebugCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[], |
| 580 | const SkRect* cull, const SkPaint& paint) { |
| 581 | this->addDrawCommand(new SkDrawTextRSXformCommand(text, byteLength, xform, cull, paint)); |
| 582 | } |
| 583 | |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 584 | void SkDebugCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 585 | const SkPaint& paint) { |
fmalita | 37283c2 | 2016-09-13 10:00:23 -0700 | [diff] [blame] | 586 | this->addDrawCommand(new SkDrawTextBlobCommand(sk_ref_sp(const_cast<SkTextBlob*>(blob)), |
| 587 | x, y, paint)); |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 588 | } |
| 589 | |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 590 | void SkDebugCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
Mike Reed | faba371 | 2016-11-03 14:45:31 -0400 | [diff] [blame] | 591 | const SkPoint texCoords[4], SkBlendMode bmode, |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 592 | const SkPaint& paint) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 593 | this->addDrawCommand(new SkDrawPatchCommand(cubics, colors, texCoords, bmode, paint)); |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 594 | } |
| 595 | |
Mike Reed | fed9cfd | 2017-03-17 12:09:04 -0400 | [diff] [blame] | 596 | void SkDebugCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode, |
| 597 | const SkPaint& paint) { |
| 598 | this->addDrawCommand(new SkDrawVerticesCommand(sk_ref_sp(const_cast<SkVertices*>(vertices)), |
| 599 | bmode, paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 600 | } |
| 601 | |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 602 | void SkDebugCanvas::willRestore() { |
| 603 | this->addDrawCommand(new SkRestoreCommand()); |
| 604 | this->INHERITED::willRestore(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 605 | } |
| 606 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 607 | void SkDebugCanvas::willSave() { |
| 608 | this->addDrawCommand(new SkSaveCommand()); |
| 609 | this->INHERITED::willSave(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 610 | } |
| 611 | |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 612 | SkCanvas::SaveLayerStrategy SkDebugCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) { |
| 613 | this->addDrawCommand(new SkSaveLayerCommand(rec)); |
| 614 | (void)this->INHERITED::getSaveLayerStrategy(rec); |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 615 | // No need for a full layer. |
| 616 | return kNoLayer_SaveLayerStrategy; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 617 | } |
| 618 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 619 | void SkDebugCanvas::didSetMatrix(const SkMatrix& matrix) { |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 620 | this->addDrawCommand(new SkSetMatrixCommand(matrix)); |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 621 | this->INHERITED::didSetMatrix(matrix); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 622 | } |
| 623 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 624 | void SkDebugCanvas::toggleCommand(int index, bool toggle) { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 625 | SkASSERT(index < fCommandVector.count()); |
| 626 | fCommandVector[index]->setVisible(toggle); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 627 | } |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 628 | |
| 629 | static const char* gFillTypeStrs[] = { |
| 630 | "kWinding_FillType", |
| 631 | "kEvenOdd_FillType", |
| 632 | "kInverseWinding_FillType", |
| 633 | "kInverseEvenOdd_FillType" |
| 634 | }; |
| 635 | |
| 636 | static const char* gOpStrs[] = { |
scroggo | 5965b73 | 2015-04-07 06:53:21 -0700 | [diff] [blame] | 637 | "kDifference_PathOp", |
| 638 | "kIntersect_PathOp", |
| 639 | "kUnion_PathOp", |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 640 | "kXor_PathOp", |
scroggo | 5965b73 | 2015-04-07 06:53:21 -0700 | [diff] [blame] | 641 | "kReverseDifference_PathOp", |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 642 | }; |
| 643 | |
| 644 | static const char kHTML4SpaceIndent[] = " "; |
| 645 | |
| 646 | void SkDebugCanvas::outputScalar(SkScalar num) { |
| 647 | if (num == (int) num) { |
| 648 | fClipStackData.appendf("%d", (int) num); |
| 649 | } else { |
| 650 | SkString str; |
| 651 | str.printf("%1.9g", num); |
| 652 | int width = (int) str.size(); |
| 653 | const char* cStr = str.c_str(); |
| 654 | while (cStr[width - 1] == '0') { |
| 655 | --width; |
| 656 | } |
| 657 | str.resize(width); |
| 658 | fClipStackData.appendf("%sf", str.c_str()); |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | void SkDebugCanvas::outputPointsCommon(const SkPoint* pts, int count) { |
| 663 | for (int index = 0; index < count; ++index) { |
| 664 | this->outputScalar(pts[index].fX); |
| 665 | fClipStackData.appendf(", "); |
| 666 | this->outputScalar(pts[index].fY); |
| 667 | if (index + 1 < count) { |
| 668 | fClipStackData.appendf(", "); |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | void SkDebugCanvas::outputPoints(const SkPoint* pts, int count) { |
| 674 | this->outputPointsCommon(pts, count); |
| 675 | fClipStackData.appendf(");<br>"); |
| 676 | } |
| 677 | |
| 678 | void SkDebugCanvas::outputConicPoints(const SkPoint* pts, SkScalar weight) { |
| 679 | this->outputPointsCommon(pts, 2); |
| 680 | fClipStackData.appendf(", "); |
| 681 | this->outputScalar(weight); |
| 682 | fClipStackData.appendf(");<br>"); |
| 683 | } |
| 684 | |
| 685 | void SkDebugCanvas::addPathData(const SkPath& path, const char* pathName) { |
| 686 | SkPath::RawIter iter(path); |
| 687 | SkPath::FillType fillType = path.getFillType(); |
| 688 | fClipStackData.appendf("%sSkPath %s;<br>", kHTML4SpaceIndent, pathName); |
| 689 | fClipStackData.appendf("%s%s.setFillType(SkPath::%s);<br>", kHTML4SpaceIndent, pathName, |
| 690 | gFillTypeStrs[fillType]); |
| 691 | iter.setPath(path); |
| 692 | uint8_t verb; |
| 693 | SkPoint pts[4]; |
| 694 | while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { |
| 695 | switch (verb) { |
| 696 | case SkPath::kMove_Verb: |
| 697 | fClipStackData.appendf("%s%s.moveTo(", kHTML4SpaceIndent, pathName); |
| 698 | this->outputPoints(&pts[0], 1); |
| 699 | continue; |
| 700 | case SkPath::kLine_Verb: |
| 701 | fClipStackData.appendf("%s%s.lineTo(", kHTML4SpaceIndent, pathName); |
| 702 | this->outputPoints(&pts[1], 1); |
| 703 | break; |
| 704 | case SkPath::kQuad_Verb: |
| 705 | fClipStackData.appendf("%s%s.quadTo(", kHTML4SpaceIndent, pathName); |
| 706 | this->outputPoints(&pts[1], 2); |
| 707 | break; |
| 708 | case SkPath::kConic_Verb: |
| 709 | fClipStackData.appendf("%s%s.conicTo(", kHTML4SpaceIndent, pathName); |
| 710 | this->outputConicPoints(&pts[1], iter.conicWeight()); |
| 711 | break; |
| 712 | case SkPath::kCubic_Verb: |
| 713 | fClipStackData.appendf("%s%s.cubicTo(", kHTML4SpaceIndent, pathName); |
| 714 | this->outputPoints(&pts[1], 3); |
| 715 | break; |
| 716 | case SkPath::kClose_Verb: |
| 717 | fClipStackData.appendf("%s%s.close();<br>", kHTML4SpaceIndent, pathName); |
| 718 | break; |
| 719 | default: |
| 720 | SkDEBUGFAIL("bad verb"); |
| 721 | return; |
| 722 | } |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | void SkDebugCanvas::addClipStackData(const SkPath& devPath, const SkPath& operand, |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 727 | SkClipOp elementOp) { |
| 728 | if (elementOp == kReplace_SkClipOp) { |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 729 | if (!lastClipStackData(devPath)) { |
| 730 | fSaveDevPath = operand; |
| 731 | } |
| 732 | fCalledAddStackData = false; |
| 733 | } else { |
| 734 | fClipStackData.appendf("<br>static void test(skiatest::Reporter* reporter," |
| 735 | " const char* filename) {<br>"); |
| 736 | addPathData(fCalledAddStackData ? devPath : fSaveDevPath, "path"); |
| 737 | addPathData(operand, "pathB"); |
| 738 | fClipStackData.appendf("%stestPathOp(reporter, path, pathB, %s, filename);<br>", |
Mike Reed | ebfce6d | 2016-12-12 10:02:12 -0500 | [diff] [blame] | 739 | kHTML4SpaceIndent, gOpStrs[static_cast<int>(elementOp)]); |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 740 | fClipStackData.appendf("}<br>"); |
| 741 | fCalledAddStackData = true; |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { |
| 746 | if (fCalledAddStackData) { |
| 747 | fClipStackData.appendf("<br>"); |
| 748 | addPathData(devPath, "pathOut"); |
| 749 | return true; |
| 750 | } |
| 751 | return false; |
| 752 | } |