summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-06-04 12:05:37 +0800
committerChia-I Wu <olv@lunarg.com>2010-06-04 12:12:50 +0800
commit22c2e57cbb0fd5ed6856a7350672fa01c02b00ca (patch)
tree6b43a33760acc1e5abf906550c6700b76c918095
parent27910c42a9769a63855db06035c9874dd2ef5da0 (diff)
st/egl: Move sw screen creation to native helper.
The code is shared by ximage and gdi backend.
-rw-r--r--src/gallium/state_trackers/egl/Makefile1
-rw-r--r--src/gallium/state_trackers/egl/common/native_helper.c18
-rw-r--r--src/gallium/state_trackers/egl/common/native_helper.h3
-rw-r--r--src/gallium/state_trackers/egl/gdi/native_gdi.c41
-rw-r--r--src/gallium/state_trackers/egl/x11/native_ximage.c82
5 files changed, 52 insertions, 93 deletions
diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile
index a3c1bb43469..8933890323a 100644
--- a/src/gallium/state_trackers/egl/Makefile
+++ b/src/gallium/state_trackers/egl/Makefile
@@ -5,6 +5,7 @@ common_INCLUDES = \
-I. \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/auxiliary \
+ -I$(TOP)/src/gallium/drivers \
-I$(TOP)/src/egl/main \
-I$(TOP)/include
diff --git a/src/gallium/state_trackers/egl/common/native_helper.c b/src/gallium/state_trackers/egl/common/native_helper.c
index 7832b2b693f..206817ed666 100644
--- a/src/gallium/state_trackers/egl/common/native_helper.c
+++ b/src/gallium/state_trackers/egl/common/native_helper.c
@@ -31,6 +31,9 @@
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "pipe/p_state.h"
+#include "softpipe/sp_public.h"
+#include "llvmpipe/lp_public.h"
+#include "target-helpers/wrap_screen.h"
#include "native_helper.h"
@@ -233,3 +236,18 @@ resource_surface_present(struct resource_surface *rsurf,
return TRUE;
}
+
+struct pipe_screen *
+native_create_sw_screen(struct sw_winsys *ws)
+{
+ struct pipe_screen *screen = NULL;
+
+#if defined(GALLIUM_LLVMPIPE)
+ if (!screen && !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE))
+ screen = llvmpipe_create_screen(ws);
+#endif
+ if (!screen)
+ screen = softpipe_create_screen(ws);
+
+ return (screen) ? gallium_wrap_screen(screen) : NULL;
+}
diff --git a/src/gallium/state_trackers/egl/common/native_helper.h b/src/gallium/state_trackers/egl/common/native_helper.h
index 62956d52201..25fafd04651 100644
--- a/src/gallium/state_trackers/egl/common/native_helper.h
+++ b/src/gallium/state_trackers/egl/common/native_helper.h
@@ -68,3 +68,6 @@ boolean
resource_surface_present(struct resource_surface *rsurf,
enum native_attachment which,
void *winsys_drawable_handle);
+
+struct pipe_screen *
+native_create_sw_screen(struct sw_winsys *ws);
diff --git a/src/gallium/state_trackers/egl/gdi/native_gdi.c b/src/gallium/state_trackers/egl/gdi/native_gdi.c
index 29e89bcae80..1791d198d50 100644
--- a/src/gallium/state_trackers/egl/gdi/native_gdi.c
+++ b/src/gallium/state_trackers/egl/gdi/native_gdi.c
@@ -32,9 +32,6 @@
#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"
@@ -369,32 +366,6 @@ gdi_create_display(HDC hDC, struct pipe_screen *screen,
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);
-}
-
struct native_probe *
native_create_probe(EGLNativeDisplayType dpy)
{
@@ -417,11 +388,19 @@ struct native_display *
native_create_display(EGLNativeDisplayType dpy,
struct native_event_handler *event_handler)
{
+ struct sw_winsys *winsys;
struct pipe_screen *screen;
- screen = gdi_create_screen();
- if (!screen)
+ winsys = gdi_create_sw_winsys();
+ if (!winsys)
+ return NULL;
+
+ screen = native_create_sw_screen(winsys);
+ if (!screen) {
+ if (winsys->destroy)
+ winsys->destroy(winsys);
return NULL;
+ }
return gdi_create_display((HDC) dpy, screen, event_handler);
}
diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c
index 3388fc61e14..45679fc9b4e 100644
--- a/src/gallium/state_trackers/egl/x11/native_ximage.c
+++ b/src/gallium/state_trackers/egl/x11/native_ximage.c
@@ -31,10 +31,7 @@
#include "pipe/p_compiler.h"
#include "util/u_inlines.h"
#include "state_tracker/xlib_sw_winsys.h"
-#include "target-helpers/wrap_screen.h"
#include "util/u_debug.h"
-#include "softpipe/sp_public.h"
-#include "llvmpipe/lp_public.h"
#include "egllog.h"
#include "common/native_helper.h"
@@ -443,65 +440,12 @@ ximage_display_destroy(struct native_display *ndpy)
FREE(xdpy);
}
-
-/* Helper function to build a subset of a driver stack consisting of
- * one of the software rasterizers (cell, llvmpipe, softpipe) and the
- * xlib winsys.
- *
- * This function could be shared, but currently causes headaches for
- * the build systems, particularly scons if we try.
- *
- * Long term, want to avoid having global #defines for things like
- * GALLIUM_LLVMPIPE, GALLIUM_CELL, etc. Scons already eliminates
- * those #defines, so things that are painful for it now are likely to
- * be painful for other build systems in the future.
- */
-static struct pipe_screen *
-swrast_xlib_create_screen( Display *display )
-{
- struct sw_winsys *winsys;
- struct pipe_screen *screen = NULL;
-
- /* Create the underlying winsys, which performs presents to Xlib
- * drawables:
- */
- winsys = xlib_create_sw_winsys( display );
- if (winsys == NULL)
- return NULL;
-
- /* Create a software rasterizer on top of that winsys. Use
- * llvmpipe if it is available.
- */
-#if defined(GALLIUM_LLVMPIPE)
- if (screen == NULL &&
- !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE))
- screen = llvmpipe_create_screen( winsys );
-#endif
-
- if (screen == NULL)
- screen = softpipe_create_screen( winsys );
-
- if (screen == NULL)
- goto fail;
-
- /* Inject any wrapping layers we want to here:
- */
- return gallium_wrap_screen( screen );
-
-fail:
- if (winsys)
- winsys->destroy( winsys );
-
- return NULL;
-}
-
-
-
struct native_display *
x11_create_ximage_display(EGLNativeDisplayType dpy,
struct native_event_handler *event_handler)
{
struct ximage_display *xdpy;
+ struct sw_winsys *winsys = NULL;
xdpy = CALLOC_STRUCT(ximage_display);
if (!xdpy)
@@ -521,12 +465,16 @@ x11_create_ximage_display(EGLNativeDisplayType dpy,
xdpy->xscr_number = DefaultScreen(xdpy->dpy);
xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number);
- if (!xdpy->xscr) {
- FREE(xdpy);
- return NULL;
- }
+ if (!xdpy->xscr)
+ goto fail;
- xdpy->base.screen = swrast_xlib_create_screen(xdpy->dpy);
+ winsys = xlib_create_sw_winsys(xdpy->dpy);
+ if (!winsys)
+ goto fail;
+
+ xdpy->base.screen = native_create_sw_screen(winsys);
+ if (!xdpy->base.screen)
+ goto fail;
xdpy->base.destroy = ximage_display_destroy;
xdpy->base.get_param = ximage_display_get_param;
@@ -537,4 +485,14 @@ x11_create_ximage_display(EGLNativeDisplayType dpy,
xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface;
return &xdpy->base;
+
+fail:
+ if (winsys && winsys->destroy)
+ winsys->destroy(winsys);
+ if (xdpy->xscr)
+ x11_screen_destroy(xdpy->xscr);
+ if (xdpy->dpy && xdpy->own_dpy)
+ XCloseDisplay(xdpy->dpy);
+ FREE(xdpy);
+ return NULL;
}