blob: eabc79fe56533a272a66d0a1cc39083255bb6df4 [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"
humper@google.com3aad3b02013-09-04 19:23:53 +000014#include "GrTBackendEffectFactory.h"
15
16class GrGLBicubicEffect;
17
18class GrBicubicEffect : public GrSingleTextureEffect {
19public:
20 virtual ~GrBicubicEffect();
21
22 static const char* Name() { return "Bicubic"; }
23 const float* coefficients() const { return fCoefficients; }
24
25 typedef GrGLBicubicEffect GLEffect;
26
27 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
28 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
29
30 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16]) {
31 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients)));
32 return CreateEffectRef(effect);
33 }
34
skia.committer@gmail.comc3723db2013-09-05 07:01:19 +000035 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16],
humper@google.com3aad3b02013-09-04 19:23:53 +000036 const SkMatrix& matrix,
37 const GrTextureParams& p,
bsalomon@google.com77af6802013-10-02 13:04:56 +000038 GrCoordSet coordSet = kLocal_GrCoordSet) {
39 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, p, coordSet)));
humper@google.com3aad3b02013-09-04 19:23:53 +000040 return CreateEffectRef(effect);
41 }
42
43 static GrEffectRef* Create(GrTexture* tex) {
44 return Create(tex, gMitchellCoefficients);
45 }
46
skia.committer@gmail.comc3723db2013-09-05 07:01:19 +000047 static GrEffectRef* Create(GrTexture* tex,
humper@google.com3aad3b02013-09-04 19:23:53 +000048 const SkMatrix& matrix,
49 const GrTextureParams& p,
bsalomon@google.com77af6802013-10-02 13:04:56 +000050 GrCoordSet coordSet = kLocal_GrCoordSet) {
51 return Create(tex, gMitchellCoefficients, matrix, p, coordSet);
humper@google.com3aad3b02013-09-04 19:23:53 +000052 }
53
54private:
55 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16]);
skia.committer@gmail.comc3723db2013-09-05 07:01:19 +000056 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16],
bsalomon@google.com77af6802013-10-02 13:04:56 +000057 const SkMatrix &matrix, const GrTextureParams &p, GrCoordSet coordSet);
humper@google.com3aad3b02013-09-04 19:23:53 +000058 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
59 float fCoefficients[16];
60
61 GR_DECLARE_EFFECT_TEST;
skia.committer@gmail.comc3723db2013-09-05 07:01:19 +000062
humper@google.com3aad3b02013-09-04 19:23:53 +000063 static const SkScalar gMitchellCoefficients[16];
64
65 typedef GrSingleTextureEffect INHERITED;
66};
67
68#endif