Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
DDLPromiseImageHelper Class Reference

#include <DDLPromiseImageHelper.h>

Public Member Functions

 DDLPromiseImageHelper (const SkYUVAPixmapInfo::SupportedDataTypes &supportedYUVADataTypes)
 
 ~DDLPromiseImageHelper ()=default
 
sk_sp< SkPicturerecreateSKP (GrDirectContext *, SkPicture *)
 
void uploadAllToGPU (SkTaskGroup *, GrDirectContext *)
 
void deleteAllFromGPU (SkTaskGroup *, GrDirectContext *)
 
void reset ()
 

Detailed Description

Definition at line 107 of file DDLPromiseImageHelper.h.

Constructor & Destructor Documentation

◆ DDLPromiseImageHelper()

DDLPromiseImageHelper::DDLPromiseImageHelper ( const SkYUVAPixmapInfo::SupportedDataTypes supportedYUVADataTypes)
inline

Definition at line 109 of file DDLPromiseImageHelper.h.

110 : fSupportedYUVADataTypes(supportedYUVADataTypes) {}

◆ ~DDLPromiseImageHelper()

DDLPromiseImageHelper::~DDLPromiseImageHelper ( )
default

Member Function Documentation

◆ deleteAllFromGPU()

void DDLPromiseImageHelper::deleteAllFromGPU ( SkTaskGroup taskGroup,
GrDirectContext direct 
)

Definition at line 279 of file DDLPromiseImageHelper.cpp.

279 {
280 if (taskGroup) {
281 for (int i = 0; i < fImageInfo.size(); ++i) {
282 PromiseImageInfo* info = &fImageInfo[i];
283
284 taskGroup->add([info]() { DeleteBETexturesForPromiseImage(info); });
285 }
286 } else {
287 for (int i = 0; i < fImageInfo.size(); ++i) {
288 DeleteBETexturesForPromiseImage(&fImageInfo[i]);
289 }
290 }
291}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
void add(std::function< void(void)> fn)
Definition: SkTaskGroup.cpp:16
int size() const
Definition: SkTArray.h:421

◆ recreateSKP()

sk_sp< SkPicture > DDLPromiseImageHelper::recreateSKP ( GrDirectContext dContext,
SkPicture inputPicture 
)

Definition at line 100 of file DDLPromiseImageHelper.cpp.

101 {
102 SkSerialProcs procs;
103
104 procs.fImageCtx = this;
105 procs.fImageProc = [](SkImage* image, void* ctx) -> sk_sp<SkData> {
106 auto helper = static_cast<DDLPromiseImageHelper*>(ctx);
107
108 int id = helper->findOrDefineImage(image);
109
110 // Even if 'id' is invalid (i.e., -1) write it to the SKP
111 return SkData::MakeWithCopy(&id, sizeof(id));
112 };
113
114 sk_sp<SkData> compressedPictureData = inputPicture->serialize(&procs);
115 if (!compressedPictureData) {
116 return nullptr;
117 }
118
119 this->createCallbackContexts(dContext);
120
121 return this->reinflateSKP(dContext->threadSafeProxy(), compressedPictureData.get());
122}
sk_sp< GrContextThreadSafeProxy > threadSafeProxy()
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Definition: SkData.cpp:111
sk_sp< SkData > serialize(const SkSerialProcs *procs=nullptr) const
Definition: SkPicture.cpp:249
T * get() const
Definition: SkRefCnt.h:303
sk_sp< const SkImage > image
Definition: SkRecords.h:269
void * fImageCtx
Definition: SkSerialProcs.h:91
SkSerialImageProc fImageProc
Definition: SkSerialProcs.h:90

◆ reset()

void DDLPromiseImageHelper::reset ( )
inline

Definition at line 121 of file DDLPromiseImageHelper.h.

121 {
122 fImageInfo.clear();
123 fPromiseImages.clear();
124 }

◆ uploadAllToGPU()

void DDLPromiseImageHelper::uploadAllToGPU ( SkTaskGroup taskGroup,
GrDirectContext direct 
)

Definition at line 265 of file DDLPromiseImageHelper.cpp.

265 {
266 if (taskGroup) {
267 for (int i = 0; i < fImageInfo.size(); ++i) {
268 PromiseImageInfo* info = &fImageInfo[i];
269
270 taskGroup->add([direct, info]() { CreateBETexturesForPromiseImage(direct, info); });
271 }
272 } else {
273 for (int i = 0; i < fImageInfo.size(); ++i) {
274 CreateBETexturesForPromiseImage(direct, &fImageInfo[i]);
275 }
276 }
277}

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