Line data Source code
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 GrSimpleTextureEffect_DEFINED
9 : #define GrSimpleTextureEffect_DEFINED
10 :
11 : #include "GrSingleTextureEffect.h"
12 : #include "GrTextureProxy.h"
13 :
14 : class GrInvariantOutput;
15 :
16 : /**
17 : * The output color of this effect is a modulation of the input color and a sample from a texture.
18 : * It allows explicit specification of the filtering and wrap modes (GrSamplerParams) and accepts
19 : * a matrix that is used to compute texture coordinates from local coordinates.
20 : */
21 : class GrSimpleTextureEffect : public GrSingleTextureEffect {
22 : public:
23 : /* unfiltered, clamp mode */
24 0 : static sk_sp<GrFragmentProcessor> Make(GrResourceProvider* resourceProvider,
25 : sk_sp<GrTextureProxy> proxy,
26 : sk_sp<GrColorSpaceXform> colorSpaceXform,
27 : const SkMatrix& matrix) {
28 : return sk_sp<GrFragmentProcessor>(
29 0 : new GrSimpleTextureEffect(resourceProvider, std::move(proxy),
30 0 : std::move(colorSpaceXform), matrix,
31 0 : GrSamplerParams::kNone_FilterMode));
32 : }
33 :
34 : /* clamp mode */
35 0 : static sk_sp<GrFragmentProcessor> Make(GrResourceProvider* resourceProvider,
36 : sk_sp<GrTextureProxy> proxy,
37 : sk_sp<GrColorSpaceXform> colorSpaceXform,
38 : const SkMatrix& matrix,
39 : GrSamplerParams::FilterMode filterMode) {
40 : return sk_sp<GrFragmentProcessor>(
41 0 : new GrSimpleTextureEffect(resourceProvider, std::move(proxy),
42 0 : std::move(colorSpaceXform),
43 0 : matrix, filterMode));
44 : }
45 :
46 0 : static sk_sp<GrFragmentProcessor> Make(GrResourceProvider* resourceProvider,
47 : sk_sp<GrTextureProxy> proxy,
48 : sk_sp<GrColorSpaceXform> colorSpaceXform,
49 : const SkMatrix& matrix,
50 : const GrSamplerParams& p) {
51 : return sk_sp<GrFragmentProcessor>(new GrSimpleTextureEffect(resourceProvider,
52 0 : std::move(proxy),
53 0 : std::move(colorSpaceXform),
54 0 : matrix, p));
55 : }
56 :
57 0 : ~GrSimpleTextureEffect() override {}
58 :
59 0 : const char* name() const override { return "SimpleTexture"; }
60 :
61 : private:
62 : GrSimpleTextureEffect(GrResourceProvider*, sk_sp<GrTextureProxy>,
63 : sk_sp<GrColorSpaceXform>, const SkMatrix& matrix,
64 : GrSamplerParams::FilterMode);
65 :
66 : GrSimpleTextureEffect(GrResourceProvider*, sk_sp<GrTextureProxy>,
67 : sk_sp<GrColorSpaceXform>, const SkMatrix& matrix,
68 : const GrSamplerParams&);
69 :
70 : GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
71 :
72 : void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
73 :
74 0 : bool onIsEqual(const GrFragmentProcessor& other) const override { return true; }
75 :
76 : GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
77 :
78 : typedef GrSingleTextureEffect INHERITED;
79 : };
80 :
81 : #endif
|