OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvasPriv.h" | 8 #include "SkCanvasPriv.h" |
9 #include "SkClipStack.h" | 9 #include "SkClipStack.h" |
10 #include "SkDebugCanvas.h" | 10 #include "SkDebugCanvas.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 typedef SkPaintFilterCanvas INHERITED; | 60 typedef SkPaintFilterCanvas INHERITED; |
61 }; | 61 }; |
62 | 62 |
63 SkDebugCanvas::SkDebugCanvas(int width, int height) | 63 SkDebugCanvas::SkDebugCanvas(int width, int height) |
64 : INHERITED(width, height) | 64 : INHERITED(width, height) |
65 , fPicture(nullptr) | 65 , fPicture(nullptr) |
66 , fFilter(false) | 66 , fFilter(false) |
67 , fMegaVizMode(false) | 67 , fMegaVizMode(false) |
68 , fOverdrawViz(false) | 68 , fOverdrawViz(false) |
69 , fOverrideFilterQuality(false) | 69 , fOverrideFilterQuality(false) |
70 , fFilterQuality(kNone_SkFilterQuality) { | 70 , fFilterQuality(kNone_SkFilterQuality) |
| 71 , fClipVizColor(SK_ColorTRANSPARENT) { |
71 fUserMatrix.reset(); | 72 fUserMatrix.reset(); |
72 | 73 |
73 // SkPicturePlayback uses the base-class' quickReject calls to cull clipped | 74 // SkPicturePlayback uses the base-class' quickReject calls to cull clipped |
74 // operations. This can lead to problems in the debugger which expects all | 75 // operations. This can lead to problems in the debugger which expects all |
75 // the operations in the captured skp to appear in the debug canvas. To | 76 // the operations in the captured skp to appear in the debug canvas. To |
76 // circumvent this we create a wide open clip here (an empty clip rect | 77 // circumvent this we create a wide open clip here (an empty clip rect |
77 // is not sufficient). | 78 // is not sufficient). |
78 // Internally, the SkRect passed to clipRect is converted to an SkIRect and | 79 // Internally, the SkRect passed to clipRect is converted to an SkIRect and |
79 // rounded out. The following code creates a nearly maximal rect that will | 80 // rounded out. The following code creates a nearly maximal rect that will |
80 // not get collapsed by the coming conversions (Due to precision loss the | 81 // not get collapsed by the coming conversions (Due to precision loss the |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // visible canvas. | 227 // visible canvas. |
227 // All active culls draw their cull box | 228 // All active culls draw their cull box |
228 fCommandVector[i]->vizExecute(canvas); | 229 fCommandVector[i]->vizExecute(canvas); |
229 } else { | 230 } else { |
230 fCommandVector[i]->setUserMatrix(fUserMatrix); | 231 fCommandVector[i]->setUserMatrix(fUserMatrix); |
231 fCommandVector[i]->execute(canvas); | 232 fCommandVector[i]->execute(canvas); |
232 } | 233 } |
233 } | 234 } |
234 } | 235 } |
235 | 236 |
| 237 if (SkColorGetA(fClipVizColor) != 0) { |
| 238 canvas->save(); |
| 239 #define LARGE_COORD 1000000000 |
| 240 canvas->clipRect(SkRect::MakeLTRB(-LARGE_COORD, -LARGE_COORD, LARGE_COOR
D, LARGE_COORD), |
| 241 SkRegion::kReverseDifference_Op); |
| 242 SkPaint clipPaint; |
| 243 clipPaint.setColor(fClipVizColor); |
| 244 canvas->drawPaint(clipPaint); |
| 245 canvas->restore(); |
| 246 } |
| 247 |
236 if (fMegaVizMode) { | 248 if (fMegaVizMode) { |
237 canvas->save(); | 249 canvas->save(); |
238 // nuke the CTM | 250 // nuke the CTM |
239 canvas->resetMatrix(); | 251 canvas->resetMatrix(); |
240 // turn off clipping | 252 // turn off clipping |
241 if (!windowRect.isEmpty()) { | 253 if (!windowRect.isEmpty()) { |
242 SkRect r = windowRect; | 254 SkRect r = windowRect; |
243 r.outset(SK_Scalar1, SK_Scalar1); | 255 r.outset(SK_Scalar1, SK_Scalar1); |
244 canvas->clipRect(r, SkRegion::kReplace_Op); | 256 canvas->clipRect(r, SkRegion::kReplace_Op); |
245 } | 257 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 } | 328 } |
317 | 329 |
318 SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() { | 330 SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() { |
319 return fCommandVector; | 331 return fCommandVector; |
320 } | 332 } |
321 | 333 |
322 Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager, int n) { | 334 Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager, int n) { |
323 Json::Value result = Json::Value(Json::objectValue); | 335 Json::Value result = Json::Value(Json::objectValue); |
324 result[SKDEBUGCANVAS_ATTRIBUTE_VERSION] = Json::Value(SKDEBUGCANVAS_VERSION)
; | 336 result[SKDEBUGCANVAS_ATTRIBUTE_VERSION] = Json::Value(SKDEBUGCANVAS_VERSION)
; |
325 Json::Value commands = Json::Value(Json::arrayValue); | 337 Json::Value commands = Json::Value(Json::arrayValue); |
326 for (int i = 0; i < this->getSize() && i < n; i++) { | 338 for (int i = 0; i < this->getSize() && i <= n; i++) { |
327 commands[i] = this->getDrawCommandAt(i)->toJSON(urlDataManager); | 339 commands[i] = this->getDrawCommandAt(i)->toJSON(urlDataManager); |
328 } | 340 } |
329 result[SKDEBUGCANVAS_ATTRIBUTE_COMMANDS] = commands; | 341 result[SKDEBUGCANVAS_ATTRIBUTE_COMMANDS] = commands; |
330 return result; | 342 return result; |
331 } | 343 } |
332 | 344 |
333 void SkDebugCanvas::updatePaintFilterCanvas() { | 345 void SkDebugCanvas::updatePaintFilterCanvas() { |
334 if (!fOverdrawViz && !fOverrideFilterQuality) { | 346 if (!fOverdrawViz && !fOverrideFilterQuality) { |
335 fPaintFilterCanvas.reset(nullptr); | 347 fPaintFilterCanvas.reset(nullptr); |
336 return; | 348 return; |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 644 } |
633 | 645 |
634 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { | 646 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { |
635 if (fCalledAddStackData) { | 647 if (fCalledAddStackData) { |
636 fClipStackData.appendf("<br>"); | 648 fClipStackData.appendf("<br>"); |
637 addPathData(devPath, "pathOut"); | 649 addPathData(devPath, "pathOut"); |
638 return true; | 650 return true; |
639 } | 651 } |
640 return false; | 652 return false; |
641 } | 653 } |
OLD | NEW |