aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xgl/egl/xegl.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
committermarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
commit3562e78743202e43aec8727005182a2558117eca (patch)
tree8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /xorg-server/hw/xgl/egl/xegl.c
downloadvcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz
vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2
vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip
Checked in the following released items:
xkeyboard-config-1.4.tar.gz ttf-bitstream-vera-1.10.tar.gz font-alias-1.0.1.tar.gz font-sun-misc-1.0.0.tar.gz font-sun-misc-1.0.0.tar.gz font-sony-misc-1.0.0.tar.gz font-schumacher-misc-1.0.0.tar.gz font-mutt-misc-1.0.0.tar.gz font-misc-misc-1.0.0.tar.gz font-misc-meltho-1.0.0.tar.gz font-micro-misc-1.0.0.tar.gz font-jis-misc-1.0.0.tar.gz font-isas-misc-1.0.0.tar.gz font-dec-misc-1.0.0.tar.gz font-daewoo-misc-1.0.0.tar.gz font-cursor-misc-1.0.0.tar.gz font-arabic-misc-1.0.0.tar.gz font-winitzki-cyrillic-1.0.0.tar.gz font-misc-cyrillic-1.0.0.tar.gz font-cronyx-cyrillic-1.0.0.tar.gz font-screen-cyrillic-1.0.1.tar.gz font-xfree86-type1-1.0.1.tar.gz font-adobe-utopia-type1-1.0.1.tar.gz font-ibm-type1-1.0.0.tar.gz font-bitstream-type1-1.0.0.tar.gz font-bitstream-speedo-1.0.0.tar.gz font-bh-ttf-1.0.0.tar.gz font-bh-type1-1.0.0.tar.gz font-bitstream-100dpi-1.0.0.tar.gz font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz font-bh-100dpi-1.0.0.tar.gz font-adobe-utopia-100dpi-1.0.1.tar.gz font-adobe-100dpi-1.0.0.tar.gz font-util-1.0.1.tar.gz font-bitstream-75dpi-1.0.0.tar.gz font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz font-adobe-utopia-75dpi-1.0.1.tar.gz font-bh-75dpi-1.0.0.tar.gz bdftopcf-1.0.1.tar.gz font-adobe-75dpi-1.0.0.tar.gz mkfontscale-1.0.6.tar.gz openssl-0.9.8k.tar.gz bigreqsproto-1.0.2.tar.gz xtrans-1.2.2.tar.gz resourceproto-1.0.2.tar.gz inputproto-1.4.4.tar.gz compositeproto-0.4.tar.gz damageproto-1.1.0.tar.gz zlib-1.2.3.tar.gz xkbcomp-1.0.5.tar.gz freetype-2.3.9.tar.gz pthreads-w32-2-8-0-release.tar.gz pixman-0.12.0.tar.gz kbproto-1.0.3.tar.gz evieext-1.0.2.tar.gz fixesproto-4.0.tar.gz recordproto-1.13.2.tar.gz randrproto-1.2.2.tar.gz scrnsaverproto-1.1.0.tar.gz renderproto-0.9.3.tar.gz xcmiscproto-1.1.2.tar.gz fontsproto-2.0.2.tar.gz xextproto-7.0.3.tar.gz xproto-7.0.14.tar.gz libXdmcp-1.0.2.tar.gz libxkbfile-1.0.5.tar.gz libfontenc-1.0.4.tar.gz libXfont-1.3.4.tar.gz libX11-1.1.5.tar.gz libXau-1.0.4.tar.gz libxcb-1.1.tar.gz xorg-server-1.5.3.tar.gz
Diffstat (limited to 'xorg-server/hw/xgl/egl/xegl.c')
-rw-r--r--xorg-server/hw/xgl/egl/xegl.c303
1 files changed, 303 insertions, 0 deletions
diff --git a/xorg-server/hw/xgl/egl/xegl.c b/xorg-server/hw/xgl/egl/xegl.c
new file mode 100644
index 000000000..1cf615bb6
--- /dev/null
+++ b/xorg-server/hw/xgl/egl/xegl.c
@@ -0,0 +1,303 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: David Reveman <davidr@novell.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <math.h>
+
+#include <glitz-egl.h>
+
+#include "inputstr.h"
+#include "cursorstr.h"
+#include "mipointer.h"
+
+#include "xegl.h"
+
+#define XEGL_DEFAULT_SCREEN_WIDTH 800
+#define XEGL_DEFAULT_SCREEN_HEIGHT 600
+
+DevPrivateKey xeglScreenPrivateKey = &xeglScreenPrivateKey;
+
+#define XEGL_GET_SCREEN_PRIV(pScreen) ((xeglScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey))
+
+#define XEGL_SET_SCREEN_PRIV(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey, v)
+
+#define XEGL_SCREEN_PRIV(pScreen) \
+ xeglScreenPtr pScreenPriv = XEGL_GET_SCREEN_PRIV (pScreen)
+
+static EGLDisplay eDisplay;
+static EGLScreenMESA eScreen;
+static ScreenPtr currentScreen = 0;
+static Bool softCursor = TRUE;
+
+extern miPointerScreenFuncRec kdPointerScreenFuncs;
+
+static Bool
+xeglAllocatePrivates (ScreenPtr pScreen)
+{
+ xeglScreenPtr pScreenPriv;
+
+ pScreenPriv = xalloc (sizeof (xeglScreenRec));
+ if (!pScreenPriv)
+ return FALSE;
+
+ XEGL_SET_SCREEN_PRIV (pScreen, pScreenPriv);
+
+ return TRUE;
+}
+
+static Bool
+xeglCloseScreen (int index,
+ ScreenPtr pScreen)
+{
+ glitz_drawable_t *drawable;
+
+ XEGL_SCREEN_PRIV (pScreen);
+
+ drawable = XGL_GET_SCREEN_PRIV (pScreen)->drawable;
+ if (drawable)
+ glitz_drawable_destroy (drawable);
+
+ xglClearVisualTypes ();
+
+ XGL_SCREEN_UNWRAP (CloseScreen);
+ xfree (pScreenPriv);
+
+ return (*pScreen->CloseScreen) (index, pScreen);
+}
+
+static Bool
+xeglScreenInit (int index,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv)
+{
+ EGLSurface eSurface;
+ EGLModeMESA mode;
+ int count;
+ xeglScreenPtr pScreenPriv;
+ glitz_drawable_format_t *format;
+ glitz_drawable_t *drawable;
+ EGLint screenAttribs[] = {
+ EGL_WIDTH, 1024,
+ EGL_HEIGHT, 768,
+ EGL_NONE
+ };
+
+ if (xglScreenInfo.width == 0 || xglScreenInfo.height == 0)
+ {
+ xglScreenInfo.width = XEGL_DEFAULT_SCREEN_WIDTH;
+ xglScreenInfo.height = XEGL_DEFAULT_SCREEN_HEIGHT;
+
+ }
+
+ screenAttribs[1] = xglScreenInfo.width;
+ screenAttribs[3] = xglScreenInfo.height;
+
+ format = xglVisuals[0].format;
+
+ if (!xeglAllocatePrivates (pScreen))
+ return FALSE;
+
+ currentScreen = pScreen;
+
+ pScreenPriv = XEGL_GET_SCREEN_PRIV (pScreen);
+
+ if (xglScreenInfo.width == 0 || xglScreenInfo.height == 0)
+ {
+ xglScreenInfo.width = XEGL_DEFAULT_SCREEN_WIDTH;
+ xglScreenInfo.height = XEGL_DEFAULT_SCREEN_HEIGHT;
+ }
+
+ eglGetModesMESA (eDisplay, eScreen, &mode, 1, &count);
+
+ eSurface = eglCreateScreenSurfaceMESA (eDisplay, format->id, screenAttribs);
+ if (eSurface == EGL_NO_SURFACE)
+ {
+ ErrorF ("failed to create screen surface\n");
+ return FALSE;
+ }
+
+ eglShowScreenSurfaceMESA (eDisplay, eScreen, eSurface, mode);
+
+ drawable = glitz_egl_create_surface (eDisplay, eScreen, format, eSurface,
+ xglScreenInfo.width,
+ xglScreenInfo.height);
+ if (!drawable)
+ {
+ ErrorF ("[%d] couldn't create glitz drawable for window\n", index);
+ return FALSE;
+ }
+
+ xglScreenInfo.drawable = drawable;
+
+ if (!xglScreenInit (pScreen))
+ return FALSE;
+
+#ifdef GLXEXT
+ if (!xglInitVisualConfigs (pScreen))
+ return FALSE;
+#endif
+
+ XGL_SCREEN_WRAP (CloseScreen, xeglCloseScreen);
+
+ miDCInitialize (pScreen, &kdPointerScreenFuncs);
+ miCreateDefColormap(pScreen);
+
+ if (!xglFinishScreenInit (pScreen))
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+xeglInitOutput (ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv)
+{
+ glitz_drawable_format_t *format, templ;
+ int i, maj, min, count;
+ unsigned long mask;
+
+ xglSetPixmapFormats (pScreenInfo);
+
+ if (!eDisplay)
+ {
+ eDisplay = eglGetDisplay (":0");
+
+ if (!eglInitialize (eDisplay, &maj, &min))
+ FatalError ("can't open display");
+
+ eglGetScreensMESA (eDisplay, &eScreen, 1, &count);
+ }
+
+ templ.samples = 1;
+ templ.doublebuffer = 1;
+ templ.color.alpha_size = 8;
+
+ mask = GLITZ_FORMAT_SAMPLES_MASK;
+
+ format = glitz_egl_find_window_config (eDisplay, eScreen,
+ mask, &templ, 0);
+
+ if (!format)
+ FatalError ("no visual format found");
+
+ xglSetVisualTypesAndMasks (pScreenInfo, format, (1 << TrueColor));
+
+ xglInitVisuals (pScreenInfo);
+
+ AddScreen (xeglScreenInit, argc, argv);
+}
+
+static void
+xeglBlockHandler (pointer blockData,
+ OSTimePtr pTimeout,
+ pointer pReadMask)
+{
+ XGL_SCREEN_PRIV (currentScreen);
+
+ if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
+ FatalError (XGL_SW_FAILURE_STRING);
+
+ glitz_surface_flush (pScreenPriv->surface);
+ glitz_drawable_finish (pScreenPriv->drawable);
+}
+
+void
+xeglInitInput (int argc,
+ char **argv)
+{
+ eglInitInput (&LinuxEvdevMouseFuncs, &LinuxEvdevKeyboardFuncs);
+ RegisterBlockAndWakeupHandlers (xeglBlockHandler, KdWakeupHandler, NULL);
+}
+
+Bool
+xeglLegalModifier (unsigned int key,
+ DeviceIntPtr pDev)
+{
+ return KdLegalModifier (key, pDev);
+}
+
+void
+xeglProcessInputEvents (void)
+{
+ KdProcessInputEvents ();
+}
+
+void
+xeglUseMsg (void)
+{
+ ErrorF ("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM] "
+ "specify screen characteristics\n");
+ ErrorF ("-softcursor force software cursor\n");
+}
+
+int
+xeglProcessArgument (int argc,
+ char **argv,
+ int i)
+{
+ if (!strcmp (argv[i], "-screen"))
+ {
+ if ((i + 1) < argc)
+ {
+ xglParseScreen (argv[i + 1]);
+ }
+ else
+ return 1;
+
+ return 2;
+ }
+ else if (!strcmp (argv[i], "-softcursor"))
+ {
+ softCursor = TRUE;
+ return 1;
+ }
+
+ return 0;
+}
+
+void
+xeglAbort (void)
+{
+}
+
+void
+xeglGiveUp (void)
+{
+ AbortDDX ();
+}
+
+void
+xeglOsVendorInit (void)
+{
+}