Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: src/utils/debugger/SkDebugCanvas.h

Issue 1678893003: moved debugger support files from src/utils/debugger to tools/debugger (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « public.bzl ('k') | src/utils/debugger/SkDebugCanvas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 SKDEBUGCANVAS_H_
11 #define SKDEBUGCANVAS_H_
12
13 #include "SkCanvas.h"
14 #include "SkDrawCommand.h"
15 #include "SkPath.h"
16 #include "SkPathOps.h"
17 #include "SkPicture.h"
18 #include "SkString.h"
19 #include "SkTArray.h"
20
21 class SkNWayCanvas;
22
23 class SK_API SkDebugCanvas : public SkCanvas {
24 public:
25 SkDebugCanvas(int width, int height);
26 virtual ~SkDebugCanvas();
27
28 void toggleFilter(bool toggle) { fFilter = toggle; }
29
30 void setMegaVizMode(bool megaVizMode) { fMegaVizMode = megaVizMode; }
31 bool getMegaVizMode() const { return fMegaVizMode; }
32
33 /**
34 * Enable or disable overdraw visualization
35 */
36 void setOverdrawViz(bool overdrawViz);
37 bool getOverdrawViz() const { return fOverdrawViz; }
38
39 bool getAllowSimplifyClip() const { return fAllowSimplifyClip; }
40
41 void setPicture(SkPicture* picture) { fPicture = picture; }
42
43 /**
44 * Enable or disable texure filtering override
45 */
46 void overrideTexFiltering(bool overrideTexFiltering, SkFilterQuality);
47
48 /**
49 Executes all draw calls to the canvas.
50 @param canvas The canvas being drawn to
51 */
52 void draw(SkCanvas* canvas);
53
54 /**
55 Executes the draw calls up to the specified index.
56 @param canvas The canvas being drawn to
57 @param index The index of the final command being executed
58 */
59 void drawTo(SkCanvas* canvas, int index);
60
61 /**
62 Returns the most recently calculated transformation matrix
63 */
64 const SkMatrix& getCurrentMatrix() {
65 return fMatrix;
66 }
67
68 /**
69 Returns the most recently calculated clip
70 */
71 const SkIRect& getCurrentClip() {
72 return fClip;
73 }
74
75 /**
76 Returns the index of the last draw command to write to the pixel at (x,y )
77 */
78 int getCommandAtPoint(int x, int y, int index);
79
80 /**
81 Removes the command at the specified index
82 @param index The index of the command to delete
83 */
84 void deleteDrawCommandAt(int index);
85
86 /**
87 Returns the draw command at the given index.
88 @param index The index of the command
89 */
90 SkDrawCommand* getDrawCommandAt(int index);
91
92 /**
93 Sets the draw command for a given index.
94 @param index The index to overwrite
95 @param command The new command
96 */
97 void setDrawCommandAt(int index, SkDrawCommand* command);
98
99 /**
100 Returns information about the command at the given index.
101 @param index The index of the command
102 */
103 const SkTDArray<SkString*>* getCommandInfo(int index) const;
104
105 /**
106 Returns the visibility of the command at the given index.
107 @param index The index of the command
108 */
109 bool getDrawCommandVisibilityAt(int index);
110
111 /**
112 Returns the vector of draw commands
113 */
114 SK_ATTR_DEPRECATED("please use getDrawCommandAt and getSize instead")
115 const SkTDArray<SkDrawCommand*>& getDrawCommands() const;
116
117 /**
118 Returns the vector of draw commands. Do not use this entry
119 point - it is going away!
120 */
121 SkTDArray<SkDrawCommand*>& getDrawCommands();
122
123 /**
124 Returns length of draw command vector.
125 */
126 int getSize() const {
127 return fCommandVector.count();
128 }
129
130 /**
131 Toggles the visibility / execution of the draw command at index i with
132 the value of toggle.
133 */
134 void toggleCommand(int index, bool toggle);
135
136 void setUserMatrix(SkMatrix matrix) {
137 fUserMatrix = matrix;
138 }
139
140 SkString clipStackData() const { return fClipStackData; }
141
142 ////////////////////////////////////////////////////////////////////////////////
143 // Inherited from SkCanvas
144 ////////////////////////////////////////////////////////////////////////////////
145
146 static const int kVizImageHeight = 256;
147 static const int kVizImageWidth = 256;
148
149 bool isClipEmpty() const override { return false; }
150 bool isClipRect() const override { return true; }
151 bool getClipBounds(SkRect* bounds) const override {
152 if (bounds) {
153 bounds->setXYWH(0, 0,
154 SkIntToScalar(this->imageInfo().width()),
155 SkIntToScalar(this->imageInfo().height()));
156 }
157 return true;
158 }
159 bool getClipDeviceBounds(SkIRect* bounds) const override {
160 if (bounds) {
161 bounds->setLargest();
162 }
163 return true;
164 }
165
166 protected:
167 void willSave() override;
168 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
169 void willRestore() override;
170
171 void didConcat(const SkMatrix&) override;
172 void didSetMatrix(const SkMatrix&) override;
173
174 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
175 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
176 const SkPaint&) override;
177 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
178 const SkPaint&) override;
179 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos [],
180 SkScalar constY, const SkPaint&) override;
181 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& pat h,
182 const SkMatrix* matrix, const SkPaint&) override;
183 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
184 const SkPaint& paint) override;
185
186 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
187 const SkPoint texCoords[4], SkXfermode* xmode, const SkPain t& paint) override;
188 void onDrawPaint(const SkPaint&) override;
189
190 void onDrawRect(const SkRect&, const SkPaint&) override;
191 void onDrawOval(const SkRect&, const SkPaint&) override;
192 void onDrawRRect(const SkRRect&, const SkPaint&) override;
193 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain t&) override;
194 void onDrawVertices(VertexMode vmode, int vertexCount,
195 const SkPoint vertices[], const SkPoint texs[],
196 const SkColor colors[], SkXfermode* xmode,
197 const uint16_t indices[], int indexCount,
198 const SkPaint&) override;
199 void onDrawPath(const SkPath&, const SkPaint&) override;
200 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain t*) override;
201 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
202 SrcRectConstraint) override;
203 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint* ) override;
204 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
205 const SkPaint*, SrcRectConstraint) override;
206 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
207 const SkPaint*) override;
208 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
209 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
210 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
211 void onClipRegion(const SkRegion& region, SkRegion::Op) override;
212
213 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de;
214
215 void markActiveCommands(int index);
216
217 private:
218 SkTDArray<SkDrawCommand*> fCommandVector;
219 SkPicture* fPicture;
220 bool fFilter;
221 bool fMegaVizMode;
222 SkMatrix fUserMatrix;
223 SkMatrix fMatrix;
224 SkIRect fClip;
225
226 SkString fClipStackData;
227 bool fCalledAddStackData;
228 SkPath fSaveDevPath;
229
230 bool fOverdrawViz;
231 bool fOverrideFilterQuality;
232 SkFilterQuality fFilterQuality;
233
234 SkAutoTUnref<SkNWayCanvas> fPaintFilterCanvas;
235
236 /**
237 The active saveLayer commands at a given point in the renderering.
238 Only used when "mega" visualization is enabled.
239 */
240 SkTDArray<SkDrawCommand*> fActiveLayers;
241
242 /**
243 Adds the command to the classes vector of commands.
244 @param command The draw command for execution
245 */
246 void addDrawCommand(SkDrawCommand* command);
247
248 /**
249 Applies any panning and zooming the user has specified before
250 drawing anything else into the canvas.
251 */
252 void applyUserTransform(SkCanvas* canvas);
253
254 void resetClipStackData() { fClipStackData.reset(); fCalledAddStackData = fa lse; }
255
256 void addClipStackData(const SkPath& devPath, const SkPath& operand, SkRegion ::Op elementOp);
257 void addPathData(const SkPath& path, const char* pathName);
258 bool lastClipStackData(const SkPath& devPath);
259 void outputConicPoints(const SkPoint* pts, SkScalar weight);
260 void outputPoints(const SkPoint* pts, int count);
261 void outputPointsCommon(const SkPoint* pts, int count);
262 void outputScalar(SkScalar num);
263
264 void updatePaintFilterCanvas();
265
266 typedef SkCanvas INHERITED;
267 };
268
269 #endif
OLDNEW
« no previous file with comments | « public.bzl ('k') | src/utils/debugger/SkDebugCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698