Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: include/effects/SkLayerDrawLooper.h

Issue 155513012: [WIP] Add Context to SkDrawLooper. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: static allocation of DrawContext; update rest of code. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void addLayer(SkScalar dx, SkScalar dy); 95 void addLayer(SkScalar dx, SkScalar dy);
96 96
97 /** 97 /**
98 * This layer will with the original paint and no offset. 98 * This layer will with the original paint and no offset.
99 */ 99 */
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 virtual SkDrawLooper::DrawContext* init(
106 virtual void init(SkCanvas*); 106 SkCanvas*, void* storage, size_t storageSize) const SK_OVERRIDE;
107 virtual bool next(SkCanvas*, SkPaint* paint);
108 107
109 SK_DEVELOPER_TO_STRING() 108 SK_DEVELOPER_TO_STRING()
110 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerDrawLooper) 109 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerDrawLooper)
111 110
112 protected: 111 protected:
113 SkLayerDrawLooper(SkReadBuffer&); 112 SkLayerDrawLooper(SkReadBuffer&);
114 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 113 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
115 114
116 private: 115 private:
117 struct Rec { 116 struct Rec {
118 Rec* fNext; 117 Rec* fNext;
119 SkPaint fPaint; 118 SkPaint fPaint;
120 LayerInfo fInfo; 119 LayerInfo fInfo;
121 }; 120 };
122 Rec* fRecs; 121 Rec* fRecs;
123 Rec* fTopRec; 122 Rec* fTopRec;
124 int fCount; 123 int fCount;
125 124
126 // state-machine during the init/next cycle 125 // state-machine during the init/next cycle
127 Rec* fCurrRec; 126 class LayerDrawLooperContext : public SkDrawLooper::DrawContext {
reed1 2014/02/07 14:46:02 Just for public brevity, can this definition be mo
Dominik Grewe 2014/02/07 16:59:17 If we move this definition out of the class scope
127 public:
128 explicit LayerDrawLooperContext(const SkLayerDrawLooper* looper);
128 129
129 static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&); 130 protected:
131 virtual bool next(SkCanvas*, SkPaint* paint) SK_OVERRIDE;
132
133 private:
134 Rec* fCurrRec;
135
136 static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo& );
137 };
130 138
131 class MyRegistrar : public SkFlattenable::Registrar { 139 class MyRegistrar : public SkFlattenable::Registrar {
132 public: 140 public:
133 MyRegistrar(); 141 MyRegistrar();
134 }; 142 };
135 143
136 typedef SkDrawLooper INHERITED; 144 typedef SkDrawLooper INHERITED;
137 }; 145 };
138 146
139 #endif 147 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698