| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 * that indicates the source of the input coords. | 45 * that indicates the source of the input coords. |
| 46 */ | 46 */ |
| 47 enum { | 47 enum { |
| 48 kMatrixTypeKeyBits = 1, | 48 kMatrixTypeKeyBits = 1, |
| 49 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1, | 49 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1, |
| 50 | 50 |
| 51 kPrecisionBits = 2, | 51 kPrecisionBits = 2, |
| 52 kPrecisionShift = kMatrixTypeKeyBits, | 52 kPrecisionShift = kMatrixTypeKeyBits, |
| 53 | 53 |
| 54 kPositionCoords_Flag = (1 << (kPrecisionShift + kPrecisionBits)), | 54 kPositionCoords_Flag = (1 << (kPrecisionShift + kPrecisionBits)), |
| 55 kDeviceCoords_Flag = kPositionCoords_Flag + kPositionCoords_Flag, |
| 55 | 56 |
| 56 kTransformKeyBits = kMatrixTypeKeyBits + kPrecisionBits + 1, | 57 kTransformKeyBits = kMatrixTypeKeyBits + kPrecisionBits + 2, |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 GR_STATIC_ASSERT(kHigh_GrSLPrecision < (1 << kPrecisionBits)); | 60 GR_STATIC_ASSERT(kHigh_GrSLPrecision < (1 << kPrecisionBits)); |
| 60 | 61 |
| 61 /** | 62 /** |
| 62 * We specialize the vertex code for each of these matrix types. | 63 * We specialize the vertex code for each of these matrix types. |
| 63 */ | 64 */ |
| 64 enum MatrixType { | 65 enum MatrixType { |
| 65 kNoPersp_MatrixType = 0, | 66 kNoPersp_MatrixType = 0, |
| 66 kGeneral_MatrixType = 1, | 67 kGeneral_MatrixType = 1, |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 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) { |
| 70 uint32_t totalKey = 0; | 71 uint32_t totalKey = 0; |
| 71 int numTransforms = stage.getProcessor()->numTransforms(); | 72 int numTransforms = stage.getProcessor()->numTransforms(); |
| 72 for (int t = 0; t < numTransforms; ++t) { | 73 for (int t = 0; t < numTransforms; ++t) { |
| 73 uint32_t key = 0; | 74 uint32_t key = 0; |
| 74 if (stage.isPerspectiveCoordTransform(t)) { | 75 if (stage.isPerspectiveCoordTransform(t)) { |
| 75 key |= kGeneral_MatrixType; | 76 key |= kGeneral_MatrixType; |
| 76 } else { | 77 } else { |
| 77 key |= kNoPersp_MatrixType; | 78 key |= kNoPersp_MatrixType; |
| 78 } | 79 } |
| 79 | 80 |
| 80 const GrCoordTransform& coordTransform = stage.getProcessor()->coordTran
sform(t); | 81 const GrCoordTransform& coordTransform = stage.getProcessor()->coordTran
sform(t); |
| 81 if (kLocal_GrCoordSet != coordTransform.sourceCoords() && useExplicitLoc
alCoords) { | 82 if (kLocal_GrCoordSet == coordTransform.sourceCoords() && !useExplicitLo
calCoords) { |
| 82 key |= kPositionCoords_Flag; | 83 key |= kPositionCoords_Flag; |
| 84 } else if (kDevice_GrCoordSet == coordTransform.sourceCoords()) { |
| 85 key |= kDeviceCoords_Flag; |
| 83 } | 86 } |
| 84 | 87 |
| 85 GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits)); | 88 GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits)); |
| 86 key |= (coordTransform.precision() << kPrecisionShift); | 89 key |= (coordTransform.precision() << kPrecisionShift); |
| 87 | 90 |
| 88 key <<= kTransformKeyBits * t; | 91 key <<= kTransformKeyBits * t; |
| 89 | 92 |
| 90 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 |
| 91 totalKey |= key; | 94 totalKey |= key; |
| 92 } | 95 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 gpu->glCaps())
; | 222 gpu->glCaps())
; |
| 220 } else { | 223 } else { |
| 221 header->fFragPosKey = 0; | 224 header->fFragPosKey = 0; |
| 222 } | 225 } |
| 223 | 226 |
| 224 header->fColorEffectCnt = optState.numColorStages(); | 227 header->fColorEffectCnt = optState.numColorStages(); |
| 225 header->fCoverageEffectCnt = optState.numCoverageStages(); | 228 header->fCoverageEffectCnt = optState.numCoverageStages(); |
| 226 desc->finalize(); | 229 desc->finalize(); |
| 227 return true; | 230 return true; |
| 228 } | 231 } |
| OLD | NEW |