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

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

Issue 211383003: Debugger improvements (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fix Mac 10.8 compilation issue Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.cpp ('k') | src/utils/debugger/SkDrawCommand.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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SKDRAWCOMMAND_H_ 9 #ifndef SKDRAWCOMMAND_H_
10 #define SKDRAWCOMMAND_H_ 10 #define SKDRAWCOMMAND_H_
11 11
12 #include "SkPictureFlat.h" 12 #include "SkPictureFlat.h"
13 #include "SkCanvas.h" 13 #include "SkCanvas.h"
14 #include "SkString.h" 14 #include "SkString.h"
15 15
16 class SK_API SkDrawCommand { 16 class SK_API SkDrawCommand {
17 public: 17 public:
18 /* TODO(chudy): Remove subclasses. */ 18 /* TODO(chudy): Remove subclasses. */
19 SkDrawCommand(DrawType drawType); 19 SkDrawCommand(DrawType drawType);
20 SkDrawCommand(); 20 SkDrawCommand();
21 21
22 virtual ~SkDrawCommand(); 22 virtual ~SkDrawCommand();
23 23
24 virtual SkString toString(); 24 virtual SkString toString();
25 25
26 void setOffset(size_t offset) { fOffset = offset; }
27 virtual size_t offset() { return fOffset; }
28
26 virtual const char* toCString() { 29 virtual const char* toCString() {
27 return GetCommandString(fDrawType); 30 return GetCommandString(fDrawType);
28 } 31 }
29 32
30 bool isVisible() const { 33 bool isVisible() const {
31 return fVisible; 34 return fVisible;
32 } 35 }
33 36
34 void setVisible(bool toggle) { 37 void setVisible(bool toggle) {
35 fVisible = toggle; 38 fVisible = toggle;
36 } 39 }
37 40
38 SkTDArray<SkString*>* Info() {return &fInfo; }; 41 SkTDArray<SkString*>* Info() {return &fInfo; };
39 virtual void execute(SkCanvas* canvas) = 0; 42 virtual void execute(SkCanvas* canvas) = 0;
40 virtual void vizExecute(SkCanvas* canvas) { }; 43 virtual void vizExecute(SkCanvas* canvas) { };
41 /** Does nothing by default, but used by save() and restore()-type 44 /** Does nothing by default, but used by save() and restore()-type
42 subclasses to track unresolved save() calls. */ 45 subclasses to track unresolved save() calls. */
43 virtual void trackSaveState(int* state) { }; 46 virtual void trackSaveState(int* state) { };
44 47
45 // The next "active" system is only used by save, saveLayer, restore, 48 // The next "active" system is only used by save, saveLayer, restore,
46 // pushCull and popCull. It is used in two ways: 49 // pushCull and popCull. It is used in two ways:
47 // To determine which saveLayers are currently active (at a 50 // To determine which saveLayers are currently active (at a
48 // given point in the rendering). 51 // given point in the rendering).
49 // save just return a kPushLayer action but don't track active state 52 // saves just return a kPushLayer action but don't track active state
50 // restore just return a kPopLayer action 53 // restores just return a kPopLayer action
51 // saveLayers return kPushLayer but also track the active state 54 // saveLayers return kPushLayer but also track the active state
52 // To determine which culls are currently active (at a given point) 55 // To determine which culls are currently active (at a given point)
53 // in the rendering). 56 // in the rendering).
54 // pushCull returns a kPushCull action 57 // pushCulls return a kPushCull action
55 // popCull returns a kPopCull action 58 // popCulls return a kPopCull action
56 enum Action { 59 enum Action {
57 kNone_Action, 60 kNone_Action,
58 kPopLayer_Action, 61 kPopLayer_Action,
59 kPushLayer_Action, 62 kPushLayer_Action,
60 kPopCull_Action, 63 kPopCull_Action,
61 kPushCull_Action 64 kPushCull_Action
62 }; 65 };
63 virtual Action action() const { return kNone_Action; } 66 virtual Action action() const { return kNone_Action; }
64 virtual void setActive(bool active) {} 67 virtual void setActive(bool active) {}
65 virtual bool active() const { return false; } 68 virtual bool active() const { return false; }
66 69
67 DrawType getType() { return fDrawType; }; 70 DrawType getType() { return fDrawType; };
68 71
69 virtual bool render(SkCanvas* canvas) const { return false; } 72 virtual bool render(SkCanvas* canvas) const { return false; }
70 73
71 static const char* GetCommandString(DrawType type); 74 static const char* GetCommandString(DrawType type);
72 75
73 protected: 76 protected:
74 DrawType fDrawType;
75 SkTDArray<SkString*> fInfo; 77 SkTDArray<SkString*> fInfo;
76 78
77 private: 79 private:
78 bool fVisible; 80 DrawType fDrawType;
81 size_t fOffset;
82 bool fVisible;
79 }; 83 };
80 84
81 class SkRestoreCommand : public SkDrawCommand { 85 class SkRestoreCommand : public SkDrawCommand {
82 public: 86 public:
83 SkRestoreCommand(); 87 SkRestoreCommand();
84 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 88 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
85 virtual void trackSaveState(int* state) SK_OVERRIDE; 89 virtual void trackSaveState(int* state) SK_OVERRIDE;
86 virtual Action action() const SK_OVERRIDE { return kPopLayer_Action; } 90 virtual Action action() const SK_OVERRIDE { return kPopLayer_Action; }
87 91
88 private: 92 private:
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 168 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
165 private: 169 private:
166 SkMatrix fMatrix; 170 SkMatrix fMatrix;
167 171
168 typedef SkDrawCommand INHERITED; 172 typedef SkDrawCommand INHERITED;
169 }; 173 };
170 174
171 class SkDrawBitmapCommand : public SkDrawCommand { 175 class SkDrawBitmapCommand : public SkDrawCommand {
172 public: 176 public:
173 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, 177 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
174 const SkPaint* paint); 178 const SkPaint* paint);
175 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 179 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
176 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; 180 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
177 private: 181 private:
178 SkBitmap fBitmap; 182 SkBitmap fBitmap;
179 SkScalar fLeft; 183 SkScalar fLeft;
180 SkScalar fTop; 184 SkScalar fTop;
181 SkPaint fPaint; 185 SkPaint fPaint;
182 SkPaint* fPaintPtr; 186 SkPaint* fPaintPtr;
183 187
184 typedef SkDrawCommand INHERITED; 188 typedef SkDrawCommand INHERITED;
185 }; 189 };
186 190
187 class SkDrawBitmapMatrixCommand : public SkDrawCommand { 191 class SkDrawBitmapMatrixCommand : public SkDrawCommand {
188 public: 192 public:
189 SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, const SkMatrix& matrix, 193 SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, const SkMatrix& matrix,
190 const SkPaint* paint); 194 const SkPaint* paint);
191 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 195 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
192 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; 196 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
193 private: 197 private:
194 SkBitmap fBitmap; 198 SkBitmap fBitmap;
195 SkMatrix fMatrix; 199 SkMatrix fMatrix;
196 SkPaint fPaint; 200 SkPaint fPaint;
197 SkPaint* fPaintPtr; 201 SkPaint* fPaintPtr;
198 202
199 typedef SkDrawCommand INHERITED; 203 typedef SkDrawCommand INHERITED;
200 }; 204 };
201 205
202 class SkDrawBitmapNineCommand : public SkDrawCommand { 206 class SkDrawBitmapNineCommand : public SkDrawCommand {
203 public: 207 public:
204 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center, 208 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
205 const SkRect& dst, const SkPaint* paint); 209 const SkRect& dst, const SkPaint* paint);
206 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 210 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
207 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; 211 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
208 private: 212 private:
209 SkBitmap fBitmap; 213 SkBitmap fBitmap;
210 SkIRect fCenter; 214 SkIRect fCenter;
211 SkRect fDst; 215 SkRect fDst;
212 SkPaint fPaint; 216 SkPaint fPaint;
213 SkPaint* fPaintPtr; 217 SkPaint* fPaintPtr;
214 218
215 typedef SkDrawCommand INHERITED; 219 typedef SkDrawCommand INHERITED;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 349
346 private: 350 private:
347 SkPicture fPicture; 351 SkPicture fPicture;
348 352
349 typedef SkDrawCommand INHERITED; 353 typedef SkDrawCommand INHERITED;
350 }; 354 };
351 355
352 class SkDrawPointsCommand : public SkDrawCommand { 356 class SkDrawPointsCommand : public SkDrawCommand {
353 public: 357 public:
354 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pt s[], 358 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pt s[],
355 const SkPaint& paint); 359 const SkPaint& paint);
356 virtual ~SkDrawPointsCommand() { delete [] fPts; } 360 virtual ~SkDrawPointsCommand() { delete [] fPts; }
357 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 361 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
358 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; 362 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
359 private: 363 private:
360 SkCanvas::PointMode fMode; 364 SkCanvas::PointMode fMode;
361 size_t fCount; 365 size_t fCount;
362 SkPoint* fPts; 366 SkPoint* fPts;
363 SkPaint fPaint; 367 SkPaint fPaint;
364 368
365 typedef SkDrawCommand INHERITED; 369 typedef SkDrawCommand INHERITED;
366 }; 370 };
367 371
368 class SkDrawTextCommand : public SkDrawCommand { 372 class SkDrawTextCommand : public SkDrawCommand {
369 public: 373 public:
370 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y, 374 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
371 const SkPaint& paint); 375 const SkPaint& paint);
372 virtual ~SkDrawTextCommand() { delete [] fText; } 376 virtual ~SkDrawTextCommand() { delete [] fText; }
373 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 377 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
374 private: 378 private:
375 char* fText; 379 char* fText;
376 size_t fByteLength; 380 size_t fByteLength;
377 SkScalar fX; 381 SkScalar fX;
378 SkScalar fY; 382 SkScalar fY;
379 SkPaint fPaint; 383 SkPaint fPaint;
380 384
381 typedef SkDrawCommand INHERITED; 385 typedef SkDrawCommand INHERITED;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 class SkPopCullCommand : public SkDrawCommand { 625 class SkPopCullCommand : public SkDrawCommand {
622 public: 626 public:
623 SkPopCullCommand(); 627 SkPopCullCommand();
624 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 628 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
625 virtual Action action() const { return kPopCull_Action; } 629 virtual Action action() const { return kPopCull_Action; }
626 private: 630 private:
627 typedef SkDrawCommand INHERITED; 631 typedef SkDrawCommand INHERITED;
628 }; 632 };
629 633
630 #endif 634 #endif
OLDNEW
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.cpp ('k') | src/utils/debugger/SkDrawCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698