blob: 0e3906e0360d707ff8eafcd2d2046aa948f42b3b [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
63 SkPicture* makePicture();
64
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
102private:
103 SkDebugCanvas* fDebugCanvas;
104 SkPicture* fPicture;
105
106 int fPictureWidth;
107 int fPictureHeight;
108 int fIndex;
109};
110
111
112#endif /* SKDEBUGGER_H_ */