2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrSimpleTextureEffect_DEFINED
9 #define GrSimpleTextureEffect_DEFINED
11 #include "GrSingleTextureEffect.h"
13 class GrInvariantOutput;
16 * The output color of this effect is a modulation of the input color and a sample from a texture.
17 * It allows explicit specification of the filtering and wrap modes (GrTextureParams). It can use
18 * local coords or device space coords as input texture coords. The input coords may be transformed
21 class GrSimpleTextureEffect : public GrSingleTextureEffect {
23 /* unfiltered, clamp mode */
24 static const GrFragmentProcessor* Create(GrTexture* tex,
25 const SkMatrix& matrix,
26 GrCoordSet coordSet = kLocal_GrCoordSet) {
27 return new GrSimpleTextureEffect(tex, matrix, GrTextureParams::kNone_FilterMode, coordSet);
31 static GrFragmentProcessor* Create(GrTexture* tex,
32 const SkMatrix& matrix,
33 GrTextureParams::FilterMode filterMode,
34 GrCoordSet coordSet = kLocal_GrCoordSet) {
35 return new GrSimpleTextureEffect(tex, matrix, filterMode, coordSet);
38 static GrFragmentProcessor* Create(GrTexture* tex,
39 const SkMatrix& matrix,
40 const GrTextureParams& p,
41 GrCoordSet coordSet = kLocal_GrCoordSet) {
42 return new GrSimpleTextureEffect(tex, matrix, p, coordSet);
45 virtual ~GrSimpleTextureEffect() {}
47 const char* name() const override { return "SimpleTexture"; }
50 GrSimpleTextureEffect(GrTexture* texture,
51 const SkMatrix& matrix,
52 GrTextureParams::FilterMode filterMode,
54 : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) {
55 this->initClassID<GrSimpleTextureEffect>();
58 GrSimpleTextureEffect(GrTexture* texture,
59 const SkMatrix& matrix,
60 const GrTextureParams& params,
62 : GrSingleTextureEffect(texture, matrix, params, coordSet) {
63 this->initClassID<GrSimpleTextureEffect>();
66 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
68 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
70 bool onIsEqual(const GrFragmentProcessor& other) const override { return true; }
72 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
74 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
76 typedef GrSingleTextureEffect INHERITED;