2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrSimpleTextureEffect_DEFINED
9 #define GrSimpleTextureEffect_DEFINED
11 #include "GrSingleTextureEffect.h"
13 class GrInvariantOutput;
16 * The output color of this effect is a modulation of the input color and a sample from a texture.
17 * It allows explicit specification of the filtering and wrap modes (GrTextureParams). It can use
18 * local coords, positions, or a custom vertex attribute as input texture coords. The input coords
19 * can have a matrix applied in the VS in both the local and position cases but not with a custom
20 * attribute coords at this time. It will add a varying to input interpolate texture coords to the
23 class GrSimpleTextureEffect : public GrSingleTextureEffect {
25 /* unfiltered, clamp mode */
26 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
28 const SkMatrix& matrix,
29 GrCoordSet coordSet = kLocal_GrCoordSet) {
30 return SkNEW_ARGS(GrSimpleTextureEffect, (procDataManager, tex, matrix,
31 GrTextureParams::kNone_FilterMode, coordSet));
35 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
37 const SkMatrix& matrix,
38 GrTextureParams::FilterMode filterMode,
39 GrCoordSet coordSet = kLocal_GrCoordSet) {
40 return SkNEW_ARGS(GrSimpleTextureEffect, (procDataManager, tex, matrix, filterMode,
44 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
46 const SkMatrix& matrix,
47 const GrTextureParams& p,
48 GrCoordSet coordSet = kLocal_GrCoordSet) {
49 return SkNEW_ARGS(GrSimpleTextureEffect, (procDataManager, tex, matrix, p, coordSet));
52 virtual ~GrSimpleTextureEffect() {}
54 const char* name() const override { return "SimpleTexture"; }
56 GrGLFragmentProcessor* createGLInstance() const override;
59 GrSimpleTextureEffect(GrProcessorDataManager* procDataManager,
61 const SkMatrix& matrix,
62 GrTextureParams::FilterMode filterMode,
64 : GrSingleTextureEffect(procDataManager, texture, matrix, filterMode, coordSet) {
65 this->initClassID<GrSimpleTextureEffect>();
68 GrSimpleTextureEffect(GrProcessorDataManager* procDataManager,
70 const SkMatrix& matrix,
71 const GrTextureParams& params,
73 : GrSingleTextureEffect(procDataManager, texture, matrix, params, coordSet) {
74 this->initClassID<GrSimpleTextureEffect>();
77 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
79 bool onIsEqual(const GrFragmentProcessor& other) const override { return true; }
81 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
83 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
85 typedef GrSingleTextureEffect INHERITED;