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 "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
10 #include "gl/builders/GrGLProgramBuilder.h" | 10 #include "gl/builders/GrGLProgramBuilder.h" |
11 #include "gl/GrGLProcessor.h" | 11 #include "gl/GrGLProcessor.h" |
12 #include "gl/GrGLSL.h" | 12 #include "gl/GrGLSL.h" |
13 #include "gl/GrGLTexture.h" | 13 #include "gl/GrGLTexture.h" |
14 #include "gl/GrGLGeometryProcessor.h" | 14 #include "gl/GrGLGeometryProcessor.h" |
15 #include "GrTBackendProcessorFactory.h" | 15 #include "GrTBackendProcessorFactory.h" |
16 #include "GrTexture.h" | 16 #include "GrTexture.h" |
17 | 17 |
18 class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor { | 18 class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor { |
19 public: | 19 public: |
20 GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, | 20 GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, cons
t GrProcessor&) |
21 const GrGeometryProcessor&, | |
22 const GrBatchTracker&) | |
23 : INHERITED (factory) {} | 21 : INHERITED (factory) {} |
24 | 22 |
25 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { | 23 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { |
26 const GrCustomCoordsTextureEffect& cte = | 24 const GrCustomCoordsTextureEffect& cte = |
27 args.fGP.cast<GrCustomCoordsTextureEffect>(); | 25 args.fGP.cast<GrCustomCoordsTextureEffect>(); |
28 | 26 |
29 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 27 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
30 | 28 |
31 GrGLVertToFrag v(kVec2f_GrSLType); | 29 GrGLVertToFrag v(kVec2f_GrSLType); |
32 args.fPB->addVarying("TextureCoords", &v); | 30 args.fPB->addVarying("TextureCoords", &v); |
(...skipping 11 matching lines...) Expand all Loading... |
44 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition()
, | 42 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition()
, |
45 vsBuilder->uViewM(), cte.inPosition()->fName); | 43 vsBuilder->uViewM(), cte.inPosition()->fName); |
46 | 44 |
47 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 45 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
48 fsBuilder->codeAppendf("%s = ", args.fOutputCoverage); | 46 fsBuilder->codeAppendf("%s = ", args.fOutputCoverage); |
49 fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_GrSLT
ype); | 47 fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_GrSLT
ype); |
50 fsBuilder->codeAppend(";"); | 48 fsBuilder->codeAppend(";"); |
51 } | 49 } |
52 | 50 |
53 virtual void setData(const GrGLProgramDataManager&, | 51 virtual void setData(const GrGLProgramDataManager&, |
54 const GrGeometryProcessor&, | 52 const GrProcessor&) SK_OVERRIDE {} |
55 const GrBatchTracker&) SK_OVERRIDE {} | |
56 | 53 |
57 static inline void GenKey(const GrGeometryProcessor& proc, | 54 static inline void GenKey(const GrProcessor& proc, const GrGLCaps&, |
58 const GrBatchTracker&, | |
59 const GrGLCaps&, | |
60 GrProcessorKeyBuilder* b) { | 55 GrProcessorKeyBuilder* b) { |
61 const GrCustomCoordsTextureEffect& gp = proc.cast<GrCustomCoordsTextureE
ffect>(); | 56 const GrCustomCoordsTextureEffect& gp = proc.cast<GrCustomCoordsTextureE
ffect>(); |
62 | 57 |
63 b->add32(SkToBool(gp.inColor())); | 58 b->add32(SkToBool(gp.inColor())); |
64 } | 59 } |
65 | 60 |
66 | 61 |
67 private: | 62 private: |
68 typedef GrGLGeometryProcessor INHERITED; | 63 typedef GrGLGeometryProcessor INHERITED; |
69 }; | 64 }; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 }; | 115 }; |
121 SkShader::TileMode tileModes[] = { | 116 SkShader::TileMode tileModes[] = { |
122 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 117 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
123 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 118 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
124 }; | 119 }; |
125 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : | 120 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : |
126 GrTextureParams::kNon
e_FilterMode); | 121 GrTextureParams::kNon
e_FilterMode); |
127 | 122 |
128 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params, random-
>nextBool()); | 123 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params, random-
>nextBool()); |
129 } | 124 } |
OLD | NEW |