blob: 9ad21e24509c315f8bd83e2d3430159fca8e3377 [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) {
29 if (fIndex > 0) {
30 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
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000047 SkTArray<SkString>* getDrawCommandsAsStrings() {
chudy@google.com607357f2012-08-07 16:12:23 +000048 return fDebugCanvas->getDrawCommandsAsStrings();
49 }
50
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000051 SkTDArray<size_t>* getDrawCommandOffsets() {
52 return fDebugCanvas->getDrawCommandOffsets();
53 }
54
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000055 const SkTDArray<SkDrawCommand*>& getDrawCommands() const {
56 return fDebugCanvas->getDrawCommands();
57 }
58
chudy@google.com607357f2012-08-07 16:12:23 +000059 void highlightCurrentCommand(bool on) {
60 fDebugCanvas->toggleFilter(on);
61 }
62
robertphillipsa8d7f0b2014-08-29 08:03:56 -070063 void setWindowSize(int width, int height) { fDebugCanvas->setWindowSize(width, height); }
chudy@google.com607357f2012-08-07 16:12:23 +000064
65 void loadPicture(SkPicture* picture);
66
robertphillips@google.com25bc2f82013-01-22 18:03:56 +000067 SkPicture* copyPicture();
chudy@google.com607357f2012-08-07 16:12:23 +000068
69 int getSize() {
70 return fDebugCanvas->getSize();
71 }
72
bungeman@google.come8cc6e82013-01-17 16:30:56 +000073 void setUserMatrix(SkMatrix userMatrix) {
chudy@google.com607357f2012-08-07 16:12:23 +000074 // Should this live in debugger instead?
bungeman@google.come8cc6e82013-01-17 16:30:56 +000075 fDebugCanvas->setUserMatrix(userMatrix);
chudy@google.com607357f2012-08-07 16:12:23 +000076 }
77
78 int getCommandAtPoint(int x, int y, int index) {
79 return fDebugCanvas->getCommandAtPoint(x, y, index);
80 }
81
chudy@google.com97cee972012-08-07 20:41:37 +000082 SkTDArray<SkString*>* getCommandInfo(int index) {
chudy@google.com607357f2012-08-07 16:12:23 +000083 return fDebugCanvas->getCommandInfo(index);
84 }
85
86 const SkMatrix& getCurrentMatrix() {
87 return fDebugCanvas->getCurrentMatrix();
88 }
89
90 const SkIRect& getCurrentClip() {
91 return fDebugCanvas->getCurrentClip();
92 }
93
robertphillipsa8d7f0b2014-08-29 08:03:56 -070094 SkRect pictureCull() const {
95 return NULL == fPicture ? SkRect::MakeEmpty() : fPicture->cullRect();
chudy@google.com607357f2012-08-07 16:12:23 +000096 }
97
98 int index() {
99 return fIndex;
100 }
101
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000102 void setOverdrawViz(bool overDrawViz) {
103 if (NULL != fDebugCanvas) {
104 fDebugCanvas->setOverdrawViz(overDrawViz);
105 }
106 }
107
commit-bot@chromium.org2a67e122014-05-19 13:53:10 +0000108 void setPathOps(bool pathOps) {
109 if (NULL != fDebugCanvas) {
110 fDebugCanvas->setAllowSimplifyClip(pathOps);
111 }
112 }
113
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000114 void setMegaViz(bool megaViz) {
115 if (NULL != fDebugCanvas) {
116 fDebugCanvas->setMegaVizMode(megaViz);
117 }
118 }
119
robertphillips@google.com32bbcf82013-10-17 17:56:10 +0000120 void setTexFilterOverride(bool texFilterOverride, SkPaint::FilterLevel level) {
121 if (NULL != fDebugCanvas) {
122 fDebugCanvas->overrideTexFiltering(texFilterOverride, level);
123 }
124 }
125
skia.committer@gmail.com91274b92013-03-13 07:01:04 +0000126 void getOverviewText(const SkTDArray<double>* typeTimes, double totTime,
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000127 SkString* overview, int numRuns);
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000128
commit-bot@chromium.org2a67e122014-05-19 13:53:10 +0000129 void getClipStackText(SkString* clipStack);
130
chudy@google.com607357f2012-08-07 16:12:23 +0000131private:
132 SkDebugCanvas* fDebugCanvas;
133 SkPicture* fPicture;
134
chudy@google.com607357f2012-08-07 16:12:23 +0000135 int fIndex;
136};
137
138
139#endif /* SKDEBUGGER_H_ */