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 GrDistanceFieldTextureEffect_DEFINED
9 #define GrDistanceFieldTextureEffect_DEFINED
12 #include "GrVertexEffect.h"
14 class GrGLDistanceFieldTextureEffect;
15 class GrGLDistanceFieldLCDTextureEffect;
18 * The output color of this effect is a modulation of the input color and a sample from a
19 * distance field texture (using a smoothed step function near 0.5).
20 * It allows explicit specification of the filtering and wrap modes (GrTextureParams). The input
21 * coords are a custom attribute.
23 class GrDistanceFieldTextureEffect : public GrVertexEffect {
25 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, bool similarity) {
26 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, similarity)));
27 return CreateEffectRef(effect);
30 virtual ~GrDistanceFieldTextureEffect() {}
32 static const char* Name() { return "DistanceFieldTexture"; }
34 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
35 bool isSimilarity() const { return fIsSimilarity; }
37 typedef GrGLDistanceFieldTextureEffect GLEffect;
39 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
42 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& params,
45 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
47 GrTextureAccess fTextureAccess;
50 GR_DECLARE_EFFECT_TEST;
52 typedef GrVertexEffect INHERITED;
56 * The output color of this effect is a modulation of the input color and samples from a
57 * distance field texture (using a smoothed step function near 0.5), adjusted for LCD displays.
58 * It allows explicit specification of the filtering and wrap modes (GrTextureParams). The input
59 * coords are a custom attribute.
61 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect {
63 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params,
64 bool uniformScale, bool useBGR) {
65 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect,
66 (tex, params, uniformScale, useBGR)));
67 return CreateEffectRef(effect);
70 virtual ~GrDistanceFieldLCDTextureEffect() {}
72 static const char* Name() { return "DistanceFieldLCDTexture"; }
74 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
75 bool isUniformScale() const { return fUniformScale; }
76 bool useBGR() const { return fUseBGR; }
78 typedef GrGLDistanceFieldLCDTextureEffect GLEffect;
80 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
83 GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& params,
84 bool uniformScale, bool useBGR);
86 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
88 GrTextureAccess fTextureAccess;
92 GR_DECLARE_EFFECT_TEST;
94 typedef GrVertexEffect INHERITED;