| 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 "GrGLProgramBuilder.h" | 8 #include "GrGLProgramBuilder.h" |
| 9 #include "gl/GrGLProgram.h" | 9 #include "gl/GrGLProgram.h" |
| 10 #include "gl/GrGLSLPrettyPrint.h" | 10 #include "gl/GrGLSLPrettyPrint.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 && !gpu->glCaps().fbFetchSupport()) { | 48 && !gpu->glCaps().fbFetchSupport()) { |
| 49 pb->fFS.emitCodeToReadDstTexture(); | 49 pb->fFS.emitCodeToReadDstTexture(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // get the initial color and coverage to feed into the first effect in each
effect chain | 52 // get the initial color and coverage to feed into the first effect in each
effect chain |
| 53 GrGLSLExpr4 inputColor, inputCoverage; | 53 GrGLSLExpr4 inputColor, inputCoverage; |
| 54 pb->setupUniformColorAndCoverageIfNeeded(&inputColor, &inputCoverage); | 54 pb->setupUniformColorAndCoverageIfNeeded(&inputColor, &inputCoverage); |
| 55 | 55 |
| 56 // if we have a vertex shader(we don't only if we are using NVPR or NVPR ES)
, then we may have | 56 // if we have a vertex shader(we don't only if we are using NVPR or NVPR ES)
, then we may have |
| 57 // to setup a few more things like builtin vertex attributes | 57 // to setup a few more things like builtin vertex attributes |
| 58 bool hasVertexShader = !header.fUseFragShaderOnly; | 58 bool hasVertexShader = !(header.fUseNvpr && |
| 59 gpu->glPathRendering()->texturingMode() == |
| 60 GrGLPathRendering::FixedFunction_TexturingMode); |
| 59 if (hasVertexShader) { | 61 if (hasVertexShader) { |
| 60 pb->fVS.setupLocalCoords(); | 62 pb->fVS.setupLocalCoords(); |
| 61 pb->fVS.transformGLToSkiaCoords(); | 63 pb->fVS.transformGLToSkiaCoords(); |
| 62 if (header.fEmitsPointSize) { | 64 if (header.fEmitsPointSize) { |
| 63 pb->fVS.codeAppend("gl_PointSize = 1.0;"); | 65 pb->fVS.codeAppend("gl_PointSize = 1.0;"); |
| 64 } | 66 } |
| 65 if (GrGLProgramDesc::kAttribute_ColorInput == header.fColorInput) { | 67 if (GrGLProgramDesc::kAttribute_ColorInput == header.fColorInput) { |
| 66 pb->fVS.setupBuiltinVertexAttribute("Color", &inputColor); | 68 pb->fVS.setupBuiltinVertexAttribute("Color", &inputColor); |
| 67 } | 69 } |
| 68 if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) { | 70 if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 | 87 |
| 86 return pb->finalize(); | 88 return pb->finalize(); |
| 87 } | 89 } |
| 88 | 90 |
| 89 GrGLProgramBuilder* | 91 GrGLProgramBuilder* |
| 90 GrGLProgramBuilder::CreateProgramBuilder(const GrGLProgramDesc& desc, | 92 GrGLProgramBuilder::CreateProgramBuilder(const GrGLProgramDesc& desc, |
| 91 const GrOptDrawState& optState, | 93 const GrOptDrawState& optState, |
| 92 GrGpu::DrawType drawType, | 94 GrGpu::DrawType drawType, |
| 93 bool hasGeometryProcessor, | 95 bool hasGeometryProcessor, |
| 94 GrGpuGL* gpu) { | 96 GrGpuGL* gpu) { |
| 95 if (desc.getHeader().fUseFragShaderOnly) { | 97 if (desc.getHeader().fUseNvpr) { |
| 96 SkASSERT(gpu->glCaps().pathRenderingSupport()); | 98 SkASSERT(gpu->glCaps().pathRenderingSupport()); |
| 97 SkASSERT(gpu->glPathRendering()->texturingMode() == | |
| 98 GrGLPathRendering::FixedFunction_TexturingMode); | |
| 99 SkASSERT(!hasGeometryProcessor); | 99 SkASSERT(!hasGeometryProcessor); |
| 100 return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState, desc)); | 100 if (gpu->glPathRendering()->texturingMode() == |
| 101 } else if (GrGpu::IsPathRenderingDrawType(drawType)) { | 101 GrGLPathRendering::FixedFunction_TexturingMode) { |
| 102 SkASSERT(gpu->glCaps().pathRenderingSupport()); | 102 return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState, desc
)); |
| 103 SkASSERT(gpu->glPathRendering()->texturingMode() == | 103 } else { |
| 104 GrGLPathRendering::SeparableShaders_TexturingMode); | 104 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState, desc)); |
| 105 SkASSERT(!hasGeometryProcessor); | 105 } |
| 106 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState, desc)); | |
| 107 } else { | 106 } else { |
| 108 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState, desc)); | 107 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState, desc)); |
| 109 } | 108 } |
| 110 } | 109 } |
| 111 | 110 |
| 112 ///////////////////////////////////////////////////////////////////////////// | 111 ///////////////////////////////////////////////////////////////////////////// |
| 113 | 112 |
| 114 GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu, | 113 GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu, |
| 115 const GrOptDrawState& optState, | 114 const GrOptDrawState& optState, |
| 116 const GrGLProgramDesc& desc) | 115 const GrGLProgramDesc& desc) |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if (0 == programID) { | 412 if (0 == programID) { |
| 414 return NULL; | 413 return NULL; |
| 415 } | 414 } |
| 416 | 415 |
| 417 // compile shaders and bind attributes / uniforms | 416 // compile shaders and bind attributes / uniforms |
| 418 SkTDArray<GrGLuint> shadersToDelete; | 417 SkTDArray<GrGLuint> shadersToDelete; |
| 419 if (!fFS.compileAndAttachShaders(programID, &shadersToDelete)) { | 418 if (!fFS.compileAndAttachShaders(programID, &shadersToDelete)) { |
| 420 this->cleanupProgram(programID, shadersToDelete); | 419 this->cleanupProgram(programID, shadersToDelete); |
| 421 return NULL; | 420 return NULL; |
| 422 } | 421 } |
| 423 if (!this->header().fUseFragShaderOnly) { | 422 if (!(this->header().fUseNvpr && |
| 423 fGpu->glPathRendering()->texturingMode() == |
| 424 GrGLPathRendering::FixedFunction_TexturingMode)) { |
| 424 if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) { | 425 if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) { |
| 425 this->cleanupProgram(programID, shadersToDelete); | 426 this->cleanupProgram(programID, shadersToDelete); |
| 426 return NULL; | 427 return NULL; |
| 427 } | 428 } |
| 428 fVS.bindVertexAttributes(programID); | 429 fVS.bindVertexAttributes(programID); |
| 429 } | 430 } |
| 430 bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation
!= NULL; | 431 bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation
!= NULL; |
| 431 if (usingBindUniform) { | 432 if (usingBindUniform) { |
| 432 this->bindUniformLocations(programID); | 433 this->bindUniformLocations(programID); |
| 433 } | 434 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 } | 509 } |
| 509 | 510 |
| 510 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 511 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 511 | 512 |
| 512 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 513 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
| 513 int numProcs = fProcs.count(); | 514 int numProcs = fProcs.count(); |
| 514 for (int e = 0; e < numProcs; ++e) { | 515 for (int e = 0; e < numProcs; ++e) { |
| 515 SkDELETE(fProcs[e]); | 516 SkDELETE(fProcs[e]); |
| 516 } | 517 } |
| 517 } | 518 } |
| OLD | NEW |