Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: src/gpu/effects/GrBicubicEffect.h

Issue 23779003: first cut at HQ GPU scaling; refactored existing bicubic scaler (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Duplicate the mitchell coefficients to avoid dependence on effects Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
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
17 class GrGLBicubicEffect;
18
19 #define DS(x) SkDoubleToScalar(x)
20
21 static const SkScalar gMitchellCoefficients[16] = {
22 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0),
23 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0),
24 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0),
25 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0),
26 };
27
28 class GrBicubicEffect : public GrSingleTextureEffect {
29 public:
30 virtual ~GrBicubicEffect();
31
32 static const char* Name() { return "Bicubic"; }
33 const float* coefficients() const { return fCoefficients; }
34
35 typedef GrGLBicubicEffect GLEffect;
36
37 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
38 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
39
40 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16]) {
41 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients))) ;
42 return CreateEffectRef(effect);
43 }
44
45 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16],
46 const SkMatrix& matrix,
47 const GrTextureParams& p,
48 CoordsType coordsType = kLocal_CoordsType) {
49 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, m atrix, p, coordsType)));
50 return CreateEffectRef(effect);
51 }
52
53 static GrEffectRef* Create(GrTexture* tex) {
54 return Create(tex, gMitchellCoefficients);
55 }
56
57 static GrEffectRef* Create(GrTexture* tex,
58 const SkMatrix& matrix,
59 const GrTextureParams& p,
60 CoordsType coordsType = kLocal_CoordsType) {
61 return Create(tex, gMitchellCoefficients, matrix, p, coordsType);
62 }
63
64 private:
65 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16]);
66 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16],
67 const SkMatrix &matrix, const GrTextureParams &p, CoordsType coordsType);
68 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
69 float fCoefficients[16];
70
71 GR_DECLARE_EFFECT_TEST;
72
73 typedef GrSingleTextureEffect INHERITED;
74 };
75
76 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698