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 GrGLSimpleTextureEffect;
16 * The output color of this effect is a modulation of the input color and a sample from a texture.
17 * The coord to sample the texture is determine by a matrix. It allows explicit specification of
18 * the filtering and wrap modes (GrTextureParams).
20 class GrSimpleTextureEffect : public GrSingleTextureEffect {
22 /* unfiltered, clamp mode */
23 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix) {
24 SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix)));
25 return CreateEffectRef(effect);
29 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, bool bilerp) {
30 SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, bilerp)));
31 return CreateEffectRef(effect);
34 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const GrTextureParams& p) {
35 SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p)));
36 return CreateEffectRef(effect);
39 virtual ~GrSimpleTextureEffect() {}
41 static const char* Name() { return "Texture"; }
43 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
45 typedef GrGLSimpleTextureEffect GLEffect;
47 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
50 GrSimpleTextureEffect(GrTexture* texture, const SkMatrix& matrix)
51 : GrSingleTextureEffect(texture, matrix) {}
52 GrSimpleTextureEffect(GrTexture* texture, const SkMatrix& matrix, bool bilerp)
53 : GrSingleTextureEffect(texture, matrix, bilerp) {}
54 GrSimpleTextureEffect(GrTexture* texture, const SkMatrix& matrix, const GrTextureParams& params)
55 : GrSingleTextureEffect(texture, matrix, params) {}
57 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
58 const GrSimpleTextureEffect& ste = static_cast<const GrSimpleTextureEffect&>(other);
59 return this->hasSameTextureParamsAndMatrix(ste);
62 GR_DECLARE_EFFECT_TEST;
64 typedef GrSingleTextureEffect INHERITED;