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