blob: 6749ff7405fa10f0d9655f6a22873a5efc580f1e [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
17class SkDebugger {
18public:
19 SkDebugger();
20
21 ~SkDebugger();
22
23 void setIndex(int index) {
24 fIndex = index;
25 }
26 void draw(SkCanvas* canvas) {
27 if (fIndex > 0) {
28 fDebugCanvas->drawTo(canvas, fIndex);
29 }
30 }
31
32 void step();
33 void stepBack();
34 void play();
35 void rewind();
36
37 bool isCommandVisible(int index) {
38 return fDebugCanvas->getDrawCommandVisibilityAt(index);
39 }
40
41 void setCommandVisible(int index, bool isVisible) {
42 fDebugCanvas->toggleCommand(index, isVisible);
43 }
44
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000045 SkTArray<SkString>* getDrawCommandsAsStrings() {
chudy@google.com607357f2012-08-07 16:12:23 +000046 return fDebugCanvas->getDrawCommandsAsStrings();
47 }
48
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000049 const SkTDArray<SkDrawCommand*>& getDrawCommands() const {
50 return fDebugCanvas->getDrawCommands();
51 }
52
chudy@google.com607357f2012-08-07 16:12:23 +000053 void highlightCurrentCommand(bool on) {
54 fDebugCanvas->toggleFilter(on);
55 }
56
57 void resize(int width, int height) {
58 fDebugCanvas->setBounds(width, height);
59 }
60
61 void loadPicture(SkPicture* picture);
62
robertphillips@google.com25bc2f82013-01-22 18:03:56 +000063 SkPicture* copyPicture();
chudy@google.com607357f2012-08-07 16:12:23 +000064
65 int getSize() {
66 return fDebugCanvas->getSize();
67 }
68
bungeman@google.come8cc6e82013-01-17 16:30:56 +000069 void setUserMatrix(SkMatrix userMatrix) {
chudy@google.com607357f2012-08-07 16:12:23 +000070 // Should this live in debugger instead?
bungeman@google.come8cc6e82013-01-17 16:30:56 +000071 fDebugCanvas->setUserMatrix(userMatrix);
chudy@google.com607357f2012-08-07 16:12:23 +000072 }
73
74 int getCommandAtPoint(int x, int y, int index) {
75 return fDebugCanvas->getCommandAtPoint(x, y, index);
76 }
77
chudy@google.com97cee972012-08-07 20:41:37 +000078 SkTDArray<SkString*>* getCommandInfo(int index) {
chudy@google.com607357f2012-08-07 16:12:23 +000079 return fDebugCanvas->getCommandInfo(index);
80 }
81
82 const SkMatrix& getCurrentMatrix() {
83 return fDebugCanvas->getCurrentMatrix();
84 }
85
86 const SkIRect& getCurrentClip() {
87 return fDebugCanvas->getCurrentClip();
88 }
89
90 int pictureHeight() {
91 return fPictureHeight;
92 }
93
94 int pictureWidth() {
95 return fPictureWidth;
96 }
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
108
chudy@google.com607357f2012-08-07 16:12:23 +0000109private:
110 SkDebugCanvas* fDebugCanvas;
111 SkPicture* fPicture;
112
113 int fPictureWidth;
114 int fPictureHeight;
115 int fIndex;
116};
117
118
119#endif /* SKDEBUGGER_H_ */