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* createContext(SkCanvas*, void* storage) const
SK_OVERRIDE; |
98 virtual void init(SkCanvas*); | 98 |
99 virtual bool next(SkCanvas*, SkPaint* paint); | 99 virtual size_t contextSize() const SK_OVERRIDE { return sizeof(LayerDrawLoop
erContext); } |
100 | 100 |
101 SK_DEVELOPER_TO_STRING() | 101 SK_DEVELOPER_TO_STRING() |
102 | 102 |
103 /// Implements Flattenable. | 103 /// Implements Flattenable. |
104 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } | 104 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } |
105 static SkFlattenable* CreateProc(SkReadBuffer& buffer); | 105 static SkFlattenable* CreateProc(SkReadBuffer& buffer); |
106 | 106 |
107 protected: | 107 protected: |
108 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 108 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
109 | 109 |
110 private: | 110 private: |
111 struct Rec { | 111 struct Rec { |
112 Rec* fNext; | 112 Rec* fNext; |
113 SkPaint fPaint; | 113 SkPaint fPaint; |
114 LayerInfo fInfo; | 114 LayerInfo fInfo; |
115 }; | 115 }; |
116 Rec* fRecs; | 116 Rec* fRecs; |
117 Rec* fTopRec; | 117 Rec* fTopRec; |
118 int fCount; | 118 int fCount; |
119 | 119 |
120 // state-machine during the init/next cycle | 120 // state-machine during the init/next cycle |
121 Rec* fCurrRec; | 121 class LayerDrawLooperContext : public SkDrawLooper::Context { |
| 122 public: |
| 123 explicit LayerDrawLooperContext(const SkLayerDrawLooper* looper); |
122 | 124 |
123 static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&); | 125 protected: |
| 126 virtual bool next(SkCanvas*, SkPaint* paint) SK_OVERRIDE; |
| 127 |
| 128 private: |
| 129 Rec* fCurrRec; |
| 130 |
| 131 static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&
); |
| 132 }; |
124 | 133 |
125 class MyRegistrar : public SkFlattenable::Registrar { | 134 class MyRegistrar : public SkFlattenable::Registrar { |
126 public: | 135 public: |
127 MyRegistrar(); | 136 MyRegistrar(); |
128 }; | 137 }; |
129 | 138 |
130 typedef SkDrawLooper INHERITED; | 139 typedef SkDrawLooper INHERITED; |
131 | 140 |
132 public: | 141 public: |
133 class SK_API Builder { | 142 class SK_API Builder { |
(...skipping 28 matching lines...) Expand all Loading... |
162 SkLayerDrawLooper* detachLooper(); | 171 SkLayerDrawLooper* detachLooper(); |
163 | 172 |
164 private: | 173 private: |
165 Rec* fRecs; | 174 Rec* fRecs; |
166 Rec* fTopRec; | 175 Rec* fTopRec; |
167 int fCount; | 176 int fCount; |
168 }; | 177 }; |
169 }; | 178 }; |
170 | 179 |
171 #endif | 180 #endif |
OLD | NEW |