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 |
34 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 38 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
35 fsBuilder->codeAppendf("%s = ", args.fOutput); | 39 fsBuilder->codeAppendf("%s = ", args.fOutput); |
36 fsBuilder->appendTextureLookupAndModulate(args.fInput, | 40 fsBuilder->appendTextureLookupAndModulate(args.fInput, |
37 args.fSamplers[0], | 41 args.fSamplers[0], |
38 v.fsIn(), | 42 v.fsIn(), |
39 kVec2f_GrSLType); | 43 kVec2f_GrSLType); |
40 fsBuilder->codeAppend(";"); | 44 fsBuilder->codeAppend(";"); |
41 } | 45 } |
42 | 46 |
43 virtual void setData(const GrGLProgramDataManager&, | 47 virtual void setData(const GrGLProgramDataManager&, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 }; | 95 }; |
92 SkShader::TileMode tileModes[] = { | 96 SkShader::TileMode tileModes[] = { |
93 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 97 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
94 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 98 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
95 }; | 99 }; |
96 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : | 100 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : |
97 GrTextureParams::kNon
e_FilterMode); | 101 GrTextureParams::kNon
e_FilterMode); |
98 | 102 |
99 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params); | 103 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params); |
100 } | 104 } |
OLD | NEW |