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 "SkClipStack.h" | 8 #include "SkClipStack.h" |
9 #include "SkDebugCanvas.h" | 9 #include "SkDebugCanvas.h" |
10 #include "SkDrawCommand.h" | 10 #include "SkDrawCommand.h" |
11 #include "SkDevice.h" | 11 #include "SkDevice.h" |
12 #include "SkPaintFilterCanvas.h" | 12 #include "SkPaintFilterCanvas.h" |
13 #include "SkOverdrawMode.h" | 13 #include "SkOverdrawMode.h" |
14 | 14 |
| 15 #define SKDEBUGCANVAS_VERSION 1 |
| 16 #define SKDEBUGCANVAS_ATTRIBUTE_VERSION "version" |
| 17 #define SKDEBUGCANVAS_ATTRIBUTE_COMMANDS "commands" |
| 18 |
15 class DebugPaintFilterCanvas : public SkPaintFilterCanvas { | 19 class DebugPaintFilterCanvas : public SkPaintFilterCanvas { |
16 public: | 20 public: |
17 DebugPaintFilterCanvas(int width, | 21 DebugPaintFilterCanvas(int width, |
18 int height, | 22 int height, |
19 bool overdrawViz, | 23 bool overdrawViz, |
20 bool overrideFilterQuality, | 24 bool overrideFilterQuality, |
21 SkFilterQuality quality) | 25 SkFilterQuality quality) |
22 : INHERITED(width, height) | 26 : INHERITED(width, height) |
23 , fOverdrawXfermode(overdrawViz ? SkOverdrawMode::Create() : nullptr) | 27 , fOverdrawXfermode(overdrawViz ? SkOverdrawMode::Create() : nullptr) |
24 , fOverrideFilterQuality(overrideFilterQuality) | 28 , fOverrideFilterQuality(overrideFilterQuality) |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 311 } |
308 | 312 |
309 const SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() const { | 313 const SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() const { |
310 return fCommandVector; | 314 return fCommandVector; |
311 } | 315 } |
312 | 316 |
313 SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() { | 317 SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() { |
314 return fCommandVector; | 318 return fCommandVector; |
315 } | 319 } |
316 | 320 |
| 321 Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager) { |
| 322 Json::Value result = Json::Value(Json::objectValue); |
| 323 result[SKDEBUGCANVAS_ATTRIBUTE_VERSION] = Json::Value(SKDEBUGCANVAS_VERSION)
; |
| 324 Json::Value commands = Json::Value(Json::arrayValue); |
| 325 for (int i = 0; i < this->getSize(); i++) { |
| 326 commands[i] = this->getDrawCommandAt(i)->toJSON(); |
| 327 } |
| 328 result[SKDEBUGCANVAS_ATTRIBUTE_COMMANDS] = commands; |
| 329 return result; |
| 330 } |
| 331 |
317 void SkDebugCanvas::updatePaintFilterCanvas() { | 332 void SkDebugCanvas::updatePaintFilterCanvas() { |
318 if (!fOverdrawViz && !fOverrideFilterQuality) { | 333 if (!fOverdrawViz && !fOverrideFilterQuality) { |
319 fPaintFilterCanvas.reset(nullptr); | 334 fPaintFilterCanvas.reset(nullptr); |
320 return; | 335 return; |
321 } | 336 } |
322 | 337 |
323 const SkImageInfo info = this->imageInfo(); | 338 const SkImageInfo info = this->imageInfo(); |
324 fPaintFilterCanvas.reset(new DebugPaintFilterCanvas(info.width(), info.heigh
t(), fOverdrawViz, | 339 fPaintFilterCanvas.reset(new DebugPaintFilterCanvas(info.width(), info.heigh
t(), fOverdrawViz, |
325 fOverrideFilterQuality,
fFilterQuality)); | 340 fOverrideFilterQuality,
fFilterQuality)); |
326 } | 341 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 } | 630 } |
616 | 631 |
617 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { | 632 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { |
618 if (fCalledAddStackData) { | 633 if (fCalledAddStackData) { |
619 fClipStackData.appendf("<br>"); | 634 fClipStackData.appendf("<br>"); |
620 addPathData(devPath, "pathOut"); | 635 addPathData(devPath, "pathOut"); |
621 return true; | 636 return true; |
622 } | 637 } |
623 return false; | 638 return false; |
624 } | 639 } |
OLD | NEW |