Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sk_gpu_test::TestContext Class Referenceabstract

#include <TestContext.h>

Inheritance diagram for sk_gpu_test::TestContext:
SkNoncopyable sk_gpu_test::GLTestContext

Public Member Functions

virtual ~TestContext ()
 
bool fenceSyncSupport () const
 
bool gpuTimingSupport () const
 
GpuTimergpuTimer () const
 
bool getMaxGpuFrameLag (int *maxFrameLag) const
 
void makeNotCurrent () const
 
void makeCurrent () const
 
SkScopeExit makeCurrentAndAutoRestore () const
 
virtual GrBackendApi backend ()=0
 
virtual sk_sp< GrDirectContextmakeContext (const GrContextOptions &)
 
void flushAndWaitOnSync (GrDirectContext *context)
 
virtual void testAbandon ()
 
void flushAndSyncCpu (GrDirectContext *)
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Protected Member Functions

 TestContext ()
 
virtual void teardown ()
 
virtual void onPlatformMakeNotCurrent () const =0
 
virtual void onPlatformMakeCurrent () const =0
 
virtual std::function< void()> onPlatformGetAutoContextRestore () const =0
 

Protected Attributes

bool fFenceSupport = false
 
std::unique_ptr< GpuTimerfGpuTimer
 

Detailed Description

An offscreen 3D context. This class is intended for Skia's internal testing needs and not for general use.

Definition at line 31 of file TestContext.h.

Constructor & Destructor Documentation

◆ ~TestContext()

sk_gpu_test::TestContext::~TestContext ( )
virtual

Definition at line 19 of file TestContext.cpp.

19 {
20 // Subclass should call teardown.
22}
#define SkASSERT(cond)
Definition: SkAssert.h:116
std::unique_ptr< GpuTimer > fGpuTimer
Definition: TestContext.h:89

◆ TestContext()

sk_gpu_test::TestContext::TestContext ( )
protected

Definition at line 17 of file TestContext.cpp.

17: fGpuTimer(nullptr) {}

Member Function Documentation

◆ backend()

virtual GrBackendApi sk_gpu_test::TestContext::backend ( )
pure virtual

Implemented in sk_gpu_test::GLTestContext.

◆ fenceSyncSupport()

bool sk_gpu_test::TestContext::fenceSyncSupport ( ) const
inline

Definition at line 35 of file TestContext.h.

35{ return fFenceSupport; }

◆ flushAndSyncCpu()

void sk_gpu_test::TestContext::flushAndSyncCpu ( GrDirectContext context)

Flush and wait until all GPU work is finished.

Definition at line 61 of file TestContext.cpp.

61 {
62 SkASSERT(context);
63 context->flush();
64 context->submit(GrSyncCpu::kYes);
65}
bool submit(GrSyncCpu sync=GrSyncCpu::kNo)
GrSemaphoresSubmitted flush(const GrFlushInfo &info)

◆ flushAndWaitOnSync()

void sk_gpu_test::TestContext::flushAndWaitOnSync ( GrDirectContext context)

This will flush work to the GPU. Additionally, if the platform supports fence syncs, we will add a finished callback to our flush call. We allow ourselves to have kMaxFrameLag number of unfinished flushes active on the GPU at a time. If we have 2 outstanding flushes then we will wait on the CPU until one has finished.

Definition at line 37 of file TestContext.cpp.

37 {
38 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
39 SkASSERT(context);
40
41 if (fFinishTrackers[fCurrentFlushIdx]) {
42 fFinishTrackers[fCurrentFlushIdx]->waitTillFinished();
43 }
44
45 fFinishTrackers[fCurrentFlushIdx].reset(new FlushFinishTracker(context));
46
47 // We add an additional ref to the current flush tracker here. This ref is owned by the finish
48 // callback on the flush call. The finish callback will unref the tracker when called.
49 fFinishTrackers[fCurrentFlushIdx]->ref();
50
51 GrFlushInfo flushInfo;
53 flushInfo.fFinishedContext = fFinishTrackers[fCurrentFlushIdx].get();
54
55 context->flush(flushInfo);
56 context->submit();
57
58 fCurrentFlushIdx = (fCurrentFlushIdx + 1) % std::size(fFinishTrackers);
59}
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
static void FlushFinished(void *finishedContext)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
GrGpuFinishedContext fFinishedContext
Definition: GrTypes.h:220
GrGpuFinishedProc fFinishedProc
Definition: GrTypes.h:219
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ getMaxGpuFrameLag()

bool sk_gpu_test::TestContext::getMaxGpuFrameLag ( int maxFrameLag) const
inline

Definition at line 40 of file TestContext.h.

40 {
41 if (!this->fenceSyncSupport()) {
42 return false;
43 }
44 *maxFrameLag = kMaxFrameLag;
45 return true;
46 }
bool fenceSyncSupport() const
Definition: TestContext.h:35

◆ gpuTimer()

GpuTimer * sk_gpu_test::TestContext::gpuTimer ( ) const
inline

Definition at line 38 of file TestContext.h.

38{ SkASSERT(fGpuTimer); return fGpuTimer.get(); }

◆ gpuTimingSupport()

bool sk_gpu_test::TestContext::gpuTimingSupport ( ) const
inline

Definition at line 37 of file TestContext.h.

37{ return fGpuTimer != nullptr; }

◆ makeContext()

sk_sp< GrDirectContext > sk_gpu_test::TestContext::makeContext ( const GrContextOptions )
virtual

Reimplemented in sk_gpu_test::GLTestContext.

Definition at line 24 of file TestContext.cpp.

24 {
25 return nullptr;
26}

◆ makeCurrent()

void sk_gpu_test::TestContext::makeCurrent ( ) const

Definition at line 29 of file TestContext.cpp.

29{ this->onPlatformMakeCurrent(); }
virtual void onPlatformMakeCurrent() const =0

◆ makeCurrentAndAutoRestore()

SkScopeExit sk_gpu_test::TestContext::makeCurrentAndAutoRestore ( ) const

Like makeCurrent() but this returns an object that will restore the previous current context in its destructor. Useful to undo the effect making this current before returning to a caller that doesn't expect the current context to be changed underneath it.

The returned object restores the current context of the same type (e.g. egl, glx, ...) in its destructor. It is undefined behavior if that context is destroyed before the destructor executes. If the concept of a current context doesn't make sense for this context type then the returned object's destructor is a no-op.

Definition at line 31 of file TestContext.cpp.

31 {
33 this->makeCurrent();
34 return asr;
35}
virtual std::function< void()> onPlatformGetAutoContextRestore() const =0

◆ makeNotCurrent()

void sk_gpu_test::TestContext::makeNotCurrent ( ) const

Definition at line 28 of file TestContext.cpp.

28{ this->onPlatformMakeNotCurrent(); }
virtual void onPlatformMakeNotCurrent() const =0

◆ onPlatformGetAutoContextRestore()

virtual std::function< void()> sk_gpu_test::TestContext::onPlatformGetAutoContextRestore ( ) const
protectedpure virtual

Subclasses should implement such that the returned function will cause the current context of this type to be made current again when it is called. It should additionally be the case that if "this" is already current when this is called, then "this" is destroyed (thereby setting the null context as current), and then the std::function is called the null context should remain current.

◆ onPlatformMakeCurrent()

virtual void sk_gpu_test::TestContext::onPlatformMakeCurrent ( ) const
protectedpure virtual

◆ onPlatformMakeNotCurrent()

virtual void sk_gpu_test::TestContext::onPlatformMakeNotCurrent ( ) const
protectedpure virtual

◆ teardown()

void sk_gpu_test::TestContext::teardown ( )
protectedvirtual

This should destroy the 3D context.

Reimplemented in sk_gpu_test::GLTestContext.

Definition at line 70 of file TestContext.cpp.

70 {
71 fGpuTimer.reset();
72}

◆ testAbandon()

void sk_gpu_test::TestContext::testAbandon ( )
virtual

This notifies the context that we are deliberately testing abandoning the context. It is useful for debugging contexts that would otherwise test that GPU resources are properly deleted. It also allows a debugging context to test that further API calls are not made by Skia GPU code.

Reimplemented in sk_gpu_test::GLTestContext.

Definition at line 67 of file TestContext.cpp.

67 {
68}

Member Data Documentation

◆ fFenceSupport

bool sk_gpu_test::TestContext::fFenceSupport = false
protected

Definition at line 87 of file TestContext.h.

◆ fGpuTimer

std::unique_ptr<GpuTimer> sk_gpu_test::TestContext::fGpuTimer
protected

Definition at line 89 of file TestContext.h.


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