blob: 4db93e20afe26b9c5d78d71f89433200216dc631 [file] [log] [blame]
Ethan Nicholas7461a4a2017-12-21 14:18:01 -05001/*
Ethan Nicholas130fb3f2018-02-01 12:14:34 -05002 * Copyright 2018 Google Inc.
Ethan Nicholas7461a4a2017-12-21 14:18:01 -05003 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Ethan Nicholas7461a4a2017-12-21 14:18:01 -05008#ifndef GrYUVtoRGBEffect_DEFINED
9#define GrYUVtoRGBEffect_DEFINED
Robert Phillips94ade752018-10-09 12:32:31 -040010
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkTypes.h"
Robert Phillips94ade752018-10-09 12:32:31 -040012
Brian Salomonca6b2f42020-01-24 11:31:21 -050013#include "include/core/SkYUVAIndex.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "src/gpu/GrCoordTransform.h"
15#include "src/gpu/GrFragmentProcessor.h"
Robert Phillips94ade752018-10-09 12:32:31 -040016
Ethan Nicholas7461a4a2017-12-21 14:18:01 -050017class GrYUVtoRGBEffect : public GrFragmentProcessor {
18public:
Michael Ludwiga6a84002019-04-12 15:03:02 -040019 // 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.
Greg Danielc7672092020-02-06 14:32:54 -050023 static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView views[],
Robert Phillips94ade752018-10-09 12:32:31 -040024 const SkYUVAIndex indices[4],
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040025 SkYUVColorSpace yuvColorSpace,
Brian Salomond71548a2020-02-29 19:43:30 -050026 GrSamplerState samplerState,
Brian Salomonca6b2f42020-01-24 11:31:21 -050027 const GrCaps&,
Michael Ludwiga6a84002019-04-12 15:03:02 -040028 const SkMatrix& localMatrix = SkMatrix::I(),
Brian Salomond71548a2020-02-29 19:43:30 -050029 const SkRect* subset = nullptr);
Brian Osman9a390ac2018-11-12 09:47:48 -050030#ifdef SK_DEBUG
Robert Phillipsba5c4392018-07-25 12:37:14 -040031 SkString dumpInfo() const override;
Brian Osman9a390ac2018-11-12 09:47:48 -050032#endif
Robert Phillips94ade752018-10-09 12:32:31 -040033
Ethan Nicholas7461a4a2017-12-21 14:18:01 -050034 std::unique_ptr<GrFragmentProcessor> clone() const override;
Brian Salomonfa9232c2019-12-04 16:09:04 -050035
Ethan Nicholas7461a4a2017-12-21 14:18:01 -050036 const char* name() const override { return "YUVtoRGBEffect"; }
37
38private:
Brian Salomonfa9232c2019-12-04 16:09:04 -050039 GrYUVtoRGBEffect(std::unique_ptr<GrFragmentProcessor> planeFPs[4], int numPlanes,
40 const SkYUVAIndex yuvaIndices[4], SkYUVColorSpace yuvColorSpace);
Michael Ludwiga6a84002019-04-12 15:03:02 -040041
Brian Salomonfa9232c2019-12-04 16:09:04 -050042 GrYUVtoRGBEffect(const GrYUVtoRGBEffect& src);
Michael Ludwiga6a84002019-04-12 15:03:02 -040043
Ethan Nicholas7461a4a2017-12-21 14:18:01 -050044 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
Brian Salomonfa9232c2019-12-04 16:09:04 -050045
Ethan Nicholas7461a4a2017-12-21 14:18:01 -050046 void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
Brian Salomonfa9232c2019-12-04 16:09:04 -050047
Ethan Nicholas7461a4a2017-12-21 14:18:01 -050048 bool onIsEqual(const GrFragmentProcessor&) const override;
Brian Salomonfa9232c2019-12-04 16:09:04 -050049
Ethan Nicholas7461a4a2017-12-21 14:18:01 -050050 GR_DECLARE_FRAGMENT_PROCESSOR_TEST
Robert Phillips94ade752018-10-09 12:32:31 -040051
Robert Phillips94ade752018-10-09 12:32:31 -040052 SkYUVAIndex fYUVAIndices[4];
Robert Phillipsb651aac2019-03-15 12:18:49 -040053 SkYUVColorSpace fYUVColorSpace;
Ethan Nicholas7461a4a2017-12-21 14:18:01 -050054};
55#endif