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