1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/gpu/effects/GrSimpleTextureEffect.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +/* 1.5 + * Copyright 2013 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#ifndef GrSimpleTextureEffect_DEFINED 1.12 +#define GrSimpleTextureEffect_DEFINED 1.13 + 1.14 +#include "GrSingleTextureEffect.h" 1.15 + 1.16 +class GrGLSimpleTextureEffect; 1.17 + 1.18 +/** 1.19 + * The output color of this effect is a modulation of the input color and a sample from a texture. 1.20 + * It allows explicit specification of the filtering and wrap modes (GrTextureParams). It can use 1.21 + * local coords, positions, or a custom vertex attribute as input texture coords. The input coords 1.22 + * can have a matrix applied in the VS in both the local and position cases but not with a custom 1.23 + * attribute coords at this time. It will add a varying to input interpolate texture coords to the 1.24 + * FS. 1.25 + */ 1.26 +class GrSimpleTextureEffect : public GrSingleTextureEffect { 1.27 +public: 1.28 + /* unfiltered, clamp mode */ 1.29 + static GrEffectRef* Create(GrTexture* tex, 1.30 + const SkMatrix& matrix, 1.31 + GrCoordSet coordSet = kLocal_GrCoordSet) { 1.32 + AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, GrTextureParams::kNone_FilterMode, coordSet))); 1.33 + return CreateEffectRef(effect); 1.34 + } 1.35 + 1.36 + /* clamp mode */ 1.37 + static GrEffectRef* Create(GrTexture* tex, 1.38 + const SkMatrix& matrix, 1.39 + GrTextureParams::FilterMode filterMode, 1.40 + GrCoordSet coordSet = kLocal_GrCoordSet) { 1.41 + AutoEffectUnref effect( 1.42 + SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, filterMode, coordSet))); 1.43 + return CreateEffectRef(effect); 1.44 + } 1.45 + 1.46 + static GrEffectRef* Create(GrTexture* tex, 1.47 + const SkMatrix& matrix, 1.48 + const GrTextureParams& p, 1.49 + GrCoordSet coordSet = kLocal_GrCoordSet) { 1.50 + AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p, coordSet))); 1.51 + return CreateEffectRef(effect); 1.52 + } 1.53 + 1.54 + virtual ~GrSimpleTextureEffect() {} 1.55 + 1.56 + static const char* Name() { return "Texture"; } 1.57 + 1.58 + virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; 1.59 + 1.60 + typedef GrGLSimpleTextureEffect GLEffect; 1.61 + 1.62 + virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 1.63 + 1.64 +private: 1.65 + GrSimpleTextureEffect(GrTexture* texture, 1.66 + const SkMatrix& matrix, 1.67 + GrTextureParams::FilterMode filterMode, 1.68 + GrCoordSet coordSet) 1.69 + : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) { 1.70 + } 1.71 + 1.72 + GrSimpleTextureEffect(GrTexture* texture, 1.73 + const SkMatrix& matrix, 1.74 + const GrTextureParams& params, 1.75 + GrCoordSet coordSet) 1.76 + : GrSingleTextureEffect(texture, matrix, params, coordSet) { 1.77 + } 1.78 + 1.79 + virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE { 1.80 + const GrSimpleTextureEffect& ste = CastEffect<GrSimpleTextureEffect>(other); 1.81 + return this->hasSameTextureParamsMatrixAndSourceCoords(ste); 1.82 + } 1.83 + 1.84 + GR_DECLARE_EFFECT_TEST; 1.85 + 1.86 + typedef GrSingleTextureEffect INHERITED; 1.87 +}; 1.88 + 1.89 +#endif