Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
sk_gpu_test::GLTestContext Class Referenceabstract

#include <GLTestContext.h>

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

Public Member Functions

 ~GLTestContext () override
 
GrBackendApi backend () override
 
bool isValid () const
 
const GrGLInterfacegl () const
 
virtual GrEGLImage texture2DToEGLImage (GrGLuint) const
 
virtual void destroyEGLImage (GrEGLImage) const
 
virtual GrGLuint eglImageToExternalTexture (GrEGLImage) const
 
void testAbandon () override
 
void overrideVersion (const char *version, const char *shadingLanguageVersion)
 
virtual std::unique_ptr< GLTestContextmakeNew () const
 
template<typename Ret , typename... Args>
void getGLProcAddress (Ret(GR_GL_FUNCTION_TYPE **out)(Args...), const char *name, const char *ext=nullptr) const
 
sk_sp< GrDirectContextmakeContext (const GrContextOptions &options) override
 
- Public Member Functions inherited from sk_gpu_test::TestContext
virtual ~TestContext ()
 
bool fenceSyncSupport () const
 
bool gpuTimingSupport () const
 
GpuTimergpuTimer () const
 
bool getMaxGpuFrameLag (int *maxFrameLag) const
 
void makeNotCurrent () const
 
void makeCurrent () const
 
SkScopeExit makeCurrentAndAutoRestore () const
 
void flushAndWaitOnSync (GrDirectContext *context)
 
void flushAndSyncCpu (GrDirectContext *)
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Protected Member Functions

 GLTestContext ()
 
void init (sk_sp< const GrGLInterface >)
 
void teardown () override
 
virtual GrGLFuncPtr onPlatformGetProcAddress (const char *) const =0
 
- Protected Member Functions inherited from sk_gpu_test::TestContext
 TestContext ()
 
virtual void onPlatformMakeNotCurrent () const =0
 
virtual void onPlatformMakeCurrent () const =0
 
virtual std::function< void()> onPlatformGetAutoContextRestore () const =0
 

Additional Inherited Members

- Protected Attributes inherited from sk_gpu_test::TestContext
bool fFenceSupport = false
 
std::unique_ptr< GpuTimerfGpuTimer
 

Detailed Description

An offscreen OpenGL context. Provides a GrGLInterface struct of function pointers for the context This class is intended for Skia's internal testing needs and not for general use. When SK_GL is not defined the GrGLInterface will always be nullptr.

Definition at line 21 of file GLTestContext.h.

Constructor & Destructor Documentation

◆ ~GLTestContext()

sk_gpu_test::GLTestContext::~GLTestContext ( )
override

Definition at line 154 of file GLTestContext.cpp.

154 {
155 SkASSERT(!fGLInterface);
156 SkASSERT(!fOriginalGLInterface);
157}
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ GLTestContext()

sk_gpu_test::GLTestContext::GLTestContext ( )
protected

Definition at line 152 of file GLTestContext.cpp.

Member Function Documentation

◆ backend()

GrBackendApi sk_gpu_test::GLTestContext::backend ( )
inlineoverridevirtual

Implements sk_gpu_test::TestContext.

Definition at line 25 of file GLTestContext.h.

◆ destroyEGLImage()

virtual void sk_gpu_test::GLTestContext::destroyEGLImage ( GrEGLImage  ) const
inlinevirtual

Definition at line 35 of file GLTestContext.h.

35{ }

◆ eglImageToExternalTexture()

virtual GrGLuint sk_gpu_test::GLTestContext::eglImageToExternalTexture ( GrEGLImage  ) const
inlinevirtual

Used for testing EGLImage integration. Takes a EGLImage and wraps it in a GL_TEXTURE_EXTERNAL_OES.

Definition at line 41 of file GLTestContext.h.

41{ return 0; }

◆ getGLProcAddress()

template<typename Ret , typename... Args>
void sk_gpu_test::GLTestContext::getGLProcAddress ( Ret(GR_GL_FUNCTION_TYPE **out)(Args...)  ,
const char *  name,
const char *  ext = nullptr 
) const
inline

Definition at line 54 of file GLTestContext.h.

55 {
56 using Proc = Ret(GR_GL_FUNCTION_TYPE*)(Args...);
57 if (!SkStrStartsWith(name, "gl")) {
58 SK_ABORT("getGLProcAddress: proc name must have 'gl' prefix");
59 *out = nullptr;
60 } else if (ext) {
62 fullname.append(ext);
63 *out = reinterpret_cast<Proc>(this->onPlatformGetProcAddress(fullname.c_str()));
64 } else {
65 *out = reinterpret_cast<Proc>(this->onPlatformGetProcAddress(name));
66 }
67 }
#define GR_GL_FUNCTION_TYPE
Definition GrGLConfig.h:27
#define SK_ABORT(message,...)
Definition SkAssert.h:70
static bool SkStrStartsWith(const char string[], const char prefixStr[])
Definition SkString.h:26
void(* Proc)(SkCanvas *, const SkRect &, const SkPaint &)
Definition blurrect.cpp:42
virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const =0
const char * name
Definition fuchsia.cc:50

◆ gl()

const GrGLInterface * sk_gpu_test::GLTestContext::gl ( ) const
inline

Definition at line 30 of file GLTestContext.h.

30{ return fGLInterface.get(); }
T * get() const
Definition SkRefCnt.h:303

◆ init()

void sk_gpu_test::GLTestContext::init ( sk_sp< const GrGLInterface gl)
protected

Definition at line 183 of file GLTestContext.cpp.

183 {
184 fGLInterface = std::move(gl);
185 fOriginalGLInterface = fGLInterface;
186 fFenceSupport = fence_is_supported(this);
187 fGpuTimer = GLGpuTimer::MakeIfSupported(this);
188}
const GrGLInterface * gl() const
std::unique_ptr< GpuTimer > fGpuTimer
Definition TestContext.h:89

◆ isValid()

bool sk_gpu_test::GLTestContext::isValid ( ) const

Does this represent a successfully created GL context?

Definition at line 159 of file GLTestContext.cpp.

159 {
160 return SkToBool(this->gl());
161}
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35

◆ makeContext()

sk_sp< GrDirectContext > sk_gpu_test::GLTestContext::makeContext ( const GrContextOptions options)
overridevirtual

Reimplemented from sk_gpu_test::TestContext.

Definition at line 224 of file GLTestContext.cpp.

224 {
225 return GrDirectContexts::MakeGL(fGLInterface, options);
226}
const char * options
SK_API sk_sp< GrDirectContext > MakeGL()

◆ makeNew()

virtual std::unique_ptr< GLTestContext > sk_gpu_test::GLTestContext::makeNew ( ) const
inlinevirtual

Creates a new GL context of the same type and makes the returned context current (if not null).

Definition at line 51 of file GLTestContext.h.

51{ return nullptr; }

◆ onPlatformGetProcAddress()

virtual GrGLFuncPtr sk_gpu_test::GLTestContext::onPlatformGetProcAddress ( const char *  ) const
protectedpure virtual

◆ overrideVersion()

void sk_gpu_test::GLTestContext::overrideVersion ( const char *  version,
const char *  shadingLanguageVersion 
)

Definition at line 206 of file GLTestContext.cpp.

206 {
207 // GrGLFunction has both a limited capture size and doesn't call a destructor when it is
208 // initialized with a lambda. So here we're trusting fOriginalGLInterface will be kept alive.
209 auto getString = [wrapped = &fOriginalGLInterface->fFunctions.fGetString,
210 version,
211 shadingLanguageVersion](GrGLenum name) {
212 if (name == GR_GL_VERSION) {
213 return reinterpret_cast<const GrGLubyte*>(version);
214 } else if (name == GR_GL_SHADING_LANGUAGE_VERSION) {
215 return reinterpret_cast<const GrGLubyte*>(shadingLanguageVersion);
216 }
217 return (*wrapped)(name);
218 };
219 auto newInterface = sk_make_sp<GrGLInterface>(*fOriginalGLInterface);
220 newInterface->fFunctions.fGetString = getString;
221 fGLInterface = std::move(newInterface);
222}
#define GR_GL_SHADING_LANGUAGE_VERSION
#define GR_GL_VERSION
unsigned int GrGLenum
Definition GrGLTypes.h:102
unsigned char GrGLubyte
Definition GrGLTypes.h:111
static sk_sp< GrTextureProxy > wrapped(skiatest::Reporter *reporter, GrRecordingContext *rContext, GrProxyProvider *proxyProvider, SkBackingFit fit)
GrGLFunction< GrGLGetStringFn > fGetString
struct GrGLInterface::Functions fFunctions

◆ teardown()

void sk_gpu_test::GLTestContext::teardown ( )
overrideprotectedvirtual

This should destroy the 3D context.

Reimplemented from sk_gpu_test::TestContext.

Definition at line 190 of file GLTestContext.cpp.

190 {
191 fGLInterface.reset();
192 fOriginalGLInterface.reset();
194}
void reset(T *ptr=nullptr)
Definition SkRefCnt.h:310

◆ testAbandon()

void sk_gpu_test::GLTestContext::testAbandon ( )
overridevirtual

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 from sk_gpu_test::TestContext.

Definition at line 196 of file GLTestContext.cpp.

196 {
198#if defined(GR_TEST_UTILS)
199 if (fGLInterface) {
200 fGLInterface->abandon();
201 fOriginalGLInterface->abandon();
202 }
203#endif
204}
virtual void testAbandon()

◆ texture2DToEGLImage()

virtual GrEGLImage sk_gpu_test::GLTestContext::texture2DToEGLImage ( GrGLuint  ) const
inlinevirtual

Used for testing EGLImage integration. Take a GL_TEXTURE_2D and wraps it in an EGL Image

Definition at line 33 of file GLTestContext.h.

33{ return nullptr; }

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