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