• 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 
getDrawCommandAt(int index)47     SkDrawCommand* getDrawCommandAt(int index) {
48         return fDebugCanvas->getDrawCommandAt(index);
49     }
50 
getDrawCommands()51     const SkTDArray<SkDrawCommand*>& getDrawCommands() const {
52         return fDebugCanvas->getDrawCommands();
53     }
54 
highlightCurrentCommand(bool on)55     void highlightCurrentCommand(bool on) {
56         fDebugCanvas->toggleFilter(on);
57     }
58 
59     void loadPicture(SkPicture* picture);
60 
61     sk_sp<SkPicture> copyPicture();
62 
getSize()63     int getSize() const {
64         return fDebugCanvas->getSize();
65     }
66 
setUserMatrix(SkMatrix userMatrix)67     void setUserMatrix(SkMatrix userMatrix) {
68         // Should this live in debugger instead?
69         fDebugCanvas->setUserMatrix(userMatrix);
70     }
71 
getCommandAtPoint(int x,int y,int index)72     int getCommandAtPoint(int x, int y, int index) {
73         return fDebugCanvas->getCommandAtPoint(x, y, index);
74     }
75 
getCommandInfo(int index)76     const SkTDArray<SkString*>* getCommandInfo(int index) const {
77         return fDebugCanvas->getCommandInfo(index);
78     }
79 
getCurrentMatrix()80     const SkMatrix& getCurrentMatrix() {
81         return fDebugCanvas->getCurrentMatrix();
82     }
83 
getCurrentClip()84     const SkIRect& getCurrentClip() {
85         return fDebugCanvas->getCurrentClip();
86     }
87 
pictureCull()88     SkRect pictureCull() const   {
89         return fPicture ? fPicture->cullRect() : SkRect::MakeEmpty();
90     }
91 
index()92     int index() {
93         return fIndex;
94     }
95 
setOverdrawViz(bool overDrawViz)96     void setOverdrawViz(bool overDrawViz) {
97         if (fDebugCanvas) {
98             fDebugCanvas->setOverdrawViz(overDrawViz);
99         }
100     }
101 
setPathOps(bool pathOps)102     void setPathOps(bool pathOps) {
103         if (fDebugCanvas) {
104             fDebugCanvas->setAllowSimplifyClip(pathOps);
105         }
106     }
107 
setMegaViz(bool megaViz)108     void setMegaViz(bool megaViz) {
109         if (fDebugCanvas) {
110             fDebugCanvas->setMegaVizMode(megaViz);
111         }
112     }
113 
setTexFilterOverride(bool texFilterOverride,SkFilterQuality quality)114     void setTexFilterOverride(bool texFilterOverride, SkFilterQuality quality) {
115         if (fDebugCanvas) {
116             fDebugCanvas->overrideTexFiltering(texFilterOverride, quality);
117         }
118     }
119 
120     void getOverviewText(const SkTDArray<double>* typeTimes, double totTime,
121                          SkString* overview, int numRuns);
122 
123     void getClipStackText(SkString* clipStack);
124 
125 private:
126     std::unique_ptr<SkDebugCanvas>  fDebugCanvas;
127     sk_sp<SkPicture>                fPicture;
128 
129     int fIndex;
130 };
131 
132 
133 #endif /* SKDEBUGGER_H_ */
134