MCPcopy Create free account
hub / github.com/Tencent/libpag / draw

Method draw

src/rendering/PAGSurface.cpp:195–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195bool PAGSurface::draw(RenderCache* cache, std::shared_ptr<Graphic> graphic,
196 BackendSemaphore* signalSemaphore, bool autoClear) {
197 auto context = lockContext();
198 if (!context) {
199 return false;
200 }
201 cache->prepareLayers();
202 auto surface = drawable->getSurface(context, true);
203 if (surface != nullptr && autoClear && contentVersion == cache->getContentVersion()) {
204 unlockContext();
205 return false;
206 }
207 if (surface == nullptr) {
208 surface = drawable->getSurface(context, false);
209 }
210 if (surface == nullptr) {
211 unlockContext();
212 return false;
213 }
214 contentVersion = cache->getContentVersion();
215 cache->attachToContext(context);
216 auto canvas = surface->getCanvas();
217 if (autoClear) {
218 canvas->clear();
219 }
220 onDraw(graphic, surface, cache);
221 if (signalSemaphore == nullptr) {
222 context->flush();
223 } else {
224 tgfx::BackendSemaphore semaphore = {};
225 context->flush(&semaphore);
226 tgfx::GLSyncInfo signalInfo = {};
227 if (semaphore.getGLSync(&signalInfo)) {
228 signalSemaphore->initGL(signalInfo.sync);
229 }
230 }
231 cache->detachFromContext();
232 context->submit();
233 drawable->setTimeStamp(pagPlayer->getTimeStampInternal());
234 drawable->present(context);
235 unlockContext();
236 return true;
237}
238
239bool PAGSurface::wait(const BackendSemaphore& waitSemaphore) {
240 if (!waitSemaphore.isInitialized()) {

Callers 4

prepareInternalMethod · 0.45
flushInternalMethod · 0.45
hitTestPointMethod · 0.45
onDrawMethod · 0.45

Calls 12

prepareLayersMethod · 0.80
attachToContextMethod · 0.80
initGLMethod · 0.80
detachFromContextMethod · 0.80
submitMethod · 0.80
getTimeStampInternalMethod · 0.80
getSurfaceMethod · 0.45
getContentVersionMethod · 0.45
clearMethod · 0.45
flushMethod · 0.45
setTimeStampMethod · 0.45
presentMethod · 0.45

Tested by

no test coverage detected