Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
sk_gpu_test::FlushFinishTracker Class Reference

#include <FlushFinishTracker.h>

Inheritance diagram for sk_gpu_test::FlushFinishTracker:
SkRefCnt SkRefCntBase

Public Member Functions

 FlushFinishTracker (GrDirectContext *context)
 
void setFinished ()
 
void waitTillFinished (std::function< void()> tick={})
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static void FlushFinished (void *finishedContext)
 
static void FlushFinishedResult (void *finishedContext, skgpu::CallbackResult)
 

Detailed Description

Definition at line 24 of file FlushFinishTracker.h.

Constructor & Destructor Documentation

◆ FlushFinishTracker()

sk_gpu_test::FlushFinishTracker::FlushFinishTracker ( GrDirectContext context)
inline

Definition at line 36 of file FlushFinishTracker.h.

36: fContext(context) {}

Member Function Documentation

◆ FlushFinished()

static void sk_gpu_test::FlushFinishTracker::FlushFinished ( void *  finishedContext)
inlinestatic

Definition at line 26 of file FlushFinishTracker.h.

26 {
27 auto tracker = static_cast<FlushFinishTracker*>(finishedContext);
28 tracker->setFinished();
29 tracker->unref();
30 }
FlushFinishTracker(GrDirectContext *context)

◆ FlushFinishedResult()

static void sk_gpu_test::FlushFinishTracker::FlushFinishedResult ( void *  finishedContext,
skgpu::CallbackResult   
)
inlinestatic

Definition at line 32 of file FlushFinishTracker.h.

32 {
33 FlushFinished(finishedContext);
34 }
static void FlushFinished(void *finishedContext)

◆ setFinished()

void sk_gpu_test::FlushFinishTracker::setFinished ( )
inline

Definition at line 41 of file FlushFinishTracker.h.

41{ fIsFinished = true; }

◆ waitTillFinished()

void sk_gpu_test::FlushFinishTracker::waitTillFinished ( std::function< void()>  tick = {})

Definition at line 21 of file FlushFinishTracker.cpp.

21 {
22 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
23 auto begin = std::chrono::steady_clock::now();
24 auto end = begin;
25 while (!fIsFinished && (end - begin) < std::chrono::seconds(2)) {
26 if (tick) {
27 tick();
28 }
29 if (fContext) {
30 fContext->checkAsyncWorkCompletion();
31 } else {
32#if defined(SK_GRAPHITE)
33 SkASSERT(fGraphiteContext);
34 fGraphiteContext->checkAsyncWorkCompletion();
35#else
36 SkDEBUGFAIL("No valid context");
37#endif
38 }
39 end = std::chrono::steady_clock::now();
40 }
41 if (!fIsFinished) {
42 SkDebugf("WARNING: Wait failed for flush sync. Timings might not be accurate.\n");
43 }
44}
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
void checkAsyncWorkCompletion()
static const char * begin(const StringSlice &s)
Definition: editor.cpp:252
glong glong end
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

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