st/egl_g3d: Always override flush_frontbuffer.
authorChia-I Wu <olvaffe@gmail.com>
Fri, 15 Jan 2010 09:39:49 +0000 (17:39 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Fri, 15 Jan 2010 09:42:57 +0000 (17:42 +0800)
Instead of letting the native displays install their own version of
flush_frontbuffer, always override the callback with a version that
calls the flush_frontbuffer of the native surface.

src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
src/gallium/state_trackers/egl_g3d/common/native.h
src/gallium/state_trackers/egl_g3d/kms/native_kms.c
src/gallium/state_trackers/egl_g3d/x11/native_dri2.c
src/gallium/state_trackers/egl_g3d/x11/native_x11.c
src/gallium/state_trackers/egl_g3d/x11/native_x11.h
src/gallium/state_trackers/egl_g3d/x11/native_ximage.c

index 8b69a8cfcb6110335da6d415cbaab3748dfdb2ae..7da9300c20024909174e840d8f69c9973425abd6 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include "pipe/p_screen.h"
 #include "util/u_memory.h"
 #include "egldriver.h"
 #include "eglcurrent.h"
@@ -456,8 +457,8 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id)
  * Flush the front buffer of the context's draw surface.
  */
 static void
-egl_g3d_flush_frontbuffer(void *dummy, struct pipe_surface *surf,
-                          void *context_private)
+egl_g3d_flush_frontbuffer(struct pipe_screen *screen,
+                          struct pipe_surface *surf, void *context_private)
 {
    struct egl_g3d_context *gctx = egl_g3d_context(context_private);
    struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface);
@@ -509,13 +510,14 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,
    }
    dpy->DriverData = gdpy;
 
-   gdpy->native =
-      native_create_display(dpy->NativeDisplay, egl_g3d_flush_frontbuffer);
+   gdpy->native = native_create_display(dpy->NativeDisplay);
    if (!gdpy->native) {
       _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)");
       goto fail;
    }
 
+   gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer;
+
    dpy->ClientAPIsMask = gdrv->api_mask;
 
    if (egl_g3d_add_configs(drv, dpy, 1) == 1) {
index 4714e24b5c6a9716b1c86191c9e6f1de5a7e4ecf..1c3b016b98a021d1c8f32872661ec0b9298ff83d 100644 (file)
@@ -114,7 +114,13 @@ struct native_display_modeset;
  * the native display server.
  */
 struct native_display {
+   /**
+    * The pipe screen of the native display.
+    *
+    * Note that the "flush_frontbuffer" callback will be overridden.
+    */
    struct pipe_screen *screen;
+
    void (*destroy)(struct native_display *ndpy);
 
    /**
@@ -204,19 +210,10 @@ struct native_display_modeset {
                       const struct native_mode *nmode);
 };
 
-/**
- * This function is called when the native display wants to display the front
- * buffer of the draw surface of the given context.
- */
-typedef void (*native_flush_frontbuffer)(void *dummy,
-                                         struct pipe_surface *surf,
-                                         void *context_private);
-
 const char *
 native_get_name(void);
 
 struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
-                      native_flush_frontbuffer flush_frontbuffer);
+native_create_display(EGLNativeDisplayType dpy);
 
 #endif /* _NATIVE_H_ */
index a44b9b9ae5cc3ec3836c643087be901edb1806eb..65829fc7b3d0da055ab2c267f94b384c1af8daa2 100644 (file)
@@ -769,8 +769,7 @@ static struct native_display_modeset kms_display_modeset = {
 };
 
 static struct native_display *
-kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api,
-                   native_flush_frontbuffer flush_frontbuffer)
+kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api)
 {
    struct kms_display *kdpy;
 
@@ -812,10 +811,6 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api,
       return NULL;
    }
 
-   kdpy->base.screen->flush_frontbuffer =
-      (void (*)(struct pipe_screen *, struct pipe_surface *, void *))
-      flush_frontbuffer;
-
    kdpy->base.destroy = kms_display_destroy;
    kdpy->base.get_configs = kms_display_get_configs;
    kdpy->base.create_context = kms_display_create_context;
@@ -826,13 +821,6 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api,
    return &kdpy->base;
 }
 
-static void
-dummy_flush_frontbuffer(void *dummy, struct pipe_surface *surf,
-                        void *context_private)
-{
-   _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied");
-}
-
 /* the api is destroyed with the native display */
 static struct drm_api *drm_api;
 
@@ -853,19 +841,15 @@ native_get_name(void)
 }
 
 struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
-                      native_flush_frontbuffer flush_frontbuffer)
+native_create_display(EGLNativeDisplayType dpy)
 {
    struct native_display *ndpy = NULL;
 
    if (!drm_api)
       drm_api = drm_api_create();
 
-   if (!flush_frontbuffer)
-      flush_frontbuffer = dummy_flush_frontbuffer;
-
    if (drm_api)
-      ndpy = kms_create_display(dpy, drm_api, flush_frontbuffer);
+      ndpy = kms_create_display(dpy, drm_api);
 
    return ndpy;
 }
index 2192a1366d293d88a5636549ccf5d35fbe13e5a8..f497d8c1c77daafc36e65e4d4e94ca26a5a73dd5 100644 (file)
@@ -641,18 +641,8 @@ dri2_display_init_screen(struct native_display *ndpy)
    return TRUE;
 }
 
-static void
-dri2_display_flush_frontbuffer(void *dummy, struct pipe_surface *surf,
-                               void *context_private)
-{
-   /* TODO get native surface from context private, and remove the callback */
-   _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied");
-}
-
 struct native_display *
-x11_create_dri2_display(EGLNativeDisplayType dpy,
-                        struct drm_api *api,
-                        native_flush_frontbuffer flush_frontbuffer)
+x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api)
 {
    struct dri2_display *dri2dpy;
 
@@ -689,13 +679,6 @@ x11_create_dri2_display(EGLNativeDisplayType dpy,
       return NULL;
    }
 
-   if (!flush_frontbuffer)
-      flush_frontbuffer = dri2_display_flush_frontbuffer;
-
-   dri2dpy->base.screen->flush_frontbuffer =
-      (void (*)(struct pipe_screen *, struct pipe_surface *, void *))
-      flush_frontbuffer;
-
    dri2dpy->base.destroy = dri2_display_destroy;
    dri2dpy->base.get_configs = dri2_display_get_configs;
    dri2dpy->base.create_context = dri2_display_create_context;
index a4f36e9deca4fb6486991c0b4109e3c26592c94a..583ce3d32932f5b7edb6b30b545600e73a0f0639 100644 (file)
@@ -48,8 +48,7 @@ native_get_name(void)
 }
 
 struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
-                      native_flush_frontbuffer flush_frontbuffer)
+native_create_display(EGLNativeDisplayType dpy)
 {
    struct native_display *ndpy = NULL;
    boolean force_sw;
@@ -59,14 +58,14 @@ native_create_display(EGLNativeDisplayType dpy,
 
    force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE);
    if (api && !force_sw) {
-      ndpy = x11_create_dri2_display(dpy, api, flush_frontbuffer);
+      ndpy = x11_create_dri2_display(dpy, api);
    }
 
    if (!ndpy) {
       EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING;
 
       _eglLog(level, "use software fallback");
-      ndpy = x11_create_ximage_display(dpy, TRUE, flush_frontbuffer);
+      ndpy = x11_create_ximage_display(dpy, TRUE);
    }
 
    return ndpy;
index 9217eb62529b5b2ad5f1deba2aaefab22f9c997e..622ddac5df6cddcf0ed63c197eb1640154c92c90 100644 (file)
 #include "common/native.h"
 
 struct native_display *
-x11_create_ximage_display(EGLNativeDisplayType dpy,
-                          boolean use_xshm,
-                          native_flush_frontbuffer flush_frontbuffer);
+x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm);
 
 struct native_display *
-x11_create_dri2_display(EGLNativeDisplayType dpy,
-                        struct drm_api *api,
-                        native_flush_frontbuffer flush_frontbuffer);
+x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api);
 
 #endif /* _NATIVE_X11_H_ */
index 1a1844ec49a113ea1da11621c9dc991f343f0891..24a50df7a0a5c726716d8180cc935da69d152691 100644 (file)
@@ -632,18 +632,8 @@ ximage_display_destroy(struct native_display *ndpy)
    free(xdpy);
 }
 
-static void
-ximage_display_flush_frontbuffer(void *dummy, struct pipe_surface *surf,
-                                 void *context_private)
-{
-   /* TODO get native surface from context private, and remove the callback */
-   _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied");
-}
-
 struct native_display *
-x11_create_ximage_display(EGLNativeDisplayType dpy,
-                          boolean use_xshm,
-                          native_flush_frontbuffer flush_frontbuffer)
+x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm)
 {
    struct ximage_display *xdpy;
 
@@ -672,12 +662,6 @@ x11_create_ximage_display(EGLNativeDisplayType dpy,
       (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM));
 
    xdpy->winsys = create_sw_winsys();
-   if (!flush_frontbuffer)
-      flush_frontbuffer = ximage_display_flush_frontbuffer;
-   xdpy->winsys->flush_frontbuffer =
-      (void (*)(struct pipe_winsys *, struct pipe_surface *, void *))
-      flush_frontbuffer;
-
    xdpy->base.screen = softpipe_create_screen(xdpy->winsys);
 
    xdpy->base.destroy = ximage_display_destroy;