OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "GrGLProgramDesc.h" | 7 #include "GrGLProgramDesc.h" |
8 | 8 |
9 #include "GrGLProcessor.h" | 9 #include "GrGLProcessor.h" |
10 #include "GrBackendProcessorFactory.h" | 10 #include "GrBackendProcessorFactory.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 GrProcessorKeyBuilder* b, | 168 GrProcessorKeyBuilder* b, |
169 uint16_t* keySize) { | 169 uint16_t* keySize) { |
170 /* 0 because no attribs on a fP */ | 170 /* 0 because no attribs on a fP */ |
171 return get_meta_key(*fps.getProcessor(), caps, gen_transform_key(fps, us
eLocalCoords), 0, | 171 return get_meta_key(*fps.getProcessor(), caps, gen_transform_key(fps, us
eLocalCoords), 0, |
172 b, keySize); | 172 b, keySize); |
173 } | 173 } |
174 }; | 174 }; |
175 | 175 |
176 | 176 |
177 template <class ProcessorKeyBuilder> | 177 template <class ProcessorKeyBuilder> |
178 bool | 178 bool GrGLProgramDescBuilder::BuildStagedProcessorKey( |
179 GrGLProgramDescBuilder::BuildStagedProcessorKey(const typename ProcessorKeyBuild
er::StagedProcessor& stage, | 179 const typename ProcessorKeyBuilder::StagedProcessor& stage, |
180 const GrGLCaps& caps, | 180 const GrGLCaps& caps, |
181 bool requiresLocalCoordAttrib, | 181 bool requiresLocalCoordAttrib, |
182 GrProgramDesc* desc, | 182 GrProgramDesc* desc, |
183 int* offsetAndSizeIndex) { | 183 int* offsetAndSizeIndex) { |
184 GrProcessorKeyBuilder b(&desc->fKey); | 184 GrProcessorKeyBuilder b(&desc->fKey); |
185 uint16_t processorKeySize; | 185 uint16_t processorKeySize; |
186 uint32_t processorOffset = desc->fKey.count(); | 186 uint32_t processorOffset = desc->fKey.count(); |
187 if (processorOffset > SK_MaxU16 || | 187 if (processorOffset > SK_MaxU16 || |
188 !ProcessorKeyBuilder::GetProcessorKey(stage, caps, requiresLocalCoor
dAttrib, &b, | 188 !ProcessorKeyBuilder::GetProcessorKey(stage, caps, requiresLocalCoor
dAttrib, &b, |
189 &processorKeySize)){ | 189 &processorKeySize)){ |
190 desc->fKey.reset(); | 190 desc->fKey.reset(); |
191 return false; | 191 return false; |
192 } | 192 } |
193 | 193 |
194 uint16_t* offsetAndSize = | 194 uint16_t* offsetAndSize = |
195 reinterpret_cast<uint16_t*>(desc->fKey.begin() + kProcessorKeyOffset
sAndLengthOffset + | 195 reinterpret_cast<uint16_t*>(desc->fKey.begin() + kProcessorKeyOffset
sAndLengthOffset + |
196 *offsetAndSizeIndex * 2 * sizeof(uint16_
t)); | 196 *offsetAndSizeIndex * 2 * sizeof(uint16_
t)); |
197 offsetAndSize[0] = SkToU16(processorOffset); | 197 offsetAndSize[0] = SkToU16(processorOffset); |
198 offsetAndSize[1] = processorKeySize; | 198 offsetAndSize[1] = processorKeySize; |
199 ++(*offsetAndSizeIndex); | 199 ++(*offsetAndSizeIndex); |
200 return true; | 200 return true; |
201 } | 201 } |
202 | 202 |
203 bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState, | 203 bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState, |
204 const GrProgramDesc::DescInfo& descInfo, | 204 const GrProgramDesc::DescInfo& descInfo, |
205 GrGpu::DrawType drawType, | 205 GrGpu::DrawType drawType, |
206 GrGpuGL* gpu, | 206 GrGpuGL* gpu, |
207 const GrDeviceCoordTexture* dstCopy, | 207 const GrDeviceCoordTexture* dstCopy, |
208 GrProgramDesc* desc) { | 208 GrProgramDesc* desc) { |
209 bool inputColorIsUsed = descInfo.fInputColorIsUsed; | 209 bool inputColorIsUsed = descInfo.fInputColorIsUsed; |
210 bool inputCoverageIsUsed = descInfo.fInputCoverageIsUsed; | 210 bool inputCoverageIsUsed = descInfo.fInputCoverageIsUsed; |
211 | 211 |
212 // The descriptor is used as a cache key. Thus when a field of the | 212 // The descriptor is used as a cache key. Thus when a field of the |
213 // descriptor will not affect program generation (because of the attribute | 213 // descriptor will not affect program generation (because of the attribute |
214 // bindings in use or other descriptor field settings) it should be set | 214 // bindings in use or other descriptor field settings) it should be set |
215 // to a canonical value to avoid duplicate programs with different keys. | 215 // to a canonical value to avoid duplicate programs with different keys. |
216 | 216 |
217 bool requiresLocalCoordAttrib = descInfo.fRequiresLocalCoordAttrib; | 217 bool requiresLocalCoordAttrib = descInfo.fRequiresLocalCoordAttrib; |
218 | 218 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 340 } |
341 | 341 |
342 header->fPrimaryOutputType = descInfo.fPrimaryOutputType; | 342 header->fPrimaryOutputType = descInfo.fPrimaryOutputType; |
343 header->fSecondaryOutputType = descInfo.fSecondaryOutputType; | 343 header->fSecondaryOutputType = descInfo.fSecondaryOutputType; |
344 | 344 |
345 header->fColorEffectCnt = optState.numColorStages(); | 345 header->fColorEffectCnt = optState.numColorStages(); |
346 header->fCoverageEffectCnt = optState.numCoverageStages(); | 346 header->fCoverageEffectCnt = optState.numCoverageStages(); |
347 desc->finalize(); | 347 desc->finalize(); |
348 return true; | 348 return true; |
349 } | 349 } |
OLD | NEW |