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

Side by Side Diff: debugger/SkDrawCommand.h

Issue 15907023: Make SkDrawCommands lighter weight (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review comments Created 7 years, 6 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 | « debugger/SkDebugCanvas.cpp ('k') | 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_
(...skipping 24 matching lines...) Expand all
35 fVisible = toggle; 35 fVisible = toggle;
36 } 36 }
37 37
38 SkTDArray<SkString*>* Info() {return &fInfo; }; 38 SkTDArray<SkString*>* Info() {return &fInfo; };
39 virtual void execute(SkCanvas* canvas)=0; 39 virtual void execute(SkCanvas* canvas)=0;
40 /** Does nothing by default, but used by save() and restore()-type 40 /** Does nothing by default, but used by save() and restore()-type
41 subclassse to track unresolved save() calls. */ 41 subclassse to track unresolved save() calls. */
42 virtual void trackSaveState(int* state) { }; 42 virtual void trackSaveState(int* state) { };
43 DrawType getType() { return fDrawType; }; 43 DrawType getType() { return fDrawType; };
44 44
45 virtual const SkBitmap* getBitmap() const { return NULL; } 45 virtual bool render(SkCanvas* canvas) const { return false; }
46 46
47 static const char* GetCommandString(DrawType type); 47 static const char* GetCommandString(DrawType type);
48 48
49 protected: 49 protected:
50 DrawType fDrawType; 50 DrawType fDrawType;
51 SkTDArray<SkString*> fInfo; 51 SkTDArray<SkString*> fInfo;
52 52
53 private: 53 private:
54 bool fVisible; 54 bool fVisible;
55 }; 55 };
(...skipping 13 matching lines...) Expand all
69 Clear(SkColor color); 69 Clear(SkColor color);
70 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 70 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
71 private: 71 private:
72 SkColor fColor; 72 SkColor fColor;
73 73
74 typedef SkDrawCommand INHERITED; 74 typedef SkDrawCommand INHERITED;
75 }; 75 };
76 76
77 class ClipPath : public SkDrawCommand { 77 class ClipPath : public SkDrawCommand {
78 public: 78 public:
79 ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap); 79 ClipPath(const SkPath& path, SkRegion::Op op, bool doAA);
80 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 80 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
81 virtual const SkBitmap* getBitmap() const SK_OVERRIDE; 81 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
82 private: 82 private:
83 SkPath fPath; 83 SkPath fPath;
84 SkRegion::Op fOp; 84 SkRegion::Op fOp;
85 bool fDoAA; 85 bool fDoAA;
86 SkBitmap fBitmap;
87 86
88 typedef SkDrawCommand INHERITED; 87 typedef SkDrawCommand INHERITED;
89 }; 88 };
90 89
91 class ClipRegion : public SkDrawCommand { 90 class ClipRegion : public SkDrawCommand {
92 public: 91 public:
93 ClipRegion(const SkRegion& region, SkRegion::Op op); 92 ClipRegion(const SkRegion& region, SkRegion::Op op);
94 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 93 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
95 private: 94 private:
96 SkRegion fRegion; 95 SkRegion fRegion;
(...skipping 16 matching lines...) Expand all
113 SkRegion::Op fOp; 112 SkRegion::Op fOp;
114 bool fDoAA; 113 bool fDoAA;
115 114
116 typedef SkDrawCommand INHERITED; 115 typedef SkDrawCommand INHERITED;
117 }; 116 };
118 117
119 class ClipRRect : public SkDrawCommand { 118 class ClipRRect : public SkDrawCommand {
120 public: 119 public:
121 ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA); 120 ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA);
122 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 121 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
122 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
123 123
124 const SkRRect& rrect() const { return fRRect; } 124 const SkRRect& rrect() const { return fRRect; }
125 SkRegion::Op op() const { return fOp; } 125 SkRegion::Op op() const { return fOp; }
126 bool doAA() const { return fDoAA; } 126 bool doAA() const { return fDoAA; }
127 127
128 private: 128 private:
129 SkRRect fRRect; 129 SkRRect fRRect;
130 SkRegion::Op fOp; 130 SkRegion::Op fOp;
131 bool fDoAA; 131 bool fDoAA;
132 132
133 typedef SkDrawCommand INHERITED; 133 typedef SkDrawCommand INHERITED;
134 }; 134 };
135 135
136 class Concat : public SkDrawCommand { 136 class Concat : public SkDrawCommand {
137 public: 137 public:
138 Concat(const SkMatrix& matrix); 138 Concat(const SkMatrix& matrix);
139 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 139 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
140 private: 140 private:
141 SkMatrix fMatrix; 141 SkMatrix fMatrix;
142 142
143 typedef SkDrawCommand INHERITED; 143 typedef SkDrawCommand INHERITED;
144 }; 144 };
145 145
146 class DrawBitmap : public SkDrawCommand { 146 class DrawBitmap : public SkDrawCommand {
147 public: 147 public:
148 DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, 148 DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
149 const SkPaint* paint, SkBitmap& resizedBitmap); 149 const SkPaint* paint);
150 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 150 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
151 virtual const SkBitmap* getBitmap() const SK_OVERRIDE; 151 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
152 private: 152 private:
153 SkBitmap fBitmap; 153 SkBitmap fBitmap;
154 SkScalar fLeft; 154 SkScalar fLeft;
155 SkScalar fTop; 155 SkScalar fTop;
156 SkPaint fPaint; 156 SkPaint fPaint;
157 SkPaint* fPaintPtr; 157 SkPaint* fPaintPtr;
158 SkBitmap fResizedBitmap;
159 158
160 typedef SkDrawCommand INHERITED; 159 typedef SkDrawCommand INHERITED;
161 }; 160 };
162 161
163 class DrawBitmapMatrix : public SkDrawCommand { 162 class DrawBitmapMatrix : public SkDrawCommand {
164 public: 163 public:
165 DrawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix, 164 DrawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
166 const SkPaint* paint, SkBitmap& resizedBitmap); 165 const SkPaint* paint);
167 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 166 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
168 virtual const SkBitmap* getBitmap() const SK_OVERRIDE; 167 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
169 private: 168 private:
170 SkBitmap fBitmap; 169 SkBitmap fBitmap;
171 SkMatrix fMatrix; 170 SkMatrix fMatrix;
172 SkPaint fPaint; 171 SkPaint fPaint;
173 SkPaint* fPaintPtr; 172 SkPaint* fPaintPtr;
174 SkBitmap fResizedBitmap;
175 173
176 typedef SkDrawCommand INHERITED; 174 typedef SkDrawCommand INHERITED;
177 }; 175 };
178 176
179 class DrawBitmapNine : public SkDrawCommand { 177 class DrawBitmapNine : public SkDrawCommand {
180 public: 178 public:
181 DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 179 DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
182 const SkRect& dst, const SkPaint* paint, 180 const SkRect& dst, const SkPaint* paint);
183 SkBitmap& resizedBitmap);
184 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 181 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
185 virtual const SkBitmap* getBitmap() const SK_OVERRIDE; 182 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
186 private: 183 private:
187 SkBitmap fBitmap; 184 SkBitmap fBitmap;
188 SkIRect fCenter; 185 SkIRect fCenter;
189 SkRect fDst; 186 SkRect fDst;
190 SkPaint fPaint; 187 SkPaint fPaint;
191 SkPaint* fPaintPtr; 188 SkPaint* fPaintPtr;
192 SkBitmap fResizedBitmap;
193 189
194 typedef SkDrawCommand INHERITED; 190 typedef SkDrawCommand INHERITED;
195 }; 191 };
196 192
197 class DrawBitmapRect : public SkDrawCommand { 193 class DrawBitmapRect : public SkDrawCommand {
198 public: 194 public:
199 DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 195 DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
200 const SkRect& dst, const SkPaint* paint, 196 const SkRect& dst, const SkPaint* paint);
201 SkBitmap& resizedBitmap);
202 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 197 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
203 virtual const SkBitmap* getBitmap() const SK_OVERRIDE; 198 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
204 199
205 const SkBitmap& bitmap() const { return fBitmap; } 200 const SkBitmap& bitmap() const { return fBitmap; }
206 201
207 // The non-const 'paint' method allows modification of this object's 202 // The non-const 'paint' method allows modification of this object's
208 // SkPaint. For this reason the ctor and setPaint method make a local copy. 203 // SkPaint. For this reason the ctor and setPaint method make a local copy.
209 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid 204 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
210 // (since only an SkPaint* is passed into the ctor). 205 // (since only an SkPaint* is passed into the ctor).
211 const SkPaint* paint() const { return fPaintPtr; } 206 const SkPaint* paint() const { return fPaintPtr; }
212 SkPaint* paint() { return fPaintPtr; } 207 SkPaint* paint() { return fPaintPtr; }
213 208
214 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; } 209 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
215 210
216 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; } 211 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
217 const SkRect& dstRect() const { return fDst; } 212 const SkRect& dstRect() const { return fDst; }
218 213
219 void setSrcRect(const SkRect& src) { fSrc = src; } 214 void setSrcRect(const SkRect& src) { fSrc = src; }
220 void setDstRect(const SkRect& dst) { fDst = dst; } 215 void setDstRect(const SkRect& dst) { fDst = dst; }
221 216
222 private: 217 private:
223 SkBitmap fBitmap; 218 SkBitmap fBitmap;
224 SkRect fSrc; 219 SkRect fSrc;
225 SkRect fDst; 220 SkRect fDst;
226 SkPaint fPaint; 221 SkPaint fPaint;
227 SkPaint* fPaintPtr; 222 SkPaint* fPaintPtr;
228 SkBitmap fResizedBitmap;
229 223
230 typedef SkDrawCommand INHERITED; 224 typedef SkDrawCommand INHERITED;
231 }; 225 };
232 226
233 class DrawData : public SkDrawCommand { 227 class DrawData : public SkDrawCommand {
234 public: 228 public:
235 DrawData(const void* data, size_t length); 229 DrawData(const void* data, size_t length);
236 virtual ~DrawData() { delete [] fData; } 230 virtual ~DrawData() { delete [] fData; }
237 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 231 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
238 private: 232 private:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 canvas->endCommentGroup(); 268 canvas->endCommentGroup();
275 }; 269 };
276 private: 270 private:
277 typedef SkDrawCommand INHERITED; 271 typedef SkDrawCommand INHERITED;
278 }; 272 };
279 273
280 class DrawOval : public SkDrawCommand { 274 class DrawOval : public SkDrawCommand {
281 public: 275 public:
282 DrawOval(const SkRect& oval, const SkPaint& paint); 276 DrawOval(const SkRect& oval, const SkPaint& paint);
283 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 277 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
278 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
284 private: 279 private:
285 SkRect fOval; 280 SkRect fOval;
286 SkPaint fPaint; 281 SkPaint fPaint;
287 282
288 typedef SkDrawCommand INHERITED; 283 typedef SkDrawCommand INHERITED;
289 }; 284 };
290 285
291 class DrawPaint : public SkDrawCommand { 286 class DrawPaint : public SkDrawCommand {
292 public: 287 public:
293 DrawPaint(const SkPaint& paint); 288 DrawPaint(const SkPaint& paint);
294 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 289 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
290 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
295 private: 291 private:
296 SkPaint fPaint; 292 SkPaint fPaint;
297 293
298 typedef SkDrawCommand INHERITED; 294 typedef SkDrawCommand INHERITED;
299 }; 295 };
300 296
301 class DrawPath : public SkDrawCommand { 297 class DrawPath : public SkDrawCommand {
302 public: 298 public:
303 DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap); 299 DrawPath(const SkPath& path, const SkPaint& paint);
304 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 300 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
305 virtual const SkBitmap* getBitmap() const SK_OVERRIDE; 301 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
306 302
307 private: 303 private:
308 SkPath fPath; 304 SkPath fPath;
309 SkPaint fPaint; 305 SkPaint fPaint;
310 SkBitmap fBitmap;
311 306
312 typedef SkDrawCommand INHERITED; 307 typedef SkDrawCommand INHERITED;
313 }; 308 };
314 309
315 class DrawPicture : public SkDrawCommand { 310 class DrawPicture : public SkDrawCommand {
316 public: 311 public:
317 DrawPicture(SkPicture& picture); 312 DrawPicture(SkPicture& picture);
318 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 313 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
319 private: 314 private:
320 SkPicture fPicture; 315 SkPicture fPicture;
321 316
322 typedef SkDrawCommand INHERITED; 317 typedef SkDrawCommand INHERITED;
323 }; 318 };
324 319
325 class DrawPoints : public SkDrawCommand { 320 class DrawPoints : public SkDrawCommand {
326 public: 321 public:
327 DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], 322 DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
328 const SkPaint& paint); 323 const SkPaint& paint);
329 virtual ~DrawPoints() { delete [] fPts; } 324 virtual ~DrawPoints() { delete [] fPts; }
330 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 325 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
331 326 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
332 private: 327 private:
333 SkCanvas::PointMode fMode; 328 SkCanvas::PointMode fMode;
334 size_t fCount; 329 size_t fCount;
335 SkPoint* fPts; 330 SkPoint* fPts;
336 SkPaint fPaint; 331 SkPaint fPaint;
337 332
338 typedef SkDrawCommand INHERITED; 333 typedef SkDrawCommand INHERITED;
339 }; 334 };
340 335
341 /* TODO(chudy): DrawText is a predefined macro and was breaking something 336 /* TODO(chudy): DrawText is a predefined macro and was breaking something
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 SkRect fRect; 410 SkRect fRect;
416 SkPaint fPaint; 411 SkPaint fPaint;
417 412
418 typedef SkDrawCommand INHERITED; 413 typedef SkDrawCommand INHERITED;
419 }; 414 };
420 415
421 class DrawRRect : public SkDrawCommand { 416 class DrawRRect : public SkDrawCommand {
422 public: 417 public:
423 DrawRRect(const SkRRect& rrect, const SkPaint& paint); 418 DrawRRect(const SkRRect& rrect, const SkPaint& paint);
424 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 419 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
420 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
425 private: 421 private:
426 SkRRect fRRect; 422 SkRRect fRRect;
427 SkPaint fPaint; 423 SkPaint fPaint;
428 424
429 typedef SkDrawCommand INHERITED; 425 typedef SkDrawCommand INHERITED;
430 }; 426 };
431 427
432 class DrawSprite : public SkDrawCommand { 428 class DrawSprite : public SkDrawCommand {
433 public: 429 public:
434 DrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint, 430 DrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
435 SkBitmap& resizedBitmap);
436 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; 431 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
437 virtual const SkBitmap* getBitmap() const SK_OVERRIDE; 432 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
438 private: 433 private:
439 SkBitmap fBitmap; 434 SkBitmap fBitmap;
440 int fLeft; 435 int fLeft;
441 int fTop; 436 int fTop;
442 SkPaint fPaint; 437 SkPaint fPaint;
443 SkPaint* fPaintPtr; 438 SkPaint* fPaintPtr;
444 SkBitmap fResizedBitmap;
445 439
446 typedef SkDrawCommand INHERITED; 440 typedef SkDrawCommand INHERITED;
447 }; 441 };
448 442
449 class DrawVertices : public SkDrawCommand { 443 class DrawVertices : public SkDrawCommand {
450 public: 444 public:
451 DrawVertices(SkCanvas::VertexMode vmode, int vertexCount, 445 DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
452 const SkPoint vertices[], const SkPoint texs[], 446 const SkPoint vertices[], const SkPoint texs[],
453 const SkColor colors[], SkXfermode* xfermode, 447 const SkColor colors[], SkXfermode* xfermode,
454 const uint16_t indices[], int indexCount, 448 const uint16_t indices[], int indexCount,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 SkScalar y() const { return fDy; } 547 SkScalar y() const { return fDy; }
554 548
555 private: 549 private:
556 SkScalar fDx; 550 SkScalar fDx;
557 SkScalar fDy; 551 SkScalar fDy;
558 552
559 typedef SkDrawCommand INHERITED; 553 typedef SkDrawCommand INHERITED;
560 }; 554 };
561 555
562 #endif 556 #endif
OLDNEW
« no previous file with comments | « debugger/SkDebugCanvas.cpp ('k') | debugger/SkDrawCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698