From 1897f28eb8ddf4b89c144c0503d004595fe8fcc2 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 31 May 2016 13:37:03 +0900 Subject: Fix logging code in GLSurfaceQtEGL::Initialize() Change-Id: I98cb984548d833121d7e3102b9d89ccc7c8a11b6 Reviewed-by: Allan Sandfeld Jensen --- src/core/gl_surface_qt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/gl_surface_qt.cpp') diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index 7596fcaff..62d6dd180 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -413,7 +413,7 @@ bool GLSurfaceQtEGL::Initialize() g_config, pbuffer_attributes); if (!m_surfaceBuffer) { - LOG(ERROR) << "eglCreatePbufferSurface failed with error ", GetLastEGLErrorString(); + LOG(ERROR) << "eglCreatePbufferSurface failed with error " << GetLastEGLErrorString(); Destroy(); return false; } -- cgit v1.2.3 From bfcbdc3ab42880dc37ffa7174af96928ccf25f03 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 31 May 2016 13:37:25 +0900 Subject: Add support for Khr_surfaceless_context This patch is a port of commit 4b0cac9dfeebb73f21a11e10e6a2bc7bddbe889b in Chromium for Qt WebEngine. The based commit says: > http://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_surfaceless_context.txt > > This patch adds support in GLSurfaceEGL to be able to use > surfaceless context when supported by the drivers. This avoids > the creation of a dummy offscreen surface. This would also enable > support for offscreen rendering on platforms (i.e Ozone-Wayland) which > donot support pbuffer surfaces. Some platforms supported by QPA, such as Mesa 3D DRI2 with drm and wayland backend also don't support pbuffer surfaces. Change-Id: I8378957931d79b691392b6fbe13082b8610b8fe6 Reviewed-by: Allan Sandfeld Jensen --- src/core/gl_surface_qt.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) (limited to 'src/core/gl_surface_qt.cpp') diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index 62d6dd180..e05021144 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -84,6 +84,7 @@ void* g_display; const char* g_extensions = NULL; +bool g_egl_surfaceless_context_supported = false; } // namespace @@ -106,6 +107,26 @@ private: DISALLOW_COPY_AND_ASSIGN(GLSurfaceQtEGL); }; +// The following comment is cited from chromium/ui/gl/gl_surface_egl.cc: +// SurfacelessEGL is used as Offscreen surface when platform supports +// KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the +// need to create a dummy EGLsurface in case we render to client API targets. +class GLSurfacelessQtEGL : public GLSurfaceQt { +public: + explicit GLSurfacelessQtEGL(const gfx::Size& size); + + public: + bool Initialize() Q_DECL_OVERRIDE; + void Destroy() Q_DECL_OVERRIDE; + bool IsSurfaceless() const Q_DECL_OVERRIDE; + bool Resize(const gfx::Size& size) Q_DECL_OVERRIDE; + EGLSurface GetHandle() Q_DECL_OVERRIDE; + void* GetShareHandle() Q_DECL_OVERRIDE; + +private: + DISALLOW_COPY_AND_ASSIGN(GLSurfacelessQtEGL); +}; + GLSurfaceQt::~GLSurfaceQt() { @@ -339,6 +360,23 @@ bool GLSurfaceQtEGL::InitializeOneOff() return false; } + g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions, "EGL_KHR_surfaceless_context"); + if (g_egl_surfaceless_context_supported) { + scoped_refptr surface = new GLSurfacelessQtEGL(Size(1, 1)); + scoped_refptr context = GLContext::CreateGLContext( + NULL, surface.get(), PreferIntegratedGpu); + + if (!context->MakeCurrent(surface.get())) + g_egl_surfaceless_context_supported = false; + + // Ensure context supports GL_OES_surfaceless_context. + if (g_egl_surfaceless_context_supported) { + g_egl_surfaceless_context_supported = context->HasExtension( + "GL_OES_surfaceless_context"); + context->ReleaseCurrent(surface.get()); + } + } + initialized = true; return true; } @@ -488,6 +526,41 @@ void* GLSurfaceQt::GetConfig() return g_config; } +GLSurfacelessQtEGL::GLSurfacelessQtEGL(const gfx::Size& size) + : GLSurfaceQt(size) +{ +} + +bool GLSurfacelessQtEGL::Initialize() +{ + return true; +} + +void GLSurfacelessQtEGL::Destroy() +{ +} + +bool GLSurfacelessQtEGL::IsSurfaceless() const +{ + return true; +} + +bool GLSurfacelessQtEGL::Resize(const gfx::Size& size) +{ + m_size = size; + return true; +} + +EGLSurface GLSurfacelessQtEGL::GetHandle() +{ + return EGL_NO_SURFACE; +} + +void* GLSurfacelessQtEGL::GetShareHandle() +{ + return NULL; +} + // static scoped_refptr GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) @@ -511,7 +584,12 @@ GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) #endif } case kGLImplementationEGLGLES2: { - scoped_refptr surface = new GLSurfaceQtEGL(size); + scoped_refptr surface; + if (g_egl_surfaceless_context_supported) + surface = new GLSurfacelessQtEGL(size); + else + surface = new GLSurfaceQtEGL(size); + if (!surface->Initialize()) return NULL; return surface; -- cgit v1.2.3