Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Friends | List of all members
GrBackendFormat Class Reference

#include <GrBackendSurface.h>

Public Member Functions

 GrBackendFormat ()
 
 GrBackendFormat (const GrBackendFormat &)
 
GrBackendFormatoperator= (const GrBackendFormat &)
 
 ~GrBackendFormat ()
 
bool operator== (const GrBackendFormat &that) const
 
bool operator!= (const GrBackendFormat &that) const
 
GrBackendApi backend () const
 
GrTextureType textureType () const
 
uint32_t channelMask () const
 
GrColorFormatDesc desc () const
 
GrColorType asMockColorType () const
 
SkTextureCompressionType asMockCompressionType () const
 
bool isMockStencilFormat () const
 
GrBackendFormat makeTexture2D () const
 
bool isValid () const
 

Static Public Member Functions

static GrBackendFormat MakeMock (GrColorType colorType, SkTextureCompressionType compression, bool isStencilFormat=false)
 

Friends

class GrBackendSurfacePriv
 
class GrBackendFormatData
 

Detailed Description

Definition at line 44 of file GrBackendSurface.h.

Constructor & Destructor Documentation

◆ GrBackendFormat() [1/2]

GrBackendFormat::GrBackendFormat ( )

Definition at line 27 of file GrBackendSurface.cpp.

27: fValid(false) {}

◆ GrBackendFormat() [2/2]

GrBackendFormat::GrBackendFormat ( const GrBackendFormat that)

Definition at line 30 of file GrBackendSurface.cpp.

31 : fBackend(that.fBackend)
32 , fValid(that.fValid)
33 , fTextureType(that.fTextureType) {
34 if (!fValid) {
35 return;
36 }
37
38 switch (fBackend) {
42 fFormatData.reset();
43 that.fFormatData->copyTo(fFormatData);
44 break; // fFormatData is sufficient
45#ifdef SK_DIRECT3D
47 fDxgiFormat = that.fDxgiFormat;
48 break;
49#endif
51 fMock = that.fMock;
52 break;
53 default:
54 SK_ABORT("Unknown GrBackend");
55 }
56}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
virtual void copyTo(AnyFormatData &) const =0
struct GrBackendFormat::@283::@285 fMock

◆ ~GrBackendFormat()

GrBackendFormat::~GrBackendFormat ( )
default

Member Function Documentation

◆ asMockColorType()

GrColorType GrBackendFormat::asMockColorType ( ) const

If the backend API is not Mock these three calls will return kUnknown, kNone or false, respectively. Otherwise, only one of the following can be true. The GrColorType is not kUnknown, the compression type is not kNone, or this is a mock stencil format.

Definition at line 152 of file GrBackendSurface.cpp.

152 {
153 if (this->isValid() && GrBackendApi::kMock == fBackend) {
154 SkASSERT(this->validateMock());
155 return fMock.fColorType;
156 }
157
159}
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool isValid() const

◆ asMockCompressionType()

SkTextureCompressionType GrBackendFormat::asMockCompressionType ( ) const

Definition at line 161 of file GrBackendSurface.cpp.

161 {
162 if (this->isValid() && GrBackendApi::kMock == fBackend) {
163 SkASSERT(this->validateMock());
164 return fMock.fCompressionType;
165 }
166
168}

◆ backend()

GrBackendApi GrBackendFormat::backend ( ) const
inline

Definition at line 65 of file GrBackendSurface.h.

65{ return fBackend; }

◆ channelMask()

uint32_t GrBackendFormat::channelMask ( ) const

Gets the channels present in the format as a bitfield of SkColorChannelFlag values. Luminance channels are reported as kGray_SkColorChannelFlag.

Definition at line 94 of file GrBackendSurface.cpp.

94 {
95 if (!this->isValid()) {
96 return 0;
97 }
98 switch (fBackend) {
102 return fFormatData->channelMask();
103#ifdef SK_DIRECT3D
105 return GrDxgiFormatChannels(fDxgiFormat);
106#endif
108 return GrColorTypeChannelFlags(fMock.fColorType);
109
110 default:
111 return 0;
112 }
113}
static constexpr uint32_t GrDxgiFormatChannels(DXGI_FORMAT format)
Definition: GrD3DUtil.h:37
static constexpr uint32_t GrColorTypeChannelFlags(GrColorType ct)
Definition: GrTypesPriv.h:661
virtual uint32_t channelMask() const =0

◆ desc()

GrColorFormatDesc GrBackendFormat::desc ( ) const

Definition at line 115 of file GrBackendSurface.cpp.

115 {
116 if (!this->isValid()) {
118 }
119 switch (fBackend) {
123 return fFormatData->desc();
124#ifdef SK_DIRECT3D
126 return GrDxgiFormatDesc(fDxgiFormat);
127#endif
129 return GrGetColorTypeDesc(fMock.fColorType);
130
131 default:
133 }
134}
static constexpr GrColorFormatDesc GrDxgiFormatDesc(DXGI_FORMAT format)
Definition: GrD3DUtil.h:61
static constexpr GrColorFormatDesc GrGetColorTypeDesc(GrColorType ct)
Definition: GrTypesPriv.h:794
virtual GrColorFormatDesc desc() const =0
static constexpr GrColorFormatDesc MakeInvalid()
Definition: GrTypesPriv.h:756

◆ isMockStencilFormat()

bool GrBackendFormat::isMockStencilFormat ( ) const

Definition at line 170 of file GrBackendSurface.cpp.

170 {
171 if (this->isValid() && GrBackendApi::kMock == fBackend) {
172 SkASSERT(this->validateMock());
173 return fMock.fIsStencilFormat;
174 }
175
176 return false;
177}

◆ isValid()

bool GrBackendFormat::isValid ( ) const
inline

Definition at line 99 of file GrBackendSurface.h.

99{ return fValid; }

◆ MakeMock()

GrBackendFormat GrBackendFormat::MakeMock ( GrColorType  colorType,
SkTextureCompressionType  compression,
bool  isStencilFormat = false 
)
static

Definition at line 189 of file GrBackendSurface.cpp.

191 {
192 return GrBackendFormat(colorType, compression, isStencilFormat);
193}
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)

◆ makeTexture2D()

GrBackendFormat GrBackendFormat::makeTexture2D ( ) const

Definition at line 179 of file GrBackendSurface.cpp.

179 {
180 GrBackendFormat copy = *this;
181 // TODO(b/293490566): Remove this kVulkan check once all backends are using fFormatData.
182 if (fBackend==GrBackendApi::kVulkan) {
183 copy.fFormatData->makeTexture2D();
184 }
185 copy.fTextureType = GrTextureType::k2D;
186 return copy;
187}
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
Definition: SkSwizzler.cpp:31
Definition: copy.py:1

◆ operator!=()

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

Definition at line 63 of file GrBackendSurface.h.

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

◆ operator=()

GrBackendFormat & GrBackendFormat::operator= ( const GrBackendFormat that)

Definition at line 58 of file GrBackendSurface.cpp.

58 {
59 if (this != &that) {
60 this->~GrBackendFormat();
61 new (this) GrBackendFormat(that);
62 }
63 return *this;
64}

◆ operator==()

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

Definition at line 195 of file GrBackendSurface.cpp.

195 {
196 // Invalid GrBackendFormats are never equal to anything.
197 if (!fValid || !that.fValid) {
198 return false;
199 }
200
201 if (fBackend != that.fBackend) {
202 return false;
203 }
204
205 switch (fBackend) {
209 return fFormatData->equal(that.fFormatData.get());
211 return fMock.fColorType == that.fMock.fColorType &&
212 fMock.fCompressionType == that.fMock.fCompressionType;
213#ifdef SK_DIRECT3D
215 return fDxgiFormat == that.fDxgiFormat;
216#endif
217 default:
218 SK_ABORT("Unknown GrBackend");
219 }
220 return false;
221}
virtual bool equal(const GrBackendFormatData *that) const =0
GrColorType fColorType
SkTextureCompressionType fCompressionType
const Base * get() const
Definition: SkAnySubclass.h:55

◆ textureType()

GrTextureType GrBackendFormat::textureType ( ) const
inline

Definition at line 66 of file GrBackendSurface.h.

66{ return fTextureType; }

Friends And Related Function Documentation

◆ GrBackendFormatData

friend class GrBackendFormatData
friend

Definition at line 112 of file GrBackendSurface.h.

◆ GrBackendSurfacePriv

friend class GrBackendSurfacePriv
friend

Definition at line 111 of file GrBackendSurface.h.

Member Data Documentation

◆ fColorType

GrColorType GrBackendFormat::fColorType

Definition at line 141 of file GrBackendSurface.h.

◆ fCompressionType

SkTextureCompressionType GrBackendFormat::fCompressionType

Definition at line 142 of file GrBackendSurface.h.

◆ fIsStencilFormat

bool GrBackendFormat::fIsStencilFormat

Definition at line 143 of file GrBackendSurface.h.

◆ 

struct { ... } GrBackendFormat::fMock

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