• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
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 #include "SkTArray.h"
16 
17 class SkString;
18 
19 class SkDebugger {
20 public:
21     SkDebugger();
22 
23     ~SkDebugger();
24 
setIndex(int index)25     void setIndex(int index) {
26         fIndex = index;
27     }
draw(SkCanvas * canvas)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 
isCommandVisible(int index)39     bool isCommandVisible(int index) {
40         return fDebugCanvas->getDrawCommandVisibilityAt(index);
41     }
42 
setCommandVisible(int index,bool isVisible)43     void setCommandVisible(int index, bool isVisible) {
44         fDebugCanvas->toggleCommand(index, isVisible);
45     }
46 
getDrawCommandsAsStrings()47     SkTArray<SkString>* getDrawCommandsAsStrings() {
48         return fDebugCanvas->getDrawCommandsAsStrings();
49     }
50 
getDrawCommandOffsets()51     SkTDArray<size_t>* getDrawCommandOffsets() {
52         return fDebugCanvas->getDrawCommandOffsets();
53     }
54 
getDrawCommands()55     const SkTDArray<SkDrawCommand*>& getDrawCommands() const {
56         return fDebugCanvas->getDrawCommands();
57     }
58 
highlightCurrentCommand(bool on)59     void highlightCurrentCommand(bool on) {
60         fDebugCanvas->toggleFilter(on);
61     }
62 
resize(int width,int height)63     void resize(int width, int height) {
64         fDebugCanvas->setBounds(width, height);
65     }
66 
67     void loadPicture(SkPicture* picture);
68 
69     SkPicture* copyPicture();
70 
getSize()71     int getSize() {
72         return fDebugCanvas->getSize();
73     }
74 
setUserMatrix(SkMatrix userMatrix)75     void setUserMatrix(SkMatrix userMatrix) {
76         // Should this live in debugger instead?
77         fDebugCanvas->setUserMatrix(userMatrix);
78     }
79 
getCommandAtPoint(int x,int y,int index)80     int getCommandAtPoint(int x, int y, int index) {
81         return fDebugCanvas->getCommandAtPoint(x, y, index);
82     }
83 
getCommandInfo(int index)84     SkTDArray<SkString*>* getCommandInfo(int index) {
85         return fDebugCanvas->getCommandInfo(index);
86     }
87 
getCurrentMatrix()88     const SkMatrix& getCurrentMatrix() {
89         return fDebugCanvas->getCurrentMatrix();
90     }
91 
getCurrentClip()92     const SkIRect& getCurrentClip() {
93         return fDebugCanvas->getCurrentClip();
94     }
95 
pictureHeight()96     int pictureHeight() {
97         return fPictureHeight;
98     }
99 
pictureWidth()100     int pictureWidth() {
101         return fPictureWidth;
102     }
103 
index()104     int index() {
105         return fIndex;
106     }
107 
setOverdrawViz(bool overDrawViz)108     void setOverdrawViz(bool overDrawViz) {
109         if (NULL != fDebugCanvas) {
110             fDebugCanvas->setOverdrawViz(overDrawViz);
111         }
112     }
113 
setPathOps(bool pathOps)114     void setPathOps(bool pathOps) {
115         if (NULL != fDebugCanvas) {
116             fDebugCanvas->setAllowSimplifyClip(pathOps);
117         }
118     }
119 
setMegaViz(bool megaViz)120     void setMegaViz(bool megaViz) {
121         if (NULL != fDebugCanvas) {
122             fDebugCanvas->setMegaVizMode(megaViz);
123         }
124     }
125 
setTexFilterOverride(bool texFilterOverride,SkPaint::FilterLevel level)126     void setTexFilterOverride(bool texFilterOverride, SkPaint::FilterLevel level) {
127         if (NULL != fDebugCanvas) {
128             fDebugCanvas->overrideTexFiltering(texFilterOverride, level);
129         }
130     }
131 
132     void getOverviewText(const SkTDArray<double>* typeTimes, double totTime,
133                          SkString* overview, int numRuns);
134 
135     void getClipStackText(SkString* clipStack);
136 
137 private:
138     SkDebugCanvas* fDebugCanvas;
139     SkPicture* fPicture;
140 
141     int fPictureWidth;
142     int fPictureHeight;
143     int fIndex;
144 };
145 
146 
147 #endif /* SKDEBUGGER_H_ */
148