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/GrFragmentProcessor.h"
15
16class GrYUVtoRGBEffect : public GrFragmentProcessor {
17public:
18 static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView views[],
19 const SkYUVAIndex indices[4],
20 SkYUVColorSpace yuvColorSpace,
21 GrSamplerState samplerState,
22 const GrCaps&,
23 const SkMatrix& localMatrix = SkMatrix::I(),
24 const SkRect* subset = nullptr,
25 const SkRect* domain = nullptr);
26 std::unique_ptr<GrFragmentProcessor> clone() const override;
27
28 const char* name() const override { return "YUVtoRGBEffect"; }
29
30private:
31 GrYUVtoRGBEffect(std::unique_ptr<GrFragmentProcessor> planeFPs[4],
32 int numPlanes,
33 const SkYUVAIndex yuvaIndices[4],
34 const bool snap[2],
35 SkYUVColorSpace yuvColorSpace);
36
37 GrYUVtoRGBEffect(const GrYUVtoRGBEffect& src);
38
39#if GR_TEST_UTILS
40 SkString onDumpInfo() const override;
41#endif
42
43 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
44
45 void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
46
47 bool onIsEqual(const GrFragmentProcessor&) const override;
48
49 GR_DECLARE_FRAGMENT_PROCESSOR_TEST
50
51 SkYUVAIndex fYUVAIndices[4];
52 SkYUVColorSpace fYUVColorSpace;
53 bool fSnap[2];
54};
55#endif
56