OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrCustomCoordsTextureEffect.h" | 8 #include "GrCustomCoordsTextureEffect.h" |
9 #include "gl/builders/GrGLProgramBuilder.h" | 9 #include "gl/builders/GrGLProgramBuilder.h" |
10 #include "gl/GrGLProcessor.h" | 10 #include "gl/GrGLProcessor.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 args.fGP.cast<GrCustomCoordsTextureEffect>(); | 24 args.fGP.cast<GrCustomCoordsTextureEffect>(); |
25 SkASSERT(1 == customCoordsTextureEffect.getVertexAttribs().count()); | 25 SkASSERT(1 == customCoordsTextureEffect.getVertexAttribs().count()); |
26 | 26 |
27 GrGLVertToFrag v(kVec2f_GrSLType); | 27 GrGLVertToFrag v(kVec2f_GrSLType); |
28 args.fPB->addVarying("TextureCoords", &v); | 28 args.fPB->addVarying("TextureCoords", &v); |
29 | 29 |
30 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 30 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
31 const GrShaderVar& inTextureCoords = customCoordsTextureEffect.inTexture
Coords(); | 31 const GrShaderVar& inTextureCoords = customCoordsTextureEffect.inTexture
Coords(); |
32 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), inTextureCoords.c_str()); | 32 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), inTextureCoords.c_str()); |
33 | 33 |
34 // setup position varying | |
35 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition()
, | |
36 vsBuilder->uViewM(), vsBuilder->inPosition()); | |
37 | |
38 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 34 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
39 fsBuilder->codeAppendf("%s = ", args.fOutput); | 35 fsBuilder->codeAppendf("%s = ", args.fOutput); |
40 fsBuilder->appendTextureLookupAndModulate(args.fInput, | 36 fsBuilder->appendTextureLookupAndModulate(args.fInput, |
41 args.fSamplers[0], | 37 args.fSamplers[0], |
42 v.fsIn(), | 38 v.fsIn(), |
43 kVec2f_GrSLType); | 39 kVec2f_GrSLType); |
44 fsBuilder->codeAppend(";"); | 40 fsBuilder->codeAppend(";"); |
45 } | 41 } |
46 | 42 |
47 virtual void setData(const GrGLProgramDataManager&, | 43 virtual void setData(const GrGLProgramDataManager&, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 }; | 91 }; |
96 SkShader::TileMode tileModes[] = { | 92 SkShader::TileMode tileModes[] = { |
97 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 93 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
98 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 94 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
99 }; | 95 }; |
100 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : | 96 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : |
101 GrTextureParams::kNon
e_FilterMode); | 97 GrTextureParams::kNon
e_FilterMode); |
102 | 98 |
103 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params); | 99 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params); |
104 } | 100 } |
OLD | NEW |