Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Side by Side Diff: src/gpu/gl/GrGLProgram.cpp

Issue 23636011: Add a GrGpuGL reference for GrGLProgram/GrGLUniformManager (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrGLProgram.h" 8 #include "GrGLProgram.h"
9 9
10 #include "GrAllocator.h" 10 #include "GrAllocator.h"
11 #include "GrEffect.h" 11 #include "GrEffect.h"
12 #include "GrDrawEffect.h" 12 #include "GrDrawEffect.h"
13 #include "GrGLEffect.h" 13 #include "GrGLEffect.h"
14 #include "GrGpuGL.h" 14 #include "GrGpuGL.h"
15 #include "GrGLShaderVar.h" 15 #include "GrGLShaderVar.h"
16 #include "GrGLSL.h" 16 #include "GrGLSL.h"
17 #include "SkTrace.h" 17 #include "SkTrace.h"
18 #include "SkXfermode.h" 18 #include "SkXfermode.h"
19 19
20 #include "SkRTConf.h" 20 #include "SkRTConf.h"
21 21
22 SK_DEFINE_INST_COUNT(GrGLProgram) 22 SK_DEFINE_INST_COUNT(GrGLProgram)
23 23
24 #define GL_CALL(X) GR_GL_CALL(fContext.interface(), X) 24 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X)
25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContext.interface(), R, X) 25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X)
26 26
27 SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, 27 SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false,
28 "Print the source code for all shaders generated."); 28 "Print the source code for all shaders generated.");
29 29
30 #define COL_ATTR_NAME "aColor" 30 #define COL_ATTR_NAME "aColor"
31 #define COV_ATTR_NAME "aCoverage" 31 #define COV_ATTR_NAME "aCoverage"
32 #define EDGE_ATTR_NAME "aEdge" 32 #define EDGE_ATTR_NAME "aEdge"
33 33
34 namespace { 34 namespace {
35 inline const char* declared_color_output_name() { return "fsColorOut"; } 35 inline const char* declared_color_output_name() { return "fsColorOut"; }
36 inline const char* dual_source_output_name() { return "dualSourceOut"; } 36 inline const char* dual_source_output_name() { return "dualSourceOut"; }
37 } 37 }
38 38
39 GrGLProgram* GrGLProgram::Create(const GrGLContext& gl, 39 GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu,
40 const GrGLProgramDesc& desc, 40 const GrGLProgramDesc& desc,
41 const GrEffectStage* colorStages[], 41 const GrEffectStage* colorStages[],
42 const GrEffectStage* coverageStages[]) { 42 const GrEffectStage* coverageStages[]) {
43 GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, colorStages, cover ageStages)); 43 GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gpu, desc, colorStages, cove rageStages));
44 if (!program->succeeded()) { 44 if (!program->succeeded()) {
45 delete program; 45 delete program;
46 program = NULL; 46 program = NULL;
47 } 47 }
48 return program; 48 return program;
49 } 49 }
50 50
51 GrGLProgram::GrGLProgram(const GrGLContext& gl, 51 GrGLProgram::GrGLProgram(GrGpuGL* gpu,
52 const GrGLProgramDesc& desc, 52 const GrGLProgramDesc& desc,
53 const GrEffectStage* colorStages[], 53 const GrEffectStage* colorStages[],
54 const GrEffectStage* coverageStages[]) 54 const GrEffectStage* coverageStages[])
55 : fContext(gl) 55 : fGpu(gpu)
56 , fUniformManager(gl) { 56 , fUniformManager(gpu) {
57 fDesc = desc; 57 fDesc = desc;
58 fVShaderID = 0; 58 fVShaderID = 0;
59 fGShaderID = 0; 59 fGShaderID = 0;
60 fFShaderID = 0; 60 fFShaderID = 0;
61 fProgramID = 0; 61 fProgramID = 0;
62 62
63 fDstCopyTexUnit = -1; 63 fDstCopyTexUnit = -1;
64 64
65 fColor = GrColor_ILLEGAL; 65 fColor = GrColor_ILLEGAL;
66 fColorFilterColor = GrColor_ILLEGAL; 66 fColorFilterColor = GrColor_ILLEGAL;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 default: 279 default:
280 GrCrash("Unknown color type."); 280 GrCrash("Unknown color type.");
281 return kNone_GrSLConstantVec; 281 return kNone_GrSLConstantVec;
282 } 282 }
283 } 283 }
284 284
285 void GrGLProgram::genGeometryShader(GrGLShaderBuilder::VertexBuilder* vertexBuil der) const { 285 void GrGLProgram::genGeometryShader(GrGLShaderBuilder::VertexBuilder* vertexBuil der) const {
286 #if GR_GL_EXPERIMENTAL_GS 286 #if GR_GL_EXPERIMENTAL_GS
287 // TODO: The builder should add all this glue code. 287 // TODO: The builder should add all this glue code.
288 if (fDesc.getHeader().fExperimentalGS) { 288 if (fDesc.getHeader().fExperimentalGS) {
289 SkASSERT(fContext.info().glslGeneration() >= k150_GrGLSLGeneration); 289 SkASSERT(fGpu->glslGeneration() >= k150_GrGLSLGeneration);
290 vertexBuilder->fGSHeader.append("layout(triangles) in;\n" 290 vertexBuilder->fGSHeader.append("layout(triangles) in;\n"
291 "layout(triangle_strip, max_vertices = 6 ) out;\n"); 291 "layout(triangle_strip, max_vertices = 6 ) out;\n");
292 vertexBuilder->gsCodeAppend("\tfor (int i = 0; i < 3; ++i) {\n" 292 vertexBuilder->gsCodeAppend("\tfor (int i = 0; i < 3; ++i) {\n"
293 "\t\tgl_Position = gl_in[i].gl_Position;\n") ; 293 "\t\tgl_Position = gl_in[i].gl_Position;\n") ;
294 if (fDesc.getHeader().fEmitsPointSize) { 294 if (fDesc.getHeader().fEmitsPointSize) {
295 vertexBuilder->gsCodeAppend("\t\tgl_PointSize = 1.0;\n"); 295 vertexBuilder->gsCodeAppend("\t\tgl_PointSize = 1.0;\n");
296 } 296 }
297 SkASSERT(vertexBuilder->fGSInputs.count() == vertexBuilder->fGSOutputs.c ount()); 297 SkASSERT(vertexBuilder->fGSInputs.count() == vertexBuilder->fGSOutputs.c ount());
298 int count = vertexBuilder->fGSInputs.count(); 298 int count = vertexBuilder->fGSInputs.count();
299 for (int i = 0; i < count; ++i) { 299 for (int i = 0; i < count; ++i) {
(...skipping 28 matching lines...) Expand all
328 for (int i = 0; i < stringCnt; ++i) { 328 for (int i = 0; i < stringCnt; ++i) {
329 if (NULL == stringLengths || stringLengths[i] < 0) { 329 if (NULL == stringLengths || stringLengths[i] < 0) {
330 GrPrintf(strings[i]); 330 GrPrintf(strings[i]);
331 } else { 331 } else {
332 GrPrintf("%.*s", stringLengths[i], strings[i]); 332 GrPrintf("%.*s", stringLengths[i], strings[i]);
333 } 333 }
334 } 334 }
335 } 335 }
336 336
337 // Compiles a GL shader, returns shader ID or 0 if failed params have same meani ng as glShaderSource 337 // Compiles a GL shader, returns shader ID or 0 if failed params have same meani ng as glShaderSource
338 GrGLuint compile_shader(const GrGLContext& gl, 338 GrGLuint compile_shader(const GrGLInterface* gli,
339 GrGLenum type, 339 GrGLenum type,
340 int stringCnt, 340 int stringCnt,
341 const char** strings, 341 const char** strings,
342 int* stringLengths) { 342 int* stringLengths) {
343 SK_TRACE_EVENT1("GrGLProgram::CompileShader", 343 SK_TRACE_EVENT1("GrGLProgram::CompileShader",
344 "stringCount", SkStringPrintf("%i", stringCnt).c_str()); 344 "stringCount", SkStringPrintf("%i", stringCnt).c_str());
345 345
346 GrGLuint shader; 346 GrGLuint shader;
347 GR_GL_CALL_RET(gl.interface(), shader, CreateShader(type)); 347 GR_GL_CALL_RET(gli, shader, CreateShader(type));
348 if (0 == shader) { 348 if (0 == shader) {
349 return 0; 349 return 0;
350 } 350 }
351 351
352 const GrGLInterface* gli = gl.interface();
353 GrGLint compiled = GR_GL_INIT_ZERO; 352 GrGLint compiled = GR_GL_INIT_ZERO;
354 GR_GL_CALL(gli, ShaderSource(shader, stringCnt, strings, stringLengths)); 353 GR_GL_CALL(gli, ShaderSource(shader, stringCnt, strings, stringLengths));
355 GR_GL_CALL(gli, CompileShader(shader)); 354 GR_GL_CALL(gli, CompileShader(shader));
356 GR_GL_CALL(gli, GetShaderiv(shader, GR_GL_COMPILE_STATUS, &compiled)); 355 GR_GL_CALL(gli, GetShaderiv(shader, GR_GL_COMPILE_STATUS, &compiled));
357 356
358 if (!compiled) { 357 if (!compiled) {
359 GrGLint infoLen = GR_GL_INIT_ZERO; 358 GrGLint infoLen = GR_GL_INIT_ZERO;
360 GR_GL_CALL(gli, GetShaderiv(shader, GR_GL_INFO_LOG_LENGTH, &infoLen)); 359 GR_GL_CALL(gli, GetShaderiv(shader, GR_GL_INFO_LOG_LENGTH, &infoLen));
361 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger 360 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger
362 if (infoLen > 0) { 361 if (infoLen > 0) {
363 // retrieve length even though we don't need it to workaround bug in chrome cmd buffer 362 // retrieve length even though we don't need it to workaround bug in chrome cmd buffer
364 // param validation. 363 // param validation.
365 GrGLsizei length = GR_GL_INIT_ZERO; 364 GrGLsizei length = GR_GL_INIT_ZERO;
366 GR_GL_CALL(gli, GetShaderInfoLog(shader, infoLen+1, 365 GR_GL_CALL(gli, GetShaderInfoLog(shader, infoLen+1,
367 &length, (char*)log.get())); 366 &length, (char*)log.get()));
368 print_shader(stringCnt, strings, stringLengths); 367 print_shader(stringCnt, strings, stringLengths);
369 GrPrintf("\n%s", log.get()); 368 GrPrintf("\n%s", log.get());
370 } 369 }
371 SkDEBUGFAIL("Shader compilation failed!"); 370 SkDEBUGFAIL("Shader compilation failed!");
372 GR_GL_CALL(gli, DeleteShader(shader)); 371 GR_GL_CALL(gli, DeleteShader(shader));
373 return 0; 372 return 0;
374 } 373 }
375 return shader; 374 return shader;
376 } 375 }
377 376
378 // helper version of above for when shader is already flattened into a single Sk String 377 // helper version of above for when shader is already flattened into a single Sk String
379 GrGLuint compile_shader(const GrGLContext& gl, GrGLenum type, const SkString& sh ader) { 378 GrGLuint compile_shader(const GrGLInterface* gli, GrGLenum type, const SkString& shader) {
380 const GrGLchar* str = shader.c_str(); 379 const GrGLchar* str = shader.c_str();
381 int length = shader.size(); 380 int length = shader.size();
382 return compile_shader(gl, type, 1, &str, &length); 381 return compile_shader(gli, type, 1, &str, &length);
383 } 382 }
384 383
385 void expand_known_value4f(SkString* string, GrSLConstantVec vec) { 384 void expand_known_value4f(SkString* string, GrSLConstantVec vec) {
386 SkASSERT(string->isEmpty() == (vec != kNone_GrSLConstantVec)); 385 SkASSERT(string->isEmpty() == (vec != kNone_GrSLConstantVec));
387 switch (vec) { 386 switch (vec) {
388 case kNone_GrSLConstantVec: 387 case kNone_GrSLConstantVec:
389 break; 388 break;
390 case kZeros_GrSLConstantVec: 389 case kZeros_GrSLConstantVec:
391 *string = GrGLSLZerosVecf(4); 390 *string = GrGLSLZerosVecf(4);
392 break; 391 break;
(...skipping 12 matching lines...) Expand all
405 SkASSERT(!fGShaderID); 404 SkASSERT(!fGShaderID);
406 SkASSERT(!fFShaderID); 405 SkASSERT(!fFShaderID);
407 406
408 SkString shader; 407 SkString shader;
409 if (GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder.getVertexBuild er()) { 408 if (GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder.getVertexBuild er()) {
410 vertexBuilder->vsGetShader(&shader); 409 vertexBuilder->vsGetShader(&shader);
411 if (c_PrintShaders) { 410 if (c_PrintShaders) {
412 GrPrintf(shader.c_str()); 411 GrPrintf(shader.c_str());
413 GrPrintf("\n"); 412 GrPrintf("\n");
414 } 413 }
415 if (!(fVShaderID = compile_shader(fContext, GR_GL_VERTEX_SHADER, shader) )) { 414 if (!(fVShaderID = compile_shader(fGpu->glInterface(), GR_GL_VERTEX_SHAD ER, shader))) {
416 return false; 415 return false;
417 } 416 }
418 417
419 #if GR_GL_EXPERIMENTAL_GS 418 #if GR_GL_EXPERIMENTAL_GS
420 if (fDesc.getHeader().fExperimentalGS) { 419 if (fDesc.getHeader().fExperimentalGS) {
421 vertexBuilder->gsGetShader(&shader); 420 vertexBuilder->gsGetShader(&shader);
422 if (c_PrintShaders) { 421 if (c_PrintShaders) {
423 GrPrintf(shader.c_str()); 422 GrPrintf(shader.c_str());
424 GrPrintf("\n"); 423 GrPrintf("\n");
425 } 424 }
426 if (!(fGShaderID = compile_shader(fContext, GR_GL_GEOMETRY_SHADER, s hader))) { 425 if (!(fGShaderID = compile_shader(fGpu->glInterface(), GR_GL_GEOMETR Y_SHADER, shader))) {
427 return false; 426 return false;
428 } 427 }
429 } 428 }
430 #endif 429 #endif
431 } 430 }
432 431
433 builder.fsGetShader(&shader); 432 builder.fsGetShader(&shader);
434 if (c_PrintShaders) { 433 if (c_PrintShaders) {
435 GrPrintf(shader.c_str()); 434 GrPrintf(shader.c_str());
436 GrPrintf("\n"); 435 GrPrintf("\n");
437 } 436 }
438 if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader))) { 437 if (!(fFShaderID = compile_shader(fGpu->glInterface(), GR_GL_FRAGMENT_SHADER , shader))) {
439 return false; 438 return false;
440 } 439 }
441 440
442 return true; 441 return true;
443 } 442 }
444 443
445 bool GrGLProgram::genProgram(const GrEffectStage* colorStages[], 444 bool GrGLProgram::genProgram(const GrEffectStage* colorStages[],
446 const GrEffectStage* coverageStages[]) { 445 const GrEffectStage* coverageStages[]) {
447 SkASSERT(0 == fProgramID); 446 SkASSERT(0 == fProgramID);
448 447
449 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader(); 448 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader();
450 449
451 bool needsVertexShader = true; 450 bool needsVertexShader = true;
452 451
453 GrGLShaderBuilder builder(fContext.info(), fUniformManager, fDesc, needsVert exShader); 452 GrGLShaderBuilder builder(fGpu->ctxInfo(), fUniformManager, fDesc, needsVert exShader);
454 453
455 if (GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder.getVertexBuild er()) { 454 if (GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder.getVertexBuild er()) {
456 const char* viewMName; 455 const char* viewMName;
457 fUniformHandles.fViewMatrixUni = builder.addUniform(GrGLShaderBuilder::k Vertex_Visibility, 456 fUniformHandles.fViewMatrixUni = builder.addUniform(GrGLShaderBuilder::k Vertex_Visibility,
458 kMat33f_GrSLType, "V iewM", &viewMName); 457 kMat33f_GrSLType, "V iewM", &viewMName);
459 458
460 vertexBuilder->vsCodeAppendf("\tvec3 pos3 = %s * vec3(%s, 1);\n" 459 vertexBuilder->vsCodeAppendf("\tvec3 pos3 = %s * vec3(%s, 1);\n"
461 "\tgl_Position = vec4(pos3.xy, 0, pos3.z);\ n", 460 "\tgl_Position = vec4(pos3.xy, 0, pos3.z);\ n",
462 viewMName, vertexBuilder->positionAttribute ().c_str()); 461 viewMName, vertexBuilder->positionAttribute ().c_str());
463 462
464 // we output point size in the GS if present 463 // we output point size in the GS if present
465 if (header.fEmitsPointSize 464 if (header.fEmitsPointSize
466 #if GR_GL_EXPERIMENTAL_GS 465 #if GR_GL_EXPERIMENTAL_GS
467 && !header.fExperimentalGS 466 && !header.fExperimentalGS
468 #endif 467 #endif
469 ) { 468 ) {
470 vertexBuilder->vsCodeAppend("\tgl_PointSize = 1.0;\n"); 469 vertexBuilder->vsCodeAppend("\tgl_PointSize = 1.0;\n");
471 } 470 }
472 } 471 }
473 472
474 // the dual source output has no canonical var name, have to 473 // the dual source output has no canonical var name, have to
475 // declare an output, which is incompatible with gl_FragColor/gl_FragData. 474 // declare an output, which is incompatible with gl_FragColor/gl_FragData.
476 bool dualSourceOutputWritten = false; 475 bool dualSourceOutputWritten = false;
477 476
478 GrGLShaderVar colorOutput; 477 GrGLShaderVar colorOutput;
479 bool isColorDeclared = GrGLSLSetupFSColorOuput(fContext.info().glslGeneratio n(), 478 bool isColorDeclared = GrGLSLSetupFSColorOuput(fGpu->glslGeneration(),
480 declared_color_output_name(), 479 declared_color_output_name(),
481 &colorOutput); 480 &colorOutput);
482 if (isColorDeclared) { 481 if (isColorDeclared) {
483 builder.fsOutputAppend(colorOutput); 482 builder.fsOutputAppend(colorOutput);
484 } 483 }
485 484
486 // incoming color to current stage being processed. 485 // incoming color to current stage being processed.
487 SkString inColor; 486 SkString inColor;
488 GrSLConstantVec knownColorValue = this->genInputColor(&builder, &inColor); 487 GrSLConstantVec knownColorValue = this->genInputColor(&builder, &inColor);
489 488
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 UniformHandle handle = effect->fSamplerUnis[s]; 789 UniformHandle handle = effect->fSamplerUnis[s];
791 if (handle.isValid()) { 790 if (handle.isValid()) {
792 fUniformManager.setSampler(handle, *texUnitIdx); 791 fUniformManager.setSampler(handle, *texUnitIdx);
793 effect->fTextureUnits[s] = (*texUnitIdx)++; 792 effect->fTextureUnits[s] = (*texUnitIdx)++;
794 } 793 }
795 } 794 }
796 } 795 }
797 796
798 /////////////////////////////////////////////////////////////////////////////// 797 ///////////////////////////////////////////////////////////////////////////////
799 798
800 void GrGLProgram::setEffectData(GrGpuGL* gpu, 799 void GrGLProgram::setEffectData(const GrEffectStage& stage,
801 const GrEffectStage& stage,
802 const EffectAndSamplers& effect) { 800 const EffectAndSamplers& effect) {
803 801
804 // Let the GrGLEffect set its data. 802 // Let the GrGLEffect set its data.
805 bool explicitLocalCoords = -1 != fDesc.getHeader().fLocalCoordAttributeIndex ; 803 bool explicitLocalCoords = -1 != fDesc.getHeader().fLocalCoordAttributeIndex ;
806 GrDrawEffect drawEffect(stage, explicitLocalCoords); 804 GrDrawEffect drawEffect(stage, explicitLocalCoords);
807 effect.fGLEffect->setData(fUniformManager, drawEffect); 805 effect.fGLEffect->setData(fUniformManager, drawEffect);
808 806
809 // Bind the texures for the effect. 807 // Bind the texures for the effect.
810 int numSamplers = effect.fSamplerUnis.count(); 808 int numSamplers = effect.fSamplerUnis.count();
811 SkASSERT((*stage.getEffect())->numTextures() == numSamplers); 809 SkASSERT((*stage.getEffect())->numTextures() == numSamplers);
812 for (int s = 0; s < numSamplers; ++s) { 810 for (int s = 0; s < numSamplers; ++s) {
813 UniformHandle handle = effect.fSamplerUnis[s]; 811 UniformHandle handle = effect.fSamplerUnis[s];
814 if (handle.isValid()) { 812 if (handle.isValid()) {
815 const GrTextureAccess& access = (*stage.getEffect())->textureAccess( s); 813 const GrTextureAccess& access = (*stage.getEffect())->textureAccess( s);
816 GrGLTexture* texture = static_cast<GrGLTexture*>(access.getTexture() ); 814 GrGLTexture* texture = static_cast<GrGLTexture*>(access.getTexture() );
817 int unit = effect.fTextureUnits[s]; 815 int unit = effect.fTextureUnits[s];
818 gpu->bindTexture(unit, access.getParams(), texture); 816 fGpu->bindTexture(unit, access.getParams(), texture);
819 } 817 }
820 } 818 }
821 } 819 }
822 820
823 void GrGLProgram::setData(GrGpuGL* gpu, 821 void GrGLProgram::setData(GrDrawState::BlendOptFlags blendOpts,
824 GrDrawState::BlendOptFlags blendOpts,
825 const GrEffectStage* colorStages[], 822 const GrEffectStage* colorStages[],
826 const GrEffectStage* coverageStages[], 823 const GrEffectStage* coverageStages[],
827 const GrDeviceCoordTexture* dstCopy, 824 const GrDeviceCoordTexture* dstCopy,
828 SharedGLState* sharedState) { 825 SharedGLState* sharedState) {
829 const GrDrawState& drawState = gpu->getDrawState(); 826 const GrDrawState& drawState = fGpu->getDrawState();
830 827
831 GrColor color; 828 GrColor color;
832 GrColor coverage; 829 GrColor coverage;
833 if (blendOpts & GrDrawState::kEmitTransBlack_BlendOptFlag) { 830 if (blendOpts & GrDrawState::kEmitTransBlack_BlendOptFlag) {
834 color = 0; 831 color = 0;
835 coverage = 0; 832 coverage = 0;
836 } else if (blendOpts & GrDrawState::kEmitCoverage_BlendOptFlag) { 833 } else if (blendOpts & GrDrawState::kEmitCoverage_BlendOptFlag) {
837 color = 0xffffffff; 834 color = 0xffffffff;
838 coverage = drawState.getCoverage(); 835 coverage = drawState.getCoverage();
839 } else { 836 } else {
(...skipping 17 matching lines...) Expand all
857 if (NULL != dstCopy) { 854 if (NULL != dstCopy) {
858 if (fUniformHandles.fDstCopyTopLeftUni.isValid()) { 855 if (fUniformHandles.fDstCopyTopLeftUni.isValid()) {
859 fUniformManager.set2f(fUniformHandles.fDstCopyTopLeftUni, 856 fUniformManager.set2f(fUniformHandles.fDstCopyTopLeftUni,
860 static_cast<GrGLfloat>(dstCopy->offset().fX), 857 static_cast<GrGLfloat>(dstCopy->offset().fX),
861 static_cast<GrGLfloat>(dstCopy->offset().fY)); 858 static_cast<GrGLfloat>(dstCopy->offset().fY));
862 fUniformManager.set2f(fUniformHandles.fDstCopyScaleUni, 859 fUniformManager.set2f(fUniformHandles.fDstCopyScaleUni,
863 1.f / dstCopy->texture()->width(), 860 1.f / dstCopy->texture()->width(),
864 1.f / dstCopy->texture()->height()); 861 1.f / dstCopy->texture()->height());
865 GrGLTexture* texture = static_cast<GrGLTexture*>(dstCopy->texture()) ; 862 GrGLTexture* texture = static_cast<GrGLTexture*>(dstCopy->texture()) ;
866 static GrTextureParams kParams; // the default is clamp, nearest fil tering. 863 static GrTextureParams kParams; // the default is clamp, nearest fil tering.
867 gpu->bindTexture(fDstCopyTexUnit, kParams, texture); 864 fGpu->bindTexture(fDstCopyTexUnit, kParams, texture);
868 } else { 865 } else {
869 SkASSERT(!fUniformHandles.fDstCopyScaleUni.isValid()); 866 SkASSERT(!fUniformHandles.fDstCopyScaleUni.isValid());
870 SkASSERT(!fUniformHandles.fDstCopySamplerUni.isValid()); 867 SkASSERT(!fUniformHandles.fDstCopySamplerUni.isValid());
871 } 868 }
872 } else { 869 } else {
873 SkASSERT(!fUniformHandles.fDstCopyTopLeftUni.isValid()); 870 SkASSERT(!fUniformHandles.fDstCopyTopLeftUni.isValid());
874 SkASSERT(!fUniformHandles.fDstCopyScaleUni.isValid()); 871 SkASSERT(!fUniformHandles.fDstCopyScaleUni.isValid());
875 SkASSERT(!fUniformHandles.fDstCopySamplerUni.isValid()); 872 SkASSERT(!fUniformHandles.fDstCopySamplerUni.isValid());
876 } 873 }
877 874
878 for (int e = 0; e < fColorEffects.count(); ++e) { 875 for (int e = 0; e < fColorEffects.count(); ++e) {
879 // We may have omitted the GrGLEffect because of the color filter logic in genProgram. 876 // We may have omitted the GrGLEffect because of the color filter logic in genProgram.
880 // This can be removed when the color filter is an effect. 877 // This can be removed when the color filter is an effect.
881 if (NULL != fColorEffects[e].fGLEffect) { 878 if (NULL != fColorEffects[e].fGLEffect) {
882 this->setEffectData(gpu, *colorStages[e], fColorEffects[e]); 879 this->setEffectData(*colorStages[e], fColorEffects[e]);
883 } 880 }
884 } 881 }
885 882
886 for (int e = 0; e < fCoverageEffects.count(); ++e) { 883 for (int e = 0; e < fCoverageEffects.count(); ++e) {
887 if (NULL != fCoverageEffects[e].fGLEffect) { 884 if (NULL != fCoverageEffects[e].fGLEffect) {
888 this->setEffectData(gpu, *coverageStages[e], fCoverageEffects[e]); 885 this->setEffectData(*coverageStages[e], fCoverageEffects[e]);
889 } 886 }
890 } 887 }
891 } 888 }
892 889
893 void GrGLProgram::setColor(const GrDrawState& drawState, 890 void GrGLProgram::setColor(const GrDrawState& drawState,
894 GrColor color, 891 GrColor color,
895 SharedGLState* sharedState) { 892 SharedGLState* sharedState) {
896 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader(); 893 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader();
897 if (!drawState.hasColorVertexAttribute()) { 894 if (!drawState.hasColorVertexAttribute()) {
898 switch (header.fColorInput) { 895 switch (header.fColorInput) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 SkScalarToFloat(m[SkMatrix::kMTransX]), 1005 SkScalarToFloat(m[SkMatrix::kMTransX]),
1009 SkScalarToFloat(m[SkMatrix::kMTransY]), 1006 SkScalarToFloat(m[SkMatrix::kMTransY]),
1010 SkScalarToFloat(m[SkMatrix::kMPersp2]) 1007 SkScalarToFloat(m[SkMatrix::kMPersp2])
1011 }; 1008 };
1012 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt); 1009 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt);
1013 fMatrixState.fViewMatrix = drawState.getViewMatrix(); 1010 fMatrixState.fViewMatrix = drawState.getViewMatrix();
1014 fMatrixState.fRenderTargetSize = size; 1011 fMatrixState.fRenderTargetSize = size;
1015 fMatrixState.fRenderTargetOrigin = rt->origin(); 1012 fMatrixState.fRenderTargetOrigin = rt->origin();
1016 } 1013 }
1017 } 1014 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLUniformManager.h » ('j') | src/gpu/gl/GrGpuGL.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698