| 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 "GrGLSLFragmentShaderBuilder.h" | 8 #include "GrGLSLFragmentShaderBuilder.h" |
| 9 #include "GrRenderTarget.h" | 9 #include "GrRenderTarget.h" |
| 10 #include "GrRenderTargetPriv.h" | 10 #include "GrRenderTargetPriv.h" |
| 11 #include "gl/GrGLGpu.h" | 11 #include "gl/GrGLGpu.h" |
| 12 #include "glsl/GrGLSL.h" | 12 #include "glsl/GrGLSL.h" |
| 13 #include "glsl/GrGLSLCaps.h" | 13 #include "glsl/GrGLSLCaps.h" |
| 14 #include "glsl/GrGLSLProgramBuilder.h" | 14 #include "glsl/GrGLSLProgramBuilder.h" |
| 15 #include "glsl/GrGLSLUniformHandler.h" | 15 #include "glsl/GrGLSLUniformHandler.h" |
| 16 #include "glsl/GrGLSLVarying.h" | 16 #include "glsl/GrGLSLVarying.h" |
| 17 | 17 |
| 18 const char* GrGLSLFragmentShaderBuilder::kDstTextureColorName = "_dstColor"; | 18 const char* GrGLSLFragmentShaderBuilder::kDstColorName = "_dstColor"; |
| 19 | 19 |
| 20 static const char* sample_offset_array_name(GrGLSLFPFragmentBuilder::Coordinates
coords) { | 20 static const char* sample_offset_array_name(GrGLSLFPFragmentBuilder::Coordinates
coords) { |
| 21 static const char* kArrayNames[] = { | 21 static const char* kArrayNames[] = { |
| 22 "deviceSpaceSampleOffsets", | 22 "deviceSpaceSampleOffsets", |
| 23 "windowSpaceSampleOffsets" | 23 "windowSpaceSampleOffsets" |
| 24 }; | 24 }; |
| 25 return kArrayNames[coords]; | 25 return kArrayNames[coords]; |
| 26 | 26 |
| 27 GR_STATIC_ASSERT(0 == GrGLSLFPFragmentBuilder::kSkiaDevice_Coordinates); | 27 GR_STATIC_ASSERT(0 == GrGLSLFPFragmentBuilder::kSkiaDevice_Coordinates); |
| 28 GR_STATIC_ASSERT(1 == GrGLSLFPFragmentBuilder::kGLSLWindow_Coordinates); | 28 GR_STATIC_ASSERT(1 == GrGLSLFPFragmentBuilder::kGLSLWindow_Coordinates); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 if (glslCaps->fbFetchSupport()) { | 257 if (glslCaps->fbFetchSupport()) { |
| 258 this->addFeature(1 << kFramebufferFetch_GLSLPrivateFeature, | 258 this->addFeature(1 << kFramebufferFetch_GLSLPrivateFeature, |
| 259 glslCaps->fbFetchExtensionString()); | 259 glslCaps->fbFetchExtensionString()); |
| 260 | 260 |
| 261 // Some versions of this extension string require declaring custom color
output on ES 3.0+ | 261 // Some versions of this extension string require declaring custom color
output on ES 3.0+ |
| 262 const char* fbFetchColorName = glslCaps->fbFetchColorName(); | 262 const char* fbFetchColorName = glslCaps->fbFetchColorName(); |
| 263 if (glslCaps->fbFetchNeedsCustomOutput()) { | 263 if (glslCaps->fbFetchNeedsCustomOutput()) { |
| 264 this->enableCustomOutput(); | 264 this->enableCustomOutput(); |
| 265 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu
t_TypeModifier); | 265 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu
t_TypeModifier); |
| 266 fbFetchColorName = DeclaredColorOutputName(); | 266 fbFetchColorName = DeclaredColorOutputName(); |
| 267 // Set the dstColor to an intermediate variable so we don't override
it with the output |
| 268 this->codeAppendf("vec4 %s = %s;", kDstColorName, fbFetchColorName); |
| 267 } | 269 } |
| 268 return fbFetchColorName; | |
| 269 } else { | |
| 270 return kDstTextureColorName; | |
| 271 } | 270 } |
| 271 return kDstColorName; |
| 272 } | 272 } |
| 273 | 273 |
| 274 void GrGLSLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEqu
ation equation) { | 274 void GrGLSLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEqu
ation equation) { |
| 275 SkASSERT(GrBlendEquationIsAdvanced(equation)); | 275 SkASSERT(GrBlendEquationIsAdvanced(equation)); |
| 276 | 276 |
| 277 const GrGLSLCaps& caps = *fProgramBuilder->glslCaps(); | 277 const GrGLSLCaps& caps = *fProgramBuilder->glslCaps(); |
| 278 if (!caps.mustEnableAdvBlendEqs()) { | 278 if (!caps.mustEnableAdvBlendEqs()) { |
| 279 return; | 279 return; |
| 280 } | 280 } |
| 281 | 281 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]
); | 389 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]
); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { | 392 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { |
| 393 SkASSERT(fSubstageIndices.count() >= 2); | 393 SkASSERT(fSubstageIndices.count() >= 2); |
| 394 fSubstageIndices.pop_back(); | 394 fSubstageIndices.pop_back(); |
| 395 fSubstageIndices.back()++; | 395 fSubstageIndices.back()++; |
| 396 int removeAt = fMangleString.findLastOf('_'); | 396 int removeAt = fMangleString.findLastOf('_'); |
| 397 fMangleString.remove(removeAt, fMangleString.size() - removeAt); | 397 fMangleString.remove(removeAt, fMangleString.size() - removeAt); |
| 398 } | 398 } |
| OLD | NEW |