From 68b58c95384dd6c2fd389a5b4bbf8fc468819454 Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Thu, 17 Jan 2013 16:50:08 +0000 Subject: Remove default implementation of GrEffect::isEqual. Make GrSingleTextureEffect abstract. Review URL: https://codereview.appspot.com/7142049 git-svn-id: http://skia.googlecode.com/svn/trunk@7254 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/effects/GrSimpleTextureEffect.h | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/gpu/effects/GrSimpleTextureEffect.h (limited to 'src/gpu/effects/GrSimpleTextureEffect.h') diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h new file mode 100644 index 0000000000..5ccbe33497 --- /dev/null +++ b/src/gpu/effects/GrSimpleTextureEffect.h @@ -0,0 +1,67 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrSimpleTextureEffect_DEFINED +#define GrSimpleTextureEffect_DEFINED + +#include "GrSingleTextureEffect.h" + +class GrGLSimpleTextureEffect; + +/** + * The output color of this effect is a modulation of the input color and a sample from a texture. + * The coord to sample the texture is determine by a matrix. It allows explicit specification of + * the filtering and wrap modes (GrTextureParams). + */ +class GrSimpleTextureEffect : public GrSingleTextureEffect { +public: + /* unfiltered, clamp mode */ + static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix) { + SkAutoTUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix))); + return CreateEffectRef(effect); + } + + /* clamp mode */ + static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, bool bilerp) { + SkAutoTUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, bilerp))); + return CreateEffectRef(effect); + } + + static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const GrTextureParams& p) { + SkAutoTUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p))); + return CreateEffectRef(effect); + } + + virtual ~GrSimpleTextureEffect() {} + + static const char* Name() { return "Texture"; } + + virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; + + typedef GrGLSimpleTextureEffect GLEffect; + + virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; + +private: + GrSimpleTextureEffect(GrTexture* texture, const SkMatrix& matrix) + : GrSingleTextureEffect(texture, matrix) {} + GrSimpleTextureEffect(GrTexture* texture, const SkMatrix& matrix, bool bilerp) + : GrSingleTextureEffect(texture, matrix, bilerp) {} + GrSimpleTextureEffect(GrTexture* texture, const SkMatrix& matrix, const GrTextureParams& params) + : GrSingleTextureEffect(texture, matrix, params) {} + + virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE { + const GrSimpleTextureEffect& ste = static_cast(other); + return this->hasSameTextureParamsAndMatrix(ste); + } + + GR_DECLARE_EFFECT_TEST; + + typedef GrSingleTextureEffect INHERITED; +}; + +#endif -- cgit v1.2.3