Flutter Engine
The Flutter Engine
Image_YUVA_Graphite.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
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 skgpu_graphite_Image_YUVA_Graphite_DEFINED
9#define skgpu_graphite_Image_YUVA_Graphite_DEFINED
10
14
15#include <functional>
16
17namespace skgpu::graphite {
18
19class Recorder;
20
21class Image_YUVA final : public Image_Base {
22public:
23 ~Image_YUVA() override;
24
25 // Create an Image_YUVA by interpreting the multiple 'planes' using 'yuvaInfo'. If the info
26 // or provided plane proxies do not produce a valid mulitplane image, null is returned.
27 static sk_sp<Image_YUVA> Make(const Caps* caps,
28 const SkYUVAInfo& yuvaInfo,
30 sk_sp<SkColorSpace> imageColorSpace);
31
32 // Wraps the Graphite-backed Image planes into a YUV[A] image. The returned image shares
33 // textures as well as any links to Devices that might modify those textures.
34 static sk_sp<Image_YUVA> WrapImages(const Caps* caps,
35 const SkYUVAInfo& yuvaInfo,
37 sk_sp<SkColorSpace> imageColorSpace);
38
40
41 size_t textureSize() const override;
42
43 bool onHasMipmaps() const override { return fMipmapped == Mipmapped::kYes; }
44
45 bool onIsProtected() const override { return fProtected == Protected::kYes; }
46
48
49 // Returns the proxy view that provides value for the YUVA channel specified by 'channelIndex'.
50 // The view of the returned proxy applies a swizzle to map the relevant data channel into all
51 // slots of the sample value. The alpha proxy may be null.
52 const TextureProxyView& proxyView(int channelIndex) const {
53 SkASSERT(channelIndex >= 0 && channelIndex < SkYUVAInfo::kYUVAChannelCount);
54 return fProxies[channelIndex];
55 }
56
57 std::tuple<int, int> uvSubsampleFactors() const { return fUVSubsampleFactors; }
58
59 const SkYUVAInfo& yuvaInfo() const { return fYUVAInfo; }
60
61private:
62 // The proxy views are ordered Y,U,V,A and if the channels are held in the same plane, the
63 // respective proxy views will share the underlying TextureProxy but have the appropriate
64 // swizzle to access the appropriate channel and return it in the R slot.
65 using YUVAProxies = std::array<TextureProxyView, SkYUVAInfo::kYUVAChannelCount>;
66
67 Image_YUVA(const YUVAProxies&,
68 const SkYUVAInfo&,
70
71 YUVAProxies fProxies;
72 SkYUVAInfo fYUVAInfo;
73 std::tuple<int, int> fUVSubsampleFactors;
74
75 // Aggregate mipmap/protected status from the proxies
76 Mipmapped fMipmapped = Mipmapped::kYes;
77 Protected fProtected = Protected::kNo;
78};
79
80} // namespace skgpu::graphite
81
82#endif // skgpu_graphite_Image_YUVA_Graphite_DEFINED
#define SkASSERT(cond)
Definition: SkAssert.h:116
static constexpr int kYUVAChannelCount
Definition: SkYUVAInfo.h:29
bool onIsProtected() const override
static sk_sp< Image_YUVA > Make(const Caps *caps, const SkYUVAInfo &yuvaInfo, SkSpan< TextureProxyView > planes, sk_sp< SkColorSpace > imageColorSpace)
sk_sp< SkImage > onReinterpretColorSpace(sk_sp< SkColorSpace >) const override
size_t textureSize() const override
std::tuple< int, int > uvSubsampleFactors() const
SkImage_Base::Type type() const override
const SkYUVAInfo & yuvaInfo() const
static sk_sp< Image_YUVA > WrapImages(const Caps *caps, const SkYUVAInfo &yuvaInfo, SkSpan< const sk_sp< SkImage > > images, sk_sp< SkColorSpace > imageColorSpace)
bool onHasMipmaps() const override
const TextureProxyView & proxyView(int channelIndex) const
std::array< MockImage, 3 > images
Definition: mock_vulkan.cc:41
Mipmapped
Definition: GpuTypes.h:53
Protected
Definition: GpuTypes.h:61