| 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/SkMatrix.h" |
| 12 |
#include "include/core/SkString.h" |
| 13 |
#include "include/core/SkYUVAInfo.h" |
| 14 |
#include "src/core/SkYUVAInfoLocation.h" // IWYU pragma: keep |
| 15 |
#include "src/gpu/ganesh/GrCaps.h" |
| 16 |
#include "src/gpu/ganesh/GrFragmentProcessor.h" |
| 17 |
#include "src/gpu/ganesh/GrProcessorUnitTest.h" |
| 18 |
#include "src/gpu/ganesh/GrSamplerState.h" |
| 19 |
|
| 20 |
#include <memory> |
| 21 |
|
| 22 |
class GrYUVATextureProxies; |
| 23 |
enum SkYUVColorSpace : int; |
| 24 |
namespace skgpu { class KeyBuilder; } |
| 25 |
struct GrShaderCaps; |
| 26 |
struct SkRect; |
| 27 |
|
| 28 |
class GrYUVtoRGBEffect : public GrFragmentProcessor { |
| 29 |
public: |
| 30 |
static std::unique_ptr<GrFragmentProcessor> Make(const GrYUVATextureProxies& yuvaProxies, |
| 31 |
GrSamplerState samplerState, |
| 32 |
const GrCaps&, |
| 33 |
const SkMatrix& localMatrix = SkMatrix::I(), |
| 34 |
const SkRect* subset = nullptr, |
| 35 |
const SkRect* domain = nullptr); |
| 36 |
std::unique_ptr<GrFragmentProcessor> clone() const override; |
| 37 |
|
| 38 |
const char* name() const override { return "YUVtoRGBEffect"; } |
| 39 |
|
| 40 |
private: |
| 41 |
GrYUVtoRGBEffect(std::unique_ptr<GrFragmentProcessor> planeFPs[4], |
| 42 |
int numPlanes, |
| 43 |
const SkYUVAInfo::YUVALocations&, |
| 44 |
const bool snap[2], |
| 45 |
SkYUVColorSpace yuvColorSpace); |
| 46 |
|
| 47 |
GrYUVtoRGBEffect(const GrYUVtoRGBEffect& src); |
| 48 |
|
| 49 |
#if defined(GPU_TEST_UTILS) |
| 50 |
SkString onDumpInfo() const override; |
| 51 |
#endif |
| 52 |
|
| 53 |
std::unique_ptr<ProgramImpl> onMakeProgramImpl() const override; |
| 54 |
|
| 55 |
void onAddToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const override; |
| 56 |
|
| 57 |
bool onIsEqual(const GrFragmentProcessor&) const override; |
| 58 |
|
| 59 |
GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
| 60 |
|
| 61 |
SkYUVAInfo::YUVALocations fLocations; |
| 62 |
SkYUVColorSpace fYUVColorSpace; |
| 63 |
bool fSnap[2]; |
| 64 |
}; |
| 65 |
#endif |