| 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 "GrProcessor.h" | 10 #include "GrProcessor.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 /** | 62 /** |
| 63 * We specialize the vertex code for each of these matrix types. | 63 * We specialize the vertex code for each of these matrix types. |
| 64 */ | 64 */ |
| 65 enum MatrixType { | 65 enum MatrixType { |
| 66 kNoPersp_MatrixType = 0, | 66 kNoPersp_MatrixType = 0, |
| 67 kGeneral_MatrixType = 1, | 67 kGeneral_MatrixType = 1, |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 static uint32_t gen_transform_key(const GrPendingFragmentStage& stage, bool useE
xplicitLocalCoords) { | 70 static uint32_t gen_transform_key(const GrPendingFragmentStage& stage, bool useE
xplicitLocalCoords) { |
| 71 uint32_t totalKey = 0; | 71 uint32_t totalKey = 0; |
| 72 int numTransforms = stage.getProcessor()->numTransforms(); | 72 int numTransforms = stage.processor()->numTransforms(); |
| 73 for (int t = 0; t < numTransforms; ++t) { | 73 for (int t = 0; t < numTransforms; ++t) { |
| 74 uint32_t key = 0; | 74 uint32_t key = 0; |
| 75 if (stage.isPerspectiveCoordTransform(t)) { | 75 if (stage.isPerspectiveCoordTransform(t)) { |
| 76 key |= kGeneral_MatrixType; | 76 key |= kGeneral_MatrixType; |
| 77 } else { | 77 } else { |
| 78 key |= kNoPersp_MatrixType; | 78 key |= kNoPersp_MatrixType; |
| 79 } | 79 } |
| 80 | 80 |
| 81 const GrCoordTransform& coordTransform = stage.getProcessor()->coordTran
sform(t); | 81 const GrCoordTransform& coordTransform = stage.processor()->coordTransfo
rm(t); |
| 82 if (kLocal_GrCoordSet == coordTransform.sourceCoords() && !useExplicitLo
calCoords) { | 82 if (kLocal_GrCoordSet == coordTransform.sourceCoords() && !useExplicitLo
calCoords) { |
| 83 key |= kPositionCoords_Flag; | 83 key |= kPositionCoords_Flag; |
| 84 } else if (kDevice_GrCoordSet == coordTransform.sourceCoords()) { | 84 } else if (kDevice_GrCoordSet == coordTransform.sourceCoords()) { |
| 85 key |= kDeviceCoords_Flag; | 85 key |= kDeviceCoords_Flag; |
| 86 } | 86 } |
| 87 | 87 |
| 88 GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits)); | 88 GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits)); |
| 89 key |= (coordTransform.precision() << kPrecisionShift); | 89 key |= (coordTransform.precision() << kPrecisionShift); |
| 90 | 90 |
| 91 key <<= kTransformKeyBits * t; | 91 key <<= kTransformKeyBits * t; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 const GrPrimitiveProcessor& primProc = *optState.getPrimitiveProcessor(); | 164 const GrPrimitiveProcessor& primProc = *optState.getPrimitiveProcessor(); |
| 165 primProc.getGLProcessorKey(optState.getBatchTracker(), gpu->glCaps(), &b); | 165 primProc.getGLProcessorKey(optState.getBatchTracker(), gpu->glCaps(), &b); |
| 166 if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) { | 166 if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) { |
| 167 desc->fKey.reset(); | 167 desc->fKey.reset(); |
| 168 return false; | 168 return false; |
| 169 } | 169 } |
| 170 | 170 |
| 171 for (int s = 0; s < optState.numFragmentStages(); ++s) { | 171 for (int s = 0; s < optState.numFragmentStages(); ++s) { |
| 172 const GrPendingFragmentStage& fps = optState.getFragmentStage(s); | 172 const GrPendingFragmentStage& fps = optState.getFragmentStage(s); |
| 173 const GrFragmentProcessor& fp = *fps.getProcessor(); | 173 const GrFragmentProcessor& fp = *fps.processor(); |
| 174 fp.getGLProcessorKey(gpu->glCaps(), &b); | 174 fp.getGLProcessorKey(gpu->glCaps(), &b); |
| 175 if (!get_meta_key(fp, gpu->glCaps(), | 175 if (!get_meta_key(fp, gpu->glCaps(), |
| 176 gen_transform_key(fps, requiresLocalCoordAttrib), &b))
{ | 176 gen_transform_key(fps, requiresLocalCoordAttrib), &b))
{ |
| 177 desc->fKey.reset(); | 177 desc->fKey.reset(); |
| 178 return false; | 178 return false; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 const GrXferProcessor& xp = *optState.getXferProcessor(); | 182 const GrXferProcessor& xp = *optState.getXferProcessor(); |
| 183 xp.getGLProcessorKey(gpu->glCaps(), &b); | 183 xp.getGLProcessorKey(gpu->glCaps(), &b); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 gpu->glCaps())
; | 222 gpu->glCaps())
; |
| 223 } else { | 223 } else { |
| 224 header->fFragPosKey = 0; | 224 header->fFragPosKey = 0; |
| 225 } | 225 } |
| 226 | 226 |
| 227 header->fColorEffectCnt = optState.numColorStages(); | 227 header->fColorEffectCnt = optState.numColorStages(); |
| 228 header->fCoverageEffectCnt = optState.numCoverageStages(); | 228 header->fCoverageEffectCnt = optState.numCoverageStages(); |
| 229 desc->finalize(); | 229 desc->finalize(); |
| 230 return true; | 230 return true; |
| 231 } | 231 } |
| OLD | NEW |