| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 bool isVisible() const { | 30 bool isVisible() const { |
| 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 virtual void vizExecute(SkCanvas* canvas) { }; |
| 40 /** Does nothing by default, but used by save() and restore()-type | 41 /** Does nothing by default, but used by save() and restore()-type |
| 41 subclasses to track unresolved save() calls. */ | 42 subclasses to track unresolved save() calls. */ |
| 42 virtual void trackSaveState(int* state) { }; | 43 virtual void trackSaveState(int* state) { }; |
| 43 | 44 |
| 44 // The next "active" system is only used by save, saveLayer and restore. | 45 // The next "active" system is only used by save, saveLayer, restore, |
| 45 // It is used to determine which saveLayers are currently active (at a | 46 // pushCull and popCull. It is used in two ways: |
| 47 // To determine which saveLayers are currently active (at a |
| 46 // given point in the rendering). | 48 // given point in the rendering). |
| 47 // save just return a kPush action but don't track active state | 49 // save just return a kPushLayer action but don't track active state |
| 48 // restore just return a kPop action | 50 // restore just return a kPopLayer action |
| 49 // saveLayers return kPush but also track the active state | 51 // saveLayers return kPushLayer but also track the active state |
| 52 // To determine which culls are currently active (at a given point) |
| 53 // in the rendering). |
| 54 // pushCull returns a kPushCull action |
| 55 // popCull returns a kPopCull action |
| 50 enum Action { | 56 enum Action { |
| 51 kNone_Action, | 57 kNone_Action, |
| 52 kPop_Action, | 58 kPopLayer_Action, |
| 53 kPush_Action | 59 kPushLayer_Action, |
| 60 kPopCull_Action, |
| 61 kPushCull_Action |
| 54 }; | 62 }; |
| 55 virtual Action action() const { return kNone_Action; } | 63 virtual Action action() const { return kNone_Action; } |
| 56 virtual void setActive(bool active) {} | 64 virtual void setActive(bool active) {} |
| 57 virtual bool active() const { return false; } | 65 virtual bool active() const { return false; } |
| 58 | 66 |
| 59 DrawType getType() { return fDrawType; }; | 67 DrawType getType() { return fDrawType; }; |
| 60 | 68 |
| 61 virtual bool render(SkCanvas* canvas) const { return false; } | 69 virtual bool render(SkCanvas* canvas) const { return false; } |
| 62 | 70 |
| 63 static const char* GetCommandString(DrawType type); | 71 static const char* GetCommandString(DrawType type); |
| 64 | 72 |
| 65 protected: | 73 protected: |
| 66 DrawType fDrawType; | 74 DrawType fDrawType; |
| 67 SkTDArray<SkString*> fInfo; | 75 SkTDArray<SkString*> fInfo; |
| 68 | 76 |
| 69 private: | 77 private: |
| 70 bool fVisible; | 78 bool fVisible; |
| 71 }; | 79 }; |
| 72 | 80 |
| 73 class SkRestoreCommand : public SkDrawCommand { | 81 class SkRestoreCommand : public SkDrawCommand { |
| 74 public: | 82 public: |
| 75 SkRestoreCommand(); | 83 SkRestoreCommand(); |
| 76 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 84 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 77 virtual void trackSaveState(int* state) SK_OVERRIDE; | 85 virtual void trackSaveState(int* state) SK_OVERRIDE; |
| 78 virtual Action action() const SK_OVERRIDE { return kPop_Action; } | 86 virtual Action action() const SK_OVERRIDE { return kPopLayer_Action; } |
| 79 | 87 |
| 80 private: | 88 private: |
| 81 typedef SkDrawCommand INHERITED; | 89 typedef SkDrawCommand INHERITED; |
| 82 }; | 90 }; |
| 83 | 91 |
| 84 class SkClearCommand : public SkDrawCommand { | 92 class SkClearCommand : public SkDrawCommand { |
| 85 public: | 93 public: |
| 86 SkClearCommand(SkColor color); | 94 SkClearCommand(SkColor color); |
| 87 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 95 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 88 private: | 96 private: |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 SkScalar fDegrees; | 514 SkScalar fDegrees; |
| 507 | 515 |
| 508 typedef SkDrawCommand INHERITED; | 516 typedef SkDrawCommand INHERITED; |
| 509 }; | 517 }; |
| 510 | 518 |
| 511 class SkSaveCommand : public SkDrawCommand { | 519 class SkSaveCommand : public SkDrawCommand { |
| 512 public: | 520 public: |
| 513 SkSaveCommand(SkCanvas::SaveFlags flags); | 521 SkSaveCommand(SkCanvas::SaveFlags flags); |
| 514 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 522 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 515 virtual void trackSaveState(int* state) SK_OVERRIDE; | 523 virtual void trackSaveState(int* state) SK_OVERRIDE; |
| 516 virtual Action action() const SK_OVERRIDE { return kPush_Action; } | 524 virtual Action action() const SK_OVERRIDE { return kPushLayer_Action; } |
| 517 private: | 525 private: |
| 518 SkCanvas::SaveFlags fFlags; | 526 SkCanvas::SaveFlags fFlags; |
| 519 | 527 |
| 520 typedef SkDrawCommand INHERITED; | 528 typedef SkDrawCommand INHERITED; |
| 521 }; | 529 }; |
| 522 | 530 |
| 523 class SkSaveLayerCommand : public SkDrawCommand { | 531 class SkSaveLayerCommand : public SkDrawCommand { |
| 524 public: | 532 public: |
| 525 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint, | 533 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint, |
| 526 SkCanvas::SaveFlags flags); | 534 SkCanvas::SaveFlags flags); |
| 527 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 535 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 536 virtual void vizExecute(SkCanvas* canvas) SK_OVERRIDE; |
| 528 virtual void trackSaveState(int* state) SK_OVERRIDE; | 537 virtual void trackSaveState(int* state) SK_OVERRIDE; |
| 529 virtual Action action() const SK_OVERRIDE{ return kPush_Action; } | 538 virtual Action action() const SK_OVERRIDE{ return kPushLayer_Action; } |
| 530 virtual void setActive(bool active) SK_OVERRIDE { fActive = active; } | 539 virtual void setActive(bool active) SK_OVERRIDE { fActive = active; } |
| 531 virtual bool active() const SK_OVERRIDE { return fActive; } | 540 virtual bool active() const SK_OVERRIDE { return fActive; } |
| 532 | 541 |
| 533 const SkPaint* paint() const { return fPaintPtr; } | 542 const SkPaint* paint() const { return fPaintPtr; } |
| 534 | 543 |
| 535 private: | 544 private: |
| 536 SkRect fBounds; | 545 SkRect fBounds; |
| 537 SkPaint fPaint; | 546 SkPaint fPaint; |
| 538 SkPaint* fPaintPtr; | 547 SkPaint* fPaintPtr; |
| 539 SkCanvas::SaveFlags fFlags; | 548 SkCanvas::SaveFlags fFlags; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 SkScalar fDx; | 600 SkScalar fDx; |
| 592 SkScalar fDy; | 601 SkScalar fDy; |
| 593 | 602 |
| 594 typedef SkDrawCommand INHERITED; | 603 typedef SkDrawCommand INHERITED; |
| 595 }; | 604 }; |
| 596 | 605 |
| 597 class SkPushCullCommand : public SkDrawCommand { | 606 class SkPushCullCommand : public SkDrawCommand { |
| 598 public: | 607 public: |
| 599 SkPushCullCommand(const SkRect&); | 608 SkPushCullCommand(const SkRect&); |
| 600 virtual void execute(SkCanvas*) SK_OVERRIDE; | 609 virtual void execute(SkCanvas*) SK_OVERRIDE; |
| 601 | 610 virtual void vizExecute(SkCanvas* canvas) SK_OVERRIDE; |
| 611 virtual Action action() const { return kPushCull_Action; } |
| 612 virtual void setActive(bool active) { fActive = active; } |
| 613 virtual bool active() const { return fActive; } |
| 602 private: | 614 private: |
| 603 SkRect fCullRect; | 615 SkRect fCullRect; |
| 616 bool fActive; |
| 604 | 617 |
| 605 typedef SkDrawCommand INHERITED; | 618 typedef SkDrawCommand INHERITED; |
| 606 }; | 619 }; |
| 607 | 620 |
| 608 class SkPopCullCommand : public SkDrawCommand { | 621 class SkPopCullCommand : public SkDrawCommand { |
| 609 public: | 622 public: |
| 610 SkPopCullCommand(); | 623 SkPopCullCommand(); |
| 611 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; | 624 virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 612 | 625 virtual Action action() const { return kPopCull_Action; } |
| 613 private: | 626 private: |
| 614 typedef SkDrawCommand INHERITED; | 627 typedef SkDrawCommand INHERITED; |
| 615 }; | 628 }; |
| 616 | 629 |
| 617 #endif | 630 #endif |
| OLD | NEW |