blob: 67fa6a0f5e4fe1752439f13156c8da4d787a1ec9 [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"
15
16class SkDebugger {
17public:
18 SkDebugger();
19
20 ~SkDebugger();
21
22 void setIndex(int index) {
23 fIndex = index;
24 }
25 void draw(SkCanvas* canvas) {
26 if (fIndex > 0) {
27 fDebugCanvas->drawTo(canvas, fIndex);
28 }
29 }
30
31 void step();
32 void stepBack();
33 void play();
34 void rewind();
35
36 bool isCommandVisible(int index) {
37 return fDebugCanvas->getDrawCommandVisibilityAt(index);
38 }
39
40 void setCommandVisible(int index, bool isVisible) {
41 fDebugCanvas->toggleCommand(index, isVisible);
42 }
43
chudy@google.com97cee972012-08-07 20:41:37 +000044 SkTDArray<SkString*>* getDrawCommands() {
chudy@google.com607357f2012-08-07 16:12:23 +000045 return fDebugCanvas->getDrawCommandsAsStrings();
46 }
47
48 void highlightCurrentCommand(bool on) {
49 fDebugCanvas->toggleFilter(on);
50 }
51
52 void resize(int width, int height) {
53 fDebugCanvas->setBounds(width, height);
54 }
55
56 void loadPicture(SkPicture* picture);
57
58 SkPicture* makePicture();
59
60 int getSize() {
61 return fDebugCanvas->getSize();
62 }
63
64 void setUserOffset(SkIPoint userOffset) {
65 // Should this live in debugger instead?
66 fDebugCanvas->setUserOffset(userOffset);
67 }
68
69 void setUserScale(float userScale) {
70 fDebugCanvas->setUserScale(userScale);
71 }
72
73 int getCommandAtPoint(int x, int y, int index) {
74 return fDebugCanvas->getCommandAtPoint(x, y, index);
75 }
76
chudy@google.com97cee972012-08-07 20:41:37 +000077 SkTDArray<SkString*>* getCommandInfo(int index) {
chudy@google.com607357f2012-08-07 16:12:23 +000078 return fDebugCanvas->getCommandInfo(index);
79 }
80
81 const SkMatrix& getCurrentMatrix() {
82 return fDebugCanvas->getCurrentMatrix();
83 }
84
85 const SkIRect& getCurrentClip() {
86 return fDebugCanvas->getCurrentClip();
87 }
88
89 int pictureHeight() {
90 return fPictureHeight;
91 }
92
93 int pictureWidth() {
94 return fPictureWidth;
95 }
96
97 int index() {
98 return fIndex;
99 }
100
101private:
102 SkDebugCanvas* fDebugCanvas;
103 SkPicture* fPicture;
104
105 int fPictureWidth;
106 int fPictureHeight;
107 int fIndex;
108};
109
110
111#endif /* SKDEBUGGER_H_ */