| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 const GrGeometryProcessor::VertexAttribArray& vars = proc.getVertexAttribs()
; | 66 const GrGeometryProcessor::VertexAttribArray& vars = proc.getVertexAttribs()
; |
| 67 int numAttributes = vars.count(); | 67 int numAttributes = vars.count(); |
| 68 SkASSERT(numAttributes <= 2); | 68 SkASSERT(numAttributes <= 2); |
| 69 for (int a = 0; a < numAttributes; ++a) { | 69 for (int a = 0; a < numAttributes; ++a) { |
| 70 uint32_t value = 1 << a; | 70 uint32_t value = 1 << a; |
| 71 key |= value; | 71 key |= value; |
| 72 } | 72 } |
| 73 return key; | 73 return key; |
| 74 } | 74 } |
| 75 | 75 |
| 76 static uint32_t gen_transform_key(const GrFragmentStage& effectStage, | 76 static uint32_t gen_transform_key(const GrPendingFragmentStage& stage, |
| 77 bool useExplicitLocalCoords) { | 77 bool useExplicitLocalCoords) { |
| 78 uint32_t totalKey = 0; | 78 uint32_t totalKey = 0; |
| 79 int numTransforms = effectStage.getProcessor()->numTransforms(); | 79 int numTransforms = stage.getProcessor()->numTransforms(); |
| 80 for (int t = 0; t < numTransforms; ++t) { | 80 for (int t = 0; t < numTransforms; ++t) { |
| 81 uint32_t key = 0; | 81 uint32_t key = 0; |
| 82 if (effectStage.isPerspectiveCoordTransform(t, useExplicitLocalCoords))
{ | 82 if (stage.isPerspectiveCoordTransform(t)) { |
| 83 key |= kGeneral_MatrixType; | 83 key |= kGeneral_MatrixType; |
| 84 } else { | 84 } else { |
| 85 key |= kNoPersp_MatrixType; | 85 key |= kNoPersp_MatrixType; |
| 86 } | 86 } |
| 87 | 87 |
| 88 const GrCoordTransform& coordTransform = effectStage.getProcessor()->coo
rdTransform(t); | 88 const GrCoordTransform& coordTransform = stage.getProcessor()->coordTran
sform(t); |
| 89 if (kLocal_GrCoordSet != coordTransform.sourceCoords() && useExplicitLoc
alCoords) { | 89 if (kLocal_GrCoordSet != coordTransform.sourceCoords() && useExplicitLoc
alCoords) { |
| 90 key |= kPositionCoords_Flag; | 90 key |= kPositionCoords_Flag; |
| 91 } | 91 } |
| 92 key <<= kTransformKeyBits * t; | 92 key <<= kTransformKeyBits * t; |
| 93 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to
overlap | 93 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to
overlap |
| 94 totalKey |= key; | 94 totalKey |= key; |
| 95 } | 95 } |
| 96 return totalKey; | 96 return totalKey; |
| 97 } | 97 } |
| 98 | 98 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 const GrGLCaps& caps, | 154 const GrGLCaps& caps, |
| 155 bool, | 155 bool, |
| 156 GrProcessorKeyBuilder* b, | 156 GrProcessorKeyBuilder* b, |
| 157 uint16_t* keySize) { | 157 uint16_t* keySize) { |
| 158 /* 0 because no transforms on a GP */ | 158 /* 0 because no transforms on a GP */ |
| 159 return get_meta_key(gp, caps, 0, gen_attrib_key(gp), b, keySize); | 159 return get_meta_key(gp, caps, 0, gen_attrib_key(gp), b, keySize); |
| 160 } | 160 } |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 struct FragmentProcessorKeyBuilder { | 163 struct FragmentProcessorKeyBuilder { |
| 164 typedef GrFragmentStage StagedProcessor; | 164 typedef GrPendingFragmentStage StagedProcessor; |
| 165 static bool GetProcessorKey(const GrFragmentStage& fps, | 165 static bool GetProcessorKey(const GrPendingFragmentStage& fps, |
| 166 const GrGLCaps& caps, | 166 const GrGLCaps& caps, |
| 167 bool useLocalCoords, | 167 bool useLocalCoords, |
| 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 |
| (...skipping 164 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 |