| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void addLayer() { this->addLayer(0, 0); } | 100 void addLayer() { this->addLayer(0, 0); } |
| 101 | 101 |
| 102 /// Similar to addLayer, but adds a layer to the top. | 102 /// Similar to addLayer, but adds a layer to the top. |
| 103 SkPaint* addLayerOnTop(const LayerInfo&); | 103 SkPaint* addLayerOnTop(const LayerInfo&); |
| 104 | 104 |
| 105 // overrides from SkDrawLooper | 105 // overrides from SkDrawLooper |
| 106 virtual void init(SkCanvas*); | 106 virtual void init(SkCanvas*); |
| 107 virtual bool next(SkCanvas*, SkPaint* paint); | 107 virtual bool next(SkCanvas*, SkPaint* paint); |
| 108 | 108 |
| 109 SK_DEVELOPER_TO_STRING() | 109 SK_DEVELOPER_TO_STRING() |
| 110 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerDrawLooper) | 110 |
| 111 /// Implements Flattenable. |
| 112 virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } |
| 113 static SkFlattenable* CreateProc(SkReadBuffer& buffer); |
| 111 | 114 |
| 112 protected: | 115 protected: |
| 113 SkLayerDrawLooper(SkReadBuffer&); | |
| 114 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 116 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 115 | 117 |
| 116 private: | 118 private: |
| 117 struct Rec { | 119 struct Rec { |
| 118 Rec* fNext; | 120 Rec* fNext; |
| 119 SkPaint fPaint; | 121 SkPaint fPaint; |
| 120 LayerInfo fInfo; | 122 LayerInfo fInfo; |
| 121 }; | 123 }; |
| 122 Rec* fRecs; | 124 Rec* fRecs; |
| 123 Rec* fTopRec; | 125 Rec* fTopRec; |
| 124 int fCount; | 126 int fCount; |
| 125 | 127 |
| 126 // state-machine during the init/next cycle | 128 // state-machine during the init/next cycle |
| 127 Rec* fCurrRec; | 129 Rec* fCurrRec; |
| 128 | 130 |
| 129 static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&); | 131 static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&); |
| 130 | 132 |
| 131 class MyRegistrar : public SkFlattenable::Registrar { | 133 class MyRegistrar : public SkFlattenable::Registrar { |
| 132 public: | 134 public: |
| 133 MyRegistrar(); | 135 MyRegistrar(); |
| 134 }; | 136 }; |
| 135 | 137 |
| 136 typedef SkDrawLooper INHERITED; | 138 typedef SkDrawLooper INHERITED; |
| 139 |
| 140 public: |
| 141 class SK_API Builder { |
| 142 public: |
| 143 Builder(); |
| 144 ~Builder(); |
| 145 |
| 146 /** |
| 147 * Call for each layer you want to add (from top to bottom). |
| 148 * This returns a paint you can modify, but that ptr is only valid unti
l |
| 149 * the next call made to addLayer(). |
| 150 */ |
| 151 SkPaint* addLayer(const LayerInfo&); |
| 152 |
| 153 /** |
| 154 * This layer will draw with the original paint, at the specified offse
t |
| 155 */ |
| 156 void addLayer(SkScalar dx, SkScalar dy); |
| 157 |
| 158 /** |
| 159 * This layer will with the original paint and no offset. |
| 160 */ |
| 161 void addLayer() { this->addLayer(0, 0); } |
| 162 |
| 163 /// Similar to addLayer, but adds a layer to the top. |
| 164 SkPaint* addLayerOnTop(const LayerInfo&); |
| 165 |
| 166 /** |
| 167 * Pass list of layers on to newly built looper and return it. This wil
l |
| 168 * also reset the builder, so it can be used to build another looper. |
| 169 */ |
| 170 SkLayerDrawLooper* detachLooper(); |
| 171 |
| 172 private: |
| 173 Rec* fRecs; |
| 174 Rec* fTopRec; |
| 175 int fCount; |
| 176 }; |
| 137 }; | 177 }; |
| 138 | 178 |
| 139 #endif | 179 #endif |
| OLD | NEW |