Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SkYUVAPixmaps Class Reference

#include <SkYUVAPixmaps.h>

Public Types

using DataType = SkYUVAPixmapInfo::DataType
 

Public Member Functions

 SkYUVAPixmaps ()=default
 
 ~SkYUVAPixmaps ()=default
 
 SkYUVAPixmaps (SkYUVAPixmaps &&that)=default
 
SkYUVAPixmapsoperator= (SkYUVAPixmaps &&that)=default
 
 SkYUVAPixmaps (const SkYUVAPixmaps &)=default
 
SkYUVAPixmapsoperator= (const SkYUVAPixmaps &that)=default
 
bool isValid () const
 
const SkYUVAInfoyuvaInfo () const
 
DataType dataType () const
 
SkYUVAPixmapInfo pixmapsInfo () const
 
int numPlanes () const
 
const std::array< SkPixmap, kMaxPlanes > & planes () const
 
const SkPixmapplane (int i) const
 
SkYUVAInfo::YUVALocations toYUVALocations () const
 
bool ownsStorage () const
 

Static Public Member Functions

static SkColorType RecommendedRGBAColorType (DataType)
 
static SkYUVAPixmaps Allocate (const SkYUVAPixmapInfo &yuvaPixmapInfo)
 
static SkYUVAPixmaps FromData (const SkYUVAPixmapInfo &, sk_sp< SkData >)
 
static SkYUVAPixmaps MakeCopy (const SkYUVAPixmaps &src)
 
static SkYUVAPixmaps FromExternalMemory (const SkYUVAPixmapInfo &, void *memory)
 
static SkYUVAPixmaps FromExternalPixmaps (const SkYUVAInfo &, const SkPixmap[kMaxPlanes])
 

Static Public Attributes

static constexpr auto kMaxPlanes = SkYUVAPixmapInfo::kMaxPlanes
 

Detailed Description

Helper to store SkPixmap planes as described by a SkYUVAPixmapInfo. Can be responsible for allocating/freeing memory for pixmaps or use external memory.

Definition at line 172 of file SkYUVAPixmaps.h.

Member Typedef Documentation

◆ DataType

Definition at line 174 of file SkYUVAPixmaps.h.

Constructor & Destructor Documentation

◆ SkYUVAPixmaps() [1/3]

SkYUVAPixmaps::SkYUVAPixmaps ( )
default

Default SkYUVAPixmaps is invalid.

◆ ~SkYUVAPixmaps()

SkYUVAPixmaps::~SkYUVAPixmaps ( )
default

◆ SkYUVAPixmaps() [2/3]

SkYUVAPixmaps::SkYUVAPixmaps ( SkYUVAPixmaps &&  that)
default

◆ SkYUVAPixmaps() [3/3]

SkYUVAPixmaps::SkYUVAPixmaps ( const SkYUVAPixmaps )
default

Member Function Documentation

◆ Allocate()

SkYUVAPixmaps SkYUVAPixmaps::Allocate ( const SkYUVAPixmapInfo yuvaPixmapInfo)
static

Allocate space for pixmaps' pixels in the SkYUVAPixmaps.

Definition at line 169 of file SkYUVAPixmaps.cpp.

169 {
170 if (!yuvaPixmapInfo.isValid()) {
171 return {};
172 }
173 return SkYUVAPixmaps(yuvaPixmapInfo,
175}
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition SkData.cpp:116
size_t computeTotalBytes(size_t planeSizes[kMaxPlanes]=nullptr) const
bool isValid() const
SkYUVAPixmaps()=default

◆ dataType()

DataType SkYUVAPixmaps::dataType ( ) const
inline

Definition at line 223 of file SkYUVAPixmaps.h.

223{ return fDataType; }

◆ FromData()

SkYUVAPixmaps SkYUVAPixmaps::FromData ( const SkYUVAPixmapInfo yuvaPixmapInfo,
sk_sp< SkData data 
)
static

Use storage in SkData as backing store for pixmaps' pixels. SkData is retained by the SkYUVAPixmaps.

Definition at line 177 of file SkYUVAPixmaps.cpp.

177 {
178 if (!yuvaPixmapInfo.isValid()) {
179 return {};
180 }
181 if (yuvaPixmapInfo.computeTotalBytes() > data->size()) {
182 return {};
183 }
184 return SkYUVAPixmaps(yuvaPixmapInfo, std::move(data));
185}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ FromExternalMemory()

SkYUVAPixmaps SkYUVAPixmaps::FromExternalMemory ( const SkYUVAPixmapInfo yuvaPixmapInfo,
void *  memory 
)
static

Use passed in memory as backing store for pixmaps' pixels. Caller must ensure memory remains allocated while pixmaps are in use. There must be at least SkYUVAPixmapInfo::computeTotalBytes() allocated starting at memory.

Definition at line 208 of file SkYUVAPixmaps.cpp.

209 {
210 if (!yuvaPixmapInfo.isValid()) {
211 return {};
212 }
213 SkPixmap pixmaps[kMaxPlanes];
214 yuvaPixmapInfo.initPixmapsFromSingleAllocation(memory, pixmaps);
215 return SkYUVAPixmaps(yuvaPixmapInfo.yuvaInfo(), yuvaPixmapInfo.dataType(), pixmaps);
216}
const SkYUVAInfo & yuvaInfo() const
bool initPixmapsFromSingleAllocation(void *memory, SkPixmap pixmaps[kMaxPlanes]) const
DataType dataType() const
static constexpr auto kMaxPlanes

◆ FromExternalPixmaps()

SkYUVAPixmaps SkYUVAPixmaps::FromExternalPixmaps ( const SkYUVAInfo yuvaInfo,
const SkPixmap  pixmaps[kMaxPlanes] 
)
static

Wraps existing SkPixmaps. The SkYUVAPixmaps will have no ownership of the SkPixmaps' pixel memory so the caller must ensure it remains valid. Will return an invalid SkYUVAPixmaps if the SkYUVAInfo isn't compatible with the SkPixmap array (number of planes, plane dimensions, sufficient color channels in planes, ...).

Definition at line 218 of file SkYUVAPixmaps.cpp.

219 {
220 SkColorType colorTypes[kMaxPlanes] = {};
221 size_t rowBytes[kMaxPlanes] = {};
223 for (int i = 0; i < numPlanes; ++i) {
224 colorTypes[i] = pixmaps[i].colorType();
225 rowBytes[i] = pixmaps[i].rowBytes();
226 }
227 SkYUVAPixmapInfo yuvaPixmapInfo(yuvaInfo, colorTypes, rowBytes);
228 if (!yuvaPixmapInfo.isValid()) {
229 return {};
230 }
231 return SkYUVAPixmaps(yuvaInfo, yuvaPixmapInfo.dataType(), pixmaps);
232}
SkColorType
Definition SkColorType.h:19
size_t rowBytes() const
Definition SkPixmap.h:145
SkColorType colorType() const
Definition SkPixmap.h:173
int numPlanes() const
Definition SkYUVAInfo.h:204
const SkYUVAInfo & yuvaInfo() const
int numPlanes() const

◆ isValid()

bool SkYUVAPixmaps::isValid ( ) const
inline

Does have initialized pixmaps compatible with its SkYUVAInfo.

Definition at line 219 of file SkYUVAPixmaps.h.

219{ return !fYUVAInfo.dimensions().isEmpty(); }
SkISize dimensions() const
Definition SkYUVAInfo.h:171
bool isEmpty() const
Definition SkSize.h:31

◆ MakeCopy()

SkYUVAPixmaps SkYUVAPixmaps::MakeCopy ( const SkYUVAPixmaps src)
static

Makes a deep copy of the src SkYUVAPixmaps. The returned SkYUVAPixmaps owns its planes' backing stores.

Definition at line 187 of file SkYUVAPixmaps.cpp.

187 {
188 if (!src.isValid()) {
189 return {};
190 }
191 SkYUVAPixmaps result = Allocate(src.pixmapsInfo());
192 int n = result.numPlanes();
193 for (int i = 0; i < n; ++i) {
194 // We use SkRectMemCpy rather than readPixels to ensure that we don't do any alpha type
195 // conversion.
196 const SkPixmap& s = src.plane(i);
197 const SkPixmap& d = result.plane(i);
198 SkRectMemcpy(d.writable_addr(),
199 d.rowBytes(),
200 s.addr(),
201 s.rowBytes(),
202 s.info().minRowBytes(),
203 s.height());
204 }
205 return result;
206}
static void SkRectMemcpy(void *dst, size_t dstRB, const void *src, size_t srcRB, size_t trimRowBytes, int rowCount)
static SkYUVAPixmaps Allocate(const SkYUVAPixmapInfo &yuvaPixmapInfo)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
struct MyStruct s
GAsyncResult * result

◆ numPlanes()

int SkYUVAPixmaps::numPlanes ( ) const
inline

Number of pixmap planes or 0 if this SkYUVAPixmaps is invalid.

Definition at line 228 of file SkYUVAPixmaps.h.

228{ return this->isValid() ? fYUVAInfo.numPlanes() : 0; }
bool isValid() const

◆ operator=() [1/2]

SkYUVAPixmaps & SkYUVAPixmaps::operator= ( const SkYUVAPixmaps that)
default

◆ operator=() [2/2]

SkYUVAPixmaps & SkYUVAPixmaps::operator= ( SkYUVAPixmaps &&  that)
default

◆ ownsStorage()

bool SkYUVAPixmaps::ownsStorage ( ) const
inline

Does this SkPixmaps own the backing store of the planes?

Definition at line 249 of file SkYUVAPixmaps.h.

249{ return SkToBool(fData); }
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35

◆ pixmapsInfo()

SkYUVAPixmapInfo SkYUVAPixmaps::pixmapsInfo ( ) const

Definition at line 251 of file SkYUVAPixmaps.cpp.

251 {
252 if (!this->isValid()) {
253 return {};
254 }
255 SkColorType colorTypes[kMaxPlanes] = {};
256 size_t rowBytes[kMaxPlanes] = {};
257 int numPlanes = this->numPlanes();
258 for (int i = 0; i < numPlanes; ++i) {
259 colorTypes[i] = fPlanes[i].colorType();
260 rowBytes[i] = fPlanes[i].rowBytes();
261 }
262 return {fYUVAInfo, colorTypes, rowBytes};
263}

◆ plane()

const SkPixmap & SkYUVAPixmaps::plane ( int  i) const
inline

Get the ith SkPixmap plane. SkPixmap will be default initialized if i >= numPlanes or this SkYUVAPixmaps is invalid.

Definition at line 240 of file SkYUVAPixmaps.h.

240{ return fPlanes[SkToSizeT(i)]; }
constexpr size_t SkToSizeT(S x)
Definition SkTo.h:31

◆ planes()

const std::array< SkPixmap, kMaxPlanes > & SkYUVAPixmaps::planes ( ) const
inline

Access the SkPixmap planes. They are default initialized if this is not a valid SkYUVAPixmaps.

Definition at line 234 of file SkYUVAPixmaps.h.

234{ return fPlanes; }

◆ RecommendedRGBAColorType()

SkColorType SkYUVAPixmaps::RecommendedRGBAColorType ( DataType  dataType)
static

Definition at line 157 of file SkYUVAPixmaps.cpp.

157 {
158 switch (dataType) {
159 case DataType::kUnorm8: return kRGBA_8888_SkColorType;
160 // F16 has better GPU support than 16 bit unorm. Often "16" bit unorm values are actually
161 // lower precision.
162 case DataType::kUnorm16: return kRGBA_F16_SkColorType;
163 case DataType::kFloat16: return kRGBA_F16_SkColorType;
164 case DataType::kUnorm10_Unorm2: return kRGBA_1010102_SkColorType;
165 }
167}
#define SkUNREACHABLE
Definition SkAssert.h:135
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition SkColorType.h:38
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:27
DataType dataType() const

◆ toYUVALocations()

SkYUVAInfo::YUVALocations SkYUVAPixmaps::toYUVALocations ( ) const

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

Definition at line 265 of file SkYUVAPixmaps.cpp.

265 {
266 uint32_t channelFlags[] = {SkColorTypeChannelFlags(fPlanes[0].colorType()),
269 SkColorTypeChannelFlags(fPlanes[3].colorType())};
270 auto result = fYUVAInfo.toYUVALocations(channelFlags);
273 SkASSERT(numPlanes == this->numPlanes());
274 return result;
275}
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static uint32_t SkColorTypeChannelFlags(SkColorType ct)
YUVALocations toYUVALocations(const uint32_t *channelFlags) const
static bool AreValidLocations(const SkYUVAInfo::YUVALocations &locations, int *numPlanes=nullptr)

◆ yuvaInfo()

const SkYUVAInfo & SkYUVAPixmaps::yuvaInfo ( ) const
inline

Definition at line 221 of file SkYUVAPixmaps.h.

221{ return fYUVAInfo; }

Member Data Documentation

◆ kMaxPlanes

constexpr auto SkYUVAPixmaps::kMaxPlanes = SkYUVAPixmapInfo::kMaxPlanes
staticconstexpr

Definition at line 175 of file SkYUVAPixmaps.h.


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