Commit 10c143b7 authored by chadversary's avatar chadversary

egl: Allow pbuffers to back wegl_surface

Add function wegl_pbuffer_init(), which initializes a struct
wegl_surface with eglCreatePbufferSurface().

Not yet used, but will be used later by the new surfaceless platform.

Cc: Gurchetan Singh <gurchetansingh@chromium.org>
Cc: Haixia Shi <hshi@chromium.org>
Reviewed-by: Emil Velikov's avatarEmil Velikov <emil.l.velikov@gmail.com>
parent fab038d8
......@@ -159,6 +159,7 @@ wegl_platform_init(struct wegl_platform *self, EGLenum egl_platform)
// window
RETRIEVE_EGL_SYMBOL(eglGetConfigAttrib);
RETRIEVE_EGL_SYMBOL(eglCreateWindowSurface);
RETRIEVE_EGL_SYMBOL(eglCreatePbufferSurface);
RETRIEVE_EGL_SYMBOL(eglDestroySurface);
RETRIEVE_EGL_SYMBOL(eglSwapBuffers);
......
......@@ -89,6 +89,8 @@ struct wegl_platform {
EGLSurface (*eglCreateWindowSurface)(EGLDisplay dpy, EGLConfig config,
EGLNativeWindowType win,
const EGLint *attrib_list);
EGLSurface (*eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
const EGLint *attrib_list);
EGLBoolean (*eglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
EGLBoolean (*eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
......
......@@ -73,6 +73,48 @@ fail:
return false;
}
bool
wegl_pbuffer_init(struct wegl_surface *surf,
struct wcore_config *wc_config,
int32_t width, int32_t height)
{
struct wegl_config *config = wegl_config(wc_config);
struct wegl_display *dpy = wegl_display(wc_config->display);
struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
bool ok;
ok = wcore_window_init(&surf->wcore, wc_config);
if (!ok)
goto fail;
// Note on pbuffers and double-buffering: The EGL spec says that pbuffers
// are single-buffered. But the spec also says that EGL_RENDER_BUFFER is
// always EGL_BACK_BUFFER for pbuffers. Because EGL is weird in its
// specification of pbuffers; and because most Piglit tests requests
// double-buffering (and we don't want to break Piglit); allow creation of
// pbuffers even if the user requested double-buffering.
(void) config->wcore.attrs.double_buffered;
EGLint attrib_list[] = {
EGL_WIDTH, width,
EGL_HEIGHT, height,
EGL_NONE,
};
surf->egl = plat->eglCreatePbufferSurface(dpy->egl, config->egl,
attrib_list);
if (!surf->egl) {
wegl_emit_error(plat, "eglCreatePbufferSurface");
goto fail;
}
return true;
fail:
wegl_surface_teardown(surf);
return false;
}
bool
wegl_surface_teardown(struct wegl_surface *surf)
{
......
......@@ -50,6 +50,11 @@ wegl_window_init(struct wegl_surface *surf,
struct wcore_config *wc_config,
intptr_t native_window);
bool
wegl_pbuffer_init(struct wegl_surface *surf,
struct wcore_config *wc_config,
int32_t width, int32_t height);
bool
wegl_surface_teardown(struct wegl_surface *surf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment