OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkLayerDrawLooper_DEFINED | 8 #ifndef SkLayerDrawLooper_DEFINED |
9 #define SkLayerDrawLooper_DEFINED | 9 #define SkLayerDrawLooper_DEFINED |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void addLayer(SkScalar dx, SkScalar dy); | 87 void addLayer(SkScalar dx, SkScalar dy); |
88 | 88 |
89 /** | 89 /** |
90 * This layer will with the original paint and no offset. | 90 * This layer will with the original paint and no offset. |
91 */ | 91 */ |
92 void addLayer() { this->addLayer(0, 0); } | 92 void addLayer() { this->addLayer(0, 0); } |
93 | 93 |
94 /// Similar to addLayer, but adds a layer to the top. | 94 /// Similar to addLayer, but adds a layer to the top. |
95 SkPaint* addLayerOnTop(const LayerInfo&); | 95 SkPaint* addLayerOnTop(const LayerInfo&); |
96 | 96 |
97 // overrides from SkDrawLooper | 97 virtual SkDrawLooper::Context* init( |
98 virtual void init(SkCanvas*); | 98 SkCanvas*, SkDrawLooper::ContextAllocator* allocator) const SK_OVERR
IDE; |
99 virtual bool next(SkCanvas*, SkPaint* paint); | |
100 | 99 |
101 SK_DEVELOPER_TO_STRING() | 100 SK_DEVELOPER_TO_STRING() |
102 | 101 |
103 /// Implements Flattenable. | 102 /// Implements Flattenable. |
104 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } | 103 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } |
105 static SkFlattenable* CreateProc(SkReadBuffer& buffer); | 104 static SkFlattenable* CreateProc(SkReadBuffer& buffer); |
106 | 105 |
107 protected: | 106 protected: |
108 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 107 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
109 | 108 |
110 private: | 109 private: |
111 struct Rec { | 110 struct Rec { |
112 Rec* fNext; | 111 Rec* fNext; |
113 SkPaint fPaint; | 112 SkPaint fPaint; |
114 LayerInfo fInfo; | 113 LayerInfo fInfo; |
115 }; | 114 }; |
116 Rec* fRecs; | 115 Rec* fRecs; |
117 Rec* fTopRec; | 116 Rec* fTopRec; |
118 int fCount; | 117 int fCount; |
119 | 118 |
120 // state-machine during the init/next cycle | 119 // state-machine during the init/next cycle |
121 Rec* fCurrRec; | 120 class LayerDrawLooperContext : public SkDrawLooper::Context { |
| 121 public: |
| 122 explicit LayerDrawLooperContext(const SkLayerDrawLooper* looper); |
122 | 123 |
123 static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&); | 124 protected: |
| 125 virtual bool next(SkCanvas*, SkPaint* paint) SK_OVERRIDE; |
| 126 |
| 127 private: |
| 128 Rec* fCurrRec; |
| 129 |
| 130 static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&
); |
| 131 }; |
124 | 132 |
125 class MyRegistrar : public SkFlattenable::Registrar { | 133 class MyRegistrar : public SkFlattenable::Registrar { |
126 public: | 134 public: |
127 MyRegistrar(); | 135 MyRegistrar(); |
128 }; | 136 }; |
129 | 137 |
130 typedef SkDrawLooper INHERITED; | 138 typedef SkDrawLooper INHERITED; |
131 | 139 |
132 public: | 140 public: |
133 class SK_API Builder { | 141 class SK_API Builder { |
(...skipping 28 matching lines...) Expand all Loading... |
162 SkLayerDrawLooper* detachLooper(); | 170 SkLayerDrawLooper* detachLooper(); |
163 | 171 |
164 private: | 172 private: |
165 Rec* fRecs; | 173 Rec* fRecs; |
166 Rec* fTopRec; | 174 Rec* fTopRec; |
167 int fCount; | 175 int fCount; |
168 }; | 176 }; |
169 }; | 177 }; |
170 | 178 |
171 #endif | 179 #endif |
OLD | NEW |