| 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 "gl/GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 fUsedProcessorFeatures = GrProcessor::kNone_RequiredFeatures; | 80 fUsedProcessorFeatures = GrProcessor::kNone_RequiredFeatures; |
| 81 fHasReadDstColor = false; | 81 fHasReadDstColor = false; |
| 82 #endif | 82 #endif |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool GrGLSLFragmentShaderBuilder::hasFragmentPosition() const { | 85 bool GrGLSLFragmentShaderBuilder::hasFragmentPosition() const { |
| 86 return 0 != fProgramBuilder->header().fFragPosKey; | 86 return 0 != fProgramBuilder->header().fFragPosKey; |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) { | 89 bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) { |
| 90 const GrGLSLCaps& glslCaps = *fProgramBuilder->glslCaps(); |
| 90 switch (feature) { | 91 switch (feature) { |
| 91 case kStandardDerivatives_GLSLFeature: { | 92 case kStandardDerivatives_GLSLFeature: |
| 92 if (!fProgramBuilder->glslCaps()->shaderDerivativeSupport()) { | 93 if (!glslCaps.shaderDerivativeSupport()) { |
| 93 return false; | 94 return false; |
| 94 } | 95 } |
| 95 const char* extension = fProgramBuilder->glslCaps()->shaderDerivativ
eExtensionString(); | 96 if (const char* extension = glslCaps.shaderDerivativeExtensionString
()) { |
| 96 if (extension) { | |
| 97 this->addFeature(1 << kStandardDerivatives_GLSLFeature, extensio
n); | 97 this->addFeature(1 << kStandardDerivatives_GLSLFeature, extensio
n); |
| 98 } | 98 } |
| 99 return true; | 99 return true; |
| 100 } | 100 case kPixelLocalStorage_GLSLFeature: |
| 101 case kPixelLocalStorage_GLSLFeature: { | 101 if (glslCaps.pixelLocalStorageSize() <= 0) { |
| 102 if (fProgramBuilder->glslCaps()->pixelLocalStorageSize() <= 0) { | |
| 103 return false; | 102 return false; |
| 104 } | 103 } |
| 105 this->addFeature(1 << kPixelLocalStorage_GLSLFeature, | 104 this->addFeature(1 << kPixelLocalStorage_GLSLFeature, |
| 106 "GL_EXT_shader_pixel_local_storage"); | 105 "GL_EXT_shader_pixel_local_storage"); |
| 107 return true; | 106 return true; |
| 108 } | 107 case kMultisampleInterpolation_GLSLFeature: |
| 108 if (!glslCaps.multisampleInterpolationSupport()) { |
| 109 return false; |
| 110 } |
| 111 if (const char* extension = glslCaps.multisampleInterpolationExtensi
onString()) { |
| 112 this->addFeature(1 << kMultisampleInterpolation_GLSLFeature, ext
ension); |
| 113 } |
| 114 return true; |
| 109 default: | 115 default: |
| 110 SkFAIL("Unexpected GLSLFeature requested."); | 116 SkFAIL("Unexpected GLSLFeature requested."); |
| 111 return false; | 117 return false; |
| 112 } | 118 } |
| 113 } | 119 } |
| 114 | 120 |
| 115 SkString GrGLSLFragmentShaderBuilder::ensureFSCoords2D(const GrGLSLTransformedCo
ordsArray& coords, | 121 SkString GrGLSLFragmentShaderBuilder::ensureFSCoords2D(const GrGLSLTransformedCo
ordsArray& coords, |
| 116 int index) { | 122 int index) { |
| 117 if (kVec3f_GrSLType != coords[index].getType()) { | 123 if (kVec3f_GrSLType != coords[index].getType()) { |
| 118 SkASSERT(kVec2f_GrSLType == coords[index].getType()); | 124 SkASSERT(kVec2f_GrSLType == coords[index].getType()); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 330 } |
| 325 | 331 |
| 326 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { | 332 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { |
| 327 SkASSERT(fSubstageIndices.count() >= 2); | 333 SkASSERT(fSubstageIndices.count() >= 2); |
| 328 fSubstageIndices.pop_back(); | 334 fSubstageIndices.pop_back(); |
| 329 fSubstageIndices.back()++; | 335 fSubstageIndices.back()++; |
| 330 int removeAt = fMangleString.findLastOf('_'); | 336 int removeAt = fMangleString.findLastOf('_'); |
| 331 fMangleString.remove(removeAt, fMangleString.size() - removeAt); | 337 fMangleString.remove(removeAt, fMangleString.size() - removeAt); |
| 332 } | 338 } |
| 333 | 339 |
| OLD | NEW |