152331797b38d271d681c734e139ac079258b3dccjvanverth@google.com/*
252331797b38d271d681c734e139ac079258b3dccjvanverth@google.com * Copyright 2013 Google Inc.
352331797b38d271d681c734e139ac079258b3dccjvanverth@google.com *
452331797b38d271d681c734e139ac079258b3dccjvanverth@google.com * Use of this source code is governed by a BSD-style license that can be
552331797b38d271d681c734e139ac079258b3dccjvanverth@google.com * found in the LICENSE file.
652331797b38d271d681c734e139ac079258b3dccjvanverth@google.com */
752331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
852331797b38d271d681c734e139ac079258b3dccjvanverth@google.com#ifndef GrDistanceFieldTextureEffect_DEFINED
952331797b38d271d681c734e139ac079258b3dccjvanverth@google.com#define GrDistanceFieldTextureEffect_DEFINED
1052331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
1152331797b38d271d681c734e139ac079258b3dccjvanverth@google.com#include "GrEffect.h"
1252331797b38d271d681c734e139ac079258b3dccjvanverth@google.com#include "GrVertexEffect.h"
1352331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
1452331797b38d271d681c734e139ac079258b3dccjvanverth@google.comclass GrGLDistanceFieldTextureEffect;
1552331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
1652331797b38d271d681c734e139ac079258b3dccjvanverth@google.com/**
178965981ad05989074bc6317d86a2386ceaa509d1skia.committer@gmail.com * The output color of this effect is a modulation of the input color and a sample from a
1852331797b38d271d681c734e139ac079258b3dccjvanverth@google.com * distance field texture (using a smoothed step function near 0.5).
1952331797b38d271d681c734e139ac079258b3dccjvanverth@google.com * It allows explicit specification of the filtering and wrap modes (GrTextureParams). The input
2052331797b38d271d681c734e139ac079258b3dccjvanverth@google.com * coords are a custom attribute.
2152331797b38d271d681c734e139ac079258b3dccjvanverth@google.com */
2252331797b38d271d681c734e139ac079258b3dccjvanverth@google.comclass GrDistanceFieldTextureEffect : public GrVertexEffect {
2352331797b38d271d681c734e139ac079258b3dccjvanverth@google.compublic:
2452331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& p) {
2552331797b38d271d681c734e139ac079258b3dccjvanverth@google.com        AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, p)));
2652331797b38d271d681c734e139ac079258b3dccjvanverth@google.com        return CreateEffectRef(effect);
2752331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    }
2852331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
2952331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    virtual ~GrDistanceFieldTextureEffect() {}
3052331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
3152331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    static const char* Name() { return "Texture"; }
3252331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
3352331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
3452331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
3552331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    typedef GrGLDistanceFieldTextureEffect GLEffect;
3652331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
3752331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
3852331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
3952331797b38d271d681c734e139ac079258b3dccjvanverth@google.comprivate:
4052331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& params);
4152331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
4252331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
4352331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
4452331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    GrTextureAccess fTextureAccess;
4552331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
4652331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    GR_DECLARE_EFFECT_TEST;
4752331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
4852331797b38d271d681c734e139ac079258b3dccjvanverth@google.com    typedef GrVertexEffect INHERITED;
4952331797b38d271d681c734e139ac079258b3dccjvanverth@google.com};
5052331797b38d271d681c734e139ac079258b3dccjvanverth@google.com
5152331797b38d271d681c734e139ac079258b3dccjvanverth@google.com#endif
52