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 28 matching lines...) Expand all Loading... |
39 const SkTDArray<SkString*>* Info() const { return &fInfo; } | 39 const SkTDArray<SkString*>* Info() const { return &fInfo; } |
40 virtual void execute(SkCanvas*) const = 0; | 40 virtual void execute(SkCanvas*) const = 0; |
41 virtual void vizExecute(SkCanvas*) const {} | 41 virtual void vizExecute(SkCanvas*) const {} |
42 | 42 |
43 virtual void setUserMatrix(const SkMatrix&) {} | 43 virtual void setUserMatrix(const SkMatrix&) {} |
44 | 44 |
45 /** Does nothing by default, but used by save() and restore()-type | 45 /** Does nothing by default, but used by save() and restore()-type |
46 subclasses to track unresolved save() calls. */ | 46 subclasses to track unresolved save() calls. */ |
47 virtual void trackSaveState(int* state) {} | 47 virtual void trackSaveState(int* state) {} |
48 | 48 |
49 // The next "active" system is only used by save, saveLayer, restore, | 49 // The next "active" system is only used by save, saveLayer, and restore. |
50 // pushCull and popCull. It is used in two ways: | 50 // It is used to determine which saveLayers are currently active (at a |
51 // To determine which saveLayers are currently active (at a | |
52 // given point in the rendering). | 51 // given point in the rendering). |
53 // saves just return a kPushLayer action but don't track active state | 52 // saves just return a kPushLayer action but don't track active state |
54 // restores just return a kPopLayer action | 53 // restores just return a kPopLayer action |
55 // saveLayers return kPushLayer but also track the active state | 54 // saveLayers return kPushLayer but also track the active state |
56 // To determine which culls are currently active (at a given point) | |
57 // in the rendering). | |
58 // pushCulls return a kPushCull action | |
59 // popCulls return a kPopCull action | |
60 enum Action { | 55 enum Action { |
61 kNone_Action, | 56 kNone_Action, |
62 kPopLayer_Action, | 57 kPopLayer_Action, |
63 kPushLayer_Action, | 58 kPushLayer_Action, |
64 kPopCull_Action, | |
65 kPushCull_Action | |
66 }; | 59 }; |
67 virtual Action action() const { return kNone_Action; } | 60 virtual Action action() const { return kNone_Action; } |
68 virtual void setActive(bool active) {} | 61 virtual void setActive(bool active) {} |
69 virtual bool active() const { return false; } | 62 virtual bool active() const { return false; } |
70 | 63 |
71 DrawType getType() const { return fDrawType; } | 64 DrawType getType() const { return fDrawType; } |
72 | 65 |
73 virtual bool render(SkCanvas* canvas) const { return false; } | 66 virtual bool render(SkCanvas* canvas) const { return false; } |
74 | 67 |
75 static const char* GetCommandString(DrawType type); | 68 static const char* GetCommandString(DrawType type); |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 SkScalar x() const { return fDx; } | 599 SkScalar x() const { return fDx; } |
607 SkScalar y() const { return fDy; } | 600 SkScalar y() const { return fDy; } |
608 | 601 |
609 private: | 602 private: |
610 SkScalar fDx; | 603 SkScalar fDx; |
611 SkScalar fDy; | 604 SkScalar fDy; |
612 | 605 |
613 typedef SkDrawCommand INHERITED; | 606 typedef SkDrawCommand INHERITED; |
614 }; | 607 }; |
615 | 608 |
616 class SkPushCullCommand : public SkDrawCommand { | |
617 public: | |
618 SkPushCullCommand(const SkRect&); | |
619 virtual void execute(SkCanvas*) const SK_OVERRIDE; | |
620 virtual void vizExecute(SkCanvas* canvas) const SK_OVERRIDE; | |
621 virtual Action action() const { return kPushCull_Action; } | |
622 virtual void setActive(bool active) { fActive = active; } | |
623 virtual bool active() const { return fActive; } | |
624 private: | |
625 SkRect fCullRect; | |
626 bool fActive; | |
627 | |
628 typedef SkDrawCommand INHERITED; | |
629 }; | |
630 | |
631 class SkPopCullCommand : public SkDrawCommand { | |
632 public: | |
633 SkPopCullCommand(); | |
634 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE; | |
635 virtual Action action() const { return kPopCull_Action; } | |
636 private: | |
637 typedef SkDrawCommand INHERITED; | |
638 }; | |
639 | |
640 #endif | 609 #endif |
OLD | NEW |