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 "GrGLProgramBuilder.h" | 8 #include "GrGLProgramBuilder.h" |
9 | 9 |
10 #include "GrAutoLocaleSetter.h" | 10 #include "GrAutoLocaleSetter.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 const char* inColor) { | 254 const char* inColor) { |
255 GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc; | 255 GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc; |
256 | 256 |
257 ifp->fGLProc.reset(fp.createGLSLInstance()); | 257 ifp->fGLProc.reset(fp.createGLSLInstance()); |
258 | 258 |
259 SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures()); | 259 SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures()); |
260 this->emitSamplers(fp, &samplers, ifp); | 260 this->emitSamplers(fp, &samplers, ifp); |
261 | 261 |
262 GrGLSLFragmentProcessor::EmitArgs args(this, | 262 GrGLSLFragmentProcessor::EmitArgs args(this, |
263 &fFS, | 263 &fFS, |
| 264 this->glslCaps(), |
264 fp, | 265 fp, |
265 outColor, | 266 outColor, |
266 inColor, | 267 inColor, |
267 fOutCoords[index], | 268 fOutCoords[index], |
268 samplers); | 269 samplers); |
269 ifp->fGLProc->emitCode(args); | 270 ifp->fGLProc->emitCode(args); |
270 | 271 |
271 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 272 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
272 // asks for dst color, then the emit code needs to follow suit | 273 // asks for dst color, then the emit code needs to follow suit |
273 verify(fp); | 274 verify(fp); |
274 fFragmentProcessors->fProcs.push_back(ifp); | 275 fFragmentProcessors->fProcs.push_back(ifp); |
275 } | 276 } |
276 | 277 |
277 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp, | 278 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp, |
278 const char* outColor, | 279 const char* outColor, |
279 const char* outCoverage) { | 280 const char* outCoverage) { |
280 SkASSERT(!fGeometryProcessor); | 281 SkASSERT(!fGeometryProcessor); |
281 fGeometryProcessor = new GrGLInstalledGeoProc; | 282 fGeometryProcessor = new GrGLInstalledGeoProc; |
282 | 283 |
283 fGeometryProcessor->fGLProc.reset(gp.createGLSLInstance(*fGpu->glCaps().glsl
Caps())); | 284 fGeometryProcessor->fGLProc.reset(gp.createGLSLInstance(*fGpu->glCaps().glsl
Caps())); |
284 | 285 |
285 SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures()); | 286 SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures()); |
286 this->emitSamplers(gp, &samplers, fGeometryProcessor); | 287 this->emitSamplers(gp, &samplers, fGeometryProcessor); |
287 | 288 |
288 GrGLSLGeometryProcessor::EmitArgs args(this, &fVS, &fFS, gp, outColor, outCo
verage, samplers, | 289 GrGLSLGeometryProcessor::EmitArgs args(this, |
289 fCoordTransforms, &fOutCoords); | 290 &fVS, |
| 291 &fFS, |
| 292 this->glslCaps(), |
| 293 gp, |
| 294 outColor, |
| 295 outCoverage, |
| 296 samplers, |
| 297 fCoordTransforms, |
| 298 &fOutCoords); |
290 fGeometryProcessor->fGLProc->emitCode(args); | 299 fGeometryProcessor->fGLProc->emitCode(args); |
291 | 300 |
292 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 301 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
293 // asks for dst color, then the emit code needs to follow suit | 302 // asks for dst color, then the emit code needs to follow suit |
294 verify(gp); | 303 verify(gp); |
295 } | 304 } |
296 | 305 |
297 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, | 306 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, |
298 const GrGLSLExpr4& colorIn, | 307 const GrGLSLExpr4& colorIn, |
299 const GrGLSLExpr4& coverageIn) { | 308 const GrGLSLExpr4& coverageIn) { |
(...skipping 14 matching lines...) Expand all Loading... |
314 fFS.enableCustomOutput(); | 323 fFS.enableCustomOutput(); |
315 } | 324 } |
316 | 325 |
317 SkString openBrace; | 326 SkString openBrace; |
318 openBrace.printf("{ // Xfer Processor: %s\n", xp.name()); | 327 openBrace.printf("{ // Xfer Processor: %s\n", xp.name()); |
319 fFS.codeAppend(openBrace.c_str()); | 328 fFS.codeAppend(openBrace.c_str()); |
320 | 329 |
321 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures()); | 330 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures()); |
322 this->emitSamplers(xp, &samplers, fXferProcessor); | 331 this->emitSamplers(xp, &samplers, fXferProcessor); |
323 | 332 |
324 GrGLSLXferProcessor::EmitArgs args(this, &fFS, xp, colorIn.c_str(), coverage
In.c_str(), | 333 GrGLSLXferProcessor::EmitArgs args(this, |
| 334 &fFS, |
| 335 this->glslCaps(), |
| 336 xp, colorIn.c_str(), |
| 337 coverageIn.c_str(), |
325 fFS.getPrimaryColorOutputName(), | 338 fFS.getPrimaryColorOutputName(), |
326 fFS.getSecondaryColorOutputName(), sample
rs); | 339 fFS.getSecondaryColorOutputName(), |
| 340 samplers); |
327 fXferProcessor->fGLProc->emitCode(args); | 341 fXferProcessor->fGLProc->emitCode(args); |
328 | 342 |
329 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 343 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
330 // asks for dst color, then the emit code needs to follow suit | 344 // asks for dst color, then the emit code needs to follow suit |
331 verify(xp); | 345 verify(xp); |
332 fFS.codeAppend("}"); | 346 fFS.codeAppend("}"); |
333 } | 347 } |
334 | 348 |
335 void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) { | 349 void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) { |
336 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition()); | 350 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition()); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 } | 551 } |
538 | 552 |
539 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 553 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
540 | 554 |
541 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 555 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
542 int numProcs = fProcs.count(); | 556 int numProcs = fProcs.count(); |
543 for (int i = 0; i < numProcs; ++i) { | 557 for (int i = 0; i < numProcs; ++i) { |
544 delete fProcs[i]; | 558 delete fProcs[i]; |
545 } | 559 } |
546 } | 560 } |
OLD | NEW |