Chromium Code Reviews| 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 "GrGeometryProcessor.h" | 8 #include "GrGeometryProcessor.h" |
| 9 | 9 |
| 10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); | 156 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); |
| 157 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 157 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 //////////////////////////////////////////////////////////////////////////////// /////////////////// | 161 //////////////////////////////////////////////////////////////////////////////// /////////////////// |
| 162 | 162 |
| 163 | 163 |
| 164 void GrGLGeometryProcessor::emitCode(EmitArgs& args) { | 164 void GrGLGeometryProcessor::emitCode(EmitArgs& args) { |
| 165 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 165 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 166 vsBuilder->codeAppendf("vec3 %s;", this->position()); | 166 GrGPArgs gpArgs; |
| 167 this->onEmitCode(args); | 167 this->onEmitCode(args, &gpArgs); |
| 168 vsBuilder->transformToNormalizedDeviceSpace(this->position()); | 168 vsBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb, | 171 void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb, |
| 172 const char* position, | 172 const GrShaderVar& posVar, |
| 173 const char* localCoords, | 173 const char* localCoords, |
| 174 const SkMatrix& localMatrix, | 174 const SkMatrix& localMatrix, |
| 175 const TransformsIn& tin, | 175 const TransformsIn& tin, |
| 176 TransformsOut* tout) { | 176 TransformsOut* tout) { |
| 177 GrGLVertexBuilder* vb = pb->getVertexShaderBuilder(); | 177 GrGLVertexBuilder* vb = pb->getVertexShaderBuilder(); |
| 178 tout->push_back_n(tin.count()); | 178 tout->push_back_n(tin.count()); |
| 179 fInstalledTransforms.push_back_n(tin.count()); | 179 fInstalledTransforms.push_back_n(tin.count()); |
| 180 for (int i = 0; i < tin.count(); i++) { | 180 for (int i = 0; i < tin.count(); i++) { |
| 181 const ProcCoords& coordTransforms = tin[i]; | 181 const ProcCoords& coordTransforms = tin[i]; |
| 182 fInstalledTransforms[i].push_back_n(coordTransforms.count()); | 182 fInstalledTransforms[i].push_back_n(coordTransforms.count()); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 207 GrGLVertToFrag v(varyingType); | 207 GrGLVertToFrag v(varyingType); |
| 208 pb->addVarying(strVaryingName.c_str(), &v, precision); | 208 pb->addVarying(strVaryingName.c_str(), &v, precision); |
| 209 | 209 |
| 210 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyin gType); | 210 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyin gType); |
| 211 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCoords , | 211 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCoords , |
| 212 (SkString(v.fsIn()), varyingType)); | 212 (SkString(v.fsIn()), varyingType)); |
| 213 | 213 |
| 214 // varying = matrix * coords (logically) | 214 // varying = matrix * coords (logically) |
| 215 if (kDevice_GrCoordSet == coordType) { | 215 if (kDevice_GrCoordSet == coordType) { |
| 216 if (kVec2f_GrSLType == varyingType) { | 216 if (kVec2f_GrSLType == varyingType) { |
| 217 vb->codeAppendf("%s = (%s * %s).xy;", v.vsOut(), uniName, po sition); | 217 if (kVec2f_GrSLType == posVar.getType()) { |
| 218 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", | |
| 219 v.vsOut(), uniName, posVar.c_str()); | |
| 220 } else { | |
| 221 vb->codeAppendf("%s = (%s * %s).xy;", v.vsOut(), uniName , posVar.c_str()); | |
|
bsalomon
2015/01/20 15:19:51
Is this right? It seems like we know that the vm i
| |
| 222 } | |
| 218 } else { | 223 } else { |
| 219 vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, positio n); | 224 if (kVec2f_GrSLType == posVar.getType()) { |
| 225 vb->codeAppendf("%s = %s * vec3(%s, 1);", | |
| 226 v.vsOut(), uniName, posVar.c_str()); | |
| 227 } else { | |
| 228 vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, pos Var.c_str()); | |
| 229 } | |
| 220 } | 230 } |
| 221 } else { | 231 } else { |
| 222 if (kVec2f_GrSLType == varyingType) { | 232 if (kVec2f_GrSLType == varyingType) { |
| 223 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), un iName, localCoords); | 233 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), un iName, localCoords); |
| 224 } else { | 234 } else { |
| 225 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName , localCoords); | 235 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName , localCoords); |
| 226 } | 236 } |
| 227 } | 237 } |
| 228 } | 238 } |
| 229 } | 239 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 240 for (int t = 0; t < numTransforms; ++t) { | 250 for (int t = 0; t < numTransforms; ++t) { |
| 241 SkASSERT(procTransforms[t].fHandle.isValid()); | 251 SkASSERT(procTransforms[t].fHandle.isValid()); |
| 242 const SkMatrix& transform = GetTransformMatrix(primProc->localMatrix(), *transforms[t]); | 252 const SkMatrix& transform = GetTransformMatrix(primProc->localMatrix(), *transforms[t]); |
| 243 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) { | 253 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) { |
| 244 pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle() , transform); | 254 pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle() , transform); |
| 245 procTransforms[t].fCurrentValue = transform; | 255 procTransforms[t].fCurrentValue = transform; |
| 246 } | 256 } |
| 247 } | 257 } |
| 248 } | 258 } |
| 249 | 259 |
| 260 void GrGLGeometryProcessor::SetupPosition(GrGLVertexBuilder* vsBuilder, | |
| 261 GrGPArgs* gpArgs, | |
| 262 const char* posName, | |
| 263 const SkMatrix& mat, | |
| 264 const char* matName) { | |
| 265 if (mat.isIdentity()) { | |
| 266 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | |
| 267 | |
| 268 vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), po sName); | |
| 269 } else if (!mat.hasPerspective()) { | |
| 270 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | |
| 271 | |
| 272 vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", | |
| 273 gpArgs->fPositionVar.c_str(), matName, posName); | |
| 274 } else { | |
| 275 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); | |
| 276 | |
| 277 vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", | |
| 278 gpArgs->fPositionVar.c_str(), matName, posName); | |
| 279 } | |
| 280 } | |
| 281 | |
| 250 //////////////////////////////////////////////////////////////////////////////// /////////////////// | 282 //////////////////////////////////////////////////////////////////////////////// /////////////////// |
| 251 | 283 |
| 252 #include "gl/GrGLGpu.h" | 284 #include "gl/GrGLGpu.h" |
| 253 #include "gl/GrGLPathRendering.h" | 285 #include "gl/GrGLPathRendering.h" |
| 254 | 286 |
| 255 struct PathBatchTracker { | 287 struct PathBatchTracker { |
| 256 GrGPInput fInputColorType; | 288 GrGPInput fInputColorType; |
| 257 GrGPInput fInputCoverageType; | 289 GrGPInput fInputCoverageType; |
| 258 GrColor fColor; | 290 GrColor fColor; |
| 259 bool fUsesLocalCoords; | 291 bool fUsesLocalCoords; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 const GrGLCaps& caps) const { | 560 const GrGLCaps& caps) const { |
| 529 SkASSERT(caps.nvprSupport() != GrGLCaps::kNone_NvprSupport); | 561 SkASSERT(caps.nvprSupport() != GrGLCaps::kNone_NvprSupport); |
| 530 if (caps.nvprSupport() == GrGLCaps::kLegacy_NvprSupport) { | 562 if (caps.nvprSupport() == GrGLCaps::kLegacy_NvprSupport) { |
| 531 return SkNEW_ARGS(GrGLLegacyPathProcessor, (*this, bt, | 563 return SkNEW_ARGS(GrGLLegacyPathProcessor, (*this, bt, |
| 532 caps.maxFixedFunctionTexture Coords())); | 564 caps.maxFixedFunctionTexture Coords())); |
| 533 } else { | 565 } else { |
| 534 return SkNEW_ARGS(GrGLNormalPathProcessor, (*this, bt)); | 566 return SkNEW_ARGS(GrGLNormalPathProcessor, (*this, bt)); |
| 535 } | 567 } |
| 536 } | 568 } |
| 537 | 569 |
| OLD | NEW |