| 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" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 m.setScale(1, -1); | 350 m.setScale(1, -1); |
| 351 m.preTranslate(-0.5f, -0.5f); | 351 m.preTranslate(-0.5f, -0.5f); |
| 352 this->defineSampleOffsetArray(sample_offset_array_name(kGLSLWindow_Coord
inates), m); | 352 this->defineSampleOffsetArray(sample_offset_array_name(kGLSLWindow_Coord
inates), m); |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 | 355 |
| 356 void GrGLSLFragmentShaderBuilder::defineSampleOffsetArray(const char* name, cons
t SkMatrix& m) { | 356 void GrGLSLFragmentShaderBuilder::defineSampleOffsetArray(const char* name, cons
t SkMatrix& m) { |
| 357 SkASSERT(fProgramBuilder->caps()->sampleLocationsSupport()); | 357 SkASSERT(fProgramBuilder->caps()->sampleLocationsSupport()); |
| 358 const GrPipeline& pipeline = fProgramBuilder->pipeline(); | 358 const GrPipeline& pipeline = fProgramBuilder->pipeline(); |
| 359 const GrRenderTargetPriv& rtp = pipeline.getRenderTarget()->renderTargetPriv
(); | 359 const GrRenderTargetPriv& rtp = pipeline.getRenderTarget()->renderTargetPriv
(); |
| 360 const GrGpu::MultisampleSpecs& specs = rtp.getMultisampleSpecs(pipeline.getS
tencil()); | 360 const GrGpu::MultisampleSpecs& specs = rtp.getMultisampleSpecs(pipeline); |
| 361 SkSTArray<16, SkPoint, true> offsets; | 361 SkSTArray<16, SkPoint, true> offsets; |
| 362 offsets.push_back_n(specs.fEffectiveSampleCnt); | 362 offsets.push_back_n(specs.fEffectiveSampleCnt); |
| 363 m.mapPoints(offsets.begin(), specs.fSampleLocations, specs.fEffectiveSampleC
nt); | 363 m.mapPoints(offsets.begin(), specs.fSampleLocations, specs.fEffectiveSampleC
nt); |
| 364 this->definitions().append("const "); | 364 this->definitions().append("const "); |
| 365 if (fProgramBuilder->glslCaps()->usesPrecisionModifiers()) { | 365 if (fProgramBuilder->glslCaps()->usesPrecisionModifiers()) { |
| 366 this->definitions().append("highp "); | 366 this->definitions().append("highp "); |
| 367 } | 367 } |
| 368 this->definitions().appendf("vec2 %s[] = vec2[](", name); | 368 this->definitions().appendf("vec2 %s[] = vec2[](", name); |
| 369 for (int i = 0; i < specs.fEffectiveSampleCnt; ++i) { | 369 for (int i = 0; i < specs.fEffectiveSampleCnt; ++i) { |
| 370 this->definitions().appendf("vec2(%f, %f)", offsets[i].x(), offsets[i].y
()); | 370 this->definitions().appendf("vec2(%f, %f)", offsets[i].x(), offsets[i].y
()); |
| 371 this->definitions().append(i + 1 != specs.fEffectiveSampleCnt ? ", " : "
);\n"); | 371 this->definitions().append(i + 1 != specs.fEffectiveSampleCnt ? ", " : "
);\n"); |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 | 374 |
| 375 void GrGLSLFragmentShaderBuilder::onBeforeChildProcEmitCode() { | 375 void GrGLSLFragmentShaderBuilder::onBeforeChildProcEmitCode() { |
| 376 SkASSERT(fSubstageIndices.count() >= 1); | 376 SkASSERT(fSubstageIndices.count() >= 1); |
| 377 fSubstageIndices.push_back(0); | 377 fSubstageIndices.push_back(0); |
| 378 // second-to-last value in the fSubstageIndices stack is the index of the ch
ild proc | 378 // second-to-last value in the fSubstageIndices stack is the index of the ch
ild proc |
| 379 // at that level which is currently emitting code. | 379 // at that level which is currently emitting code. |
| 380 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]
); | 380 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]
); |
| 381 } | 381 } |
| 382 | 382 |
| 383 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { | 383 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { |
| 384 SkASSERT(fSubstageIndices.count() >= 2); | 384 SkASSERT(fSubstageIndices.count() >= 2); |
| 385 fSubstageIndices.pop_back(); | 385 fSubstageIndices.pop_back(); |
| 386 fSubstageIndices.back()++; | 386 fSubstageIndices.back()++; |
| 387 int removeAt = fMangleString.findLastOf('_'); | 387 int removeAt = fMangleString.findLastOf('_'); |
| 388 fMangleString.remove(removeAt, fMangleString.size() - removeAt); | 388 fMangleString.remove(removeAt, fMangleString.size() - removeAt); |
| 389 } | 389 } |
| OLD | NEW |