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