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

Side by Side Diff: src/gpu/GrProgramDesc.h

Issue 755363002: remove proc key (Closed) Base URL: https://skia.googlesource.com/skia.git@fixkey
Patch Set: address nit Created 6 years 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
« no previous file with comments | « src/effects/gradients/SkTwoPointRadialGradient.cpp ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 GrProgramDesc_DEFINED 8 #ifndef GrProgramDesc_DEFINED
9 #define GrProgramDesc_DEFINED 9 #define GrProgramDesc_DEFINED
10 10
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 int numCoverageEffects() const { 133 int numCoverageEffects() const {
134 return this->header().fCoverageEffectCnt; 134 return this->header().fCoverageEffectCnt;
135 } 135 }
136 136
137 int numTotalEffects() const { return this->numColorEffects() + this->numCove rageEffects(); } 137 int numTotalEffects() const { return this->numColorEffects() + this->numCove rageEffects(); }
138 138
139 // This should really only be used internally, base classes should return th eir own headers 139 // This should really only be used internally, base classes should return th eir own headers
140 const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderO ffset>(); } 140 const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderO ffset>(); }
141 141
142 /** Used to provide effects' keys to their emitCode() function. */
143 class ProcKeyProvider {
144 public:
145 enum ProcessorType {
146 kGeometry_ProcessorType,
147 kFragment_ProcessorType,
148 };
149
150 ProcKeyProvider(const GrProgramDesc* desc, ProcessorType type, int effec tOffset)
151 : fDesc(desc), fBaseIndex(0), fEffectOffset(effectOffset) {
152 switch (type) {
153 case kGeometry_ProcessorType:
154 // there can be only one
155 fBaseIndex = 0;
156 break;
157 case kFragment_ProcessorType:
158 fBaseIndex = desc->hasGeometryProcessor() ? 1 : 0;
159 break;
160 }
161 }
162
163 GrProcessorKey get(int index) const {
164 const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t* >(
165 fDesc->fKey.begin() + fEffectOffset);
166 // We store two uint16_ts per effect, one for the offset to the effe ct's key and one for
167 // its length. Here we just need the offset.
168 uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0];
169 uint16_t length = offsetsAndLengths[2 * (fBaseIndex + index) + 1];
170 // Currently effects must add to the key in units of uint32_t.
171 SkASSERT(0 == (length % sizeof(uint32_t)));
172 return GrProcessorKey(reinterpret_cast<const uint32_t*>(fDesc->fKey. begin() + offset),
173 length / sizeof(uint32_t));
174 }
175 private:
176 const GrProgramDesc* fDesc;
177 int fBaseIndex;
178 int fEffectOffset;
179 };
180
181 // A struct to communicate descriptor information to the program descriptor builder 142 // A struct to communicate descriptor information to the program descriptor builder
182 struct DescInfo { 143 struct DescInfo {
183 int positionAttributeIndex() const { 144 int positionAttributeIndex() const {
184 return fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBin ding]; 145 return fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBin ding];
185 } 146 }
186 int localCoordAttributeIndex() const { 147 int localCoordAttributeIndex() const {
187 return fFixedFunctionVertexAttribIndices[kLocalCoord_GrVertexAttribB inding]; 148 return fFixedFunctionVertexAttribIndices[kLocalCoord_GrVertexAttribB inding];
188 } 149 }
189 int colorVertexAttributeIndex() const { 150 int colorVertexAttributeIndex() const {
190 return fFixedFunctionVertexAttribIndices[kColor_GrVertexAttribBindin g]; 151 return fFixedFunctionVertexAttribIndices[kColor_GrVertexAttribBindin g];
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 kPreAllocSize = kHeaderOffset + kHeaderSize + 221 kPreAllocSize = kHeaderOffset + kHeaderSize +
261 kMaxPreallocProcessors * sizeof(uint32_t) * kIntsPerProc essor, 222 kMaxPreallocProcessors * sizeof(uint32_t) * kIntsPerProc essor,
262 }; 223 };
263 224
264 SkSTArray<kPreAllocSize, uint8_t, true> fKey; 225 SkSTArray<kPreAllocSize, uint8_t, true> fKey;
265 226
266 friend class GrGLProgramDescBuilder; 227 friend class GrGLProgramDescBuilder;
267 }; 228 };
268 229
269 #endif 230 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointRadialGradient.cpp ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698