#include <assert.h>
#include <string.h>
+#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "egldriver.h"
#include "eglcurrent.h"
* 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);
}
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) {
* 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);
/**
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_ */
};
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;
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;
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;
}
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;
}
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;
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;
}
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;
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;
#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_ */
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;
(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;