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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 } | 128 } |
129 | 129 |
130 //////////////////////////////////////////////////////////////////////////////// /////////////////// | 130 //////////////////////////////////////////////////////////////////////////////// /////////////////// |
131 | 131 |
132 void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { | 132 void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { |
133 fCoordTransforms.push_back(transform); | 133 fCoordTransforms.push_back(transform); |
134 fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_G rCoordSet; | 134 fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_G rCoordSet; |
135 SkDEBUGCODE(transform->setInProcessor();) | 135 SkDEBUGCODE(transform->setInProcessor();) |
136 } | 136 } |
137 | 137 |
138 void GrFragmentProcessor::registerChildProcessor(GrFragmentProcessor* child) { | 138 int GrFragmentProcessor::registerChildProcessor(GrFragmentProcessor* child) { |
139 fChildProcessors.push_back(child); | 139 // Append the child's transforms to our transforms array and the child's tex tures array to our |
140 // textures array, and empty the child's arrays. | |
141 if (!child->fCoordTransforms.empty()) { | |
142 fCoordTransforms.push_back_n(child->fCoordTransforms.count(), | |
143 child->fCoordTransforms.begin()); | |
144 child->fCoordTransforms.reset(); | |
joshualitt
2015/08/12 14:49:52
I think we don't want to reset the child's data be
wangyix
2015/08/12 15:09:24
Done.
bsalomon
2015/08/12 15:14:22
sgtm
| |
145 } | |
146 if (!child->fTextureAccesses.empty()) { | |
147 fTextureAccesses.push_back_n(child->fTextureAccesses.count(), | |
148 child->fTextureAccesses.begin()); | |
149 child->fTextureAccesses.reset(); | |
150 } | |
151 | |
152 int index = fChildProcessors.count(); | |
153 fChildProcessors.push_back(GrFragmentStage(child)); | |
154 | |
155 SkDEBUGCODE(child->fIsChild = true); | |
156 | |
157 if (child->willReadFragmentPosition()) | |
158 this->setWillReadFragmentPosition(); | |
159 | |
160 return index; | |
140 } | 161 } |
141 | 162 |
142 bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con st { | 163 bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con st { |
143 if (fCoordTransforms.count() != that.fCoordTransforms.count()) { | 164 if (this->numTransforms() != that.numTransforms()) { |
144 return false; | 165 return false; |
145 } | 166 } |
146 int count = fCoordTransforms.count(); | 167 int count = this->numTransforms(); |
147 for (int i = 0; i < count; ++i) { | 168 for (int i = 0; i < count; ++i) { |
148 if (*fCoordTransforms[i] != *that.fCoordTransforms[i]) { | 169 if (this->coordTransform(i) != that.coordTransform(i)) { |
149 return false; | 170 return false; |
150 } | 171 } |
151 } | 172 } |
152 return true; | 173 return true; |
153 } | 174 } |
154 | 175 |
155 void GrFragmentProcessor::computeInvariantOutput(GrInvariantOutput* inout) const { | 176 void GrFragmentProcessor::computeInvariantOutput(GrInvariantOutput* inout) const { |
156 this->onComputeInvariantOutput(inout); | 177 this->onComputeInvariantOutput(inout); |
157 } | 178 } |
158 | 179 |
159 //////////////////////////////////////////////////////////////////////////////// /////////////////// | 180 //////////////////////////////////////////////////////////////////////////////// /////////////////// |
160 | 181 |
161 // Initial static variable from GrXPFactory | 182 // Initial static variable from GrXPFactory |
162 int32_t GrXPFactory::gCurrXPFClassID = | 183 int32_t GrXPFactory::gCurrXPFClassID = |
163 GrXPFactory::kIllegalXPFClassID; | 184 GrXPFactory::kIllegalXPFClassID; |
164 | 185 |
165 //////////////////////////////////////////////////////////////////////////////// /////////////////// | 186 //////////////////////////////////////////////////////////////////////////////// /////////////////// |
166 | 187 |
167 // GrProcessorDataManager lives in the same pool | 188 // GrProcessorDataManager lives in the same pool |
168 void* GrProcessorDataManager::operator new(size_t size) { | 189 void* GrProcessorDataManager::operator new(size_t size) { |
169 return MemoryPoolAccessor().pool()->allocate(size); | 190 return MemoryPoolAccessor().pool()->allocate(size); |
170 } | 191 } |
171 | 192 |
172 void GrProcessorDataManager::operator delete(void* target) { | 193 void GrProcessorDataManager::operator delete(void* target) { |
173 return MemoryPoolAccessor().pool()->release(target); | 194 return MemoryPoolAccessor().pool()->release(target); |
174 } | 195 } |
OLD | NEW |