OLD | NEW |
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 #include "GrPrimitiveProcessor.h" | 8 #include "GrPrimitiveProcessor.h" |
9 | 9 |
10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 /** | 31 /** |
32 * We specialize the vertex code for each of these matrix types. | 32 * We specialize the vertex code for each of these matrix types. |
33 */ | 33 */ |
34 enum MatrixType { | 34 enum MatrixType { |
35 kNoPersp_MatrixType = 0, | 35 kNoPersp_MatrixType = 0, |
36 kGeneral_MatrixType = 1, | 36 kGeneral_MatrixType = 1, |
37 }; | 37 }; |
38 | 38 |
39 uint32_t | 39 uint32_t |
40 GrPrimitiveProcessor::getTransformKey(const SkTArray<const GrCoordTransform*, tr
ue>& coords) const { | 40 GrPrimitiveProcessor::getTransformKey(const SkTArray<const GrCoordTransform*, tr
ue>& coords, |
| 41 int numCoords) const { |
41 uint32_t totalKey = 0; | 42 uint32_t totalKey = 0; |
42 for (int t = 0; t < coords.count(); ++t) { | 43 for (int t = 0; t < numCoords; ++t) { |
43 uint32_t key = 0; | 44 uint32_t key = 0; |
44 const GrCoordTransform* coordTransform = coords[t]; | 45 const GrCoordTransform* coordTransform = coords[t]; |
45 if (coordTransform->getMatrix().hasPerspective()) { | 46 if (coordTransform->getMatrix().hasPerspective()) { |
46 key |= kGeneral_MatrixType; | 47 key |= kGeneral_MatrixType; |
47 } else { | 48 } else { |
48 key |= kNoPersp_MatrixType; | 49 key |= kNoPersp_MatrixType; |
49 } | 50 } |
50 | 51 |
51 if (kLocal_GrCoordSet == coordTransform->sourceCoords() && | 52 if (kLocal_GrCoordSet == coordTransform->sourceCoords() && |
52 !this->hasExplicitLocalCoords()) { | 53 !this->hasExplicitLocalCoords()) { |
53 key |= kPositionCoords_Flag; | 54 key |= kPositionCoords_Flag; |
54 } else if (kDevice_GrCoordSet == coordTransform->sourceCoords()) { | 55 } else if (kDevice_GrCoordSet == coordTransform->sourceCoords()) { |
55 key |= kDeviceCoords_Flag; | 56 key |= kDeviceCoords_Flag; |
56 } | 57 } |
57 | 58 |
58 GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits)); | 59 GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits)); |
59 key |= (coordTransform->precision() << kPrecisionShift); | 60 key |= (coordTransform->precision() << kPrecisionShift); |
60 | 61 |
61 key <<= kTransformKeyBits * t; | 62 key <<= kTransformKeyBits * t; |
62 | 63 |
63 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to
overlap | 64 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to
overlap |
64 totalKey |= key; | 65 totalKey |= key; |
65 } | 66 } |
66 return totalKey; | 67 return totalKey; |
67 } | 68 } |
OLD | NEW |