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 <gurchetansi...@chromium.org>
Cc: Haixia Shi <h...@chromium.org>
---
 src/waffle/egl/wegl_platform.c |  1 +
 src/waffle/egl/wegl_platform.h |  2 ++
 src/waffle/egl/wegl_surface.c  | 42 ++++++++++++++++++++++++++++++++++++++++++
 src/waffle/egl/wegl_surface.h  |  5 +++++
 4 files changed, 50 insertions(+)

diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 71eb29e..331cc89 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -139,6 +139,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);
 
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index d6788eb..a5092a5 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -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);
 };
diff --git a/src/waffle/egl/wegl_surface.c b/src/waffle/egl/wegl_surface.c
index ccd0799..0bd0857 100644
--- a/src/waffle/egl/wegl_surface.c
+++ b/src/waffle/egl/wegl_surface.c
@@ -74,6 +74,48 @@ fail:
 }
 
 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)
 {
     struct wegl_display *dpy = wegl_display(surf->wcore.display);
diff --git a/src/waffle/egl/wegl_surface.h b/src/waffle/egl/wegl_surface.h
index b107423..51835c4 100644
--- a/src/waffle/egl/wegl_surface.h
+++ b/src/waffle/egl/wegl_surface.h
@@ -51,6 +51,11 @@ wegl_window_init(struct wegl_surface *surf,
                  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);
 
 bool
-- 
2.10.0

_______________________________________________
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle

Reply via email to