diff options
Diffstat (limited to 'tools/fiddle/egl_context.cpp')
-rw-r--r-- | tools/fiddle/egl_context.cpp | 76 |
1 files changed, 15 insertions, 61 deletions
diff --git a/tools/fiddle/egl_context.cpp b/tools/fiddle/egl_context.cpp index 7994b01a67..1dac076b66 100644 --- a/tools/fiddle/egl_context.cpp +++ b/tools/fiddle/egl_context.cpp @@ -9,78 +9,32 @@ #include "SkRefCnt.h" #include "gl/GrGLFunctions.h" #include "gl/GrGLInterface.h" +#include "gl/GLTestContext.h" #include <EGL/egl.h> #include <GLES2/gl2.h> #include <sstream> -static const EGLint configAttribs[] = { - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, - EGL_BLUE_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_RED_SIZE, 8, - EGL_DEPTH_SIZE, 8, - EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, - EGL_NONE -}; - -static const int pbufferWidth = 9; -static const int pbufferHeight = 9; - -static const EGLint pbufferAttribs[] = { - EGL_WIDTH, pbufferWidth, - EGL_HEIGHT, pbufferHeight, - EGL_NONE, -}; - // create_grcontext implementation for EGL. -sk_sp<GrContext> create_grcontext(std::ostringstream &driverinfo) { - EGLDisplay eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (EGL_NO_DISPLAY == eglDpy) { +sk_sp<GrContext> create_grcontext(std::ostringstream& driverinfo, + std::unique_ptr<sk_gpu_test::GLTestContext>* glContext) { + // We are leaking tc, but that's OK because fiddle is a short lived proces. + glContext->reset(sk_gpu_test::CreatePlatformGLTestContext(kGLES_GrGLStandard)); + if (!glContext) { return nullptr; } - - EGLint major, minor; - if (EGL_TRUE != eglInitialize(eglDpy, &major, &minor)) { + (*glContext)->makeCurrent(); + sk_sp<GrContext> result = (*glContext)->makeGrContext(GrContextOptions()); + if (!result) { + glContext->reset(); return nullptr; } - EGLint numConfigs; - EGLConfig eglCfg; - if (EGL_TRUE != eglChooseConfig(eglDpy, configAttribs, &eglCfg, 1, &numConfigs)) { - return nullptr; - } - - EGLSurface eglSurf = eglCreatePbufferSurface(eglDpy, eglCfg, pbufferAttribs); - if (EGL_NO_SURFACE == eglSurf) { - return nullptr; - } - - if (EGL_TRUE != eglBindAPI(EGL_OPENGL_API)) { - return nullptr; - } - - EGLContext eglCtx = eglCreateContext(eglDpy, eglCfg, EGL_NO_CONTEXT, nullptr); - if (EGL_NO_CONTEXT == eglCtx) { - return nullptr; - } - if (EGL_FALSE == eglMakeCurrent(eglDpy, eglSurf, eglSurf, eglCtx)) { - return nullptr; - } - - driverinfo << "EGL " << major << "." << minor << "\n"; - GrGLGetStringProc getString = (GrGLGetStringProc )eglGetProcAddress("glGetString"); - driverinfo << "GL Versionr: " << getString(GL_VERSION) << "\n"; - driverinfo << "GL Vendor: " << getString(GL_VENDOR) << "\n"; - driverinfo << "GL Renderer: " << getString(GL_RENDERER) << "\n"; - driverinfo << "GL Extensions: " << getString(GL_EXTENSIONS) << "\n"; - - auto interface = GrGLMakeNativeInterface(); - if (!interface) { - return nullptr; - } - eglTerminate(eglDpy); + driverinfo << "GL Version: " << glGetString(GL_VERSION) << "\n"; + driverinfo << "GL Vendor: " << glGetString(GL_VENDOR) << "\n"; + driverinfo << "GL Renderer: " << glGetString(GL_RENDERER) << "\n"; + driverinfo << "GL Extensions: " << glGetString(GL_EXTENSIONS) << "\n"; - return sk_sp<GrContext>(GrContext::MakeGL(interface)); + return result; } |