blob: 182f226683bbedccf5f7842aff845a526b27266e [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
borenet@google.com2d9dbd42013-03-12 13:07:40 +000017class SkString;
18
chudy@google.com607357f2012-08-07 16:12:23 +000019class SkDebugger {
20public:
21 SkDebugger();
22
23 ~SkDebugger();
24
25 void setIndex(int index) {
26 fIndex = index;
27 }
28 void draw(SkCanvas* canvas) {
29 if (fIndex > 0) {
30 fDebugCanvas->drawTo(canvas, fIndex);
31 }
32 }
33
34 void step();
35 void stepBack();
36 void play();
37 void rewind();
38
39 bool isCommandVisible(int index) {
40 return fDebugCanvas->getDrawCommandVisibilityAt(index);
41 }
42
43 void setCommandVisible(int index, bool isVisible) {
44 fDebugCanvas->toggleCommand(index, isVisible);
45 }
46
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000047 SkTArray<SkString>* getDrawCommandsAsStrings() {
chudy@google.com607357f2012-08-07 16:12:23 +000048 return fDebugCanvas->getDrawCommandsAsStrings();
49 }
50
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000051 const SkTDArray<SkDrawCommand*>& getDrawCommands() const {
52 return fDebugCanvas->getDrawCommands();
53 }
54
chudy@google.com607357f2012-08-07 16:12:23 +000055 void highlightCurrentCommand(bool on) {
56 fDebugCanvas->toggleFilter(on);
57 }
58
59 void resize(int width, int height) {
60 fDebugCanvas->setBounds(width, height);
61 }
62
63 void loadPicture(SkPicture* picture);
64
robertphillips@google.com25bc2f82013-01-22 18:03:56 +000065 SkPicture* copyPicture();
chudy@google.com607357f2012-08-07 16:12:23 +000066
67 int getSize() {
68 return fDebugCanvas->getSize();
69 }
70
bungeman@google.come8cc6e82013-01-17 16:30:56 +000071 void setUserMatrix(SkMatrix userMatrix) {
chudy@google.com607357f2012-08-07 16:12:23 +000072 // Should this live in debugger instead?
bungeman@google.come8cc6e82013-01-17 16:30:56 +000073 fDebugCanvas->setUserMatrix(userMatrix);
chudy@google.com607357f2012-08-07 16:12:23 +000074 }
75
76 int getCommandAtPoint(int x, int y, int index) {
77 return fDebugCanvas->getCommandAtPoint(x, y, index);
78 }
79
chudy@google.com97cee972012-08-07 20:41:37 +000080 SkTDArray<SkString*>* getCommandInfo(int index) {
chudy@google.com607357f2012-08-07 16:12:23 +000081 return fDebugCanvas->getCommandInfo(index);
82 }
83
84 const SkMatrix& getCurrentMatrix() {
85 return fDebugCanvas->getCurrentMatrix();
86 }
87
88 const SkIRect& getCurrentClip() {
89 return fDebugCanvas->getCurrentClip();
90 }
91
92 int pictureHeight() {
93 return fPictureHeight;
94 }
95
96 int pictureWidth() {
97 return fPictureWidth;
98 }
99
100 int index() {
101 return fIndex;
102 }
103
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000104 void setOverdrawViz(bool overDrawViz) {
105 if (NULL != fDebugCanvas) {
106 fDebugCanvas->setOverdrawViz(overDrawViz);
107 }
108 }
109
robertphillips@google.com32bbcf82013-10-17 17:56:10 +0000110 void setTexFilterOverride(bool texFilterOverride, SkPaint::FilterLevel level) {
111 if (NULL != fDebugCanvas) {
112 fDebugCanvas->overrideTexFiltering(texFilterOverride, level);
113 }
114 }
115
skia.committer@gmail.com91274b92013-03-13 07:01:04 +0000116 void getOverviewText(const SkTDArray<double>* typeTimes, double totTime,
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000117 SkString* overview, int numRuns);
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000118
chudy@google.com607357f2012-08-07 16:12:23 +0000119private:
120 SkDebugCanvas* fDebugCanvas;
121 SkPicture* fPicture;
122
123 int fPictureWidth;
124 int fPictureHeight;
125 int fIndex;
126};
127
128
129#endif /* SKDEBUGGER_H_ */