GrSingleTextureEffect.h revision b9086a026844e4cfd08b219e49ce3f12294cba98
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 11#include "GrEffect.h" 12#include "SkMatrix.h" 13 14class GrGLSingleTextureEffect; 15 16/** 17 * An effect that merely blits a single texture; commonly used as a base class. 18 */ 19class GrSingleTextureEffect : public GrEffect { 20 21public: 22 /** These three constructors assume an identity matrix */ 23 GrSingleTextureEffect(GrTexture* texture); /* unfiltered, clamp mode */ 24 GrSingleTextureEffect(GrTexture* texture, bool bilerp); /* clamp mode */ 25 GrSingleTextureEffect(GrTexture* texture, const GrTextureParams&); 26 27 /** These three constructors take an explicit matrix */ 28 GrSingleTextureEffect(GrTexture*, const SkMatrix&); /* unfiltered, clamp mode */ 29 GrSingleTextureEffect(GrTexture*, const SkMatrix&, bool bilerp); /* clamp mode */ 30 GrSingleTextureEffect(GrTexture*, const SkMatrix&, const GrTextureParams&); 31 32 virtual ~GrSingleTextureEffect(); 33 34 virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE; 35 36 static const char* Name() { return "Single Texture"; } 37 38 const SkMatrix& getMatrix() const { return fMatrix; } 39 40 typedef GrGLSingleTextureEffect GLEffect; 41 42 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 43 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 } 48private: 49 GR_DECLARE_EFFECT_TEST; 50 51 GrTextureAccess fTextureAccess; 52 SkMatrix fMatrix; 53 54 typedef GrEffect INHERITED; 55}; 56 57#endif 58