blob: 02e7c440135b7298b0a146280c5fd08f3d49f7f7 [file] [log] [blame]
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +00001/*
2 * Copyright 2013 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 GrCustomCoordsTextureEffect_DEFINED
9#define GrCustomCoordsTextureEffect_DEFINED
10
11#include "GrEffect.h"
joshualitt249af152014-09-15 11:41:13 -070012#include "GrGeometryProcessor.h"
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000013
14class GrGLCustomCoordsTextureEffect;
15
16/**
17 * The output color of this effect is a modulation of the input color and a sample from a texture.
18 * It allows explicit specification of the filtering and wrap modes (GrTextureParams). The input
19 * coords are a custom attribute.
20 */
joshualitt249af152014-09-15 11:41:13 -070021class GrCustomCoordsTextureEffect : public GrGeometryProcessor {
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000022public:
bsalomon83d081a2014-07-08 09:56:10 -070023 static GrEffect* Create(GrTexture* tex, const GrTextureParams& p) {
bsalomon55fad7a2014-07-08 07:34:20 -070024 return SkNEW_ARGS(GrCustomCoordsTextureEffect, (tex, p));
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000025 }
26
27 virtual ~GrCustomCoordsTextureEffect() {}
28
29 static const char* Name() { return "Texture"; }
30
31 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
32
joshualitt249af152014-09-15 11:41:13 -070033 const GrShaderVar& inTextureCoords() const { return fInTextureCoords; }
34
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000035 typedef GrGLCustomCoordsTextureEffect GLEffect;
36
37 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
38
39private:
40 GrCustomCoordsTextureEffect(GrTexture* texture, const GrTextureParams& params);
41
42 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
43
joshualitt249af152014-09-15 11:41:13 -070044 GrTextureAccess fTextureAccess;
45 const GrShaderVar& fInTextureCoords;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000046
47 GR_DECLARE_EFFECT_TEST;
48
joshualitt249af152014-09-15 11:41:13 -070049 typedef GrGeometryProcessor INHERITED;
commit-bot@chromium.org76eaf742013-09-30 18:41:38 +000050};
51
52#endif