#include "util/u_memory.h"
#include "util/u_format.h"
#include "util/u_inlines.h"
-#include "target-helpers/wrap_screen.h"
-#include "llvmpipe/lp_public.h"
-#include "softpipe/sp_public.h"
#include "gdi/gdi_sw_winsys.h"
#include "common/native_helper.h"
return ret;
}
+static boolean
+gdi_surface_present(struct native_surface *nsurf,
+ enum native_attachment natt,
+ boolean preserve,
+ uint swap_interval)
+{
+ boolean ret;
+
+ if (preserve || swap_interval)
+ return FALSE;
+
+ switch (natt) {
+ case NATIVE_ATTACHMENT_FRONT_LEFT:
+ ret = gdi_surface_flush_frontbuffer(nsurf);
+ break;
+ case NATIVE_ATTACHMENT_BACK_LEFT:
+ ret = gdi_surface_swap_buffers(nsurf);
+ break;
+ default:
+ ret = FALSE;
+ break;
+ }
+
+ return ret;
+}
+
static boolean
gdi_surface_validate(struct native_surface *nsurf, uint attachment_mask,
unsigned int *seq_num, struct pipe_resource **textures,
gdi_surface_update_geometry(&gsurf->base);
gsurf->base.destroy = gdi_surface_destroy;
- gsurf->base.swap_buffers = gdi_surface_swap_buffers;
- gsurf->base.flush_frontbuffer = gdi_surface_flush_frontbuffer;
+ gsurf->base.present = gdi_surface_present;
gsurf->base.validate = gdi_surface_validate;
gsurf->base.wait = gdi_surface_wait;
nconf->color_format = formats[i];
nconf->window_bit = TRUE;
- nconf->slow_config = TRUE;
}
gdpy->num_configs = count;
/* private buffers are allocated */
val = FALSE;
break;
+ case NATIVE_PARAM_PRESERVE_BUFFER:
+ case NATIVE_PARAM_MAX_SWAP_INTERVAL:
default:
val = 0;
break;
}
static struct native_display *
-gdi_create_display(HDC hDC, struct pipe_screen *screen,
- struct native_event_handler *event_handler)
+gdi_create_display(HDC hDC, struct native_event_handler *event_handler,
+ void *user_data)
{
struct gdi_display *gdpy;
+ struct sw_winsys *winsys;
gdpy = CALLOC_STRUCT(gdi_display);
if (!gdpy)
gdpy->hDC = hDC;
gdpy->event_handler = event_handler;
+ gdpy->base.user_data = user_data;
- gdpy->base.screen = screen;
+ winsys = gdi_create_sw_winsys();
+ if (!winsys) {
+ FREE(gdpy);
+ return NULL;
+ }
+
+ gdpy->base.screen = gdpy->event_handler->new_sw_screen(&gdpy->base, winsys);
+ if (!gdpy->base.screen) {
+ if (winsys->destroy)
+ winsys->destroy(winsys);
+ FREE(gdpy);
+ return NULL;
+ }
gdpy->base.destroy = gdi_display_destroy;
gdpy->base.get_param = gdi_display_get_param;
return &gdpy->base;
}
-static struct pipe_screen *
-gdi_create_screen(void)
-{
- struct sw_winsys *winsys;
- struct pipe_screen *screen = NULL;
-
- winsys = gdi_create_sw_winsys();
- if (!winsys)
- return NULL;
-
-#if defined(GALLIUM_LLVMPIPE)
- if (!screen && !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE))
- screen = llvmpipe_create_screen(winsys);
-#endif
- if (!screen)
- screen = softpipe_create_screen(winsys);
-
- if (!screen) {
- if (winsys->destroy)
- winsys->destroy(winsys);
- return NULL;
- }
-
- return gallium_wrap_screen(screen);
-}
+static struct native_event_handler *gdi_event_handler;
-struct native_probe *
-native_create_probe(EGLNativeDisplayType dpy)
+static void
+native_set_event_handler(struct native_event_handler *event_handler)
{
- return NULL;
+ gdi_event_handler = event_handler;
}
-enum native_probe_result
-native_get_probe_result(struct native_probe *nprobe)
+static struct native_display *
+native_create_display(void *dpy, boolean use_sw, void *user_data)
{
- return NATIVE_PROBE_UNKNOWN;
+ return gdi_create_display((HDC) dpy, gdi_event_handler, user_data);
}
-const char *
-native_get_name(void)
-{
- return "GDI";
-}
+static const struct native_platform gdi_platform = {
+ "GDI", /* name */
+ native_set_event_handler,
+ native_create_display
+};
-struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
- struct native_event_handler *event_handler)
+const struct native_platform *
+native_get_gdi_platform(void)
{
- struct pipe_screen *screen;
-
- screen = gdi_create_screen();
- if (!screen)
- return NULL;
-
- return gdi_create_display((HDC) dpy, screen, event_handler);
+ return &gdi_platform;
}