12#include "third_party/skia/include/gpu/ganesh/gl/GrGLAssembleInterface.h"
13#include "third_party/skia/include/gpu/ganesh/gl/GrGLInterface.h"
15#if defined(FML_OS_ANDROID)
16#include "third_party/skia/include/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.h"
19#if defined(FML_OS_LINUX) && defined(SK_GLX)
20#include "third_party/skia/include/gpu/ganesh/gl/glx/GrGLMakeGLXInterface.h"
23#if defined(FML_OS_MACOSX)
24#include "third_party/skia/include/gpu/ganesh/gl/mac/GrGLMakeMacInterface.h"
27#if defined(FML_OS_IOS)
28#include "third_party/skia/include/gpu/ganesh/gl/ios/GrGLMakeIOSInterface.h"
60#define GPU_GL_VERSION 0x1F02
61 constexpr char kGLESVersionPrefix[] =
"OpenGL ES";
64 using GLGetStringProc =
const char*(__stdcall*)(uint32_t);
66 using GLGetStringProc =
const char* (*)(uint32_t);
69 GLGetStringProc gl_get_string =
70 reinterpret_cast<GLGetStringProc
>(proc_resolver(
"glGetString"));
73 <<
"The GL proc resolver could not resolve glGetString";
78 <<
"The GL proc resolver's glGetString(GL_VERSION) failed";
80 return strncmp(gl_version_string, kGLESVersionPrefix,
81 strlen(kGLESVersionPrefix)) == 0;
86 if (proc_resolver ==
nullptr) {
87#if defined(FML_OS_ANDROID)
88 return GrGLInterfaces::MakeEGL();
89#elif defined(FML_OS_LINUX)
91 return GrGLInterfaces::MakeGLX();
95#elif defined(FML_OS_IOS)
96 return GrGLInterfaces::MakeIOS();
97#elif defined(FML_OS_MACOSX)
98 return GrGLInterfaces::MakeMac();
103 return GrGLMakeNativeInterface();
107 struct ProcResolverContext {
111 ProcResolverContext
context = {proc_resolver};
113 GrGLGetProc gl_get_proc = [](
void*
context,
114 const char gl_proc_name[]) -> GrGLFuncPtr {
115 auto proc_resolver_context =
116 reinterpret_cast<ProcResolverContext*
>(
context);
117 return reinterpret_cast<GrGLFuncPtr
>(
118 proc_resolver_context->resolver(gl_proc_name));
123 return GrGLMakeAssembledGLESInterface(&
context, gl_get_proc);
127 if (
auto interface = GrGLMakeAssembledGLInterface(&
context, gl_get_proc)) {
131 FML_LOG(ERROR) <<
"Could not create a valid GL interface.";
144sk_sp<const GrGLInterface>
virtual bool AllowsDrawingWhenGpuDisabled() const
std::function< void *(const char *)> GLProcResolver
static sk_sp< const GrGLInterface > GetDefaultPlatformGLInterface()
virtual GLProcResolver GetGLProcResolver() const
virtual sk_sp< const GrGLInterface > GetGLInterface() const
virtual bool GLContextFBOResetAfterPresent() const
virtual SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const
virtual DlMatrix GLContextSurfaceTransformation() const
#define FML_LOG(severity)
#define FML_CHECK(condition)
impeller::Matrix DlMatrix
static sk_sp< const GrGLInterface > CreateGLInterface(const GPUSurfaceGLDelegate::GLProcResolver &proc_resolver)
static bool IsProcResolverOpenGLES(const GPUSurfaceGLDelegate::GLProcResolver &proc_resolver)
std::shared_ptr< ContextGLES > context
A 4x4 matrix using column-major storage.