Chromium Code Reviews| Index: src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp |
| diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp |
| index 44db57e68d840067e7cd6da474b026bb60e84366..a7d383532e3bf090aa44f425043bfa742156fc6e 100644 |
| --- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp |
| +++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp |
| @@ -170,6 +170,11 @@ const char* GrGLSLFragmentShaderBuilder::fragmentPosition() { |
| } |
| } |
| +void GrGLSLFragmentShaderBuilder::appendSampleOffset(const char* sampleIdx) { |
| + SkASSERT(fProgramBuilder->pipeline().hasSampleLocations()); |
|
Chris Dalton
2016/02/23 01:51:01
I guess maskSampleCoverage() does a test/SkDEBUGFA
|
| + this->codeAppendf("sampleOffsets[%s]", sampleIdx); |
| +} |
| + |
| void GrGLSLFragmentShaderBuilder::maskSampleCoverage(const char* mask, bool invert) { |
| const GrGLSLCaps& glslCaps = *fProgramBuilder->glslCaps(); |
| if (!glslCaps.sampleVariablesSupport()) { |
| @@ -306,6 +311,23 @@ void GrGLSLFragmentShaderBuilder::onFinalize() { |
| GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, |
| *fProgramBuilder->glslCaps(), |
| &this->precisionQualifier()); |
| + if (fProgramBuilder->pipeline().hasSampleLocations()) { |
| + const GrPipeline& pipeline = fProgramBuilder->pipeline(); |
| + int effectiveSampleCnt = pipeline.effectiveSampleCount(); |
| + const SkPoint* sampleLocations = pipeline.getSampleLocations(); |
| + this->definitions().append("const "); |
| + if (fProgramBuilder->glslCaps()->usesPrecisionModifiers()) { |
| + this->definitions().append("highp "); |
| + } |
| + this->definitions().appendf("vec2 sampleOffsets[] = vec2[]("); |
| + for (int i = 0; i < effectiveSampleCnt; ++i) { |
| + this->definitions().appendf("vec2(%f, %f)%s", |
| + sampleLocations[i].x() - 0.5f, |
| + sampleLocations[i].y() - 0.5f, |
| + i + 1 != effectiveSampleCnt ? ", " : ");\n"); |
| + } |
| + SkASSERT(fProgramBuilder->header().fSamplePatternKey == pipeline.getSamplePatternID()); |
| + } |
| } |
| void GrGLSLFragmentShaderBuilder::onBeforeChildProcEmitCode() { |