blob: 50ab18168d5b8f48c93ea628b6a2bfc3e3731463 [file] [log] [blame]
chudy@google.com607357f2012-08-07 16:12:23 +00001
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
10#ifndef SKDEBUGGER_H_
11#define SKDEBUGGER_H_
12
13#include "SkDebugCanvas.h"
14#include "SkPicture.h"
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000015#include "SkTArray.h"
chudy@google.com607357f2012-08-07 16:12:23 +000016
borenet@google.com2d9dbd42013-03-12 13:07:40 +000017class SkString;
18
chudy@google.com607357f2012-08-07 16:12:23 +000019class SkDebugger {
20public:
21 SkDebugger();
22
23 ~SkDebugger();
24
25 void setIndex(int index) {
26 fIndex = index;
27 }
28 void draw(SkCanvas* canvas) {
kkinnunen5a2315e2015-01-05 11:51:13 -080029 if (fIndex >= 0) {
chudy@google.com607357f2012-08-07 16:12:23 +000030 fDebugCanvas->drawTo(canvas, fIndex);
31 }
32 }
33
34 void step();
35 void stepBack();
36 void play();
37 void rewind();
38
39 bool isCommandVisible(int index) {
40 return fDebugCanvas->getDrawCommandVisibilityAt(index);
41 }
42
43 void setCommandVisible(int index, bool isVisible) {
44 fDebugCanvas->toggleCommand(index, isVisible);
45 }
46
kkinnunen5037e9d2014-12-30 07:22:58 -080047 SkDrawCommand* getDrawCommandAt(int index) {
48 return fDebugCanvas->getDrawCommandAt(index);
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000049 }
50
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000051 const SkTDArray<SkDrawCommand*>& getDrawCommands() const {
52 return fDebugCanvas->getDrawCommands();
53 }
54
chudy@google.com607357f2012-08-07 16:12:23 +000055 void highlightCurrentCommand(bool on) {
56 fDebugCanvas->toggleFilter(on);
57 }
58
chudy@google.com607357f2012-08-07 16:12:23 +000059 void loadPicture(SkPicture* picture);
60
robertphillips587ea712016-03-25 07:04:35 -070061 sk_sp<SkPicture> copyPicture();
chudy@google.com607357f2012-08-07 16:12:23 +000062
kkinnunen5037e9d2014-12-30 07:22:58 -080063 int getSize() const {
chudy@google.com607357f2012-08-07 16:12:23 +000064 return fDebugCanvas->getSize();
65 }
66
bungeman@google.come8cc6e82013-01-17 16:30:56 +000067 void setUserMatrix(SkMatrix userMatrix) {
chudy@google.com607357f2012-08-07 16:12:23 +000068 // Should this live in debugger instead?
bungeman@google.come8cc6e82013-01-17 16:30:56 +000069 fDebugCanvas->setUserMatrix(userMatrix);
chudy@google.com607357f2012-08-07 16:12:23 +000070 }
71
72 int getCommandAtPoint(int x, int y, int index) {
73 return fDebugCanvas->getCommandAtPoint(x, y, index);
74 }
75
fmalita8c89c522014-11-08 16:18:56 -080076 const SkTDArray<SkString*>* getCommandInfo(int index) const {
chudy@google.com607357f2012-08-07 16:12:23 +000077 return fDebugCanvas->getCommandInfo(index);
78 }
79
80 const SkMatrix& getCurrentMatrix() {
81 return fDebugCanvas->getCurrentMatrix();
82 }
83
84 const SkIRect& getCurrentClip() {
85 return fDebugCanvas->getCurrentClip();
86 }
87
Ben Wagner63fd7602017-10-09 15:45:33 -040088 SkRect pictureCull() const {
Florin Malitaf5305862016-11-15 10:03:32 -050089 return fPicture ? fPicture->cullRect() : SkRect::MakeEmpty();
chudy@google.com607357f2012-08-07 16:12:23 +000090 }
91
92 int index() {
93 return fIndex;
94 }
95
robertphillips@google.comf4741c12013-02-06 20:13:54 +000096 void setOverdrawViz(bool overDrawViz) {
bsalomon49f085d2014-09-05 13:34:00 -070097 if (fDebugCanvas) {
robertphillips@google.comf4741c12013-02-06 20:13:54 +000098 fDebugCanvas->setOverdrawViz(overDrawViz);
99 }
100 }
101
commit-bot@chromium.org2a67e122014-05-19 13:53:10 +0000102 void setPathOps(bool pathOps) {
bsalomon49f085d2014-09-05 13:34:00 -0700103 if (fDebugCanvas) {
commit-bot@chromium.org2a67e122014-05-19 13:53:10 +0000104 fDebugCanvas->setAllowSimplifyClip(pathOps);
105 }
106 }
107
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000108 void setMegaViz(bool megaViz) {
bsalomon49f085d2014-09-05 13:34:00 -0700109 if (fDebugCanvas) {
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000110 fDebugCanvas->setMegaVizMode(megaViz);
111 }
112 }
113
reede7903c72015-03-16 10:26:13 -0700114 void setTexFilterOverride(bool texFilterOverride, SkFilterQuality quality) {
bsalomon49f085d2014-09-05 13:34:00 -0700115 if (fDebugCanvas) {
reede7903c72015-03-16 10:26:13 -0700116 fDebugCanvas->overrideTexFiltering(texFilterOverride, quality);
robertphillips@google.com32bbcf82013-10-17 17:56:10 +0000117 }
118 }
119
skia.committer@gmail.com91274b92013-03-13 07:01:04 +0000120 void getOverviewText(const SkTDArray<double>* typeTimes, double totTime,
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000121 SkString* overview, int numRuns);
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000122
commit-bot@chromium.org2a67e122014-05-19 13:53:10 +0000123 void getClipStackText(SkString* clipStack);
124
chudy@google.com607357f2012-08-07 16:12:23 +0000125private:
Florin Malitaf5305862016-11-15 10:03:32 -0500126 std::unique_ptr<SkDebugCanvas> fDebugCanvas;
127 sk_sp<SkPicture> fPicture;
chudy@google.com607357f2012-08-07 16:12:23 +0000128
chudy@google.com607357f2012-08-07 16:12:23 +0000129 int fIndex;
130};
131
132
133#endif /* SKDEBUGGER_H_ */