blob: fc37ddb99a2f73cfa2918850c09a41fbf26fe258 [file] [log] [blame]
jvanverth@google.comd830d132013-11-11 20:54:09 +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 GrDistanceFieldTextureEffect_DEFINED
9#define GrDistanceFieldTextureEffect_DEFINED
10
11#include "GrEffect.h"
12#include "GrVertexEffect.h"
13
14class GrGLDistanceFieldTextureEffect;
15
16/**
skia.committer@gmail.com11a253b2013-11-12 07:02:05 +000017 * The output color of this effect is a modulation of the input color and a sample from a
jvanverth@google.comd830d132013-11-11 20:54:09 +000018 * distance field texture (using a smoothed step function near 0.5).
19 * It allows explicit specification of the filtering and wrap modes (GrTextureParams). The input
20 * coords are a custom attribute.
21 */
22class GrDistanceFieldTextureEffect : public GrVertexEffect {
23public:
24 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& p) {
25 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, p)));
26 return CreateEffectRef(effect);
27 }
28
29 virtual ~GrDistanceFieldTextureEffect() {}
30
31 static const char* Name() { return "Texture"; }
32
33 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
34
35 typedef GrGLDistanceFieldTextureEffect GLEffect;
36
37 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
38
39private:
40 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& params);
41
42 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
43
44 GrTextureAccess fTextureAccess;
45
46 GR_DECLARE_EFFECT_TEST;
47
48 typedef GrVertexEffect INHERITED;
49};
50
51#endif