Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
YUVABackendTextures.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_YUVABackendTextures_DEFINED
9#define skgpu_graphite_YUVABackendTextures_DEFINED
10
11#include "include/core/SkSpan.h"
14
15#include <tuple>
16
17namespace skgpu::graphite {
18class Recorder;
19
20/**
21 * A description of a set of BackendTextures that hold the planar data described by a SkYUVAInfo.
22 */
24public:
25 static constexpr auto kMaxPlanes = SkYUVAInfo::kMaxPlanes;
26
27 /** Default YUVABackendTextureInfo is invalid. */
31
32 /**
33 * Initializes a YUVABackendTextureInfo to describe a set of textures that can store the
34 * planes indicated by the SkYUVAInfo. The texture dimensions are taken from the SkYUVAInfo's
35 * plane dimensions. All the described textures share a common origin. The planar image this
36 * describes will be mip mapped if all the textures are individually mip mapped as indicated
37 * by Mipmapped. This will produce an invalid result (return false from isValid()) if the
38 * passed formats' channels don't agree with SkYUVAInfo.
39 */
41 const SkYUVAInfo&,
43 Mipmapped);
44
45 bool operator==(const YUVABackendTextureInfo&) const;
46 bool operator!=(const YUVABackendTextureInfo& that) const { return !(*this == that); }
47
48 /** TextureInfo for the ith plane, or invalid if i >= numPlanes() */
49 const TextureInfo& planeTextureInfo(int i) const {
50 SkASSERT(i >= 0);
51 return fPlaneTextureInfos[static_cast<size_t>(i)];
52 }
53
54 const SkYUVAInfo& yuvaInfo() const { return fYUVAInfo; }
55
56 SkYUVColorSpace yuvColorSpace() const { return fYUVAInfo.yuvColorSpace(); }
57
58 Mipmapped mipmapped() const { return fMipmapped; }
59
60 /** The number of planes, 0 if this YUVABackendTextureInfo is invalid. */
61 int numPlanes() const { return fYUVAInfo.numPlanes(); }
62
63 /**
64 * Returns true if this has been configured with a valid SkYUVAInfo with compatible texture
65 * formats.
66 */
67 bool isValid() const { return fYUVAInfo.isValid(); }
68
69 /**
70 * Computes a YUVALocations representation of the planar layout. The result is guaranteed to be
71 * valid if this->isValid().
72 */
73 SkYUVAInfo::YUVALocations toYUVALocations() const;
74
75private:
76 SkYUVAInfo fYUVAInfo;
77 std::array<TextureInfo, kMaxPlanes> fPlaneTextureInfos;
78 std::array<uint32_t, kMaxPlanes> fPlaneChannelMasks;
79 Mipmapped fMipmapped = Mipmapped::kNo;
80};
81
82/**
83 * A set of BackendTextures that hold the planar data for an image described a SkYUVAInfo.
84 */
86public:
87 static constexpr auto kMaxPlanes = SkYUVAInfo::kMaxPlanes;
88
92
93 /**
94 * Initializes a YUVABackendTextures object from a set of textures that store the planes
95 * indicated by the SkYUVAInfo. This will produce an invalid result (return false from
96 * isValid()) if the passed texture formats' channels don't agree with SkYUVAInfo.
97 */
99 const SkYUVAInfo&,
101
105
106 /** BackendTexture for the ith plane, or invalid if i >= numPlanes() */
108 SkASSERT(i >= 0);
109 return fPlaneTextures[static_cast<size_t>(i)];
110 }
111
112 const SkYUVAInfo& yuvaInfo() const { return fYUVAInfo; }
113
114 SkYUVColorSpace yuvColorSpace() const { return fYUVAInfo.yuvColorSpace(); }
115
116 /** The number of planes, 0 if this YUVABackendTextureInfo is invalid. */
117 int numPlanes() const { return fYUVAInfo.numPlanes(); }
118
119 /**
120 * Returns true if this has been configured with a valid SkYUVAInfo with compatible texture
121 * formats.
122 */
123 bool isValid() const { return fYUVAInfo.isValid(); }
124
125 /**
126 * Computes a YUVALocations representation of the planar layout. The result is guaranteed to be
127 * valid if this->isValid().
128 */
129 SkYUVAInfo::YUVALocations toYUVALocations() const;
130
131private:
132 SkYUVAInfo fYUVAInfo;
133 std::array<BackendTexture, kMaxPlanes> fPlaneTextures;
134 std::array<uint32_t, kMaxPlanes> fPlaneChannelMasks;
135};
136
137} // End of namespace skgpu::graphite
138
139#endif // skgpu_graphite_YUVABackendTextures_DEFINED
#define SK_API
Definition SkAPI.h:35
#define SkASSERT(cond)
Definition SkAssert.h:116
SkYUVColorSpace
Definition SkImageInfo.h:68
static constexpr int kMaxPlanes
Definition SkYUVAInfo.h:98
std::array< YUVALocation, kYUVAChannelCount > YUVALocations
Definition SkYUVAInfo.h:32
bool operator!=(const YUVABackendTextureInfo &that) const
YUVABackendTextureInfo(const YUVABackendTextureInfo &)=default
YUVABackendTextureInfo & operator=(const YUVABackendTextureInfo &)=default
const TextureInfo & planeTextureInfo(int i) const
BackendTexture planeTexture(int i) const
YUVABackendTextures(const YUVABackendTextures &)=delete
SkSpan< const BackendTexture > planeTextures() const
YUVABackendTextures & operator=(const YUVABackendTextures &)=delete
bool operator==(const FlutterPoint &a, const FlutterPoint &b)
Mipmapped
Definition GpuTypes.h:53