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 | 7 |
8 #include "GrPathProcessor.h" | 8 #include "GrPathProcessor.h" |
9 | 9 |
10 #include "gl/GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 pd.set4fv(fColorUniform, 1, c); | 89 pd.set4fv(fColorUniform, 1, c); |
90 fColor = pathProc.color(); | 90 fColor = pathProc.color(); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 void setTransformData(const GrPrimitiveProcessor& primProc, | 94 void setTransformData(const GrPrimitiveProcessor& primProc, |
95 const GrGLSLProgramDataManager& pdman, | 95 const GrGLSLProgramDataManager& pdman, |
96 int index, | 96 int index, |
97 const SkTArray<const GrCoordTransform*, true>& coordTr
ansforms) override { | 97 const SkTArray<const GrCoordTransform*, true>& coordTr
ansforms) override { |
98 const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); | 98 const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); |
99 SkSTArray<2, VaryingTransform, true>& transforms = fInstalledTransforms[
index]; | 99 SkTArray<TransformVarying, true>& transforms = fInstalledTransforms[inde
x]; |
100 int numTransforms = transforms.count(); | 100 int numTransforms = transforms.count(); |
101 for (int t = 0; t < numTransforms; ++t) { | 101 for (int t = 0; t < numTransforms; ++t) { |
102 SkASSERT(transforms[t].fHandle.isValid()); | 102 SkASSERT(transforms[t].fHandle.isValid()); |
103 const SkMatrix& transform = GetTransformMatrix(pathProc.localMatrix(
), | 103 const SkMatrix& transform = GetTransformMatrix(pathProc.localMatrix(
), |
104 *coordTransforms[t]); | 104 *coordTransforms[t]); |
105 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { | 105 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { |
106 continue; | 106 continue; |
107 } | 107 } |
108 transforms[t].fCurrentValue = transform; | 108 transforms[t].fCurrentValue = transform; |
109 | 109 |
110 SkASSERT(transforms[t].fType == kVec2f_GrSLType || | 110 SkASSERT(transforms[t].fType == kVec2f_GrSLType || |
111 transforms[t].fType == kVec3f_GrSLType); | 111 transforms[t].fType == kVec3f_GrSLType); |
112 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3
; | 112 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3
; |
113 pdman.setPathFragmentInputTransform(transforms[t].fHandle, component
s, transform); | 113 pdman.setPathFragmentInputTransform(transforms[t].fHandle, component
s, transform); |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 private: | 117 private: |
118 typedef GrGLSLProgramDataManager::VaryingHandle VaryingHandle; | 118 typedef GrGLSLProgramDataManager::VaryingHandle VaryingHandle; |
119 struct VaryingTransform : public Transform { | 119 struct TransformVarying { |
120 VaryingTransform() : Transform() {} | |
121 VaryingHandle fHandle; | 120 VaryingHandle fHandle; |
| 121 SkMatrix fCurrentValue = SkMatrix::InvalidMatrix(); |
| 122 GrSLType fType = kVoid_GrSLType; |
122 }; | 123 }; |
123 | 124 |
124 SkSTArray<8, SkSTArray<2, VaryingTransform, true> > fInstalledTransforms; | 125 SkSTArray<8, SkSTArray<2, TransformVarying, true> > fInstalledTransforms; |
125 | 126 |
126 UniformHandle fColorUniform; | 127 UniformHandle fColorUniform; |
127 GrColor fColor; | 128 GrColor fColor; |
128 | 129 |
129 typedef GrGLSLPrimitiveProcessor INHERITED; | 130 typedef GrGLSLPrimitiveProcessor INHERITED; |
130 }; | 131 }; |
131 | 132 |
132 GrPathProcessor::GrPathProcessor(GrColor color, | 133 GrPathProcessor::GrPathProcessor(GrColor color, |
133 const GrXPOverridesForBatch& overrides, | 134 const GrXPOverridesForBatch& overrides, |
134 const SkMatrix& viewMatrix, | 135 const SkMatrix& viewMatrix, |
135 const SkMatrix& localMatrix) | 136 const SkMatrix& localMatrix) |
136 : fColor(color) | 137 : fColor(color) |
137 , fViewMatrix(viewMatrix) | 138 , fViewMatrix(viewMatrix) |
138 , fLocalMatrix(localMatrix) | 139 , fLocalMatrix(localMatrix) |
139 , fOverrides(overrides) { | 140 , fOverrides(overrides) { |
140 this->initClassID<GrPathProcessor>(); | 141 this->initClassID<GrPathProcessor>(); |
141 } | 142 } |
142 | 143 |
143 void GrPathProcessor::getGLSLProcessorKey(const GrGLSLCaps& caps, | 144 void GrPathProcessor::getGLSLProcessorKey(const GrGLSLCaps& caps, |
144 GrProcessorKeyBuilder* b) const { | 145 GrProcessorKeyBuilder* b) const { |
145 GrGLPathProcessor::GenKey(*this, caps, b); | 146 GrGLPathProcessor::GenKey(*this, caps, b); |
146 } | 147 } |
147 | 148 |
148 GrGLSLPrimitiveProcessor* GrPathProcessor::createGLSLInstance(const GrGLSLCaps&
caps) const { | 149 GrGLSLPrimitiveProcessor* GrPathProcessor::createGLSLInstance(const GrGLSLCaps&
caps) const { |
149 SkASSERT(caps.pathRenderingSupport()); | 150 SkASSERT(caps.pathRenderingSupport()); |
150 return new GrGLPathProcessor(); | 151 return new GrGLPathProcessor(); |
151 } | 152 } |
OLD | NEW |