blob: eb724f38224e1e840aa6c0119d3eb6a1d440eddb [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
44 // TODO(chudy): Replace with SkTDArray
45 std::vector<std::string>* getDrawCommands() {
46 return fDebugCanvas->getDrawCommandsAsStrings();
47 }
48
49 void highlightCurrentCommand(bool on) {
50 fDebugCanvas->toggleFilter(on);
51 }
52
53 void resize(int width, int height) {
54 fDebugCanvas->setBounds(width, height);
55 }
56
57 void loadPicture(SkPicture* picture);
58
59 SkPicture* makePicture();
60
61 int getSize() {
62 return fDebugCanvas->getSize();
63 }
64
65 void setUserOffset(SkIPoint userOffset) {
66 // Should this live in debugger instead?
67 fDebugCanvas->setUserOffset(userOffset);
68 }
69
70 void setUserScale(float userScale) {
71 fDebugCanvas->setUserScale(userScale);
72 }
73
74 int getCommandAtPoint(int x, int y, int index) {
75 return fDebugCanvas->getCommandAtPoint(x, y, index);
76 }
77
78 std::vector<std::string>* getCommandInfo(int index) {
79 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_ */