blob: e598f2f66ee83b04b5ee3abad55ccfbea43e6151 [file] [log] [blame]
tomhudson@google.comd0c1a062012-07-12 17:23:52 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrSingleTextureEffect_DEFINED
9#define GrSingleTextureEffect_DEFINED
10
bsalomon@google.coma469c282012-10-24 18:28:34 +000011#include "GrEffect.h"
bsalomon@google.comb9086a02012-11-01 18:02:54 +000012#include "SkMatrix.h"
tomhudson@google.comd0c1a062012-07-12 17:23:52 +000013
tomhudson@google.comaa72eab2012-07-19 18:01:07 +000014class GrGLSingleTextureEffect;
15
16/**
17 * An effect that merely blits a single texture; commonly used as a base class.
18 */
bsalomon@google.coma469c282012-10-24 18:28:34 +000019class GrSingleTextureEffect : public GrEffect {
tomhudson@google.comd0c1a062012-07-12 17:23:52 +000020
21public:
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +000022 /** These three constructors assume an identity matrix */
23 GrSingleTextureEffect(GrTexture* texture); /* unfiltered, clamp mode */
24 GrSingleTextureEffect(GrTexture* texture, bool bilerp); /* clamp mode */
bsalomon@google.com115b06f2012-11-01 15:47:55 +000025 GrSingleTextureEffect(GrTexture* texture, const GrTextureParams&);
bsalomon@google.comc3a58f32012-11-01 15:40:47 +000026
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +000027 /** These three constructors take an explicit matrix */
bsalomon@google.comb9086a02012-11-01 18:02:54 +000028 GrSingleTextureEffect(GrTexture*, const SkMatrix&); /* unfiltered, clamp mode */
29 GrSingleTextureEffect(GrTexture*, const SkMatrix&, bool bilerp); /* clamp mode */
30 GrSingleTextureEffect(GrTexture*, const SkMatrix&, const GrTextureParams&);
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +000031
tomhudson@google.comd0c1a062012-07-12 17:23:52 +000032 virtual ~GrSingleTextureEffect();
33
bsalomon@google.com6d003d12012-09-11 15:45:20 +000034 virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
tomhudson@google.comd0c1a062012-07-12 17:23:52 +000035
tomhudson@google.comaa72eab2012-07-19 18:01:07 +000036 static const char* Name() { return "Single Texture"; }
37
bsalomon@google.comb9086a02012-11-01 18:02:54 +000038 const SkMatrix& getMatrix() const { return fMatrix; }
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +000039
bsalomon@google.com422e81a2012-10-25 14:11:03 +000040 typedef GrGLSingleTextureEffect GLEffect;
tomhudson@google.comaa72eab2012-07-19 18:01:07 +000041
bsalomon@google.com396e61f2012-10-25 19:00:29 +000042 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
tomhudson@google.comaa72eab2012-07-19 18:01:07 +000043
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +000044 virtual bool isEqual(const GrEffect& effect) const SK_OVERRIDE {
45 const GrSingleTextureEffect& ste = static_cast<const GrSingleTextureEffect&>(effect);
46 return INHERITED::isEqual(effect) && fMatrix.cheapEqualTo(ste.getMatrix());
47 }
tomhudson@google.comd0c1a062012-07-12 17:23:52 +000048private:
bsalomon@google.comf271cc72012-10-24 19:35:13 +000049 GR_DECLARE_EFFECT_TEST;
bsalomon@google.com0a7672f2012-08-03 18:12:20 +000050
bsalomon@google.com6d003d12012-09-11 15:45:20 +000051 GrTextureAccess fTextureAccess;
bsalomon@google.comb9086a02012-11-01 18:02:54 +000052 SkMatrix fMatrix;
tomhudson@google.comd0c1a062012-07-12 17:23:52 +000053
bsalomon@google.coma469c282012-10-24 18:28:34 +000054 typedef GrEffect INHERITED;
tomhudson@google.comd0c1a062012-07-12 17:23:52 +000055};
56
57#endif