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

Side by Side Diff: src/utils/debugger/SkDrawCommand.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 | « 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
(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 #ifndef SKDRAWCOMMAND_H_
10 #define SKDRAWCOMMAND_H_
11
12 #include "SkCanvas.h"
13 #include "SkTLazy.h"
14 #include "SkPath.h"
15 #include "SkRRect.h"
16 #include "SkString.h"
17 #include "SkTDArray.h"
18
19 class SK_API SkDrawCommand {
20 public:
21 enum OpType {
22 kBeginDrawPicture_OpType,
23 kClipPath_OpType,
24 kClipRegion_OpType,
25 kClipRect_OpType,
26 kClipRRect_OpType,
27 kConcat_OpType,
28 kDrawBitmap_OpType,
29 kDrawBitmapNine_OpType,
30 kDrawBitmapRect_OpType,
31 kDrawClear_OpType,
32 kDrawDRRect_OpType,
33 kDrawImage_OpType,
34 kDrawImageRect_OpType,
35 kDrawOval_OpType,
36 kDrawPaint_OpType,
37 kDrawPatch_OpType,
38 kDrawPath_OpType,
39 kDrawPoints_OpType,
40 kDrawPosText_OpType,
41 kDrawPosTextH_OpType,
42 kDrawRect_OpType,
43 kDrawRRect_OpType,
44 kDrawText_OpType,
45 kDrawTextBlob_OpType,
46 kDrawTextOnPath_OpType,
47 kDrawVertices_OpType,
48 kEndDrawPicture_OpType,
49 kRestore_OpType,
50 kSave_OpType,
51 kSaveLayer_OpType,
52 kSetMatrix_OpType,
53
54 kLast_OpType = kSetMatrix_OpType
55 };
56
57 static const int kOpTypeCount = kLast_OpType + 1;
58
59 SkDrawCommand(OpType opType);
60
61 virtual ~SkDrawCommand();
62
63 virtual SkString toString() const;
64
65 virtual const char* toCString() const {
66 return GetCommandString(fOpType);
67 }
68
69 bool isVisible() const {
70 return fVisible;
71 }
72
73 void setVisible(bool toggle) {
74 fVisible = toggle;
75 }
76
77 const SkTDArray<SkString*>* Info() const { return &fInfo; }
78 virtual void execute(SkCanvas*) const = 0;
79 virtual void vizExecute(SkCanvas*) const {}
80
81 virtual void setUserMatrix(const SkMatrix&) {}
82
83 // The next "active" system is only used by save, saveLayer, and restore.
84 // It is used to determine which saveLayers are currently active (at a
85 // given point in the rendering).
86 // saves just return a kPushLayer action but don't track active state
87 // restores just return a kPopLayer action
88 // saveLayers return kPushLayer but also track the active state
89 enum Action {
90 kNone_Action,
91 kPopLayer_Action,
92 kPushLayer_Action,
93 };
94 virtual Action action() const { return kNone_Action; }
95 virtual void setActive(bool active) {}
96 virtual bool active() const { return false; }
97
98 OpType getType() const { return fOpType; }
99
100 virtual bool render(SkCanvas* canvas) const { return false; }
101
102 static const char* GetCommandString(OpType type);
103
104 protected:
105 SkTDArray<SkString*> fInfo;
106
107 private:
108 OpType fOpType;
109 bool fVisible;
110 };
111
112 class SkRestoreCommand : public SkDrawCommand {
113 public:
114 SkRestoreCommand();
115 void execute(SkCanvas* canvas) const override;
116 Action action() const override { return kPopLayer_Action; }
117
118 private:
119 typedef SkDrawCommand INHERITED;
120 };
121
122 class SkClearCommand : public SkDrawCommand {
123 public:
124 SkClearCommand(SkColor color);
125 void execute(SkCanvas* canvas) const override;
126 private:
127 SkColor fColor;
128
129 typedef SkDrawCommand INHERITED;
130 };
131
132 class SkClipPathCommand : public SkDrawCommand {
133 public:
134 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA);
135 void execute(SkCanvas* canvas) const override;
136 bool render(SkCanvas* canvas) const override;
137 private:
138 SkPath fPath;
139 SkRegion::Op fOp;
140 bool fDoAA;
141
142 typedef SkDrawCommand INHERITED;
143 };
144
145 class SkClipRegionCommand : public SkDrawCommand {
146 public:
147 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op);
148 void execute(SkCanvas* canvas) const override;
149 private:
150 SkRegion fRegion;
151 SkRegion::Op fOp;
152
153 typedef SkDrawCommand INHERITED;
154 };
155
156 class SkClipRectCommand : public SkDrawCommand {
157 public:
158 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA);
159 void execute(SkCanvas* canvas) const override;
160
161 const SkRect& rect() const { return fRect; }
162 SkRegion::Op op() const { return fOp; }
163 bool doAA() const { return fDoAA; }
164
165 private:
166 SkRect fRect;
167 SkRegion::Op fOp;
168 bool fDoAA;
169
170 typedef SkDrawCommand INHERITED;
171 };
172
173 class SkClipRRectCommand : public SkDrawCommand {
174 public:
175 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA);
176 void execute(SkCanvas* canvas) const override;
177 bool render(SkCanvas* canvas) const override;
178
179 const SkRRect& rrect() const { return fRRect; }
180 SkRegion::Op op() const { return fOp; }
181 bool doAA() const { return fDoAA; }
182
183 private:
184 SkRRect fRRect;
185 SkRegion::Op fOp;
186 bool fDoAA;
187
188 typedef SkDrawCommand INHERITED;
189 };
190
191 class SkConcatCommand : public SkDrawCommand {
192 public:
193 SkConcatCommand(const SkMatrix& matrix);
194 void execute(SkCanvas* canvas) const override;
195 private:
196 SkMatrix fMatrix;
197
198 typedef SkDrawCommand INHERITED;
199 };
200
201 class SkDrawBitmapCommand : public SkDrawCommand {
202 public:
203 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
204 const SkPaint* paint);
205 void execute(SkCanvas* canvas) const override;
206 bool render(SkCanvas* canvas) const override;
207 private:
208 SkBitmap fBitmap;
209 SkScalar fLeft;
210 SkScalar fTop;
211 SkPaint fPaint;
212 SkPaint* fPaintPtr;
213
214 typedef SkDrawCommand INHERITED;
215 };
216
217 class SkDrawBitmapNineCommand : public SkDrawCommand {
218 public:
219 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
220 const SkRect& dst, const SkPaint* paint);
221 void execute(SkCanvas* canvas) const override;
222 bool render(SkCanvas* canvas) const override;
223 private:
224 SkBitmap fBitmap;
225 SkIRect fCenter;
226 SkRect fDst;
227 SkPaint fPaint;
228 SkPaint* fPaintPtr;
229
230 typedef SkDrawCommand INHERITED;
231 };
232
233 class SkDrawBitmapRectCommand : public SkDrawCommand {
234 public:
235 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
236 const SkRect& dst, const SkPaint* paint,
237 SkCanvas::SrcRectConstraint);
238 void execute(SkCanvas* canvas) const override;
239 bool render(SkCanvas* canvas) const override;
240
241 const SkBitmap& bitmap() const { return fBitmap; }
242
243 // The non-const 'paint' method allows modification of this object's
244 // SkPaint. For this reason the ctor and setPaint method make a local copy.
245 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
246 // (since only an SkPaint* is passed into the ctor).
247 const SkPaint* paint() const { return fPaintPtr; }
248 SkPaint* paint() { return fPaintPtr; }
249
250 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
251
252 const SkRect* srcRect() const { return fSrc.isEmpty() ? nullptr : &fSrc; }
253 void setSrcRect(const SkRect& src) { fSrc = src; }
254
255 const SkRect& dstRect() const { return fDst; }
256 void setDstRect(const SkRect& dst) { fDst = dst; }
257
258 SkCanvas::SrcRectConstraint constraint() const { return fConstraint; }
259 void setConstraint(SkCanvas::SrcRectConstraint constraint) { fConstraint = c onstraint; }
260
261 private:
262 SkBitmap fBitmap;
263 SkRect fSrc;
264 SkRect fDst;
265 SkPaint fPaint;
266 SkPaint* fPaintPtr;
267 SkCanvas::SrcRectConstraint fConstraint;
268
269 typedef SkDrawCommand INHERITED;
270 };
271
272 class SkDrawImageCommand : public SkDrawCommand {
273 public:
274 SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint);
275 void execute(SkCanvas* canvas) const override;
276 bool render(SkCanvas* canvas) const override;
277 private:
278 SkAutoTUnref<const SkImage> fImage;
279 SkScalar fLeft;
280 SkScalar fTop;
281 SkTLazy<SkPaint> fPaint;
282
283 typedef SkDrawCommand INHERITED;
284 };
285
286 class SkDrawImageRectCommand : public SkDrawCommand {
287 public:
288 SkDrawImageRectCommand(const SkImage* image, const SkRect* src, const SkRect & dst,
289 const SkPaint* paint, SkCanvas::SrcRectConstraint con straint);
290 void execute(SkCanvas* canvas) const override;
291 bool render(SkCanvas* canvas) const override;
292 private:
293 SkAutoTUnref<const SkImage> fImage;
294 SkTLazy<SkRect> fSrc;
295 SkRect fDst;
296 SkTLazy<SkPaint> fPaint;
297 SkCanvas::SrcRectConstraint fConstraint;
298
299 typedef SkDrawCommand INHERITED;
300 };
301
302 class SkDrawOvalCommand : public SkDrawCommand {
303 public:
304 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
305 void execute(SkCanvas* canvas) const override;
306 bool render(SkCanvas* canvas) const override;
307 private:
308 SkRect fOval;
309 SkPaint fPaint;
310
311 typedef SkDrawCommand INHERITED;
312 };
313
314 class SkDrawPaintCommand : public SkDrawCommand {
315 public:
316 SkDrawPaintCommand(const SkPaint& paint);
317 void execute(SkCanvas* canvas) const override;
318 bool render(SkCanvas* canvas) const override;
319 private:
320 SkPaint fPaint;
321
322 typedef SkDrawCommand INHERITED;
323 };
324
325 class SkDrawPathCommand : public SkDrawCommand {
326 public:
327 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
328 void execute(SkCanvas* canvas) const override;
329 bool render(SkCanvas* canvas) const override;
330
331 private:
332 SkPath fPath;
333 SkPaint fPaint;
334
335 typedef SkDrawCommand INHERITED;
336 };
337
338 class SkBeginDrawPictureCommand : public SkDrawCommand {
339 public:
340 SkBeginDrawPictureCommand(const SkPicture* picture,
341 const SkMatrix* matrix,
342 const SkPaint* paint);
343
344 void execute(SkCanvas* canvas) const override;
345 bool render(SkCanvas* canvas) const override;
346
347 private:
348 SkAutoTUnref<const SkPicture> fPicture;
349 SkTLazy<SkMatrix> fMatrix;
350 SkTLazy<SkPaint> fPaint;
351
352 typedef SkDrawCommand INHERITED;
353 };
354
355 class SkEndDrawPictureCommand : public SkDrawCommand {
356 public:
357 SkEndDrawPictureCommand(bool restore);
358
359 void execute(SkCanvas* canvas) const override;
360
361 private:
362 bool fRestore;
363
364 typedef SkDrawCommand INHERITED;
365 };
366
367 class SkDrawPointsCommand : public SkDrawCommand {
368 public:
369 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pt s[],
370 const SkPaint& paint);
371 virtual ~SkDrawPointsCommand() { delete [] fPts; }
372 void execute(SkCanvas* canvas) const override;
373 bool render(SkCanvas* canvas) const override;
374 private:
375 SkCanvas::PointMode fMode;
376 size_t fCount;
377 SkPoint* fPts;
378 SkPaint fPaint;
379
380 typedef SkDrawCommand INHERITED;
381 };
382
383 class SkDrawTextCommand : public SkDrawCommand {
384 public:
385 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
386 const SkPaint& paint);
387 virtual ~SkDrawTextCommand() { delete [] fText; }
388 void execute(SkCanvas* canvas) const override;
389 private:
390 char* fText;
391 size_t fByteLength;
392 SkScalar fX;
393 SkScalar fY;
394 SkPaint fPaint;
395
396 typedef SkDrawCommand INHERITED;
397 };
398
399 class SkDrawPosTextCommand : public SkDrawCommand {
400 public:
401 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[ ],
402 const SkPaint& paint);
403 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
404 void execute(SkCanvas* canvas) const override;
405 private:
406 char* fText;
407 size_t fByteLength;
408 SkPoint* fPos;
409 SkPaint fPaint;
410
411 typedef SkDrawCommand INHERITED;
412 };
413
414 class SkDrawTextOnPathCommand : public SkDrawCommand {
415 public:
416 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& p ath,
417 const SkMatrix* matrix, const SkPaint& paint);
418 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
419 void execute(SkCanvas* canvas) const override;
420 private:
421 char* fText;
422 size_t fByteLength;
423 SkPath fPath;
424 SkMatrix fMatrix;
425 SkPaint fPaint;
426
427 typedef SkDrawCommand INHERITED;
428 };
429
430 class SkDrawPosTextHCommand : public SkDrawCommand {
431 public:
432 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xp os[],
433 SkScalar constY, const SkPaint& paint);
434 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
435 void execute(SkCanvas* canvas) const override;
436 private:
437 SkScalar* fXpos;
438 char* fText;
439 size_t fByteLength;
440 SkScalar fConstY;
441 SkPaint fPaint;
442
443 typedef SkDrawCommand INHERITED;
444 };
445
446 class SkDrawTextBlobCommand : public SkDrawCommand {
447 public:
448 SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
449
450 void execute(SkCanvas* canvas) const override;
451 bool render(SkCanvas* canvas) const override;
452
453 private:
454 SkAutoTUnref<const SkTextBlob> fBlob;
455 SkScalar fXPos;
456 SkScalar fYPos;
457 SkPaint fPaint;
458
459 typedef SkDrawCommand INHERITED;
460 };
461
462 class SkDrawPatchCommand : public SkDrawCommand {
463 public:
464 SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
465 const SkPoint texCoords[4], SkXfermode* xmode,
466 const SkPaint& paint);
467 void execute(SkCanvas* canvas) const override;
468
469 private:
470 SkPoint fCubics[12];
471 SkColor fColors[4];
472 SkPoint fTexCoords[4];
473 SkAutoTUnref<SkXfermode> fXfermode;
474 SkPaint fPaint;
475
476 typedef SkDrawCommand INHERITED;
477 };
478
479
480 class SkDrawRectCommand : public SkDrawCommand {
481 public:
482 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
483 void execute(SkCanvas* canvas) const override;
484
485 const SkRect& rect() const { return fRect; }
486 const SkPaint& paint() const { return fPaint; }
487 private:
488 SkRect fRect;
489 SkPaint fPaint;
490
491 typedef SkDrawCommand INHERITED;
492 };
493
494 class SkDrawRRectCommand : public SkDrawCommand {
495 public:
496 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
497 void execute(SkCanvas* canvas) const override;
498 bool render(SkCanvas* canvas) const override;
499 private:
500 SkRRect fRRect;
501 SkPaint fPaint;
502
503 typedef SkDrawCommand INHERITED;
504 };
505
506 class SkDrawDRRectCommand : public SkDrawCommand {
507 public:
508 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
509 const SkPaint& paint);
510 void execute(SkCanvas* canvas) const override;
511 bool render(SkCanvas* canvas) const override;
512 private:
513 SkRRect fOuter;
514 SkRRect fInner;
515 SkPaint fPaint;
516
517 typedef SkDrawCommand INHERITED;
518 };
519
520 class SkDrawVerticesCommand : public SkDrawCommand {
521 public:
522 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
523 const SkPoint vertices[], const SkPoint texs[],
524 const SkColor colors[], SkXfermode* xfermode,
525 const uint16_t indices[], int indexCount,
526 const SkPaint& paint);
527 virtual ~SkDrawVerticesCommand();
528 void execute(SkCanvas* canvas) const override;
529 private:
530 SkCanvas::VertexMode fVmode;
531 int fVertexCount;
532 SkPoint* fVertices;
533 SkPoint* fTexs;
534 SkColor* fColors;
535 SkXfermode* fXfermode;
536 uint16_t* fIndices;
537 int fIndexCount;
538 SkPaint fPaint;
539
540 typedef SkDrawCommand INHERITED;
541 };
542
543 class SkSaveCommand : public SkDrawCommand {
544 public:
545 SkSaveCommand();
546 void execute(SkCanvas* canvas) const override;
547 Action action() const override { return kPushLayer_Action; }
548 private:
549 typedef SkDrawCommand INHERITED;
550 };
551
552 class SkSaveLayerCommand : public SkDrawCommand {
553 public:
554 SkSaveLayerCommand(const SkCanvas::SaveLayerRec&);
555 void execute(SkCanvas* canvas) const override;
556 void vizExecute(SkCanvas* canvas) const override;
557 Action action() const override{ return kPushLayer_Action; }
558 void setActive(bool active) override { fActive = active; }
559 bool active() const override { return fActive; }
560
561 const SkPaint* paint() const { return fPaintPtr; }
562
563 private:
564 SkRect fBounds;
565 SkPaint fPaint;
566 SkPaint* fPaintPtr;
567 uint32_t fSaveLayerFlags;
568
569 bool fActive;
570
571 typedef SkDrawCommand INHERITED;
572 };
573
574 class SkSetMatrixCommand : public SkDrawCommand {
575 public:
576 SkSetMatrixCommand(const SkMatrix& matrix);
577 void setUserMatrix(const SkMatrix&) override;
578 void execute(SkCanvas* canvas) const override;
579 private:
580 SkMatrix fUserMatrix;
581 SkMatrix fMatrix;
582
583 typedef SkDrawCommand INHERITED;
584 };
585
586 #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