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.fUseNvpr && | 58 bool hasVertexShader = !header.fUseFragShaderOnly; |
59 gpu->glPathRendering()->texturingMode() == | |
60 GrGLPathRendering::FixedFunction_TexturingMode); | |
61 if (hasVertexShader) { | 59 if (hasVertexShader) { |
62 pb->fVS.setupLocalCoords(); | 60 pb->fVS.setupLocalCoords(); |
63 pb->fVS.transformGLToSkiaCoords(); | 61 pb->fVS.transformGLToSkiaCoords(); |
64 if (header.fEmitsPointSize) { | 62 if (header.fEmitsPointSize) { |
65 pb->fVS.codeAppend("gl_PointSize = 1.0;"); | 63 pb->fVS.codeAppend("gl_PointSize = 1.0;"); |
66 } | 64 } |
67 if (GrGLProgramDesc::kAttribute_ColorInput == header.fColorInput) { | 65 if (GrGLProgramDesc::kAttribute_ColorInput == header.fColorInput) { |
68 pb->fVS.setupBuiltinVertexAttribute("Color", &inputColor); | 66 pb->fVS.setupBuiltinVertexAttribute("Color", &inputColor); |
69 } | 67 } |
70 if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) { | 68 if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) { |
(...skipping 16 matching lines...) Expand all Loading... |
87 | 85 |
88 return pb->finalize(); | 86 return pb->finalize(); |
89 } | 87 } |
90 | 88 |
91 GrGLProgramBuilder* | 89 GrGLProgramBuilder* |
92 GrGLProgramBuilder::CreateProgramBuilder(const GrGLProgramDesc& desc, | 90 GrGLProgramBuilder::CreateProgramBuilder(const GrGLProgramDesc& desc, |
93 const GrOptDrawState& optState, | 91 const GrOptDrawState& optState, |
94 GrGpu::DrawType drawType, | 92 GrGpu::DrawType drawType, |
95 bool hasGeometryProcessor, | 93 bool hasGeometryProcessor, |
96 GrGpuGL* gpu) { | 94 GrGpuGL* gpu) { |
97 if (desc.getHeader().fUseNvpr) { | 95 if (desc.getHeader().fUseFragShaderOnly) { |
98 SkASSERT(gpu->glCaps().pathRenderingSupport()); | 96 SkASSERT(gpu->glCaps().pathRenderingSupport()); |
| 97 SkASSERT(gpu->glPathRendering()->texturingMode() == |
| 98 GrGLPathRendering::FixedFunction_TexturingMode); |
99 SkASSERT(!hasGeometryProcessor); | 99 SkASSERT(!hasGeometryProcessor); |
100 if (gpu->glPathRendering()->texturingMode() == | 100 return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState, desc)); |
101 GrGLPathRendering::FixedFunction_TexturingMode) { | 101 } else if (GrGpu::IsPathRenderingDrawType(drawType)) { |
102 return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState, desc
)); | 102 SkASSERT(gpu->glCaps().pathRenderingSupport()); |
103 } else { | 103 SkASSERT(gpu->glPathRendering()->texturingMode() == |
104 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState, desc)); | 104 GrGLPathRendering::SeparableShaders_TexturingMode); |
105 } | 105 SkASSERT(!hasGeometryProcessor); |
| 106 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState, desc)); |
106 } else { | 107 } else { |
107 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState, desc)); | 108 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState, desc)); |
108 } | 109 } |
109 } | 110 } |
110 | 111 |
111 ///////////////////////////////////////////////////////////////////////////// | 112 ///////////////////////////////////////////////////////////////////////////// |
112 | 113 |
113 GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu, | 114 GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu, |
114 const GrOptDrawState& optState, | 115 const GrOptDrawState& optState, |
115 const GrGLProgramDesc& desc) | 116 const GrGLProgramDesc& desc) |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 if (0 == programID) { | 413 if (0 == programID) { |
413 return NULL; | 414 return NULL; |
414 } | 415 } |
415 | 416 |
416 // compile shaders and bind attributes / uniforms | 417 // compile shaders and bind attributes / uniforms |
417 SkTDArray<GrGLuint> shadersToDelete; | 418 SkTDArray<GrGLuint> shadersToDelete; |
418 if (!fFS.compileAndAttachShaders(programID, &shadersToDelete)) { | 419 if (!fFS.compileAndAttachShaders(programID, &shadersToDelete)) { |
419 this->cleanupProgram(programID, shadersToDelete); | 420 this->cleanupProgram(programID, shadersToDelete); |
420 return NULL; | 421 return NULL; |
421 } | 422 } |
422 if (!(this->header().fUseNvpr && | 423 if (!this->header().fUseFragShaderOnly) { |
423 fGpu->glPathRendering()->texturingMode() == | |
424 GrGLPathRendering::FixedFunction_TexturingMode)) { | |
425 if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) { | 424 if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) { |
426 this->cleanupProgram(programID, shadersToDelete); | 425 this->cleanupProgram(programID, shadersToDelete); |
427 return NULL; | 426 return NULL; |
428 } | 427 } |
429 fVS.bindVertexAttributes(programID); | 428 fVS.bindVertexAttributes(programID); |
430 } | 429 } |
431 bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation
!= NULL; | 430 bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation
!= NULL; |
432 if (usingBindUniform) { | 431 if (usingBindUniform) { |
433 this->bindUniformLocations(programID); | 432 this->bindUniformLocations(programID); |
434 } | 433 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 } | 508 } |
510 | 509 |
511 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 510 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
512 | 511 |
513 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 512 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
514 int numProcs = fProcs.count(); | 513 int numProcs = fProcs.count(); |
515 for (int e = 0; e < numProcs; ++e) { | 514 for (int e = 0; e < numProcs; ++e) { |
516 SkDELETE(fProcs[e]); | 515 SkDELETE(fProcs[e]); |
517 } | 516 } |
518 } | 517 } |
OLD | NEW |