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  GrMipmapped 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];
75  GrMipmapped fMipmapped = GrMipmapped::kNo;
77 };
78 
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
GrYUVABackendTextureInfo::isValid
bool isValid() const
Returns true if this has been configured with a valid SkYUVAInfo with compatible texture formats.
Definition: GrYUVABackendTextures.h:64
GrYUVABackendTextures::isValid
bool isValid() const
Definition: GrYUVABackendTextures.h:110
SkYUVColorSpace
SkYUVColorSpace
Definition: SkImageInfo.h:148
kTopLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:199
GrSurfaceOrigin
GrSurfaceOrigin
GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to either t...
Definition: GrTypes.h:198
SkYUVAInfo.h
GrYUVABackendTextureInfo
A description of a set GrBackendTextures that hold the planar data described by a SkYUVAInfo.
Definition: GrYUVABackendTextures.h:19
GrYUVABackendTextures::operator=
GrYUVABackendTextures & operator=(const GrYUVABackendTextures &)=delete
GrYUVABackendTextureInfo::GrYUVABackendTextureInfo
GrYUVABackendTextureInfo(const SkYUVAInfo &, const GrBackendFormat[kMaxPlanes], GrMipmapped, GrSurfaceOrigin)
Initializes a GrYUVABackendTextureInfo to describe a set of textures that can store the planes indica...
GrYUVABackendTextures
A set of GrBackendTextures that hold the planar data for an image described a SkYUVAInfo.
Definition: GrYUVABackendTextures.h:82
GrYUVABackendTextureInfo::numPlanes
int numPlanes() const
The number of SkPixmap planes, 0 if this GrYUVABackendTextureInfo is invalid.
Definition: GrYUVABackendTextures.h:55
GrMipmapped
GrMipmapped
Used to say whether a texture has mip levels allocated or not.
Definition: GrTypes.h:169
GrBackendSurface.h
GrYUVABackendTextures::toYUVALocations
SkYUVAInfo::YUVALocations toYUVALocations() const
Computes a YUVALocations representation of the planar layout.
GrBackendFormat
Definition: GrBackendSurface.h:48
GrYUVABackendTextureInfo::mipmapped
GrMipmapped mipmapped() const
Definition: GrYUVABackendTextures.h:50
GrYUVABackendTextures::yuvaInfo
const SkYUVAInfo & yuvaInfo() const
Definition: GrYUVABackendTextures.h:104
SK_API
#define SK_API
Definition: SkTypes.h:181
SkASSERT
#define SkASSERT(cond)
Definition: SkTypes.h:460
GrYUVABackendTextureInfo::operator=
GrYUVABackendTextureInfo & operator=(const GrYUVABackendTextureInfo &)=default
GrYUVABackendTextureInfo::GrYUVABackendTextureInfo
GrYUVABackendTextureInfo()=default
Default GrYUVABackendTextureInfo is invalid.
GrYUVABackendTextures::GrYUVABackendTextures
GrYUVABackendTextures(const GrYUVABackendTextures &)=delete
GrYUVABackendTextures::textures
const std::array< GrBackendTexture, SkYUVAInfo::kMaxPlanes > & textures() const
Definition: GrYUVABackendTextures.h:95
GrYUVABackendTextures::numPlanes
int numPlanes() const
Definition: GrYUVABackendTextures.h:106
GrYUVABackendTextures::textureOrigin
GrSurfaceOrigin textureOrigin() const
Definition: GrYUVABackendTextures.h:108
SkYUVAInfo::YUVALocations
std::array< YUVALocation, kYUVAChannelCount > YUVALocations
Definition: SkYUVAInfo.h:28
GrYUVABackendTextureInfo::toYUVALocations
SkYUVAInfo::YUVALocations toYUVALocations() const
Computes a YUVALocations representation of the planar layout.
SkYUVAInfo::kMaxPlanes
static constexpr int kMaxPlanes
Definition: SkYUVAInfo.h:94
GrYUVABackendTextureInfo::GrYUVABackendTextureInfo
GrYUVABackendTextureInfo(const GrYUVABackendTextureInfo &)=default
SkYUVAInfo
Specifies the structure of planes for a YUV image with optional alpha.
Definition: SkYUVAInfo.h:22
GrBackendTexture
Definition: GrBackendSurface.h:54
GrYUVABackendTextures::operator=
GrYUVABackendTextures & operator=(GrYUVABackendTextures &&)=default
GrYUVABackendTextures::texture
GrBackendTexture texture(int i) const
Definition: GrYUVABackendTextures.h:99
GrYUVABackendTextureInfo::operator!=
bool operator!=(const GrYUVABackendTextureInfo &that) const
Definition: GrYUVABackendTextures.h:44
GrYUVABackendTextureInfo::planeFormat
const GrBackendFormat & planeFormat(int i) const
Format of the ith plane, or invalid format if i >= numPlanes()
Definition: GrYUVABackendTextures.h:58
GrYUVABackendTextures::GrYUVABackendTextures
GrYUVABackendTextures()=default
GrYUVABackendTextureInfo::operator==
bool operator==(const GrYUVABackendTextureInfo &) const
GrYUVABackendTextures::GrYUVABackendTextures
GrYUVABackendTextures(const SkYUVAInfo &, const GrBackendTexture[SkYUVAInfo::kMaxPlanes], GrSurfaceOrigin textureOrigin)
GrYUVABackendTextureInfo::yuvColorSpace
SkYUVColorSpace yuvColorSpace() const
Definition: GrYUVABackendTextures.h:48
GrMipmapped::kNo
@ kNo
GrYUVABackendTextures::GrYUVABackendTextures
GrYUVABackendTextures(GrYUVABackendTextures &&)=default
GrYUVABackendTextureInfo::yuvaInfo
const SkYUVAInfo & yuvaInfo() const
Definition: GrYUVABackendTextures.h:46
GrYUVABackendTextureInfo::textureOrigin
GrSurfaceOrigin textureOrigin() const
Definition: GrYUVABackendTextures.h:52