tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 1 | /* |
| 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.com | a469c28 | 2012-10-24 18:28:34 +0000 | [diff] [blame] | 11 | #include "GrEffect.h" |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame^] | 12 | #include "SkMatrix.h" |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 13 | |
tomhudson@google.com | aa72eab | 2012-07-19 18:01:07 +0000 | [diff] [blame] | 14 | class GrGLSingleTextureEffect; |
| 15 | |
| 16 | /** |
| 17 | * An effect that merely blits a single texture; commonly used as a base class. |
| 18 | */ |
bsalomon@google.com | a469c28 | 2012-10-24 18:28:34 +0000 | [diff] [blame] | 19 | class GrSingleTextureEffect : public GrEffect { |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 20 | |
| 21 | public: |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 22 | /** These three constructors assume an identity matrix */ |
| 23 | GrSingleTextureEffect(GrTexture* texture); /* unfiltered, clamp mode */ |
| 24 | GrSingleTextureEffect(GrTexture* texture, bool bilerp); /* clamp mode */ |
bsalomon@google.com | 115b06f | 2012-11-01 15:47:55 +0000 | [diff] [blame] | 25 | GrSingleTextureEffect(GrTexture* texture, const GrTextureParams&); |
bsalomon@google.com | c3a58f3 | 2012-11-01 15:40:47 +0000 | [diff] [blame] | 26 | |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 27 | /** These three constructors take an explicit matrix */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame^] | 28 | 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.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 31 | |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 32 | virtual ~GrSingleTextureEffect(); |
| 33 | |
bsalomon@google.com | 6d003d1 | 2012-09-11 15:45:20 +0000 | [diff] [blame] | 34 | virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE; |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 35 | |
tomhudson@google.com | aa72eab | 2012-07-19 18:01:07 +0000 | [diff] [blame] | 36 | static const char* Name() { return "Single Texture"; } |
| 37 | |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame^] | 38 | const SkMatrix& getMatrix() const { return fMatrix; } |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 39 | |
bsalomon@google.com | 422e81a | 2012-10-25 14:11:03 +0000 | [diff] [blame] | 40 | typedef GrGLSingleTextureEffect GLEffect; |
tomhudson@google.com | aa72eab | 2012-07-19 18:01:07 +0000 | [diff] [blame] | 41 | |
bsalomon@google.com | 396e61f | 2012-10-25 19:00:29 +0000 | [diff] [blame] | 42 | virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
tomhudson@google.com | aa72eab | 2012-07-19 18:01:07 +0000 | [diff] [blame] | 43 | |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 44 | 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.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 48 | private: |
bsalomon@google.com | f271cc7 | 2012-10-24 19:35:13 +0000 | [diff] [blame] | 49 | GR_DECLARE_EFFECT_TEST; |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 50 | |
bsalomon@google.com | 6d003d1 | 2012-09-11 15:45:20 +0000 | [diff] [blame] | 51 | GrTextureAccess fTextureAccess; |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame^] | 52 | SkMatrix fMatrix; |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 53 | |
bsalomon@google.com | a469c28 | 2012-10-24 18:28:34 +0000 | [diff] [blame] | 54 | typedef GrEffect INHERITED; |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | #endif |