blob: 618ef1a7793073367b0ddbd635f7935a26823cb0 [file] [log] [blame]
humper@google.com3aad3b02013-09-04 19:23:53 +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 GrBicubicTextureEffect_DEFINED
9#define GrBicubicTextureEffect_DEFINED
10
11#include "GrSingleTextureEffect.h"
12#include "GrDrawEffect.h"
13#include "gl/GrGLEffect.h"
14#include "gl/GrGLEffectMatrix.h"
15#include "GrTBackendEffectFactory.h"
16
17class GrGLBicubicEffect;
18
19class GrBicubicEffect : public GrSingleTextureEffect {
20public:
21 virtual ~GrBicubicEffect();
22
23 static const char* Name() { return "Bicubic"; }
24 const float* coefficients() const { return fCoefficients; }
25
26 typedef GrGLBicubicEffect GLEffect;
27
28 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
29 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
30
31 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16]) {
32 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients)));
33 return CreateEffectRef(effect);
34 }
35
36 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16],
37 const SkMatrix& matrix,
38 const GrTextureParams& p,
39 CoordsType coordsType = kLocal_CoordsType) {
40 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, p, coordsType)));
41 return CreateEffectRef(effect);
42 }
43
44 static GrEffectRef* Create(GrTexture* tex) {
45 return Create(tex, gMitchellCoefficients);
46 }
47
48 static GrEffectRef* Create(GrTexture* tex,
49 const SkMatrix& matrix,
50 const GrTextureParams& p,
51 CoordsType coordsType = kLocal_CoordsType) {
52 return Create(tex, gMitchellCoefficients, matrix, p, coordsType);
53 }
54
55private:
56 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16]);
57 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16],
58 const SkMatrix &matrix, const GrTextureParams &p, CoordsType coordsType);
59 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
60 float fCoefficients[16];
61
62 GR_DECLARE_EFFECT_TEST;
63
64 static const SkScalar gMitchellCoefficients[16];
65
66 typedef GrSingleTextureEffect INHERITED;
67};
68
69#endif