blob: a0a1682ba7c99d07a5d703f40939518552d070ce [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
69 void setUserOffset(SkIPoint userOffset) {
70 // Should this live in debugger instead?
71 fDebugCanvas->setUserOffset(userOffset);
72 }
73
74 void setUserScale(float userScale) {
75 fDebugCanvas->setUserScale(userScale);
76 }
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
94 int pictureHeight() {
95 return fPictureHeight;
96 }
97
98 int pictureWidth() {
99 return fPictureWidth;
100 }
101
102 int index() {
103 return fIndex;
104 }
105
106private:
107 SkDebugCanvas* fDebugCanvas;
108 SkPicture* fPicture;
109
110 int fPictureWidth;
111 int fPictureHeight;
112 int fIndex;
113};
114
115
116#endif /* SKDEBUGGER_H_ */