Skia
2D Graphics Library
GrYUVABackendTextures.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 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 GrYUVABackendTextures_DEFINED
9 #define GrYUVABackendTextures_DEFINED
10 
13 
14 #include <tuple>
15 
20 public:
21  static constexpr auto kMaxPlanes = SkYUVAInfo::kMaxPlanes;
22 
25 
35  const GrBackendFormat[kMaxPlanes],
38 
40 
42 
44  bool operator!=(const GrYUVABackendTextureInfo& that) const { return !(*this == that); }
45 
46  const SkYUVAInfo& yuvaInfo() const { return fYUVAInfo; }
47 
48  SkYUVColorSpace yuvColorSpace() const { return fYUVAInfo.yuvColorSpace(); }
49 
50  skgpu::Mipmapped mipmapped() const { return fMipmapped; }
51 
52  GrSurfaceOrigin textureOrigin() const { return fTextureOrigin; }
53 
55  int numPlanes() const { return fYUVAInfo.numPlanes(); }
56 
58  const GrBackendFormat& planeFormat(int i) const { return fPlaneFormats[i]; }
59 
64  bool isValid() const { return fYUVAInfo.isValid(); }
65 
71 
72 private:
73  SkYUVAInfo fYUVAInfo;
74  GrBackendFormat fPlaneFormats[kMaxPlanes];
77 };
78 
82 class SK_API GrYUVABackendTextures {
83 public:
84  GrYUVABackendTextures() = default;
87 
90 
93  GrSurfaceOrigin textureOrigin);
94 
95  const std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes>& textures() const {
96  return fTextures;
97  }
98 
99  GrBackendTexture texture(int i) const {
100  SkASSERT(i >= 0 && i < SkYUVAInfo::kMaxPlanes);
101  return fTextures[static_cast<size_t>(i)];
102  }
103 
104  const SkYUVAInfo& yuvaInfo() const { return fYUVAInfo; }
105 
106  int numPlanes() const { return fYUVAInfo.numPlanes(); }
107 
108  GrSurfaceOrigin textureOrigin() const { return fTextureOrigin; }
109 
110  bool isValid() const { return fYUVAInfo.isValid(); }
111 
117 
118 private:
119  SkYUVAInfo fYUVAInfo;
120  std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes> fTextures;
121  GrSurfaceOrigin fTextureOrigin = kTopLeft_GrSurfaceOrigin;
122 };
123 
124 #endif
GrSurfaceOrigin
GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to either t...
Definition: GrTypes.h:156
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:157
SkYUVColorSpace
Definition: SkImageInfo.h:68
Definition: GrBackendSurface.h:49
Definition: GrBackendSurface.h:176
A description of a set GrBackendTextures that hold the planar data described by a SkYUVAInfo.
Definition: GrYUVABackendTextures.h:19
skgpu::Mipmapped mipmapped() const
Definition: GrYUVABackendTextures.h:50
bool operator==(const GrYUVABackendTextureInfo &) const
GrYUVABackendTextureInfo(const SkYUVAInfo &, const GrBackendFormat[kMaxPlanes], skgpu::Mipmapped, GrSurfaceOrigin)
Initializes a GrYUVABackendTextureInfo to describe a set of textures that can store the planes indica...
const GrBackendFormat & planeFormat(int i) const
Format of the ith plane, or invalid format if i >= numPlanes()
Definition: GrYUVABackendTextures.h:58
GrYUVABackendTextureInfo & operator=(const GrYUVABackendTextureInfo &)=default
bool isValid() const
Returns true if this has been configured with a valid SkYUVAInfo with compatible texture formats.
Definition: GrYUVABackendTextures.h:64
GrSurfaceOrigin textureOrigin() const
Definition: GrYUVABackendTextures.h:52
SkYUVAInfo::YUVALocations toYUVALocations() const
Computes a YUVALocations representation of the planar layout.
int numPlanes() const
The number of SkPixmap planes, 0 if this GrYUVABackendTextureInfo is invalid.
Definition: GrYUVABackendTextures.h:55
GrYUVABackendTextureInfo()=default
Default GrYUVABackendTextureInfo is invalid.
bool operator!=(const GrYUVABackendTextureInfo &that) const
Definition: GrYUVABackendTextures.h:44
GrYUVABackendTextureInfo(const GrYUVABackendTextureInfo &)=default
SkYUVColorSpace yuvColorSpace() const
Definition: GrYUVABackendTextures.h:48
const SkYUVAInfo & yuvaInfo() const
Definition: GrYUVABackendTextures.h:46
A set of GrBackendTextures that hold the planar data for an image described a SkYUVAInfo.
Definition: GrYUVABackendTextures.h:82
bool isValid() const
Definition: GrYUVABackendTextures.h:110
const std::array< GrBackendTexture, SkYUVAInfo::kMaxPlanes > & textures() const
Definition: GrYUVABackendTextures.h:95
int numPlanes() const
Definition: GrYUVABackendTextures.h:106
const SkYUVAInfo & yuvaInfo() const
Definition: GrYUVABackendTextures.h:104
GrYUVABackendTextures & operator=(GrYUVABackendTextures &&)=default
GrYUVABackendTextures & operator=(const GrYUVABackendTextures &)=delete
GrYUVABackendTextures(GrYUVABackendTextures &&)=default
GrYUVABackendTextures(const GrYUVABackendTextures &)=delete
GrBackendTexture texture(int i) const
Definition: GrYUVABackendTextures.h:99
GrSurfaceOrigin textureOrigin() const
Definition: GrYUVABackendTextures.h:108
SkYUVAInfo::YUVALocations toYUVALocations() const
Computes a YUVALocations representation of the planar layout.
GrYUVABackendTextures()=default
GrYUVABackendTextures(const SkYUVAInfo &, const GrBackendTexture[SkYUVAInfo::kMaxPlanes], GrSurfaceOrigin textureOrigin)
Specifies the structure of planes for a YUV image with optional alpha.
Definition: SkYUVAInfo.h:26
static constexpr int kMaxPlanes
Definition: SkYUVAInfo.h:98
std::array< YUVALocation, kYUVAChannelCount > YUVALocations
Definition: SkYUVAInfo.h:32
Mipmapped
Is the texture mipmapped or not.
Definition: GpuTypes.h:53