Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
GrYUVABackendTextureInfo Class Reference

#include <GrYUVABackendTextures.h>

Public Member Functions

 GrYUVABackendTextureInfo ()=default
 
 GrYUVABackendTextureInfo (const SkYUVAInfo &, const GrBackendFormat[kMaxPlanes], skgpu::Mipmapped, GrSurfaceOrigin)
 
 GrYUVABackendTextureInfo (const GrYUVABackendTextureInfo &)=default
 
GrYUVABackendTextureInfooperator= (const GrYUVABackendTextureInfo &)=default
 
bool operator== (const GrYUVABackendTextureInfo &) const
 
bool operator!= (const GrYUVABackendTextureInfo &that) const
 
const SkYUVAInfoyuvaInfo () const
 
SkYUVColorSpace yuvColorSpace () const
 
skgpu::Mipmapped mipmapped () const
 
GrSurfaceOrigin textureOrigin () const
 
int numPlanes () const
 
const GrBackendFormatplaneFormat (int i) const
 
bool isValid () const
 
SkYUVAInfo::YUVALocations toYUVALocations () const
 

Static Public Attributes

static constexpr auto kMaxPlanes = SkYUVAInfo::kMaxPlanes
 

Detailed Description

A description of a set GrBackendTextures that hold the planar data described by a SkYUVAInfo.

Definition at line 19 of file GrYUVABackendTextures.h.

Constructor & Destructor Documentation

◆ GrYUVABackendTextureInfo() [1/3]

GrYUVABackendTextureInfo::GrYUVABackendTextureInfo ( )
default

Default GrYUVABackendTextureInfo is invalid.

◆ GrYUVABackendTextureInfo() [2/3]

GrYUVABackendTextureInfo::GrYUVABackendTextureInfo ( const SkYUVAInfo yuvaInfo,
const GrBackendFormat  formats[kMaxPlanes],
skgpu::Mipmapped  mipmapped,
GrSurfaceOrigin  origin 
)

Initializes a GrYUVABackendTextureInfo to describe a set of textures that can store the planes indicated by the SkYUVAInfo. The texture dimensions are taken from the SkYUVAInfo's plane dimensions. All the described textures share a common origin. The planar image this describes will be mip mapped if all the textures are individually mip mapped as indicated by skgpu::Mipmapped. This will produce an invalid result (return false from isValid()) if the passed formats' channels don't agree with SkYUVAInfo.

Definition at line 25 of file GrYUVABackendTextures.cpp.

29 : fYUVAInfo(yuvaInfo), fMipmapped(mipmapped), fTextureOrigin(origin) {
30 if (!yuvaInfo.isValid()) {
31 *this = {};
32 SkASSERT(!this->isValid());
33 return;
34 }
35 int n = yuvaInfo.numPlanes();
36 for (size_t i = 0; i < static_cast<size_t>(n); ++i) {
37 if (!formats[i].isValid() || formats[i].backend() != formats[0].backend()) {
38 *this = {};
39 SkASSERT(!this->isValid());
40 return;
41 }
42 int numRequiredChannels = yuvaInfo.numChannelsInPlane(i);
43 SkASSERT(numRequiredChannels > 0);
44 int numActualChannels = num_channels(formats[i]);
45 if (numActualChannels < numRequiredChannels) {
46 *this = {};
47 SkASSERT(!this->isValid());
48 return;
49 }
50 fPlaneFormats[i] = formats[i];
51 }
52 SkASSERT(this->isValid());
53}
static int num_channels(const GrBackendFormat &format)
#define SkASSERT(cond)
Definition: SkAssert.h:116
GrBackendApi backend() const
skgpu::Mipmapped mipmapped() const
const SkYUVAInfo & yuvaInfo() const
int numPlanes() const
Definition: SkYUVAInfo.h:204
bool isValid() const
Definition: SkYUVAInfo.h:233
int numChannelsInPlane(int i) const
Definition: SkYUVAInfo.h:206

◆ GrYUVABackendTextureInfo() [3/3]

GrYUVABackendTextureInfo::GrYUVABackendTextureInfo ( const GrYUVABackendTextureInfo )
default

Member Function Documentation

◆ isValid()

bool GrYUVABackendTextureInfo::isValid ( ) const
inline

Returns true if this has been configured with a valid SkYUVAInfo with compatible texture formats.

Definition at line 64 of file GrYUVABackendTextures.h.

64{ return fYUVAInfo.isValid(); }

◆ mipmapped()

skgpu::Mipmapped GrYUVABackendTextureInfo::mipmapped ( ) const
inline

Definition at line 50 of file GrYUVABackendTextures.h.

50{ return fMipmapped; }

◆ numPlanes()

int GrYUVABackendTextureInfo::numPlanes ( ) const
inline

The number of SkPixmap planes, 0 if this GrYUVABackendTextureInfo is invalid.

Definition at line 55 of file GrYUVABackendTextures.h.

55{ return fYUVAInfo.numPlanes(); }

◆ operator!=()

bool GrYUVABackendTextureInfo::operator!= ( const GrYUVABackendTextureInfo that) const
inline

Definition at line 44 of file GrYUVABackendTextures.h.

44{ return !(*this == that); }

◆ operator=()

GrYUVABackendTextureInfo & GrYUVABackendTextureInfo::operator= ( const GrYUVABackendTextureInfo )
default

◆ operator==()

bool GrYUVABackendTextureInfo::operator== ( const GrYUVABackendTextureInfo that) const

Definition at line 55 of file GrYUVABackendTextures.cpp.

55 {
56 if (fYUVAInfo != that.fYUVAInfo ||
57 fMipmapped != that.fMipmapped ||
58 fTextureOrigin != that.fTextureOrigin) {
59 return false;
60 }
61 int n = fYUVAInfo.numPlanes();
62 return std::equal(fPlaneFormats, fPlaneFormats + n, that.fPlaneFormats);
63}
static bool equal(const SkBitmap &a, const SkBitmap &b)
Definition: ImageTest.cpp:1395

◆ planeFormat()

const GrBackendFormat & GrYUVABackendTextureInfo::planeFormat ( int  i) const
inline

Format of the ith plane, or invalid format if i >= numPlanes()

Definition at line 58 of file GrYUVABackendTextures.h.

58{ return fPlaneFormats[i]; }

◆ textureOrigin()

GrSurfaceOrigin GrYUVABackendTextureInfo::textureOrigin ( ) const
inline

Definition at line 52 of file GrYUVABackendTextures.h.

52{ return fTextureOrigin; }

◆ toYUVALocations()

SkYUVAInfo::YUVALocations GrYUVABackendTextureInfo::toYUVALocations ( ) const

Computes a YUVALocations representation of the planar layout. The result is guaranteed to be valid if this->isValid().

Definition at line 65 of file GrYUVABackendTextures.cpp.

65 {
66 uint32_t channelFlags[] = {fPlaneFormats[0].channelMask(),
67 fPlaneFormats[1].channelMask(),
68 fPlaneFormats[2].channelMask(),
69 fPlaneFormats[3].channelMask()};
70 auto result = fYUVAInfo.toYUVALocations(channelFlags);
73 SkASSERT(numPlanes == this->numPlanes());
74 return result;
75}
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
uint32_t channelMask() const
YUVALocations toYUVALocations(const uint32_t *channelFlags) const
Definition: SkYUVAInfo.cpp:358
GAsyncResult * result
static bool AreValidLocations(const SkYUVAInfo::YUVALocations &locations, int *numPlanes=nullptr)

◆ yuvaInfo()

const SkYUVAInfo & GrYUVABackendTextureInfo::yuvaInfo ( ) const
inline

Definition at line 46 of file GrYUVABackendTextures.h.

46{ return fYUVAInfo; }

◆ yuvColorSpace()

SkYUVColorSpace GrYUVABackendTextureInfo::yuvColorSpace ( ) const
inline

Definition at line 48 of file GrYUVABackendTextures.h.

48{ return fYUVAInfo.yuvColorSpace(); }
SkYUVColorSpace yuvColorSpace() const
Definition: SkYUVAInfo.h:175

Member Data Documentation

◆ kMaxPlanes

constexpr auto GrYUVABackendTextureInfo::kMaxPlanes = SkYUVAInfo::kMaxPlanes
staticconstexpr

Definition at line 21 of file GrYUVABackendTextures.h.


The documentation for this class was generated from the following files: