OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 return fVisible; | 31 return fVisible; |
32 } | 32 } |
33 | 33 |
34 void setVisible(bool toggle) { | 34 void setVisible(bool toggle) { |
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 subclasses to track unresolved save() calls. */ |
42 virtual void trackSaveState(int* state) { }; | 42 virtual void trackSaveState(int* state) { }; |
| 43 |
| 44 // The next "active" system is only used by save, saveLayer and restore. |
| 45 // It is used to determine which saveLayers are currently active (at a |
| 46 // given point in the rendering). |
| 47 // save just return a kPush action but don't track active state |
| 48 // restore just return a kPop action |
| 49 // saveLayers return kPush but also track the active state |
| 50 enum Action { |
| 51 kNone_Action, |
| 52 kPop_Action, |
| 53 kPush_Action |
| 54 }; |
| 55 virtual Action action() const { return kNone_Action; } |
| 56 virtual void setActive(bool active) {} |
| 57 virtual bool active() const { return false; } |
| 58 |
43 DrawType getType() { return fDrawType; }; | 59 DrawType getType() { return fDrawType; }; |
44 | 60 |
45 virtual bool render(SkCanvas* canvas) const { return false; } | 61 virtual bool render(SkCanvas* canvas) const { return false; } |
46 | 62 |
47 static const char* GetCommandString(DrawType type); | 63 static const char* GetCommandString(DrawType type); |
48 | 64 |
49 protected: | 65 protected: |
50 DrawType fDrawType; | 66 DrawType fDrawType; |
51 SkTDArray<SkString*> fInfo; | 67 SkTDArray<SkString*> fInfo; |
52 | 68 |
53 private: | 69 private: |
54 bool fVisible; | 70 bool fVisible; |
55 }; | 71 }; |
56 | 72 |
57 class SkRestoreCommand : public SkDrawCommand { | 73 class SkRestoreCommand : public SkDrawCommand { |
58 public: | 74 public: |
59 SkRestoreCommand(); | 75 SkRestoreCommand(); |
60 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 76 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
61 virtual void trackSaveState(int* state) SK_OVERRIDE; | 77 virtual void trackSaveState(int* state) SK_OVERRIDE; |
| 78 virtual Action action() const SK_OVERRIDE { return kPop_Action; } |
62 | 79 |
63 private: | 80 private: |
64 typedef SkDrawCommand INHERITED; | 81 typedef SkDrawCommand INHERITED; |
65 }; | 82 }; |
66 | 83 |
67 class SkClearCommand : public SkDrawCommand { | 84 class SkClearCommand : public SkDrawCommand { |
68 public: | 85 public: |
69 SkClearCommand(SkColor color); | 86 SkClearCommand(SkColor color); |
70 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 87 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
71 private: | 88 private: |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 SkScalar fDegrees; | 506 SkScalar fDegrees; |
490 | 507 |
491 typedef SkDrawCommand INHERITED; | 508 typedef SkDrawCommand INHERITED; |
492 }; | 509 }; |
493 | 510 |
494 class SkSaveCommand : public SkDrawCommand { | 511 class SkSaveCommand : public SkDrawCommand { |
495 public: | 512 public: |
496 SkSaveCommand(SkCanvas::SaveFlags flags); | 513 SkSaveCommand(SkCanvas::SaveFlags flags); |
497 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 514 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
498 virtual void trackSaveState(int* state) SK_OVERRIDE; | 515 virtual void trackSaveState(int* state) SK_OVERRIDE; |
| 516 virtual Action action() const SK_OVERRIDE { return kPush_Action; } |
499 private: | 517 private: |
500 SkCanvas::SaveFlags fFlags; | 518 SkCanvas::SaveFlags fFlags; |
501 | 519 |
502 typedef SkDrawCommand INHERITED; | 520 typedef SkDrawCommand INHERITED; |
503 }; | 521 }; |
504 | 522 |
505 class SkSaveLayerCommand : public SkDrawCommand { | 523 class SkSaveLayerCommand : public SkDrawCommand { |
506 public: | 524 public: |
507 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint, | 525 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint, |
508 SkCanvas::SaveFlags flags); | 526 SkCanvas::SaveFlags flags); |
509 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 527 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
510 virtual void trackSaveState(int* state) SK_OVERRIDE; | 528 virtual void trackSaveState(int* state) SK_OVERRIDE; |
| 529 virtual Action action() const SK_OVERRIDE{ return kPush_Action; } |
| 530 virtual void setActive(bool active) SK_OVERRIDE { fActive = active; } |
| 531 virtual bool active() const SK_OVERRIDE { return fActive; } |
511 | 532 |
512 const SkPaint* paint() const { return fPaintPtr; } | 533 const SkPaint* paint() const { return fPaintPtr; } |
513 | 534 |
514 private: | 535 private: |
515 SkRect fBounds; | 536 SkRect fBounds; |
516 SkPaint fPaint; | 537 SkPaint fPaint; |
517 SkPaint* fPaintPtr; | 538 SkPaint* fPaintPtr; |
518 SkCanvas::SaveFlags fFlags; | 539 SkCanvas::SaveFlags fFlags; |
519 | 540 |
| 541 bool fActive; |
| 542 |
520 typedef SkDrawCommand INHERITED; | 543 typedef SkDrawCommand INHERITED; |
521 }; | 544 }; |
522 | 545 |
523 class SkScaleCommand : public SkDrawCommand { | 546 class SkScaleCommand : public SkDrawCommand { |
524 public: | 547 public: |
525 SkScaleCommand(SkScalar sx, SkScalar sy); | 548 SkScaleCommand(SkScalar sx, SkScalar sy); |
526 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 549 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
527 | 550 |
528 SkScalar x() const { return fSx; } | 551 SkScalar x() const { return fSx; } |
529 SkScalar y() const { return fSy; } | 552 SkScalar y() const { return fSy; } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 class SkPopCullCommand : public SkDrawCommand { | 608 class SkPopCullCommand : public SkDrawCommand { |
586 public: | 609 public: |
587 SkPopCullCommand(); | 610 SkPopCullCommand(); |
588 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 611 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
589 | 612 |
590 private: | 613 private: |
591 typedef SkDrawCommand INHERITED; | 614 typedef SkDrawCommand INHERITED; |
592 }; | 615 }; |
593 | 616 |
594 #endif | 617 #endif |
OLD | NEW |