summaryrefslogtreecommitdiffstats
path: root/src/core/gl_surface_qt.cpp
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2016-05-31 13:37:25 +0900
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-06-03 19:59:22 +0000
commitbfcbdc3ab42880dc37ffa7174af96928ccf25f03 (patch)
tree59fcc8c0861b4781d0101f9b3e730d416cc4c3b8 /src/core/gl_surface_qt.cpp
parentc1e67d9211701bee8f5eb46bbc5aeafa1075013a (diff)
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 <allan.jensen@qt.io>
Diffstat (limited to 'src/core/gl_surface_qt.cpp')
-rw-r--r--src/core/gl_surface_qt.cpp80
1 files changed, 79 insertions, 1 deletions
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<GLSurface> surface = new GLSurfacelessQtEGL(Size(1, 1));
+ scoped_refptr<GLContext> 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>
GLSurface::CreateOffscreenGLSurface(const gfx::Size& size)
@@ -511,7 +584,12 @@ GLSurface::CreateOffscreenGLSurface(const gfx::Size& size)
#endif
}
case kGLImplementationEGLGLES2: {
- scoped_refptr<GLSurface> surface = new GLSurfaceQtEGL(size);
+ scoped_refptr<GLSurface> surface;
+ if (g_egl_surfaceless_context_supported)
+ surface = new GLSurfacelessQtEGL(size);
+ else
+ surface = new GLSurfaceQtEGL(size);
+
if (!surface->Initialize())
return NULL;
return surface;