Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
16/**
17 * A description of a set GrBackendTextures that hold the planar data described by a SkYUVAInfo.
18 */
20public:
21 static constexpr auto kMaxPlanes = SkYUVAInfo::kMaxPlanes;
22
23 /** Default GrYUVABackendTextureInfo is invalid. */
25
26 /**
27 * Initializes a GrYUVABackendTextureInfo to describe a set of textures that can store the
28 * planes indicated by the SkYUVAInfo. The texture dimensions are taken from the SkYUVAInfo's
29 * plane dimensions. All the described textures share a common origin. The planar image this
30 * describes will be mip mapped if all the textures are individually mip mapped as indicated
31 * by skgpu::Mipmapped. This will produce an invalid result (return false from isValid()) if the
32 * passed formats' channels don't agree with SkYUVAInfo.
33 */
35 const GrBackendFormat[kMaxPlanes],
38
40
42
43 bool operator==(const GrYUVABackendTextureInfo&) const;
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
54 /** The number of SkPixmap planes, 0 if this GrYUVABackendTextureInfo is invalid. */
55 int numPlanes() const { return fYUVAInfo.numPlanes(); }
56
57 /** Format of the ith plane, or invalid format if i >= numPlanes() */
58 const GrBackendFormat& planeFormat(int i) const { return fPlaneFormats[i]; }
59
60 /**
61 * Returns true if this has been configured with a valid SkYUVAInfo with compatible texture
62 * formats.
63 */
64 bool isValid() const { return fYUVAInfo.isValid(); }
65
66 /**
67 * Computes a YUVALocations representation of the planar layout. The result is guaranteed to be
68 * valid if this->isValid().
69 */
70 SkYUVAInfo::YUVALocations toYUVALocations() const;
71
72private:
73 SkYUVAInfo fYUVAInfo;
74 GrBackendFormat fPlaneFormats[kMaxPlanes];
75 skgpu::Mipmapped fMipmapped = skgpu::Mipmapped::kNo;
77};
78
79/**
80 * A set of GrBackendTextures that hold the planar data for an image described a SkYUVAInfo.
81 */
83public:
87
90
93 GrSurfaceOrigin textureOrigin);
94
95 const std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes>& textures() const {
96 return fTextures;
97 }
98
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
112 /**
113 * Computes a YUVALocations representation of the planar layout. The result is guaranteed to be
114 * valid if this->isValid().
115 */
116 SkYUVAInfo::YUVALocations toYUVALocations() const;
117
118private:
119 SkYUVAInfo fYUVAInfo;
120 std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes> fTextures;
122};
123
124#endif
GrSurfaceOrigin
Definition GrTypes.h:147
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
#define SK_API
Definition SkAPI.h:35
#define SkASSERT(cond)
Definition SkAssert.h:116
SkYUVColorSpace
Definition SkImageInfo.h:68
skgpu::Mipmapped mipmapped() const
GrYUVABackendTextureInfo & operator=(const GrYUVABackendTextureInfo &)=default
const SkYUVAInfo & yuvaInfo() const
GrSurfaceOrigin textureOrigin() const
const GrBackendFormat & planeFormat(int i) const
GrYUVABackendTextureInfo()=default
bool operator!=(const GrYUVABackendTextureInfo &that) const
GrYUVABackendTextureInfo(const GrYUVABackendTextureInfo &)=default
SkYUVColorSpace yuvColorSpace() const
GrYUVABackendTextures & operator=(GrYUVABackendTextures &&)=default
const SkYUVAInfo & yuvaInfo() const
GrYUVABackendTextures & operator=(const GrYUVABackendTextures &)=delete
GrYUVABackendTextures(GrYUVABackendTextures &&)=default
GrYUVABackendTextures(const GrYUVABackendTextures &)=delete
GrBackendTexture texture(int i) const
const std::array< GrBackendTexture, SkYUVAInfo::kMaxPlanes > & textures() const
GrSurfaceOrigin textureOrigin() const
GrYUVABackendTextures()=default
static constexpr int kMaxPlanes
Definition SkYUVAInfo.h:98
std::array< YUVALocation, kYUVAChannelCount > YUVALocations
Definition SkYUVAInfo.h:32
bool operator==(const FlutterPoint &a, const FlutterPoint &b)
Mipmapped
Definition GpuTypes.h:53