Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrBicubicEffect.h
Go to the documentation of this file.
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
16
17#include <memory>
18
19class GrCaps;
21class SkMatrix;
22enum SkAlphaType : int;
23struct GrShaderCaps;
24struct SkRect;
25
26namespace skgpu { class KeyBuilder; }
27
29public:
30 inline static constexpr SkCubicResampler gMitchell = { 1.0f/3, 1.0f/3 };
31 inline static constexpr SkCubicResampler gCatmullRom = { 0, 1.0f/2 };
32
33 enum class Direction {
34 /** Apply bicubic kernel in local coord x, nearest neighbor in y. */
35 kX,
36 /** Apply bicubic kernel in local coord y, nearest neighbor in x. */
37 kY,
38 /** Apply bicubic in both x and y. */
39 kXY
40 };
41
42 const char* name() const override { return "Bicubic"; }
43
44 std::unique_ptr<GrFragmentProcessor> clone() const override {
45 return std::unique_ptr<GrFragmentProcessor>(new GrBicubicEffect(*this));
46 }
47
48 /**
49 * Create a bicubic filter effect with specified texture matrix with clamp wrap mode.
50 */
51 static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView view,
53 const SkMatrix&,
55 Direction);
56
57 /**
58 * Create a bicubic filter effect for a texture with arbitrary wrap modes.
59 */
60 static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView view,
62 const SkMatrix&,
63 const GrSamplerState::WrapMode wrapX,
64 const GrSamplerState::WrapMode wrapY,
67 const GrCaps&);
68
69 /**
70 * Create a bicubic filter effect for a subset of a texture, specified by a texture coordinate
71 * rectangle subset. The WrapModes apply to the subset.
72 */
73 static std::unique_ptr<GrFragmentProcessor> MakeSubset(GrSurfaceProxyView view,
75 const SkMatrix&,
76 const GrSamplerState::WrapMode wrapX,
77 const GrSamplerState::WrapMode wrapY,
78 const SkRect& subset,
81 const GrCaps&);
82
83 /**
84 * Same as above but provides a known 'domain' that bounds the coords at which bicubic sampling
85 * occurs. Note that this is a bound on the coords after transformed by the matrix parameter.
86 */
87 static std::unique_ptr<GrFragmentProcessor> MakeSubset(GrSurfaceProxyView view,
89 const SkMatrix&,
90 const GrSamplerState::WrapMode wrapX,
91 const GrSamplerState::WrapMode wrapY,
92 const SkRect& subset,
93 const SkRect& domain,
96 const GrCaps&);
97
98 /**
99 * Make a bicubic filter of a another fragment processor. The bicubic filter assumes that the
100 * discrete samples of the provided processor are at half-integer coords.
101 */
102 static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor>,
104 const SkMatrix&,
106 Direction);
107
108private:
109 class Impl;
110
111 enum class Clamp {
112 kUnpremul, // clamps rgba to 0..1
113 kPremul, // clamps a to 0..1 and rgb to 0..a
114 };
115
116 GrBicubicEffect(std::unique_ptr<GrFragmentProcessor>,
118 Direction,
119 Clamp);
120
121 explicit GrBicubicEffect(const GrBicubicEffect&);
122
123 std::unique_ptr<ProgramImpl> onMakeProgramImpl() const override;
124
125 void onAddToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const override;
126
127 bool onIsEqual(const GrFragmentProcessor&) const override;
128
130
131 SkCubicResampler fKernel;
132 Direction fDirection;
133 Clamp fClamp;
134
136
138};
139
140#endif
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST
SkAlphaType
Definition SkAlphaType.h:26
#define INHERITED(method,...)
@ kUnpremul
Type::kYUV Type::kRGBA() int(0.7 *637)
const char * name() const override
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView view, SkAlphaType, const SkMatrix &, SkCubicResampler, Direction)
void onAddToKey(const GrShaderCaps &, skgpu::KeyBuilder *) const override
static constexpr SkCubicResampler gCatmullRom
static std::unique_ptr< GrFragmentProcessor > MakeSubset(GrSurfaceProxyView view, SkAlphaType, const SkMatrix &, const GrSamplerState::WrapMode wrapX, const GrSamplerState::WrapMode wrapY, const SkRect &subset, SkCubicResampler, Direction, const GrCaps &)
bool onIsEqual(const GrFragmentProcessor &) const override
std::unique_ptr< GrFragmentProcessor > clone() const override
static constexpr SkCubicResampler gMitchell
std::unique_ptr< ProgramImpl > onMakeProgramImpl() const override
SkPMColor4f constantOutputForConstantInput(const SkPMColor4f &) const override