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

Side by Side Diff: tools/debugger/SkDebugCanvas.h

Issue 2167223002: Revert of Creating framework for drawShadowedPicture (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 5 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 | « tests/CanvasTest.cpp ('k') | tools/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
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #ifndef SKDEBUGCANVAS_H_ 9 #ifndef SKDEBUGCANVAS_H_
10 #define SKDEBUGCANVAS_H_ 10 #define SKDEBUGCANVAS_H_
11 11
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkDrawCommand.h" 13 #include "SkDrawCommand.h"
14 #include "SkPath.h" 14 #include "SkPath.h"
15 #include "SkPathOps.h" 15 #include "SkPathOps.h"
16 #include "SkPicture.h" 16 #include "SkPicture.h"
17 #include "SkString.h" 17 #include "SkString.h"
18 #include "SkTArray.h" 18 #include "SkTArray.h"
19 #include "UrlDataManager.h" 19 #include "UrlDataManager.h"
20 20
21 class GrAuditTrail; 21 class GrAuditTrail;
22 class SkNWayCanvas; 22 class SkNWayCanvas;
23 23
24 class SK_API SkDebugCanvas : public SkCanvas { 24 class SK_API SkDebugCanvas : public SkCanvas {
25 public: 25 public:
26 SkDebugCanvas(int width, int height); 26 SkDebugCanvas(int width, int height);
27
28 virtual ~SkDebugCanvas(); 27 virtual ~SkDebugCanvas();
29 28
30 void toggleFilter(bool toggle) { fFilter = toggle; } 29 void toggleFilter(bool toggle) { fFilter = toggle; }
31 30
32 void setMegaVizMode(bool megaVizMode) { fMegaVizMode = megaVizMode; } 31 void setMegaVizMode(bool megaVizMode) { fMegaVizMode = megaVizMode; }
33
34 bool getMegaVizMode() const { return fMegaVizMode; } 32 bool getMegaVizMode() const { return fMegaVizMode; }
35 33
36 /** 34 /**
37 * Enable or disable overdraw visualization 35 * Enable or disable overdraw visualization
38 */ 36 */
39 void setOverdrawViz(bool overdrawViz); 37 void setOverdrawViz(bool overdrawViz);
40
41 bool getOverdrawViz() const { return fOverdrawViz; } 38 bool getOverdrawViz() const { return fOverdrawViz; }
42 39
43 /** 40 /**
44 * Set the color of the clip visualization. An alpha of zero renders the cli p invisible. 41 * Set the color of the clip visualization. An alpha of zero renders the cli p invisible.
45 */ 42 */
46 void setClipVizColor(SkColor clipVizColor) { this->fClipVizColor = clipVizCo lor; } 43 void setClipVizColor(SkColor clipVizColor) { this->fClipVizColor = clipVizCo lor; }
47
48 SkColor getClipVizColor() const { return fClipVizColor; } 44 SkColor getClipVizColor() const { return fClipVizColor; }
49 45
50 void setDrawGpuBatchBounds(bool drawGpuBatchBounds) { 46 void setDrawGpuBatchBounds(bool drawGpuBatchBounds) {
51 fDrawGpuBatchBounds = drawGpuBatchBounds; 47 fDrawGpuBatchBounds = drawGpuBatchBounds;
52 } 48 }
53 49
54 bool getDrawGpuBatchBounds() const { return fDrawGpuBatchBounds; } 50 bool getDrawGpuBatchBounds() const { return fDrawGpuBatchBounds; }
55 51
56 bool getAllowSimplifyClip() const { return fAllowSimplifyClip; } 52 bool getAllowSimplifyClip() const { return fAllowSimplifyClip; }
57 53
58 void setPicture(SkPicture *picture) { fPicture = picture; } 54 void setPicture(SkPicture* picture) { fPicture = picture; }
59 55
60 /** 56 /**
61 * Enable or disable texure filtering override 57 * Enable or disable texure filtering override
62 */ 58 */
63 void overrideTexFiltering(bool overrideTexFiltering, SkFilterQuality); 59 void overrideTexFiltering(bool overrideTexFiltering, SkFilterQuality);
64 60
65 /** 61 /**
66 Executes all draw calls to the canvas. 62 Executes all draw calls to the canvas.
67 @param canvas The canvas being drawn to 63 @param canvas The canvas being drawn to
68 */ 64 */
69 void draw(SkCanvas *canvas); 65 void draw(SkCanvas* canvas);
70 66
71 /** 67 /**
72 Executes the draw calls up to the specified index. 68 Executes the draw calls up to the specified index.
73 @param canvas The canvas being drawn to 69 @param canvas The canvas being drawn to
74 @param index The index of the final command being executed 70 @param index The index of the final command being executed
75 @param m an optional Mth gpu batch to highlight, or -1 71 @param m an optional Mth gpu batch to highlight, or -1
76 */ 72 */
77 void drawTo(SkCanvas *canvas, int index, int m = -1); 73 void drawTo(SkCanvas* canvas, int index, int m = -1);
78 74
79 /** 75 /**
80 Returns the most recently calculated transformation matrix 76 Returns the most recently calculated transformation matrix
81 */ 77 */
82 const SkMatrix &getCurrentMatrix() { 78 const SkMatrix& getCurrentMatrix() {
83 return fMatrix; 79 return fMatrix;
84 } 80 }
85 81
86 /** 82 /**
87 Returns the most recently calculated clip 83 Returns the most recently calculated clip
88 */ 84 */
89 const SkIRect &getCurrentClip() { 85 const SkIRect& getCurrentClip() {
90 return fClip; 86 return fClip;
91 } 87 }
92 88
93 /** 89 /**
94 Returns the index of the last draw command to write to the pixel at (x,y ) 90 Returns the index of the last draw command to write to the pixel at (x,y )
95 */ 91 */
96 int getCommandAtPoint(int x, int y, int index); 92 int getCommandAtPoint(int x, int y, int index);
97 93
98 /** 94 /**
99 Removes the command at the specified index 95 Removes the command at the specified index
100 @param index The index of the command to delete 96 @param index The index of the command to delete
101 */ 97 */
102 void deleteDrawCommandAt(int index); 98 void deleteDrawCommandAt(int index);
103 99
104 /** 100 /**
105 Returns the draw command at the given index. 101 Returns the draw command at the given index.
106 @param index The index of the command 102 @param index The index of the command
107 */ 103 */
108 SkDrawCommand *getDrawCommandAt(int index); 104 SkDrawCommand* getDrawCommandAt(int index);
109 105
110 /** 106 /**
111 Sets the draw command for a given index. 107 Sets the draw command for a given index.
112 @param index The index to overwrite 108 @param index The index to overwrite
113 @param command The new command 109 @param command The new command
114 */ 110 */
115 void setDrawCommandAt(int index, SkDrawCommand *command); 111 void setDrawCommandAt(int index, SkDrawCommand* command);
116 112
117 /** 113 /**
118 Returns information about the command at the given index. 114 Returns information about the command at the given index.
119 @param index The index of the command 115 @param index The index of the command
120 */ 116 */
121 const SkTDArray<SkString *> *getCommandInfo(int index) const; 117 const SkTDArray<SkString*>* getCommandInfo(int index) const;
122 118
123 /** 119 /**
124 Returns the visibility of the command at the given index. 120 Returns the visibility of the command at the given index.
125 @param index The index of the command 121 @param index The index of the command
126 */ 122 */
127 bool getDrawCommandVisibilityAt(int index); 123 bool getDrawCommandVisibilityAt(int index);
128 124
129 /** 125 /**
130 Returns the vector of draw commands 126 Returns the vector of draw commands
131 */ 127 */
132 SK_ATTR_DEPRECATED("please use getDrawCommandAt and getSize instead") 128 SK_ATTR_DEPRECATED("please use getDrawCommandAt and getSize instead")
133 const SkTDArray<SkDrawCommand *> &getDrawCommands() const; 129 const SkTDArray<SkDrawCommand*>& getDrawCommands() const;
134 130
135 /** 131 /**
136 Returns the vector of draw commands. Do not use this entry 132 Returns the vector of draw commands. Do not use this entry
137 point - it is going away! 133 point - it is going away!
138 */ 134 */
139 SkTDArray<SkDrawCommand *> &getDrawCommands(); 135 SkTDArray<SkDrawCommand*>& getDrawCommands();
140 136
141 /** 137 /**
142 Returns length of draw command vector. 138 Returns length of draw command vector.
143 */ 139 */
144 int getSize() const { 140 int getSize() const {
145 return fCommandVector.count(); 141 return fCommandVector.count();
146 } 142 }
147 143
148 /** 144 /**
149 Toggles the visibility / execution of the draw command at index i with 145 Toggles the visibility / execution of the draw command at index i with
150 the value of toggle. 146 the value of toggle.
151 */ 147 */
152 void toggleCommand(int index, bool toggle); 148 void toggleCommand(int index, bool toggle);
153 149
154 void setUserMatrix(SkMatrix matrix) { 150 void setUserMatrix(SkMatrix matrix) {
155 fUserMatrix = matrix; 151 fUserMatrix = matrix;
156 } 152 }
157 153
158 SkString clipStackData() const { return fClipStackData; } 154 SkString clipStackData() const { return fClipStackData; }
159 155
160 /** 156 /**
161 Returns a JSON object representing up to the Nth draw, where N is less t han 157 Returns a JSON object representing up to the Nth draw, where N is less t han
162 SkDebugCanvas::getSize(). The encoder may use the UrlDataManager to stor e binary data such 158 SkDebugCanvas::getSize(). The encoder may use the UrlDataManager to stor e binary data such
163 as images, referring to them via URLs embedded in the JSON. 159 as images, referring to them via URLs embedded in the JSON.
164 */ 160 */
165 Json::Value toJSON(UrlDataManager &urlDataManager, int n, SkCanvas *); 161 Json::Value toJSON(UrlDataManager& urlDataManager, int n, SkCanvas*);
166 162
167 Json::Value toJSONBatchList(int n, SkCanvas *); 163 Json::Value toJSONBatchList(int n, SkCanvas*);
168 164
169 //////////////////////////////////////////////////////////////////////////////// 165 ////////////////////////////////////////////////////////////////////////////////
170 // Inherited from SkCanvas 166 // Inherited from SkCanvas
171 //////////////////////////////////////////////////////////////////////////////// 167 ////////////////////////////////////////////////////////////////////////////////
172 168
173 static const int kVizImageHeight = 256; 169 static const int kVizImageHeight = 256;
174 static const int kVizImageWidth = 256; 170 static const int kVizImageWidth = 256;
175 171
176 bool isClipEmpty() const override { return false; } 172 bool isClipEmpty() const override { return false; }
177
178 bool isClipRect() const override { return true; } 173 bool isClipRect() const override { return true; }
179 174 bool getClipBounds(SkRect* bounds) const override {
180 bool getClipBounds(SkRect *bounds) const override {
181 if (bounds) { 175 if (bounds) {
182 bounds->setXYWH(0, 0, 176 bounds->setXYWH(0, 0,
183 SkIntToScalar(this->imageInfo().width()), 177 SkIntToScalar(this->imageInfo().width()),
184 SkIntToScalar(this->imageInfo().height())); 178 SkIntToScalar(this->imageInfo().height()));
185 } 179 }
186 return true; 180 return true;
187 } 181 }
188 182 bool getClipDeviceBounds(SkIRect* bounds) const override {
189 bool getClipDeviceBounds(SkIRect *bounds) const override {
190 if (bounds) { 183 if (bounds) {
191 bounds->setLargest(); 184 bounds->setLargest();
192 } 185 }
193 return true; 186 return true;
194 } 187 }
195 188
196 protected: 189 protected:
197 void willSave() override; 190 void willSave() override;
198 191 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
199 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &) override;
200
201 void willRestore() override; 192 void willRestore() override;
202 193
203 void didConcat(const SkMatrix &) override; 194 void didConcat(const SkMatrix&) override;
195 void didSetMatrix(const SkMatrix&) override;
204 196
205 void didSetMatrix(const SkMatrix &) override;
206
207 #ifdef SK_EXPERIMENTAL_SHADOWING
208 void didTranslateZ(SkScalar) override; 197 void didTranslateZ(SkScalar) override;
209 #else
210 void didTranslateZ(SkScalar);
211 #endif
212 198
213 void onDrawAnnotation(const SkRect&, const char[], SkData*) override; 199 void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
214 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; 200 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
215 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 201 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
216 const SkPaint&) override; 202 const SkPaint&) override;
217 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 203 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
218 const SkPaint&) override; 204 const SkPaint&) override;
219 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos [], 205 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos [],
220 SkScalar constY, const SkPaint&) override; 206 SkScalar constY, const SkPaint&) override;
221 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& pat h, 207 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& pat h,
(...skipping 25 matching lines...) Expand all
247 const SkPaint*, SrcRectConstraint) override; 233 const SkPaint*, SrcRectConstraint) override;
248 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, 234 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
249 const SkPaint*) override; 235 const SkPaint*) override;
250 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; 236 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
251 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; 237 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
252 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; 238 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
253 void onClipRegion(const SkRegion& region, SkRegion::Op) override; 239 void onClipRegion(const SkRegion& region, SkRegion::Op) override;
254 240
255 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de; 241 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de;
256 242
257 #ifdef SK_EXPERIMENTAL_SHADOWING
258 void onDrawShadowedPicture(const SkPicture*,
259 const SkMatrix*,
260 const SkPaint*) override;
261 #else
262 void onDrawShadowedPicture(const SkPicture*,
263 const SkMatrix*,
264 const SkPaint*);
265 #endif
266
267 void markActiveCommands(int index); 243 void markActiveCommands(int index);
268 244
269 private: 245 private:
270 SkTDArray<SkDrawCommand*> fCommandVector; 246 SkTDArray<SkDrawCommand*> fCommandVector;
271 SkPicture* fPicture; 247 SkPicture* fPicture;
272 bool fFilter; 248 bool fFilter;
273 bool fMegaVizMode; 249 bool fMegaVizMode;
274 SkMatrix fUserMatrix; 250 SkMatrix fUserMatrix;
275 SkMatrix fMatrix; 251 SkMatrix fMatrix;
276 SkIRect fClip; 252 SkIRect fClip;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 GrAuditTrail* getAuditTrail(SkCanvas*); 294 GrAuditTrail* getAuditTrail(SkCanvas*);
319 295
320 void updatePaintFilterCanvas(); 296 void updatePaintFilterCanvas();
321 void drawAndCollectBatches(int n, SkCanvas*); 297 void drawAndCollectBatches(int n, SkCanvas*);
322 void cleanupAuditTrail(SkCanvas*); 298 void cleanupAuditTrail(SkCanvas*);
323 299
324 typedef SkCanvas INHERITED; 300 typedef SkCanvas INHERITED;
325 }; 301 };
326 302
327 #endif 303 #endif
OLDNEW
« no previous file with comments | « tests/CanvasTest.cpp ('k') | tools/debugger/SkDebugCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698