1 | /* |
2 | * Copyright 2018 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 GrYUVtoRGBEffect_DEFINED |
9 | #define GrYUVtoRGBEffect_DEFINED |
10 | |
11 | #include "include/core/SkTypes.h" |
12 | |
13 | #include "include/core/SkYUVAIndex.h" |
14 | #include "src/gpu/GrCoordTransform.h" |
15 | #include "src/gpu/GrFragmentProcessor.h" |
16 | |
17 | class GrYUVtoRGBEffect : public GrFragmentProcessor { |
18 | public: |
19 | // The domain supported by this effect is more limited than the general GrTextureDomain due |
20 | // to the multi-planar, varying resolution images that it has to sample. If 'domain' is provided |
21 | // it is the Y plane's domain. This will automatically inset for bilinear filtering, and only |
22 | // the clamp wrap mode is supported. |
23 | static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView views[], |
24 | const SkYUVAIndex indices[4], |
25 | SkYUVColorSpace yuvColorSpace, |
26 | GrSamplerState samplerState, |
27 | const GrCaps&, |
28 | const SkMatrix& localMatrix = SkMatrix::I(), |
29 | const SkRect* subset = nullptr); |
30 | #ifdef SK_DEBUG |
31 | SkString dumpInfo() const override; |
32 | #endif |
33 | |
34 | std::unique_ptr<GrFragmentProcessor> clone() const override; |
35 | |
36 | const char* name() const override { return "YUVtoRGBEffect" ; } |
37 | |
38 | private: |
39 | GrYUVtoRGBEffect(std::unique_ptr<GrFragmentProcessor> planeFPs[4], int numPlanes, |
40 | const SkYUVAIndex yuvaIndices[4], SkYUVColorSpace yuvColorSpace); |
41 | |
42 | GrYUVtoRGBEffect(const GrYUVtoRGBEffect& src); |
43 | |
44 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
45 | |
46 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; |
47 | |
48 | bool onIsEqual(const GrFragmentProcessor&) const override; |
49 | |
50 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
51 | |
52 | SkYUVAIndex fYUVAIndices[4]; |
53 | SkYUVColorSpace fYUVColorSpace; |
54 | }; |
55 | #endif |
56 | |