OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "GrProcessor.h" | 8 #include "GrProcessor.h" |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 for (int i = 0; i < this->numTextures(); ++i) { | 123 for (int i = 0; i < this->numTextures(); ++i) { |
124 if (this->textureAccess(i) != that.textureAccess(i)) { | 124 if (this->textureAccess(i) != that.textureAccess(i)) { |
125 return false; | 125 return false; |
126 } | 126 } |
127 } | 127 } |
128 return true; | 128 return true; |
129 } | 129 } |
130 | 130 |
131 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 131 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
132 | 132 |
| 133 GrFragmentProcessor::~GrFragmentProcessor() { |
| 134 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 135 fChildProcessors[i]->unref(); |
| 136 } |
| 137 } |
| 138 |
133 bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that, | 139 bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that, |
134 bool ignoreCoordTransforms) const { | 140 bool ignoreCoordTransforms) const { |
135 if (this->classID() != that.classID() || | 141 if (this->classID() != that.classID() || |
136 !this->hasSameTextureAccesses(that)) { | 142 !this->hasSameTextureAccesses(that)) { |
137 return false; | 143 return false; |
138 } | 144 } |
139 if (ignoreCoordTransforms) { | 145 if (ignoreCoordTransforms) { |
140 if (this->numTransforms() != that.numTransforms()) { | 146 if (this->numTransforms() != that.numTransforms()) { |
141 return false; | 147 return false; |
142 } | 148 } |
(...skipping 11 matching lines...) Expand all Loading... |
154 return false; | 160 return false; |
155 } | 161 } |
156 } | 162 } |
157 return true; | 163 return true; |
158 } | 164 } |
159 | 165 |
160 GrGLFragmentProcessor* GrFragmentProcessor::createGLInstance() const { | 166 GrGLFragmentProcessor* GrFragmentProcessor::createGLInstance() const { |
161 GrGLFragmentProcessor* glFragProc = this->onCreateGLInstance(); | 167 GrGLFragmentProcessor* glFragProc = this->onCreateGLInstance(); |
162 glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); | 168 glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); |
163 for (int i = 0; i < fChildProcessors.count(); ++i) { | 169 for (int i = 0; i < fChildProcessors.count(); ++i) { |
164 glFragProc->fChildProcessors[i] = fChildProcessors[i].processor()->creat
eGLInstance(); | 170 glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLInstance(
); |
165 } | 171 } |
166 return glFragProc; | 172 return glFragProc; |
167 } | 173 } |
168 | 174 |
169 void GrFragmentProcessor::addTextureAccess(const GrTextureAccess* textureAccess)
{ | 175 void GrFragmentProcessor::addTextureAccess(const GrTextureAccess* textureAccess)
{ |
170 // Can't add texture accesses after registering any children since their tex
ture accesses have | 176 // Can't add texture accesses after registering any children since their tex
ture accesses have |
171 // already been bubbled up into our fTextureAccesses array | 177 // already been bubbled up into our fTextureAccesses array |
172 SkASSERT(fChildProcessors.empty()); | 178 SkASSERT(fChildProcessors.empty()); |
173 | 179 |
174 INHERITED::addTextureAccess(textureAccess); | 180 INHERITED::addTextureAccess(textureAccess); |
(...skipping 17 matching lines...) Expand all Loading... |
192 if (!child->fCoordTransforms.empty()) { | 198 if (!child->fCoordTransforms.empty()) { |
193 fCoordTransforms.push_back_n(child->fCoordTransforms.count(), | 199 fCoordTransforms.push_back_n(child->fCoordTransforms.count(), |
194 child->fCoordTransforms.begin()); | 200 child->fCoordTransforms.begin()); |
195 } | 201 } |
196 if (!child->fTextureAccesses.empty()) { | 202 if (!child->fTextureAccesses.empty()) { |
197 fTextureAccesses.push_back_n(child->fTextureAccesses.count(), | 203 fTextureAccesses.push_back_n(child->fTextureAccesses.count(), |
198 child->fTextureAccesses.begin()); | 204 child->fTextureAccesses.begin()); |
199 } | 205 } |
200 | 206 |
201 int index = fChildProcessors.count(); | 207 int index = fChildProcessors.count(); |
202 fChildProcessors.push_back(GrFragmentStage(child)); | 208 fChildProcessors.push_back(SkRef(child)); |
203 | 209 |
204 if (child->willReadFragmentPosition()) { | 210 if (child->willReadFragmentPosition()) { |
205 this->setWillReadFragmentPosition(); | 211 this->setWillReadFragmentPosition(); |
206 } | 212 } |
207 | 213 |
208 if (child->usesLocalCoords()) { | 214 if (child->usesLocalCoords()) { |
209 fUsesLocalCoords = true; | 215 fUsesLocalCoords = true; |
210 } | 216 } |
211 | 217 |
212 return index; | 218 return index; |
(...skipping 25 matching lines...) Expand all Loading... |
238 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 244 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
239 | 245 |
240 // GrProcessorDataManager lives in the same pool | 246 // GrProcessorDataManager lives in the same pool |
241 void* GrProcessorDataManager::operator new(size_t size) { | 247 void* GrProcessorDataManager::operator new(size_t size) { |
242 return MemoryPoolAccessor().pool()->allocate(size); | 248 return MemoryPoolAccessor().pool()->allocate(size); |
243 } | 249 } |
244 | 250 |
245 void GrProcessorDataManager::operator delete(void* target) { | 251 void GrProcessorDataManager::operator delete(void* target) { |
246 return MemoryPoolAccessor().pool()->release(target); | 252 return MemoryPoolAccessor().pool()->release(target); |
247 } | 253 } |
OLD | NEW |