Updated xgl code drop from Novell + xserver tree changes

This commit is contained in:
Dave Airlie 2006-01-18 07:15:55 +00:00
parent b5356e0afa
commit e70b64b930
42 changed files with 11214 additions and 2747 deletions

View File

@ -1,3 +1,10 @@
2006-01-18 Dave Airlie <airlied@linux.ie>
Update XGL server from the xserver tree, and fix to work
in X.org tree (look out for a branch appearing RSN),
Most of the changes are from David Reveman @ Novell
and the rest are from either myself or Eric Anholt.
2006-01-18 Dave Airlie <airlied@linux.ie>
* Xext/Makefile.am:

View File

@ -22,12 +22,18 @@ AM_CFLAGS = \
@SERVER_DEFINES@ \
-DHAVE_XGL_CONFIG_H \
-DHAVE_DIX_CONFIG_H \
-I$(top_srcdir)/GL/glx \
-I$(top_srcdir)/GL/include \
-I@MESA_SOURCE@/include \
-I@MESA_SOURCE@/src/mesa/glapi \
$(XGLMODULES_CFLAGS)
noinst_LIBRARIES = libxgl.a
libxgl_a_SOURCES = \
xgl.h \
xglmodule.h \
xglglx.h \
xglinput.c \
xgloutput.c \
xglcmap.c \
@ -46,13 +52,14 @@ libxgl_a_SOURCES = \
xglget.c \
xglgc.c \
xglshm.c \
xglcomp.c \
xglcompose.c \
xglpict.c \
xglglyph.c \
xgltrap.c \
xglloader.c \
xglhash.c \
xglloader.c \
xglglx.c
xglglx.c \
xglxv.c
EXTRA_DIST = \
xglmodule.h
@ -69,8 +76,7 @@ Xgl_LDADD = \
$(XORG_CORE_LIBS) \
$(XGL_LIBS) \
$(XSERVER_LIBS) \
$(EXTENSION_LIBS) \
$(XGLMODULES_LIBS)
$(EXTENSION_LIBS) -lglitz -ldl
Xgl_programs = Xgl
bin_PROGRAMS = $(Xgl_programs)

View File

@ -10,6 +10,11 @@ SUBDIRS = \
AM_CFLAGS = \
-I$(srcdir)/.. \
-I$(srcdir)/../glxext \
-I$(top_srcdir)/GL/glx \
-I$(top_srcdir)/GL/include \
-I@MESA_SOURCE@/include \
-I@MESA_SOURCE@/src/mesa/glapi \
@SERVER_DEFINES@ \
-DHAVE_XGL_CONFIG_H \
-DHAVE_DIX_CONFIG_H \
@ -19,24 +24,25 @@ noinst_LTLIBRARIES = libxglx.la
libxglx_la_SOURCES = \
xglx.h \
xglx.c
xglx.c \
xglxorg.c
Xglx_DEPENDENCIES = @XGLX_LIBS@
Xglx_LDFLAGS = -export-dynamic
Xglx_SOURCES = \
xglxinit.c \
$(top_srcdir)/mi/miinitext.c \
$(top_srcdir)/Xext/dpmsstubs.c \
$(top_srcdir)/Xi/stubs.c \
$(top_srcdir)/fb/fbcmap.c
Xglx_LDADD = \
libxglx.la \
../libxgl.a \
$(XORG_CORE_LIBS) \
$(XGLX_LIBS) \
$(XSERVER_LIBS) \
$(EXTENSION_LIBS) \
$(XGLXMODULES_LIBS)
Xglx_programs = Xglx
# Xglx_DEPENDENCIES = @XGLX_LIBS@
# Xglx_LDFLAGS = -export-dynamic
# Xglx_SOURCES = \
# xglxinit.c \
# $(top_srcdir)/mi/miinitext.c \
# $(top_srcdir)/Xext/dpmsstubs.c \
# $(top_srcdir)/Xi/stubs.c \
# $(top_srcdir)/fb/fbcmap.c
#Xglx_LDADD = \
# libxglx.la \
# ../libxgl.a \
# $(XORG_CORE_LIBS) \
# $(XGLX_LIBS) \
# $(EXTENSION_LIBS) \
# $(XGLXMODULES_LIBS) \
# -lXrandr
#Xglx_programs = Xglx
bin_PROGRAMS = $(Xglx_programs)

View File

@ -1,13 +1,20 @@
if GLX
GLX_LIB = $(top_builddir)/hw/xgl/glxext/libxglglxext.la
endif
AM_CFLAGS = \
-I$(srcdir)/.. \
-I$(srcdir)/../.. \
$(XGLXMODULES_CFLAGS)
libxglx_la_DEPENDENCIES = $(GLX_LIB)
libxglx_la_LDFLAGS = -avoid-version
libxglx_la_SOURCES = xglxmodule.c
libxglx_la_LIBADD = \
$(top_builddir)/hw/xgl/glx/libxglx.la \
$(XGLXMODULES_LIBS)
$(GLX_LIB) \
$(XGLXMODULES_LIBS) \
-lXrandr
moduledir = @xglmoduledir@

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,62 @@
#include "xgl.h"
#ifdef _XSERVER64
#define _XSERVER64_tmp
#undef _XSERVER64
typedef unsigned long XID64;
typedef unsigned long Mask64;
typedef unsigned long Atom64;
typedef unsigned long VisualID64;
typedef unsigned long Time64;
#define XID XID64
#define Mask Mask64
#define Atom Atom64
#define VisualID VisualID64
#define Time Time64
typedef XID Window64;
typedef XID Drawable64;
typedef XID Font64;
typedef XID Pixmap64;
typedef XID Cursor64;
typedef XID Colormap64;
typedef XID GContext64;
typedef XID KeySym64;
#define Window Window64
#define Drawable Drawable64
#define Font Font64
#define Pixmap Pixmap64
#define Cursor Cursor64
#define Colormap Colormap64
#define GContext GContext64
#define KeySym KeySym64
#endif
#define GC XlibGC
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#undef GC
#ifdef _XSERVER64_tmp
#ifndef _XSERVER64
#define _XSERVER64
#endif
#undef _XSERVER64_tmp
#undef XID
#undef Mask
#undef Atom
#undef VisualID
#undef Time
#undef Window
#undef Drawable
#undef Font
#undef Pixmap
#undef Cursor
#undef Colormap
#undef GContext
#undef KeySym
#endif
void
xglxInitOutput (ScreenInfo *pScreenInfo,
int argc,
@ -61,4 +117,22 @@ xglxGiveUp (void);
void
xglxOsVendorInit (void);
#ifndef NXGLXORG
void
xglxUseXorgMsg (void);
int
xglxProcessXorgArgument (int argc,
char **argv,
int i);
void
xglxAbortXorg (void);
char *
xglxInitXorg (void);
#endif
#endif /* _XGLX_H_ */

View File

@ -24,19 +24,30 @@
*/
#include "xglx.h"
#include "xglglx.h"
xglScreenInfoRec xglScreenInfo = {
NULL, 0, 0, 0, 0,
NULL, 0, 0, 0, 0, 0,
DEFAULT_GEOMETRY_DATA_TYPE,
DEFAULT_GEOMETRY_USAGE,
FALSE,
XGL_DEFAULT_PBO_MASK,
FALSE,
FALSE
{
{ FALSE, FALSE, { 0, 0, 0, 0 } },
{ FALSE, FALSE, { 0, 0, 0, 0 } },
{ FALSE, FALSE, { 0, 0, 0, 0 } },
{ FALSE, FALSE, { 0, 0, 0, 0 } }
}
};
#ifdef GLXEXT
static Bool loadGlx = TRUE;
#ifndef NGLXEXTLOG
static char *glxExtLogFile = 0;
#endif
#endif
void
@ -50,6 +61,18 @@ InitOutput (ScreenInfo *pScreenInfo,
{
if (!xglLoadGLXModules ())
FatalError ("No GLX modules loaded");
#ifndef NGLXEXTLOG
if (glxExtLogFile)
{
__xglGLXLogFp = fopen (glxExtLogFile, "w");
if (!__xglGLXLogFp)
perror ("InitOutput");
}
else
__xglGLXLogFp = 0;
#endif
}
#endif
@ -83,6 +106,11 @@ ddxUseMsg (void)
#ifdef GLXEXT
ErrorF ("-noglx don't load glx extension\n");
#ifndef NGLXEXTLOG
ErrorF ("-glxlog file glx extension log file\n");
#endif
#endif
xglUseMsg ();
@ -103,6 +131,15 @@ ddxProcessArgument (int argc,
loadGlx = FALSE;
return 1;
}
#ifndef NGLXEXTLOG
else if (!strcmp (argv[i], "-glxlog"))
{
if (++i < argc)
glxExtLogFile = argv[i];
}
#endif
#endif
skip = xglProcessArgument (argc, argv, i);
@ -130,6 +167,6 @@ OsVendorInit (void)
xglxOsVendorInit ();
}
void ddxInitGlobals(void)
void ddxInitGlobals()
{
}

676
hw/xgl/glx/xglxorg.c Normal file
View File

@ -0,0 +1,676 @@
/*
* Copyright © 2005 Novell, Inc.
*
* 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
* Novell, Inc. not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
* Novell, Inc. makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. 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.
*
* Authors: David Reveman <davidr@novell.com>
* Matthias Hopf <mhopf@suse.de>
*/
#include "xglx.h"
#ifndef NXGLXORG
#include <X11/Xauth.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <signal.h>
#include <setjmp.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <libgen.h>
typedef void (*sighandler_t) (int);
#define XORG_DIE_TIMEOUT 3
#define XORG_DEV_RANDOM "/dev/urandom"
static char xorgAuthBuf[256];
static char *xorgAuthTempl = "/tmp/.Xgl-auth-XXXXXX";
static char *xorgAuth = NULL;
static char *xorgProgs[] = { "/usr/bin/Xorg", "/usr/X11R6/bin/Xorg" };
static char *xorgProg = NULL;
static char *xorgDisplay = ":93";
static char *xorgTerminate = "-terminate";
static pid_t xorgPid = 0;
static int receivedUsr1 = 0;
static jmp_buf jumpbuf;
static Bool waitAndExit = FALSE;
static char **xorgArgv = 0;
static int nXorgArgv = 0;
typedef struct _xglxArg *xglxArgPtr;
typedef int (*xglxProcessArgumentProc) (xglxArgPtr, int, char **, int);
typedef struct _xglxArg {
xglxProcessArgumentProc processArgument;
const char *name;
const char *usage;
} xglxArgRec;
static int
xglxAddXorgArguments (char **argv,
int n)
{
char **newArgv;
int i;
newArgv = xrealloc (xorgArgv, sizeof (char *) * (nXorgArgv + n));
if (!newArgv)
return 0;
for (i = 0; i < n; i++)
newArgv[nXorgArgv + i] = argv[i];
xorgArgv = newArgv;
nXorgArgv += n;
return n;
}
static int
xglxProcessCommonXorgArgument (xglxArgPtr pArg,
int n,
int argc,
char **argv,
int i)
{
if (strcmp (argv[i], pArg->name) == 0)
{
if (i + n - 1 < argc)
return xglxAddXorgArguments (&argv[i], n);
}
return 0;
}
#define PROCESS_COMMON_XORG_ARGUMENT_IMP(args) \
static int \
xglxProcess ## args ## CommonXorgArgument (xglxArgPtr pArg, \
int argc, \
char **argv, \
int i) \
{ \
return xglxProcessCommonXorgArgument (pArg, args, argc, argv, i); \
}
PROCESS_COMMON_XORG_ARGUMENT_IMP (1)
PROCESS_COMMON_XORG_ARGUMENT_IMP (2)
static int
xglxProcessXorgVTArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
if (argv[i][0] == 'v' && argv[i][1] == 't' &&
strspn (&argv[i][2], "0123456789") == strlen (&argv[i][2]))
return xglxAddXorgArguments (&argv[i], 1);
return 0;
}
static int
xglxProcessXorgAcArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
static char *ac = "-ac";
if (strcmp (argv[i], pArg->name) == 0)
{
if (xglxAddXorgArguments (&ac, 1))
return 1;
}
return 0;
}
static int
xglxProcessXorgVersionArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
static char *version = "-version";
if (strcmp (argv[i], pArg->name) == 0)
{
if (xglxAddXorgArguments (&version, 1))
{
waitAndExit = TRUE;
return 1;
}
}
return 0;
}
static int
xglxProcessXorgProgArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
if (strcmp (argv[i], pArg->name) == 0)
{
if (i + 1 < argc)
{
xorgProg = argv[i + 1];
return 2;
}
}
return 0;
}
static int
xglxProcessXorgDisplayArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
if (strcmp (argv[i], pArg->name) == 0)
{
if (i + 1 < argc)
{
xorgDisplay = argv[i + 1];
return 2;
}
}
return 0;
}
static int
xglxProcessXorgWaitExitArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
if (xglxProcessCommonXorgArgument (pArg, 1, argc, argv, i))
{
waitAndExit = TRUE;
return 1;
}
return 0;
}
#define ARG(processArgument, name, usage) \
{ processArgument, name, usage }
#define XORG_ARG(name, args) \
ARG (xglxProcess ## args ## CommonXorgArgument, name, 0)
#define XORG_UARG(name, usage, args) \
ARG (xglxProcess ## args ## CommonXorgArgument, name, usage)
xglxArgRec xorgUid0Args[] = {
XORG_UARG ("-modulepath", " paths specify the module search path", 2),
XORG_UARG ("-logfile", " file specify a log file name", 2),
ARG (xglxProcessXorgWaitExitArgument, "-configure",
" probe for devices and write an Xorg config")
};
xglxArgRec xorgUidArgs[] = {
XORG_UARG ("-config",
" file specify configuration file, relative to the\n"
" Xorg config search path, "
"only root can use absolute", 2)
};
xglxArgRec xorgArgs[] = {
ARG (xglxProcessXorgWaitExitArgument, "-probeonly",
" probe for devices, then exit"),
ARG (xglxProcessXorgWaitExitArgument, "-scanpci",
" execute the scanpci module and exit"),
XORG_UARG ("-verbose", " [n] verbose startup messages", 2),
XORG_UARG ("-logverbose", " [n] verbose log messages", 2),
XORG_UARG ("-quiet", " minimal startup messages", 1),
XORG_UARG ("-depth", " n set colour depth. Default: 8", 2),
XORG_UARG ("-gamma",
" f set gamma value (0.1 < f < 10.0) "
"Default: 1.0", 2),
XORG_UARG ("-rgamma", " f set gamma value for red phase", 2),
XORG_UARG ("-ggamma", " f set gamma value for green phase",
2),
XORG_UARG ("-bgamma", " f set gamma value for blue phase", 2),
XORG_UARG ("-layout",
" name specify the ServerLayout section name", 2),
XORG_UARG ("-screen",
" name specify the Screen section name", 2),
XORG_UARG ("-keyboard",
" name specify the core keyboard InputDevice name", 2),
XORG_UARG ("-pointer",
" name specify the core pointer InputDevice name", 2),
XORG_UARG ("-nosilk", " disable Silken Mouse", 1),
XORG_UARG ("-disableModInDev",
" disable dynamic modification of input device settings",
1),
XORG_UARG ("-allowMouseOpenFail",
" start server even if the mouse can't be initialized", 1),
XORG_UARG ("-bestRefresh",
" choose modes with the best refresh rate", 1),
XORG_UARG ("-ignoreABI",
" make module ABI mismatches non-fatal", 1),
XORG_UARG ("-isolateDevice",
" bus_id restrict device resets to bus_id (PCI only)", 2),
ARG (xglxProcessXorgVTArgument, "vtXX",
" use the specified VT number"),
XORG_UARG ("-keeptty",
" don't detach controlling tty "
"(for debugging only)", 1),
XORG_UARG ("-novtswitch", " don't immediately switch to new VT",
1),
XORG_UARG ("-sharevts", " share VTs with another X server",
1),
ARG (xglxProcessXorgAcArgument, "-xorgAc",
" disable access control restrictions"),
ARG (xglxProcessXorgProgArgument, "-xorgProgram",
" server program"),
ARG (xglxProcessXorgDisplayArgument, "-xorgDisplay",
" server display"),
ARG (xglxProcessXorgVersionArgument, "-xorgVersion",
" show the server version")
};
xglxArgRec sharedArgs[] = {
XORG_ARG ("-br", 1)
};
void
xglxUseXorgMsg (void)
{
int i;
ErrorF ("\nXorg usage:\n");
if (getuid () == 0)
{
for (i = 0; i < sizeof (xorgUid0Args) / sizeof (xglxArgRec); i++)
ErrorF ("%s%s\n", xorgUid0Args[i].name, xorgUid0Args[i].usage);
}
else
{
for (i = 0; i < sizeof (xorgUidArgs) / sizeof (xglxArgRec); i++)
ErrorF ("%s%s\n", xorgUidArgs[i].name, xorgUidArgs[i].usage);
}
for (i = 0; i < sizeof (xorgArgs) / sizeof (xglxArgRec); i++)
ErrorF ("%s%s\n", xorgArgs[i].name, xorgArgs[i].usage);
}
int
xglxProcessXorgArgument (int argc,
char **argv,
int i)
{
int skip, j;
if (nXorgArgv == 0)
{
if (!xglxAddXorgArguments (&xorgProg, 1))
return 0;
}
if (getuid () == 0)
{
for (j = 0; j < sizeof (xorgUid0Args) / sizeof (xglxArgRec); j++)
{
skip = (*xorgUid0Args[j].processArgument) (&xorgUid0Args[j],
argc, argv, i);
if (skip)
return skip;
}
}
else
{
for (j = 0; j < sizeof (xorgUidArgs) / sizeof (xglxArgRec); j++)
{
skip = (*xorgUidArgs[j].processArgument) (&xorgUidArgs[j],
argc, argv, i);
if (skip)
return skip;
}
}
for (j = 0; j < sizeof (xorgArgs) / sizeof (xorgArgs[0]); j++)
{
skip = (*xorgArgs[j].processArgument) (&xorgArgs[j], argc, argv, i);
if (skip)
return skip;
}
for (j = 0; j < sizeof (sharedArgs) / sizeof (sharedArgs[0]); j++)
{
skip = (*sharedArgs[j].processArgument) (&sharedArgs[j], argc, argv, i);
if (skip)
return 0;
}
return 0;
}
static void
sigAlarm (int sig)
{
ErrorF ("%s won't die, killing it\n", basename (xorgProg));
kill (xorgPid, SIGKILL);
if (xorgPid)
while (waitpid (xorgPid, NULL, 0) == -1 && errno == EINTR);
}
void
xglxAbortXorg (void)
{
sighandler_t oldSigAlarm;
unsigned int oldAlarm;
int status = 0;
char *name;
if (!xorgPid)
return;
name = basename (xorgProg);
oldAlarm = alarm (0);
oldSigAlarm = signal (SIGALRM, sigAlarm);
kill (xorgPid, SIGTERM);
alarm (XORG_DIE_TIMEOUT);
while (waitpid (xorgPid, &status, 0) == -1 && errno == EINTR);
alarm (0);
signal (SIGALRM, oldSigAlarm);
alarm (oldAlarm);
if (WIFEXITED (status))
{
if (WEXITSTATUS (status))
ErrorF ("%s died, exit status %d\n", name, WEXITSTATUS (status));
}
else if (WIFSIGNALED (status))
ErrorF ("%s died, signal %d\n", name, WTERMSIG (status));
else
ErrorF ("%s died, dubious exit\n", name);
if (xorgAuth)
unlink (xorgAuth);
}
static void
sigUsr1Waiting (int sig)
{
signal (sig, sigUsr1Waiting);
receivedUsr1++;
}
static void
sigUsr1Jump (int sig)
{
#ifdef HAVE_SIGPROCMASK
sigset_t set;
#endif
signal (sig, sigUsr1Waiting);
#ifdef HAVE_SIGPROCMASK
sigemptyset (&set);
sigaddset (&set, SIGUSR1);
sigprocmask (SIG_UNBLOCK, &set, NULL);
#endif
longjmp (jumpbuf, 1);
}
#define AUTH_DATA_LEN 16 /* bytes of authorization data */
static Bool
xglxSetupAuth (char *name, int authFd)
{
Xauth auth;
int randomFd;
ssize_t bytes, size;
char authHost[256];
char authData[AUTH_DATA_LEN];
FILE *file;
auth.family = FamilyLocal;
gethostname (authHost, sizeof (authHost));
auth.address = authHost;
auth.address_length = strlen (authHost);
auth.number = strrchr (xorgDisplay, ':');
if (!auth.number)
{
ErrorF ("Bad Xorg display name: %s\n", xorgDisplay);
return FALSE;
}
auth.number++;
auth.number_length = strlen (auth.number);
if (!auth.number_length)
{
ErrorF ("Bad Xorg display name: %s\n", xorgDisplay);
return FALSE;
}
auth.name = "MIT-MAGIC-COOKIE-1";
auth.name_length = strlen (auth.name);
randomFd = open (XORG_DEV_RANDOM, O_RDONLY);
if (randomFd == -1)
{
ErrorF ("Failed to open " XORG_DEV_RANDOM "\n");
return FALSE;
}
bytes = 0;
do {
size = read (randomFd, authData + bytes, AUTH_DATA_LEN - bytes);
if (size <= 0)
break;
bytes += size;
} while (bytes != AUTH_DATA_LEN);
close (randomFd);
if (bytes != AUTH_DATA_LEN)
{
ErrorF ("Failed to read %d random bytes from " XORG_DEV_RANDOM "\n",
AUTH_DATA_LEN);
return FALSE;
}
auth.data = authData;
auth.data_length = AUTH_DATA_LEN;
file = fdopen (authFd, "w");
if (!file)
{
ErrorF ("Failed to open authorization file: %s\n", name);
close (authFd);
return FALSE;
}
XauWriteAuth (file, &auth);
fclose (file);
return TRUE;
}
char *
xglxInitXorg (void)
{
sighandler_t oldSigUsr1;
pid_t pid;
char *name;
char *auth[] = { "-auth", xorgAuthBuf, "-nolisten", "tcp" };
char *saver[] = { "-dpms", "-v", "-s", "0" };
char *endArg = NULL;
int authFd;
int mask;
if (xorgPid)
return xorgDisplay;
if (!xorgProg)
{
struct stat buf;
int i;
for (i = 0; i < sizeof (xorgProgs) / sizeof (char *); i++)
{
if (stat (xorgProgs[i], &buf) == 0)
{
xorgProg = xorgProgs[i];
break;
}
}
if (!xorgProg)
FatalError ("Can't find Xorg executable\n");
}
strcpy (xorgAuthBuf, xorgAuthTempl);
mask = umask (0077);
authFd = mkstemp (xorgAuthBuf);
umask (mask);
if (authFd == -1)
FatalError ("Failed to generate unique authorization file\n");
xorgAuth = xorgAuthBuf;
if (nXorgArgv == 0)
{
if (!xglxAddXorgArguments (&xorgProg, 1))
return 0;
}
else
{
xorgArgv[0] = xorgProg;
}
if (!xglxAddXorgArguments (auth, sizeof (auth) / sizeof (char *)))
return 0;
if (!xglxAddXorgArguments (saver, sizeof (saver) / sizeof (char *)))
return 0;
if (!xglxAddXorgArguments (&xorgDisplay, 1))
return 0;
if (!xglxAddXorgArguments (&xorgTerminate, 1))
return 0;
if (!xglxAddXorgArguments (&endArg, 1))
return 0;
name = basename (xorgProg);
if (!xglxSetupAuth (xorgAuth, authFd))
FatalError ("Failed to set up authorization: %s\n", xorgAuth);
oldSigUsr1 = signal (SIGUSR1, sigUsr1Waiting);
pid = fork ();
switch (pid) {
case -1:
perror ("fork");
FatalError ("fork");
break;
case 0:
signal (SIGUSR1, SIG_IGN);
execv (xorgArgv[0], xorgArgv);
perror (xorgArgv[0]);
exit (2);
break;
default:
xorgPid = pid;
break;
}
for (;;)
{
int status;
signal (SIGUSR1, sigUsr1Waiting);
if (setjmp (jumpbuf) && !waitAndExit)
break;
signal (SIGUSR1, sigUsr1Jump);
if (receivedUsr1 && !waitAndExit)
break;
if (waitpid (xorgPid, &status, 0) != -1)
{
if (WIFEXITED (status))
{
if (waitAndExit)
{
if (WEXITSTATUS (status))
FatalError ("%s died, exit status %d\n", name,
WEXITSTATUS (status));
exit (WEXITSTATUS (status));
}
else
{
FatalError ("%s died, exit status %d\n", name,
WEXITSTATUS (status));
}
}
else if (WIFSIGNALED (status))
FatalError ("%s died, signal %d\n", name, WTERMSIG (status));
else
FatalError ("%s died, dubious exit\n", name);
}
}
signal (SIGUSR1, oldSigUsr1);
setenv ("XAUTHORITY", xorgAuth, 1);
return xorgDisplay;
}
#endif

View File

@ -1,13 +1,21 @@
SUBDIRS = module
INCLUDES = \
@XGL_INCS@ \
@XSERVER_CFLAGS@
AM_CFLAGS = \
@SERVER_DEFINES@ \
-DHAVE_XGL_CONFIG_H \
-DHAVE_DIX_CONFIG_H \
$(XGLMODULES_CFLAGS) \
-I$(top_srcdir)/GL/glx \
-I$(top_srcdir)/GL/include \
-I$(top_srcdir)/hw/xgl \
-I@MESA_SOURCE@/include \
-I@MESA_SOURCE@/src/mesa/glapi
libxglglxext_libraries = libxglglxext.la
libxglglxext_la_SOURCES = \
xglglxext.h \
xglglxext.c
xglglxext.c \
xglglxlog.c
noinst_LTLIBRARIES = $(libxglglxext_libraries)

View File

@ -1,6 +1,9 @@
INCLUDES = \
@XGLX_INCS@ \
@XSERVER_CFLAGS@
AM_CFLAGS = \
@SERVER_DEFINES@ \
-DHAVE_XGL_CONFIG_H \
-DHAVE_DIX_CONFIG_H \
$(XGLMODULES_CFLAGS) \
-I$(top_srcdir)/hw/xgl
libglx_la_LDFLAGS = -avoid-version
libglx_la_SOURCES = glxmodule.c
@ -9,11 +12,11 @@ libglx_modules = libglx.la
libglcore_la_LDFLAGS = -avoid-version
libglcore_la_SOURCES = glcoremodule.c
libglcore_la_LIBADD = $(top_builddir)/GL/mesa/libglcore.la
libglcore_la_LIBADD = $(top_builddir)/GL/mesa/libGLcore.la
libglcore_modules = libglcore.la
moduledir = @MODULEPATH@/xgl
moduledir = @XGL_MODULE_PATH@
module_LTLIBRARIES = \
$(libglcore_modules) \
$(libglx_modules)
$(libglx_modules)

File diff suppressed because it is too large Load Diff

View File

@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. 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,
* 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.
*
@ -26,11 +26,16 @@
#ifndef _XGL_GLXEXT_H_
#define _XGL_GLXEXT_H_
#include <xgl-config.h>
#include "scrnintstr.h"
Bool
xglInitVisualConfigs (ScreenPtr pScreen);
#ifndef NGLXEXTLOG
void
xglInitGlxLog (void);
#endif
#endif /* _XGL_GLXEXT_H_ */

4519
hw/xgl/glxext/xglglxlog.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -28,8 +28,6 @@
#include <xgl-config.h>
#include <stdint.h>
#include <stdio.h>
#include <X11/X.h>
#define NEED_EVENTS
#include <X11/Xproto.h>
@ -44,11 +42,23 @@
#include "dix.h"
#include "damage.h"
#include "gc.h"
#include "micmap.h"
/* I'd like gc.h to provide this */
typedef struct _GCFuncs *GCFuncsPtr;
#ifdef RENDER
#include "mipict.h"
#else
#ifdef XV
#undef XV /* Xv implementation require RENDER */
#endif
#endif
#ifdef XV
#define XGL_XV_FORMAT_YUY2 0
#define XGL_XV_FORMAT_YV12 1
#define XGL_XV_FORMAT_RGB 2
#define XGL_XV_FORMAT_NUM 3
#endif
/* For the modules. We should decide what the actual version numbering should
@ -60,18 +70,39 @@ extern WindowPtr *WindowTable;
#define XGL_DEFAULT_PBO_MASK 0
typedef struct _xglSizeConstraint {
int minWidth;
int minHeight;
int aboveWidth;
int aboveHeight;
} xglSizeConstraintRec, *xglSizeConstraintPtr;
typedef struct _xglAccelInfo {
Bool enabled;
Bool pbuffer;
xglSizeConstraintRec size;
} xglAccelInfoRec, *xglAccelInfoPtr;
typedef struct _xglScreenAccelInfo {
xglAccelInfoRec pixmap;
xglAccelInfoRec window;
xglAccelInfoRec glx;
xglAccelInfoRec xv;
} xglScreenAccelInfoRec, *xglScreenAccelInfoPtr;
typedef struct _xglScreenInfo {
glitz_drawable_t *drawable;
unsigned int width;
unsigned int height;
unsigned int widthMm;
unsigned int heightMm;
int geometryDataType;
int geometryUsage;
Bool yInverted;
int pboMask;
Bool lines;
Bool fbo;
glitz_drawable_t *drawable;
unsigned int depth;
unsigned int width;
unsigned int height;
unsigned int widthMm;
unsigned int heightMm;
int geometryDataType;
int geometryUsage;
Bool yInverted;
int pboMask;
Bool lines;
xglScreenAccelInfoRec accel;
} xglScreenInfoRec, *xglScreenInfoPtr;
extern xglScreenInfoRec xglScreenInfo;
@ -82,18 +113,17 @@ typedef struct _xglPixelFormat {
} xglPixelFormatRec, *xglPixelFormatPtr;
typedef struct _xglVisual {
glitz_drawable_format_t *format;
xglPixelFormatPtr pPixel;
unsigned long visuals;
struct _xglVisual *next;
VisualID vid;
xglPixelFormatPtr pPixel;
Bool pbuffer;
struct {
glitz_drawable_format_t *drawable;
glitz_format_t *surface;
} format;
} xglVisualRec, *xglVisualPtr;
typedef struct _xglPixmapFormat {
glitz_format_t *format;
xglPixelFormatPtr pPixel;
} xglPixmapFormatRec, *xglPixmapFormatPtr;
extern xglVisualPtr xglVisuals;
extern int nxglVisuals;
#define xglAreaAvailable 0
#define xglAreaDivided 1
@ -114,7 +144,7 @@ typedef struct _xglArea {
typedef struct _xglAreaFuncs {
Bool (*Create) (xglAreaPtr pArea);
Bool (*MoveIn) (xglAreaPtr pArea,
pointer closure);
@ -124,7 +154,7 @@ typedef struct _xglAreaFuncs {
int (*CompareScore) (xglAreaPtr pArea,
pointer closure1,
pointer closure2);
} xglAreaFuncsRec, *xglAreaFuncsPtr;
typedef struct _xglRootArea {
@ -166,7 +196,7 @@ typedef struct _xglRange {
} xglRangeRec, *xglRangePtr;
typedef struct _xglGlyphTexture {
glitz_surface_t *mask;
PicturePtr pMask;
glitz_pixel_format_t pixel;
glitz_geometry_format_t format;
int geometryDataType;
@ -206,11 +236,18 @@ extern int xglGlyphPrivateIndex;
typedef struct _xglScreen {
xglVisualPtr pVisual;
xglPixmapFormatRec pixmapFormats[33];
#ifdef GLXEXT
xglVisualPtr pGlxVisual;
#endif
#ifdef XV
xglVisualRec pXvVisual[XGL_XV_FORMAT_NUM];
#endif
xglVisualPtr rootVisual;
glitz_drawable_t *drawable;
glitz_surface_t *surface;
glitz_surface_t *backSurface;
glitz_surface_t *solid;
PixmapPtr pScreenPixmap;
unsigned long features;
int geometryUsage;
@ -218,22 +255,22 @@ typedef struct _xglScreen {
Bool yInverted;
int pboMask;
Bool lines;
Bool fbo;
xglGeometryRec scratchGeometry;
xglScreenAccelInfoRec accel;
#ifdef RENDER
xglGlyphCacheRec glyphCache[33];
PicturePtr pSolidAlpha;
struct _trapInfo {
PicturePtr pMask;
glitz_surface_t *mask;
glitz_geometry_format_t format;
} trapInfo;
#endif
GetImageProcPtr GetImage;
GetSpansProcPtr GetSpans;
CreateWindowProcPtr CreateWindow;
DestroyWindowProcPtr DestroyWindow;
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
PaintWindowBackgroundProcPtr PaintWindowBackground;
PaintWindowBorderProcPtr PaintWindowBorder;
@ -258,16 +295,11 @@ typedef struct _xglScreen {
#endif
BSFuncRec BackingStoreFuncs;
#ifdef GLXEXT
DestroyWindowProcPtr DestroyWindow;
#endif
} xglScreenRec, *xglScreenPtr;
extern int xglScreenPrivateIndex;
#define XGL_GET_SCREEN_PRIV(pScreen) \
#define XGL_GET_SCREEN_PRIV(pScreen) \
((xglScreenPtr) (pScreen)->devPrivates[xglScreenPrivateIndex].ptr)
#define XGL_SET_SCREEN_PRIV(pScreen, v) \
@ -293,17 +325,17 @@ extern int xglScreenPrivateIndex;
#endif
#define xglGCSoftwareDrawableFlag (1L << 0)
#define xglGCReadOnlyDrawableFlag (1L << 1)
#define xglGCBadFunctionFlag (1L << 2)
#define xglGCPlaneMaskFlag (1L << 3)
#define xglGCBadFunctionFlag (1L << 1)
#define xglGCPlaneMaskFlag (1L << 2)
typedef struct _xglGC {
glitz_color_t fg;
glitz_color_t bg;
glitz_operator_t op;
unsigned long flags;
GCFuncsPtr funcs;
GCOpsPtr ops;
glitz_surface_t *fg;
glitz_surface_t *bg;
glitz_format_id_t id;
glitz_operator_t op;
unsigned long flags;
GCFuncsPtr funcs;
GCOpsPtr ops;
} xglGCRec, *xglGCPtr;
extern int xglGCPrivateIndex;
@ -324,7 +356,7 @@ extern int xglGCPrivateIndex;
#define xglPCFillMask (1L << 0)
#define xglPCFilterMask (1L << 1)
#define xglPCTransformMask (1L << 2)
#define xglPCTransformMask (1L << 2)
#define xglPCComponentAlphaMask (1L << 3)
#define xglPCDitherMask (1L << 4)
@ -334,22 +366,36 @@ extern int xglGCPrivateIndex;
#define xglPixmapTargetOut 1
#define xglPixmapTargetIn 2
#ifdef XV
typedef struct _xglXvPort {
PixmapPtr pPixmap;
PicturePtr pSrc;
PicturePtr pDst;
} xglXvPortRec, *xglXvPortPtr;
#endif
typedef struct _xglPixmap {
xglPixelFormatPtr pPixel;
glitz_format_t *format;
glitz_surface_t *surface;
glitz_buffer_t *buffer;
int target;
Bool acceleratedTile;
pointer bits;
int stride;
DamagePtr pDamage;
BoxRec damageBox;
BoxRec bitBox;
Bool allBits;
unsigned long pictureMask;
xglGeometryPtr pGeometry;
int lock;
xglVisualPtr pVisual;
glitz_surface_t *surface;
glitz_drawable_t *drawable;
glitz_buffer_t *buffer;
int target;
Bool acceleratedTile;
pointer bits;
int stride;
DamagePtr pDamage;
BoxRec damageBox;
RegionRec bitRegion;
Bool allBits;
unsigned long pictureMask;
xglGeometryPtr pGeometry;
#ifdef XV
xglXvPortPtr pPortPriv;
#endif
} xglPixmapRec, *xglPixmapPtr;
extern int xglPixmapPrivateIndex;
@ -364,7 +410,7 @@ extern int xglPixmapPrivateIndex;
#define XGL_PICTURE_FAILURES(pictureMask) (pictureMask & 0xffff0000)
typedef struct _xglWin {
PixmapPtr pPixmap;
PixmapPtr pPixmap;
} xglWinRec, *xglWinPtr;
extern int xglWinPrivateIndex;
@ -463,28 +509,42 @@ xglInitInput (int argc, char **argv);
void
xglSetPixmapFormats (ScreenInfo *pScreenInfo);
void
xglSetRootClip (ScreenPtr pScreen,
Bool enable);
/* xglcmap.c */
void
xglSetVisualTypesAndMasks (ScreenInfo *pScreenInfo,
glitz_drawable_format_t *format,
unsigned long visuals);
xglSetVisualTypes (int depth,
int visuals,
int redSize,
int greenSize,
int blueSize);
Bool
xglHasVisualTypes (xglVisualPtr pVisual,
int depth);
glitz_format_t *
xglFindBestSurfaceFormat (ScreenPtr pScreen,
xglPixelFormatPtr pPixel);
void
xglInitVisuals (ScreenInfo *pScreenInfo);
xglInitVisuals (ScreenPtr pScreen);
xglVisualPtr
xglFindVisualWithDepth (ScreenPtr pScreen,
int depth);
xglVisualPtr
xglFindVisualWithId (ScreenPtr pScreen,
int vid);
void
xglClearVisualTypes (void);
void
xglInitPixmapFormats (ScreenPtr pScreen);
void
xglPixelToColor (xglPixelFormatPtr pFormat,
CARD32 pixel,
glitz_color_t *color);
/* xglparse.c */
@ -680,7 +740,7 @@ extern xglDataTypeInfoRec xglGeometryDataTypes[2];
#define GEOMETRY_ADD_REGION_AT(pScreen, pGeometry, pRegion, offset) \
xglGeometryAddBox (pScreen, pGeometry, \
REGION_RECTS (pRegion), \
REGION_NUM_RECTS (pRegion), \
REGION_NUM_RECTS (pRegion), \
offset)
#define GEOMETRY_ADD_REGION(pScreen, pGeometry, pRegion) \
@ -792,7 +852,7 @@ xglGetScratchVertexGeometry (ScreenPtr pScreen,
int count);
Bool
xglSetGeometry (xglGeometryPtr pGeometry,
xglSetGeometry (xglGeometryPtr pGeometry,
glitz_surface_t *surface);
@ -813,7 +873,7 @@ xglSetGeometry (xglGeometryPtr pGeometry,
PixmapPtr
xglCreatePixmap (ScreenPtr pScreen,
int width,
int height,
int height,
int depth);
void
@ -831,6 +891,10 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
int devKind,
pointer pPixData);
void
xglSetPixmapVisual (PixmapPtr pPixmap,
xglVisualPtr pVisual);
RegionPtr
xglPixmapToRegion (PixmapPtr pPixmap);
@ -851,6 +915,14 @@ xglMapPixmapBits (PixmapPtr pPixmap);
Bool
xglUnmapPixmapBits (PixmapPtr pPixmap);
Bool
xglCheckPixmapSize (PixmapPtr pPixmap,
xglSizeConstraintPtr pSize);
void
xglEnablePixmapAccel (PixmapPtr pPixmap,
xglAccelInfoPtr pAccel);
/* xglsync.c */
@ -887,7 +959,7 @@ xglAddCurrentBitDamage (DrawablePtr pDrawable);
Bool
xglSolid (DrawablePtr pDrawable,
glitz_operator_t op,
glitz_color_t *color,
glitz_surface_t *solid,
xglGeometryPtr pGeometry,
int x,
int y,
@ -960,7 +1032,7 @@ Bool
xglFill (DrawablePtr pDrawable,
GCPtr pGC,
xglGeometryPtr pGeometry,
int x,
int x,
int y,
int width,
int height,
@ -975,8 +1047,8 @@ xglFillSpan (DrawablePtr pDrawable,
int *pwidth);
void
xglFillRect (DrawablePtr pDrawable,
GCPtr pGC,
xglFillRect (DrawablePtr pDrawable,
GCPtr pGC,
int nrect,
xRectangle *prect);
@ -989,7 +1061,7 @@ xglFillLine (DrawablePtr pDrawable,
Bool
xglFillSegment (DrawablePtr pDrawable,
GCPtr pGC,
GCPtr pGC,
int nsegInit,
xSegment *pSegInit);
@ -1008,13 +1080,16 @@ xglFillGlyph (DrawablePtr pDrawable,
Bool
xglCreateWindow (WindowPtr pWin);
Bool
xglDestroyWindow (WindowPtr pWin);
Bool
xglChangeWindowAttributes (WindowPtr pWin,
unsigned long mask);
void
xglCopyWindow (WindowPtr pWin,
DDXPointRec ptOldOrg,
void
xglCopyWindow (WindowPtr pWin,
DDXPointRec ptOldOrg,
RegionPtr prgnSrc);
void
@ -1027,6 +1102,13 @@ xglPaintWindowBorder (WindowPtr pWin,
RegionPtr pRegion,
int what);
PixmapPtr
xglGetWindowPixmap (WindowPtr pWin);
void
xglSetWindowPixmap (WindowPtr pWin,
PixmapPtr pPixmap);
/* xglbstore.c */
@ -1058,11 +1140,11 @@ xglGetImage (DrawablePtr pDrawable,
char *d);
void
xglGetSpans (DrawablePtr pDrawable,
int wMax,
DDXPointPtr ppt,
int *pwidth,
int nspans,
xglGetSpans (DrawablePtr pDrawable,
int wMax,
DDXPointPtr ppt,
int *pwidth,
int nspans,
char *pchardstStart);
@ -1071,6 +1153,9 @@ xglGetSpans (DrawablePtr pDrawable,
Bool
xglCreateGC (GCPtr pGC);
void
xglDestroyGC (GCPtr pGC);
void
xglValidateGC (GCPtr pGC,
unsigned long changes,
@ -1144,13 +1229,13 @@ xglPolylines (DrawablePtr pDrawable,
void
xglPolySegment (DrawablePtr pDrawable,
GCPtr pGC,
GCPtr pGC,
int nsegInit,
xSegment *pSegInit);
void
xglPolyArc (DrawablePtr pDrawable,
GCPtr pGC,
GCPtr pGC,
int narcs,
xArc *pArcs);
@ -1162,7 +1247,7 @@ xglPolyFillRect (DrawablePtr pDrawable,
void
xglPolyFillArc (DrawablePtr pDrawable,
GCPtr pGC,
GCPtr pGC,
int narcs,
xArc *pArcs);
@ -1217,25 +1302,6 @@ xglShmPutImage (DrawablePtr pDrawable,
#ifdef RENDER
/* xglcomp.c */
Bool
xglComp (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height,
xglGeometryPtr pGeometry,
glitz_surface_t *mask);
/* xglpict.c */
void
@ -1273,8 +1339,18 @@ xglChangePictureFilter (PicturePtr pPicture,
xFixed *params,
int nparams);
void
xglUpdatePicture (PicturePtr pPicture);
PicturePtr
xglCreateDevicePicture (pointer data);
Bool
xglSyncPicture (ScreenPtr pScreen,
PicturePtr pPicture,
INT16 x,
INT16 y,
CARD16 width,
CARD16 height,
INT16 *xOff,
INT16 *yOff);
Bool
xglPictureInit (ScreenPtr pScreen);
@ -1283,6 +1359,25 @@ void
xglPictureClipExtents (PicturePtr pPicture,
BoxPtr extents);
/* xglcompose.c */
Bool
xglCompositeGeneral (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
xglGeometryPtr pGeometry,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
/* xglglyph.c */
Bool
@ -1344,7 +1439,8 @@ typedef struct _xglSymbol {
} xglSymbolRec, *xglSymbolPtr;
void *
xglLoadModule (const char *name);
xglLoadModule (const char *name,
int flag);
void
xglUnloadModule (void *handle);
@ -1356,18 +1452,17 @@ xglLookupSymbols (void *handle,
#endif
#ifdef GLXEXT
/* xglglx.c */
/* xglxv.c */
#ifdef XV
Bool
xglLoadGLXModules (void);
void
xglUnloadGLXModules (void);
xglXvScreenInit (ScreenPtr pScreen);
#endif
/* xglhash.c */
typedef struct _xglHashTable *xglHashTablePtr;

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2005 Novell, Inc.
*
*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. 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,
* 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.
*
@ -31,7 +31,7 @@ xglAreaMoveIn (xglAreaPtr pArea,
{
pArea->closure = closure;
pArea->state = xglAreaOccupied;
return (*pArea->pRoot->funcs->MoveIn) (pArea, closure);
}
@ -54,7 +54,7 @@ xglAreaCreate (xglRootAreaPtr pRoot,
{
xglAreaPtr pArea;
int n = 4;
pArea = xalloc (sizeof (xglAreaRec) + pRoot->devPrivateSize);
if (!pArea)
return NULL;
@ -67,7 +67,7 @@ xglAreaCreate (xglRootAreaPtr pRoot,
pArea->pRoot = pRoot;
pArea->closure = (pointer) 0;
pArea->state = xglAreaAvailable;
while (n--)
pArea->pArea[n] = NULL;
@ -81,13 +81,13 @@ xglAreaCreate (xglRootAreaPtr pRoot,
free (pArea);
return NULL;
}
return pArea;
}
static void
xglAreaDestroy (xglAreaPtr pArea)
{
{
if (!pArea)
return;
@ -98,11 +98,11 @@ xglAreaDestroy (xglAreaPtr pArea)
else
{
int n = 4;
while (n--)
xglAreaDestroy (pArea->pArea[n]);
}
xfree (pArea);
}
@ -111,7 +111,7 @@ xglAreaGetTopScoredSubArea (xglAreaPtr pArea)
{
if (!pArea)
return NULL;
switch (pArea->state) {
case xglAreaOccupied:
return pArea;
@ -120,7 +120,7 @@ xglAreaGetTopScoredSubArea (xglAreaPtr pArea)
case xglAreaDivided: {
xglAreaPtr tmp, top = NULL;
int i;
for (i = 0; i < 4; i++)
{
tmp = xglAreaGetTopScoredSubArea (pArea->pArea[i]);
@ -139,7 +139,7 @@ xglAreaGetTopScoredSubArea (xglAreaPtr pArea)
return top;
}
}
return NULL;
}
@ -161,11 +161,11 @@ xglAreaFind (xglAreaPtr pArea,
pArea->closure,
closure) >= 0)
return FALSE;
xglAreaMoveOut (pArea);
} else
return FALSE;
/* fall-through */
case xglAreaAvailable:
{
@ -178,15 +178,15 @@ xglAreaFind (xglAreaPtr pArea,
else
{
int dx[4], dy[4], w[4], h[4], i;
dx[0] = dx[2] = dy[0] = dy[1] = 0;
w[0] = w[2] = dx[1] = dx[3] = width;
h[0] = h[1] = dy[2] = dy[3] = height;
w[1] = w[3] = pArea->width - width;
h[2] = h[3] = pArea->height - height;
for (i = 0; i < 2; i++)
{
if (w[i])
@ -210,7 +210,7 @@ xglAreaFind (xglAreaPtr pArea,
}
pArea->state = xglAreaDivided;
if (xglAreaFind (pArea->pArea[0], width, height, kickOut, closure))
return TRUE;
}
@ -230,7 +230,7 @@ xglAreaFind (xglAreaPtr pArea,
if (xglFindArea (pArea->pArea[i], width, height, kickOut,
closure))
return TRUE;
rejected = TRUE;
}
}
@ -257,12 +257,12 @@ xglAreaFind (xglAreaPtr pArea,
xglAreaDestroy (pArea->pArea[i]);
pArea->pArea[i] = NULL;
}
pArea->closure = (pointer) 0;
pArea->state = xglAreaAvailable;
if (xglFindArea (pArea, width, height, TRUE, closure))
return TRUE;
} break;
}
@ -286,7 +286,7 @@ xglRootAreaInit (xglRootAreaPtr pRoot,
pRoot->pArea = xglAreaCreate (pRoot, 0, 0, 0, width, height);
if (!pRoot->pArea)
return FALSE;
return TRUE;
}
@ -298,7 +298,7 @@ xglRootAreaFini (xglRootAreaPtr pRoot)
void
xglLeaveArea (xglAreaPtr pArea)
{
{
xglAreaMoveOut (pArea);
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -69,12 +69,12 @@ xglSaveAreas (PixmapPtr pPixmap,
box.y1 += yorg;
box.x2 += xorg;
box.y2 += yorg;
if (!xglSyncBits (&pWin->drawable, &box))
FatalError (XGL_SW_FAILURE_STRING);
XGL_BSTORE_FALLBACK_PROLOGUE (&pPixmap->drawable,
BackingStoreFuncs.RestoreAreas);
BackingStoreFuncs.SaveAreas);
(*pScreen->BackingStoreFuncs.SaveAreas) (pPixmap, prgnSave,
xorg, yorg, pWin);
XGL_BSTORE_FALLBACK_EPILOGUE (&pPixmap->drawable,
@ -111,10 +111,10 @@ xglRestoreAreas (PixmapPtr pPixmap,
box.y1 = pExt->y1 - yorg;
box.x2 = pExt->x2 - xorg;
box.y2 = pExt->y2 - yorg;
if (!xglSyncBits (&pPixmap->drawable, &box))
FatalError (XGL_SW_FAILURE_STRING);
XGL_BSTORE_FALLBACK_PROLOGUE (&pWin->drawable,
BackingStoreFuncs.RestoreAreas);
(*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgnRestore,

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,18 +12,17 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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 <stdint.h>
#include "xgl.h"
#include "colormapst.h"
#include "micmap.h"
@ -81,225 +80,387 @@ static xglPixelFormatRec xglPixelFormats[] = {
#define NUM_XGL_PIXEL_FORMATS \
(sizeof (xglPixelFormats) / sizeof (xglPixelFormats[0]))
xglVisualPtr xglVisuals = NULL;
int nxglVisuals = 0;
xglVisualPtr xglVisuals = NULL;
xglVisualPtr xglPbufferVisuals = NULL;
int nxglPbufferVisuals = 0;
static xglPixelFormatPtr
xglFindPixelFormat (glitz_drawable_format_t *format,
int visuals)
void
xglSetVisualTypes (int depth,
int visuals,
int redSize,
int greenSize,
int blueSize)
{
glitz_color_format_t *color;
int depth, i;
xglPixelFormatPtr pBestFormat = 0;
int i, rs, gs, bs, diff, bestDiff = 0;
color = &format->color;
depth = color->red_size + color->green_size + color->blue_size;
if (!visuals)
depth += color->alpha_size;
for (i = 0; i < NUM_XGL_PIXEL_FORMATS; i++)
{
if (xglPixelFormats[i].depth == depth)
{
xglPixelFormatPtr pPixel;
pPixel = &xglPixelFormats[i];
if (Ones (pPixel->masks.red_mask) == color->red_size &&
Ones (pPixel->masks.green_mask) == color->green_size &&
Ones (pPixel->masks.blue_mask) == color->blue_size)
if (visuals)
{
if (visuals)
return pPixel;
rs = Ones (xglPixelFormats[i].masks.red_mask);
gs = Ones (xglPixelFormats[i].masks.green_mask);
bs = Ones (xglPixelFormats[i].masks.blue_mask);
if (Ones (pPixel->masks.alpha_mask) == color->alpha_size)
return pPixel;
}
}
}
return NULL;
}
void
xglSetVisualTypesAndMasks (ScreenInfo *pScreenInfo,
glitz_drawable_format_t *format,
unsigned long visuals)
{
xglPixelFormatPtr pPixelFormat;
pPixelFormat = xglFindPixelFormat (format, visuals);
if (pPixelFormat)
{
if (visuals)
{
xglVisuals = xrealloc (xglVisuals,
(nxglVisuals + 1) * sizeof (xglVisualRec));
if (xglVisuals)
{
xglVisuals[nxglVisuals].format = format;
xglVisuals[nxglVisuals].pPixel = pPixelFormat;
xglVisuals[nxglVisuals].visuals = visuals;
nxglVisuals++;
}
}
}
}
void
xglInitVisuals (ScreenInfo *pScreenInfo)
{
int i, j;
for (i = 0; i < pScreenInfo->numPixmapFormats; i++)
{
unsigned long visuals;
unsigned int bitsPerRGB;
Pixel rm, gm, bm;
visuals = 0;
bitsPerRGB = 0;
rm = gm = bm = 0;
for (j = 0; j < nxglVisuals; j++)
{
if (pScreenInfo->formats[i].depth == xglVisuals[j].pPixel->depth)
{
visuals = xglVisuals[j].visuals;
bitsPerRGB = xglVisuals[j].pPixel->bitsPerRGB;
rm = xglVisuals[j].pPixel->masks.red_mask;
gm = xglVisuals[j].pPixel->masks.green_mask;
bm = xglVisuals[j].pPixel->masks.blue_mask;
fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
visuals, bitsPerRGB,
rm, gm, bm);
}
}
if (!visuals)
{
for (j = 0; j < NUM_XGL_PIXEL_FORMATS; j++)
{
if (pScreenInfo->formats[i].depth == xglPixelFormats[j].depth)
if (redSize >= rs &&
greenSize >= gs &&
blueSize >= bs)
{
bitsPerRGB = xglPixelFormats[j].bitsPerRGB;
rm = xglPixelFormats[j].masks.red_mask;
gm = xglPixelFormats[j].masks.green_mask;
bm = xglPixelFormats[j].masks.blue_mask;
break;
diff = (redSize - rs) + (greenSize - gs) + (blueSize - bs);
if (pBestFormat)
{
if (diff < bestDiff)
{
pBestFormat = &xglPixelFormats[i];
bestDiff = diff;
}
}
else
{
pBestFormat = &xglPixelFormats[i];
bestDiff = diff;
}
}
}
fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
visuals, bitsPerRGB,
rm, gm, bm);
else
{
pBestFormat = &xglPixelFormats[i];
break;
}
}
}
if (pBestFormat)
{
xglVisualPtr new, *prev, v;
unsigned int bitsPerRGB;
Pixel rm, gm, bm;
new = xalloc (sizeof (xglVisualRec));
if (!new)
return;
new->next = 0;
new->format.surface = 0;
new->format.drawable = 0;
new->pPixel = pBestFormat;
new->vid = 0;
bitsPerRGB = pBestFormat->bitsPerRGB;
rm = pBestFormat->masks.red_mask;
gm = pBestFormat->masks.green_mask;
bm = pBestFormat->masks.blue_mask;
fbSetVisualTypesAndMasks (depth, visuals, bitsPerRGB, rm, gm, bm);
for (prev = &xglVisuals; (v = *prev); prev = &v->next);
*prev = new;
}
else
{
fbSetVisualTypesAndMasks (depth, 0, 0, 0, 0, 0);
}
}
Bool
xglHasVisualTypes (xglVisualPtr pVisual,
int depth)
{
xglVisualPtr v;
for (v = pVisual; v; v = v->next)
if (v->pPixel->depth == depth)
return TRUE;
return FALSE;
}
glitz_format_t *
xglFindBestSurfaceFormat (ScreenPtr pScreen,
xglPixelFormatPtr pPixel)
{
glitz_format_t templ, *format, *best = 0;
unsigned int mask;
unsigned short rs, gs, bs, as;
int i = 0;
XGL_SCREEN_PRIV (pScreen);
rs = Ones (pPixel->masks.red_mask);
gs = Ones (pPixel->masks.green_mask);
bs = Ones (pPixel->masks.blue_mask);
as = Ones (pPixel->masks.alpha_mask);
templ.color.fourcc = GLITZ_FOURCC_RGB;
mask = GLITZ_FORMAT_FOURCC_MASK;
do {
format = glitz_find_format (pScreenPriv->drawable, mask, &templ, i++);
if (format)
{
if (format->color.red_size >= rs &&
format->color.green_size >= gs &&
format->color.blue_size >= bs &&
format->color.alpha_size >= as)
{
if (best)
{
if (((format->color.red_size - rs) +
(format->color.green_size - gs) +
(format->color.blue_size - bs)) <
((best->color.red_size - rs) +
(best->color.green_size - gs) +
(best->color.blue_size - bs)))
best = format;
}
else
{
best = format;
}
}
}
} while (format);
return best;
}
static Bool
xglInitVisual (ScreenPtr pScreen,
xglVisualPtr pVisual,
xglPixelFormatPtr pPixel,
VisualID vid)
{
glitz_format_t *format;
XGL_SCREEN_PRIV (pScreen);
format = xglFindBestSurfaceFormat (pScreen, pPixel);
if (format)
{
glitz_drawable_format_t templ;
unsigned long mask;
templ.color = format->color;
templ.depth_size = 0;
templ.stencil_size = 0;
templ.doublebuffer = 0;
templ.samples = 1;
mask =
GLITZ_FORMAT_FOURCC_MASK |
GLITZ_FORMAT_RED_SIZE_MASK |
GLITZ_FORMAT_GREEN_SIZE_MASK |
GLITZ_FORMAT_BLUE_SIZE_MASK |
GLITZ_FORMAT_ALPHA_SIZE_MASK |
GLITZ_FORMAT_DEPTH_SIZE_MASK |
GLITZ_FORMAT_STENCIL_SIZE_MASK |
GLITZ_FORMAT_DOUBLEBUFFER_MASK |
GLITZ_FORMAT_SAMPLES_MASK;
pVisual->next = 0;
pVisual->vid = vid;
pVisual->pPixel = pPixel;
pVisual->pbuffer = FALSE;
pVisual->format.surface = format;
pVisual->format.drawable =
glitz_find_drawable_format (pScreenPriv->drawable,
mask, &templ, 0);
return TRUE;
}
return FALSE;
}
static Bool
xglInitPbufferVisual (ScreenPtr pScreen,
xglVisualPtr pVisual,
xglPixelFormatPtr pPixel,
VisualID vid)
{
glitz_format_t *format;
XGL_SCREEN_PRIV (pScreen);
format = xglFindBestSurfaceFormat (pScreen, pPixel);
if (format)
{
glitz_drawable_format_t templ, *screenFormat;
unsigned long mask;
/* use same drawable format as screen for pbuffers */
screenFormat = glitz_drawable_get_format (pScreenPriv->drawable);
templ.id = screenFormat->id;
templ.color = format->color;
templ.samples = 1;
mask =
GLITZ_FORMAT_ID_MASK |
GLITZ_FORMAT_FOURCC_MASK |
GLITZ_FORMAT_RED_SIZE_MASK |
GLITZ_FORMAT_GREEN_SIZE_MASK |
GLITZ_FORMAT_BLUE_SIZE_MASK |
GLITZ_FORMAT_SAMPLES_MASK;
pVisual->next = 0;
pVisual->vid = vid;
pVisual->pPixel = pPixel;
pVisual->pbuffer = TRUE;
pVisual->format.surface = format;
pVisual->format.drawable =
glitz_find_pbuffer_format (pScreenPriv->drawable,
mask, &templ, 0);
if (pVisual->format.drawable)
return TRUE;
}
return FALSE;
}
void
xglInitVisuals (ScreenPtr pScreen)
{
xglVisualPtr pVisual, v, new, *prev;
int i;
XGL_SCREEN_PRIV (pScreen);
for (i = 0; i < pScreen->numVisuals; i++)
{
for (pVisual = xglVisuals; pVisual; pVisual = pVisual->next)
if (pVisual->pPixel->depth == pScreen->visuals[i].nplanes)
break;
if (pVisual)
{
new = xalloc (sizeof (xglVisualRec));
if (new)
{
if (xglInitVisual (pScreen, new, pVisual->pPixel,
pScreen->visuals[i].vid))
{
new->next = 0;
prev = &pScreenPriv->pVisual;
while ((v = *prev))
prev = &v->next;
*prev = new;
}
else
{
xfree (new);
}
}
new = xalloc (sizeof (xglVisualRec));
if (new)
{
if (xglInitPbufferVisual (pScreen, new, pVisual->pPixel,
pScreen->visuals[i].vid))
{
new->next = 0;
prev = &pScreenPriv->pVisual;
while ((v = *prev))
prev = &v->next;
*prev = new;
}
else
{
xfree (new);
}
}
}
}
/* Add additional Xgl visuals for pixmap formats */
for (i = 0; i < screenInfo.numPixmapFormats; i++)
{
if (!xglHasVisualTypes (pScreenPriv->pVisual,
screenInfo.formats[i].depth))
{
for (v = xglVisuals; v; v = v->next)
if (v->pPixel->depth == screenInfo.formats[i].depth)
break;
if (v)
{
new = xalloc (sizeof (xglVisualRec));
if (new)
{
if (xglInitVisual (pScreen, new, v->pPixel, 0))
{
new->next = 0;
prev = &pScreenPriv->pVisual;
while ((v = *prev))
prev = &v->next;
*prev = new;
}
else
{
xfree (new);
}
}
}
}
}
}
xglVisualPtr
xglFindVisualWithDepth (ScreenPtr pScreen,
int depth)
{
xglVisualPtr v;
XGL_SCREEN_PRIV (pScreen);
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->pPixel->depth == depth)
return v;
}
return 0;
}
xglVisualPtr
xglFindVisualWithId (ScreenPtr pScreen,
int vid)
{
xglVisualPtr v;
XGL_SCREEN_PRIV (pScreen);
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->vid == vid)
return v;
}
return 0;
}
void
xglClearVisualTypes (void)
{
nxglVisuals = 0;
nxglPbufferVisuals = 0;
xglVisualPtr v;
if (xglVisuals)
xfree (xglVisuals);
if (xglPbufferVisuals)
xfree (xglPbufferVisuals);
xglVisuals = NULL;
xglPbufferVisuals = NULL;
while (xglVisuals)
{
v = xglVisuals;
xglVisuals = v->next;
xfree (v);
}
miClearVisualTypes ();
}
void
xglInitPixmapFormats (ScreenPtr pScreen)
{
glitz_format_t *format, **best;
int i, j;
XGL_SCREEN_PRIV (pScreen);
for (i = 0; i < 33; i++)
{
pScreenPriv->pixmapFormats[i].pPixel = NULL;
pScreenPriv->pixmapFormats[i].format = NULL;
for (j = 0; j < NUM_XGL_PIXEL_FORMATS; j++)
{
if (xglPixelFormats[j].depth == i)
{
int rs, gs, bs, as, k;
pScreenPriv->pixmapFormats[i].pPixel = &xglPixelFormats[j];
pScreenPriv->pixmapFormats[i].format = NULL;
best = &pScreenPriv->pixmapFormats[i].format;
rs = Ones (xglPixelFormats[j].masks.red_mask);
gs = Ones (xglPixelFormats[j].masks.green_mask);
bs = Ones (xglPixelFormats[j].masks.blue_mask);
as = Ones (xglPixelFormats[j].masks.alpha_mask);
k = 0;
do {
format = glitz_find_format (pScreenPriv->drawable,
0, NULL, k++);
if (format && format->color.fourcc == GLITZ_FOURCC_RGB)
{
/* find best matching sufficient format */
if (format->color.red_size >= rs &&
format->color.green_size >= gs &&
format->color.blue_size >= bs &&
format->color.alpha_size >= as)
{
if (*best)
{
if (((format->color.red_size - rs) +
(format->color.green_size - gs) +
(format->color.blue_size - bs)) <
(((*best)->color.red_size - rs) +
((*best)->color.green_size - gs) +
((*best)->color.blue_size - bs)))
*best = format;
} else
*best = format;
}
}
} while (format);
}
}
}
}
#define PIXEL_TO_COLOR(p, mask) \
(((uint32_t) ((((uint64_t) (((uint32_t) (p)) & (mask))) * 0xffffffff) / \
((uint64_t) (mask)))))
#define PIXEL_TO_RGB_COLOR(p, mask) \
((mask)? PIXEL_TO_COLOR (p, mask): 0)
void
xglPixelToColor (xglPixelFormatPtr pFormat,
CARD32 pixel,
glitz_color_t *color)
{
color->red = PIXEL_TO_RGB_COLOR (pixel, pFormat->masks.red_mask);
color->green = PIXEL_TO_RGB_COLOR (pixel, pFormat->masks.green_mask);
color->blue = PIXEL_TO_RGB_COLOR (pixel, pFormat->masks.blue_mask);
if (pFormat->masks.alpha_mask)
color->alpha = PIXEL_TO_COLOR (pixel, pFormat->masks.alpha_mask);
else
color->alpha = 0xffff;
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -48,56 +48,64 @@ static glitz_operator_t xglOperators[] = {
#define XGL_OPERATOR(op) (xglOperators[op])
#define XGL_GET_SOURCE_PICTURE(pPicture, outSurface) \
(outSurface) = ((pPicture)->pDrawable) ? \
XGL_GET_PIXMAP_PRIV ((PixmapPtr) (pPicture)->pDrawable)->surface : \
(glitz_surface_t *) (pPicture)->pSourcePict->source.devPrivate.ptr
Bool
xglComp (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height,
xglGeometryPtr pGeometry,
glitz_surface_t *mask)
xglCompositeGeneral (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
xglGeometryPtr pGeometry,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height)
{
ScreenPtr pScreen = pDst->pDrawable->pScreen;
xglPixmapPtr pSrcPriv;
glitz_surface_t *src, *dst;
INT16 xOff, yOff;
glitz_surface_t *src, *mask = NULL, *dst;
int dstXoff, dstYoff;
RegionRec region;
BoxPtr pBox;
BoxPtr pBox, pExt;
int nBox;
if (pDst->alphaMap)
return FALSE;
if (op >= NUM_XGL_OPERATORS)
return FALSE;
if (pSrc->pSourcePict)
return FALSE;
if (pSrc->pDrawable)
{
if (pSrc->pDrawable->type != DRAWABLE_PIXMAP)
return FALSE;
if (pSrc->pDrawable->type != DRAWABLE_PIXMAP)
return FALSE;
if (pSrc->pDrawable->bitsPerPixel == 1)
return FALSE;
if (pSrc->pDrawable->bitsPerPixel == 1)
return FALSE;
}
if (pMask)
{
if (pMask->pSourcePict)
return FALSE;
if (pMask->pDrawable->type != DRAWABLE_PIXMAP)
return FALSE;
if (pMask->pDrawable)
{
if (pMask->pDrawable->type != DRAWABLE_PIXMAP)
return FALSE;
if (pSrc->pDrawable == pMask->pDrawable && pSrc != pMask)
return FALSE;
if (pSrc->pDrawable == pMask->pDrawable && pSrc != pMask)
return FALSE;
}
}
if (!xglPrepareTarget (pDst->pDrawable))
return FALSE;
if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
xSrc, ySrc, xMask, yMask,
xDst, yDst, width, height))
@ -105,33 +113,30 @@ xglComp (CARD8 op,
pBox = REGION_RECTS (&region);
nBox = REGION_NUM_RECTS (&region);
if (!xglPrepareTarget (pDst->pDrawable))
{
REGION_UNINIT (pScreen, &region);
return FALSE;
}
pExt = REGION_EXTENTS (pScreen, &region);
XGL_GET_DRAWABLE (pDst->pDrawable, dst, dstXoff, dstYoff);
if (!xglSyncSurface (pSrc->pDrawable))
if (!xglSyncPicture (pScreen, pSrc,
pExt->x1 + xSrc - xDst,
pExt->y1 + ySrc - yDst,
pExt->x2 - pExt->x1,
pExt->y2 - pExt->y1,
&xOff, &yOff))
{
REGION_UNINIT (pScreen, &region);
return FALSE;
}
pSrcPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
if (XGL_PICTURE_CHANGES (pSrcPriv->pictureMask))
xglUpdatePicture (pSrc);
src = pSrcPriv->surface;
xSrc -= xOff;
ySrc -= yOff;
XGL_GET_SOURCE_PICTURE (pSrc, src);
if (pMask)
{
xglPixmapPtr pMaskPriv;
/* bitmap as mask */
if (pMask->pDrawable->bitsPerPixel == 1)
if (pMask->pDrawable && pMask->pDrawable->bitsPerPixel == 1)
{
if (pGeometry)
{
@ -139,10 +144,9 @@ xglComp (CARD8 op,
return FALSE;
}
pGeometry =
xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
xDst - xMask,
yDst - yMask);
pGeometry = xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
xDst - xMask,
yDst - yMask);
if (!pGeometry)
{
REGION_UNINIT (pScreen, &region);
@ -151,17 +155,21 @@ xglComp (CARD8 op,
}
else
{
if (!xglSyncSurface (pMask->pDrawable))
if (!xglSyncPicture (pScreen, pMask,
pExt->x1 + xMask - xDst,
pExt->y1 + yMask - yDst,
pExt->x2 - pExt->x1,
pExt->y2 - pExt->y1,
&xOff, &yOff))
{
REGION_UNINIT (pScreen, &region);
return FALSE;
}
pMaskPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pMask->pDrawable);
if (XGL_PICTURE_CHANGES (pMaskPriv->pictureMask))
xglUpdatePicture (pMask);
mask = pMaskPriv->surface;
xMask -= xOff;
yMask -= yOff;
XGL_GET_SOURCE_PICTURE (pMask, mask);
}
}
@ -169,10 +177,12 @@ xglComp (CARD8 op,
{
if (!pSrc->transform && pSrc->filter != PictFilterConvolution)
{
if (pSrc->repeat)
if (pSrc->pDrawable && pSrc->repeat == RepeatNormal)
{
XGL_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
/* tile */
if (!pSrcPriv->acceleratedTile)
if (!pPixmapPriv->acceleratedTile)
{
pGeometry =
xglTiledBoxGeometry ((PixmapPtr) pSrc->pDrawable,
@ -183,8 +193,8 @@ xglComp (CARD8 op,
REGION_UNINIT (pScreen, &region);
return FALSE;
}
pBox = REGION_EXTENTS (pScreen, &region);
pBox = pExt;
nBox = 1;
}
}
@ -210,10 +220,10 @@ xglComp (CARD8 op,
if (nBox > 1)
{
pGeometry = xglGetScratchVertexGeometry (pScreen, 4 * nBox);
GEOMETRY_ADD_BOX (pScreen, pGeometry, pBox, nBox);
pBox = REGION_EXTENTS (pScreen, &region);
pBox = pExt;
}
xSrc += pBox->x1 - xDst;
@ -224,10 +234,10 @@ xglComp (CARD8 op,
xMask += pBox->x1 - xDst;
yMask += pBox->y1 - yDst;
}
xDst = pBox->x1;
yDst = pBox->y1;
width = pBox->x2 - pBox->x1;
height = pBox->y2 - pBox->y1;
}
@ -244,10 +254,11 @@ xglComp (CARD8 op,
if (!GEOMETRY_ENABLE (pGeometry, dst))
{
REGION_UNINIT (pScreen, &region);
REGION_UNINIT (pScreen, &region);
return FALSE;
}
} else
}
else
GEOMETRY_DISABLE (dst);
glitz_composite (XGL_OPERATOR (op),
@ -260,10 +271,10 @@ xglComp (CARD8 op,
glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
REGION_UNINIT (pScreen, &region);
if (glitz_surface_get_status (dst))
return FALSE;
return TRUE;
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -38,6 +38,8 @@ xglCopy (DrawablePtr pSrc,
int srcXoff, srcYoff;
int dstXoff, dstYoff;
XGL_DRAWABLE_PIXMAP (pDst);
if (!nBox)
return TRUE;
@ -50,11 +52,11 @@ xglCopy (DrawablePtr pSrc,
{
if (!xglPrepareTarget (pSrc))
return FALSE;
if (!xglSyncSurface (pDst))
return FALSE;
}
XGL_GET_DRAWABLE (pSrc, src, srcXoff, srcYoff);
XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff);
@ -64,18 +66,18 @@ xglCopy (DrawablePtr pSrc,
glitz_copy_area (src,
dst,
pDst->x + srcXoff + dx,
pDst->y + srcYoff + dy,
pDst->width,
pDst->height,
pDst->x + dstXoff,
pDst->y + dstYoff);
srcXoff + dx,
srcYoff + dy,
pPixmap->drawable.width - dstXoff,
pPixmap->drawable.height - dstYoff,
dstXoff,
dstYoff);
glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
if (glitz_surface_get_status (dst))
return FALSE;
return TRUE;
}
@ -96,24 +98,16 @@ xglCopyProc (DrawablePtr pSrc,
if (!xglCopy (pSrc, pDst, dx, dy, pBox, nBox))
{
RegionPtr pDamageRegion;
glitz_surface_t *dst;
int dstXoff, dstYoff;
RegionRec region;
BoxRec box;
RegionRec region;
XGL_DRAWABLE_PIXMAP (pDst);
XGL_PIXMAP_PRIV (pPixmap);
XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff);
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
if (!xglSyncBits (pSrc, pSrcBox))
FatalError (XGL_SW_FAILURE_STRING);
if (!xglMapPixmapBits (pPixmap))
FatalError (XGL_SW_FAILURE_STRING);
if (!xglSyncBits (pSrc, pSrcBox))
FatalError (XGL_SW_FAILURE_STRING);
fbCopyNtoN (pSrc, pDst, pGC,
pBox, nBox,
@ -122,19 +116,11 @@ xglCopyProc (DrawablePtr pSrc,
(void *) 0);
pPixmapPriv->damageBox = miEmptyBox;
if (!pPixmapPriv->format)
return;
while (nBox--)
{
box.x1 = pBox->x1 + dstXoff;
box.y1 = pBox->y1 + dstYoff;
box.x2 = pBox->x2 + dstXoff;
box.y2 = pBox->y2 + dstYoff;
REGION_INIT (pDst->pScreen, &region, &box, 1);
REGION_UNION (pDst->pScreen,
pDamageRegion, pDamageRegion, &region);
REGION_INIT (pDst->pScreen, &region, pBox, 1);
xglAddSurfaceDamage (pDst, &region);
REGION_UNINIT (pDst->pScreen, &region);
pBox++;

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -31,7 +31,7 @@ Bool
xglFill (DrawablePtr pDrawable,
GCPtr pGC,
xglGeometryPtr pGeometry,
int x,
int x,
int y,
int width,
int height,
@ -43,7 +43,7 @@ xglFill (DrawablePtr pDrawable,
switch (pGC->fillStyle) {
case FillSolid:
if (xglSolid (pDrawable,
pGCPriv->op, &pGCPriv->fg,
pGCPriv->op, pGCPriv->fg,
pGeometry,
x, y,
width, height,
@ -70,26 +70,21 @@ xglFill (DrawablePtr pDrawable,
}
static void
xglFillBox (DrawablePtr pDrawable,
xglFillBox (DrawablePtr pDrawable,
GCPtr pGC,
int x,
int x,
int y,
int width,
int height,
BoxPtr pBox,
int nBox)
{
BoxRec box;
if (!nBox)
return;
return;
if (!xglFill (pDrawable, pGC, NULL, x, y, width, height, pBox, nBox))
{
RegionRec region;
RegionPtr pDamageRegion;
glitz_surface_t *surface;
int xOff, yOff;
RegionRec region;
XGL_DRAWABLE_PIXMAP (pDrawable);
XGL_PIXMAP_PRIV (pPixmap);
@ -111,31 +106,18 @@ xglFillBox (DrawablePtr pDrawable,
break;
}
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
pPixmapPriv->damageBox = miEmptyBox;
while (nBox--)
{
fbFill (pDrawable, pGC,
pBox->x1, pBox->y1,
pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
if (pPixmapPriv->format)
{
box.x1 = pBox->x1 + xOff;
box.y1 = pBox->y1 + yOff;
box.x2 = pBox->x2 + xOff;
box.y2 = pBox->y2 + yOff;
REGION_INIT (pDrawable->pScreen, &region, &box, 1);
REGION_UNION (pDrawable->pScreen,
pDamageRegion, pDamageRegion, &region);
REGION_UNINIT (pDrawable->pScreen, &region);
}
REGION_INIT (pDrawable->pScreen, &region, pBox, 1);
xglAddSurfaceDamage (pDrawable, &region);
REGION_UNINIT (pDrawable->pScreen, &region);
pBox++;
}
} else
@ -150,11 +132,11 @@ xglMoreBoxes (BoxPtr stackBox,
int nBoxes)
{
Bool stack = !heapBox;
heapBox = xrealloc (heapBox, sizeof (BoxRec) * nBoxes);
if (!heapBox)
return NULL;
if (stack)
memcpy (heapBox, stackBox, sizeof (BoxRec) * N_STACK_BOX);
@ -182,8 +164,8 @@ xglMoreBoxes (BoxPtr stackBox,
}
void
xglFillRect (DrawablePtr pDrawable,
GCPtr pGC,
xglFillRect (DrawablePtr pDrawable,
GCPtr pGC,
int nrect,
xRectangle *prect)
{
@ -205,19 +187,19 @@ xglFillRect (DrawablePtr pDrawable,
full.y2 = full.y1 + (int) prect->height;
prect++;
if (full.x1 < pExtent->x1)
full.x1 = pExtent->x1;
if (full.y1 < pExtent->y1)
full.y1 = pExtent->y1;
full.y1 = pExtent->y1;
if (full.x2 > pExtent->x2)
full.x2 = pExtent->x2;
if (full.y2 > pExtent->y2)
full.y2 = pExtent->y2;
if (full.x1 >= full.x2 || full.y1 >= full.y2)
continue;
nClip = REGION_NUM_RECTS (pClip);
if (nClip == 1)
{
@ -238,7 +220,7 @@ xglFillRect (DrawablePtr pDrawable,
part.x2 = full.x2;
if (part.y2 > full.y2)
part.y2 = full.y2;
if (part.x1 < part.x2 && part.y1 < part.y2)
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
}
@ -249,7 +231,7 @@ xglFillRect (DrawablePtr pDrawable,
pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
(heapBox) ? heapBox : stackBox, nBox);
if (heapBox)
xfree (heapBox);
}
@ -280,19 +262,19 @@ xglFillSpan (DrawablePtr pDrawable,
pwidth++;
ppt++;
if (full.x1 < pExtent->x1)
full.x1 = pExtent->x1;
if (full.y1 < pExtent->y1)
full.y1 = pExtent->y1;
full.y1 = pExtent->y1;
if (full.x2 > pExtent->x2)
full.x2 = pExtent->x2;
if (full.y2 > pExtent->y2)
full.y2 = pExtent->y2;
if (full.x1 >= full.x2 || full.y1 >= full.y2)
continue;
nClip = REGION_NUM_RECTS (pClip);
if (nClip == 1)
{
@ -313,7 +295,7 @@ xglFillSpan (DrawablePtr pDrawable,
part.x2 = full.x2;
if (part.y2 > full.y2)
part.y2 = full.y2;
if (part.x1 < part.x2 && part.y1 < part.y2)
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
}
@ -324,7 +306,7 @@ xglFillSpan (DrawablePtr pDrawable,
pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
(heapBox) ? heapBox : stackBox, nBox);
if (heapBox)
xfree (heapBox);
}
@ -346,28 +328,28 @@ xglFillLine (DrawablePtr pDrawable,
xglGeometryPtr pGeometry;
XGL_SCREEN_PRIV (pGC->pScreen);
if (npt < 2)
return TRUE;
pt = *ppt;
nptTmp = npt - 1;
pptTmp = ppt + 1;
if (mode == CoordModePrevious)
{
while (nptTmp--)
{
if (pptTmp->x && pptTmp->y)
horizontalAndVertical = FALSE;
pt.x += pptTmp->x;
pt.y += pptTmp->y;
pptTmp++;
}
if (pt.x == ppt->x && pt.y == ppt->y)
coincidentEndpoints = TRUE;
}
@ -383,7 +365,7 @@ xglFillLine (DrawablePtr pDrawable,
pt = *pptTmp++;
}
if (ppt[npt - 1].x == ppt->x && ppt[npt - 1].y == ppt->y)
coincidentEndpoints = TRUE;
}
@ -403,7 +385,7 @@ xglFillLine (DrawablePtr pDrawable,
ppt++;
npt--;
while (npt--)
{
if (mode == CoordModePrevious)
@ -416,13 +398,13 @@ xglFillLine (DrawablePtr pDrawable,
dx = ppt->x - pt.x;
dy = ppt->y - pt.y;
}
if (dx)
{
if (dx > 0)
{
full.x1 = pt.x + pDrawable->x;
if (npt || coincidentEndpoints)
full.x2 = full.x1 + dx;
else
@ -437,7 +419,7 @@ xglFillLine (DrawablePtr pDrawable,
else
full.x1 = full.x2 + dx - 1;
}
full.y1 = pt.y + pDrawable->y;
full.y2 = full.y1 + 1;
}
@ -446,7 +428,7 @@ xglFillLine (DrawablePtr pDrawable,
if (dy > 0)
{
full.y1 = pt.y + pDrawable->y;
if (npt || coincidentEndpoints)
full.y2 = full.y1 + dy;
else
@ -461,28 +443,28 @@ xglFillLine (DrawablePtr pDrawable,
else
full.y1 = full.y2 + dy - 1;
}
full.x1 = pt.x + pDrawable->x;
full.x2 = full.x1 + 1;
}
pt.x += dx;
pt.y += dy;
ppt++;
if (full.x1 < pExtent->x1)
full.x1 = pExtent->x1;
if (full.y1 < pExtent->y1)
full.y1 = pExtent->y1;
full.y1 = pExtent->y1;
if (full.x2 > pExtent->x2)
full.x2 = pExtent->x2;
if (full.y2 > pExtent->y2)
full.y2 = pExtent->y2;
if (full.x1 >= full.x2 || full.y1 >= full.y2)
continue;
nClip = REGION_NUM_RECTS (pClip);
if (nClip == 1)
{
@ -503,7 +485,7 @@ xglFillLine (DrawablePtr pDrawable,
part.x2 = full.x2;
if (part.y2 > full.y2)
part.y2 = full.y2;
if (part.x1 < part.x2 && part.y1 < part.y2)
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
}
@ -514,7 +496,7 @@ xglFillLine (DrawablePtr pDrawable,
pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
(heapBox) ? heapBox : stackBox, nBox);
if (heapBox)
xfree (heapBox);
@ -526,9 +508,9 @@ xglFillLine (DrawablePtr pDrawable,
if (coincidentEndpoints)
npt--;
pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, npt);
GEOMETRY_ADD_LINE (pGC->pScreen, pGeometry,
coincidentEndpoints, mode, npt, ppt);
@ -539,24 +521,27 @@ xglFillLine (DrawablePtr pDrawable,
/* Lines need a 0.5 translate */
GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip);
if (xglFill (pDrawable, pGC, pGeometry,
pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
REGION_RECTS (pGC->pCompositeClip),
REGION_NUM_RECTS (pGC->pCompositeClip)))
{
xglAddCurrentBitDamage (pDrawable);
return TRUE;
}
return FALSE;
}
Bool
xglFillSegment (DrawablePtr pDrawable,
GCPtr pGC,
GCPtr pGC,
int nSegInit,
xSegment *pSegInit)
{
@ -632,19 +617,19 @@ xglFillSegment (DrawablePtr pDrawable,
}
pSegInit++;
if (full.x1 < pExtent->x1)
full.x1 = pExtent->x1;
if (full.y1 < pExtent->y1)
full.y1 = pExtent->y1;
full.y1 = pExtent->y1;
if (full.x2 > pExtent->x2)
full.x2 = pExtent->x2;
if (full.y2 > pExtent->y2)
full.y2 = pExtent->y2;
if (full.x1 >= full.x2 || full.y1 >= full.y2)
continue;
nClip = REGION_NUM_RECTS (pClip);
if (nClip == 1)
{
@ -665,7 +650,7 @@ xglFillSegment (DrawablePtr pDrawable,
part.x2 = full.x2;
if (part.y2 > full.y2)
part.y2 = full.y2;
if (part.x1 < part.x2 && part.y1 < part.y2)
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
}
@ -676,7 +661,7 @@ xglFillSegment (DrawablePtr pDrawable,
pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
(heapBox) ? heapBox : stackBox, nBox);
if (heapBox)
xfree (heapBox);
@ -685,24 +670,27 @@ xglFillSegment (DrawablePtr pDrawable,
if (!pScreenPriv->lines)
return FALSE;
pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, 2 * nSegInit);
GEOMETRY_ADD_SEGMENT (pGC->pScreen, pGeometry, nSegInit, pSegInit);
/* Line segments need 0.5 translate */
GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINES);
GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
if (xglFill (pDrawable, pGC, pGeometry,
pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
REGION_RECTS (pGC->pCompositeClip),
REGION_NUM_RECTS (pGC->pCompositeClip)))
{
xglAddCurrentBitDamage (pDrawable);
return TRUE;
}
return FALSE;
}
@ -745,9 +733,10 @@ xglFillGlyph (DrawablePtr pDrawable,
REGION_NUM_RECTS (pGC->pCompositeClip)))
{
GEOMETRY_UNINIT (&geometry);
xglAddCurrentBitDamage (pDrawable);
return TRUE;
}
GEOMETRY_UNINIT (&geometry);
return FALSE;
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -58,7 +58,7 @@ static const GCFuncs xglGCFuncs = {
xglValidateGC,
miChangeGC,
miCopyGC,
miDestroyGC,
xglDestroyGC,
miChangeClip,
miDestroyClip,
miCopyClip
@ -123,7 +123,7 @@ xglSetSpans (DrawablePtr pDrawable,
int fSorted)
{
XGL_GC_PRIV (pGC);
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -163,7 +163,7 @@ xglPutImage (DrawablePtr pDrawable,
XGL_GC_UNWRAP (funcs);
XGL_GC_UNWRAP (ops);
(*pGC->ops->PutImage) (pDrawable, pGC, depth,
x, y, w, h, leftPad, format, bits);
@ -174,7 +174,7 @@ xglPutImage (DrawablePtr pDrawable,
box.y1 = pDrawable->y + y;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
REGION_INIT (pDrawable->pScreen, &region, &box, 1);
REGION_INTERSECT (pDrawable->pScreen, &region, pClip, &region);
@ -197,7 +197,7 @@ xglCopyArea (DrawablePtr pSrc,
{
RegionPtr pRegion;
BoxRec box;
XGL_GC_PRIV (pGC);
box.x1 = pSrc->x + srcX;
@ -205,11 +205,11 @@ xglCopyArea (DrawablePtr pSrc,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
if (pGC->alu != GXcopy || (pGCPriv->flags &= ~xglGCReadOnlyDrawableFlag))
if (pGC->alu != GXcopy || pGCPriv->flags)
{
if (!xglSyncBits (pSrc, &box))
FatalError (XGL_SW_FAILURE_STRING);
XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
pRegion = (*pGC->ops->CopyArea) (pSrc, pDst, pGC,
srcX, srcY, w, h, dstX, dstY);
@ -243,14 +243,14 @@ xglCopyPlane (DrawablePtr pSrc,
{
RegionPtr pRegion;
BoxRec box;
XGL_GC_PRIV (pGC);
box.x1 = pSrc->x + srcX;
box.y1 = pSrc->y + srcY;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
if (!xglSyncBits (pSrc, &box))
FatalError (XGL_SW_FAILURE_STRING);
@ -293,13 +293,10 @@ xglPolylines (DrawablePtr pDrawable,
if (pGC->lineStyle == LineSolid)
{
if (xglFillLine (pDrawable, pGC, mode, npt, ppt))
{
xglAddCurrentBitDamage (pDrawable);
return;
}
}
}
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppt);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -315,7 +312,7 @@ xglPolylines (DrawablePtr pDrawable,
void
xglPolySegment (DrawablePtr pDrawable,
GCPtr pGC,
GCPtr pGC,
int nsegInit,
xSegment *pSegInit)
{
@ -328,10 +325,7 @@ xglPolySegment (DrawablePtr pDrawable,
if (pGC->lineStyle == LineSolid)
{
if (xglFillSegment (pDrawable, pGC, nsegInit, pSegInit))
{
xglAddCurrentBitDamage (pDrawable);
return;
}
}
}
@ -344,14 +338,14 @@ xglPolySegment (DrawablePtr pDrawable,
void
xglPolyArc (DrawablePtr pDrawable,
GCPtr pGC,
GCPtr pGC,
int narcs,
xArc *pArcs)
{
if (pGC->lineWidth == 0)
{
XGL_GC_PRIV (pGC);
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PolyArc) (pDrawable, pGC, narcs, pArcs);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -367,7 +361,7 @@ xglPolyFillRect (DrawablePtr pDrawable,
{
XGL_GC_PRIV (pGC);
if (pGCPriv->flags || pGC->fillStyle == FillStippled)
if (pGC->fillStyle == FillStippled || pGCPriv->flags)
{
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrect, prect);
@ -382,12 +376,12 @@ xglPolyFillRect (DrawablePtr pDrawable,
void
xglPolyFillArc (DrawablePtr pDrawable,
GCPtr pGC,
GCPtr pGC,
int narcs,
xArc *pArcs)
{
XGL_GC_PRIV (pGC);
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, pArcs);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -404,7 +398,7 @@ xglImageGlyphBlt (DrawablePtr pDrawable,
{
XGL_GC_PRIV (pGC);
if (!(pGCPriv->flags & ~xglGCBadFunctionFlag))
if (!pGCPriv->flags)
{
if (xglSolidGlyph (pDrawable,
pGC,
@ -413,10 +407,7 @@ xglImageGlyphBlt (DrawablePtr pDrawable,
nglyph,
ppci,
pglyphBase))
{
xglAddCurrentBitDamage (pDrawable);
return;
}
}
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
@ -445,12 +436,9 @@ xglPolyGlyphBlt (DrawablePtr pDrawable,
nglyph,
ppci,
pglyphBase))
{
xglAddCurrentBitDamage (pDrawable);
return;
}
}
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -469,7 +457,7 @@ xglPushPixels (GCPtr pGC,
if (!xglSyncBits (&pBitmap->drawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING);
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PushPixels) (pGC, pBitmap, pDrawable, w, h, x, y);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -478,10 +466,9 @@ xglPushPixels (GCPtr pGC,
Bool
xglCreateGC (GCPtr pGC)
{
static glitz_color_t black = { 0x0, 0x0, 0x0, 0xffff };
ScreenPtr pScreen = pGC->pScreen;
Bool ret;
ScreenPtr pScreen = pGC->pScreen;
Bool ret;
XGL_SCREEN_PRIV (pScreen);
XGL_GC_PRIV (pGC);
@ -491,15 +478,35 @@ xglCreateGC (GCPtr pGC)
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
pGCPriv->flags = 0;
pGCPriv->op = GLITZ_OPERATOR_SRC;
pGCPriv->fg = black;
pGCPriv->bg = black;
pGCPriv->fg = NULL;
pGCPriv->bg = NULL;
pGCPriv->id = ~0;
return ret;
}
void
xglDestroyGC (GCPtr pGC)
{
XGL_GC_PRIV (pGC);
if (pGCPriv->fg)
glitz_surface_destroy (pGCPriv->fg);
if (pGCPriv->bg)
glitz_surface_destroy (pGCPriv->bg);
XGL_GC_UNWRAP (funcs);
XGL_GC_UNWRAP (ops);
(*pGC->funcs->DestroyGC) (pGC);
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
}
void
xglValidateGC (GCPtr pGC,
unsigned long changes,
@ -509,12 +516,12 @@ xglValidateGC (GCPtr pGC,
if (changes & GCTile)
{
if (!pGC->tileIsPixel &&
if (!pGC->tileIsPixel &&
FbEvenTile (pGC->tile.pixmap->drawable.width *
pDrawable->bitsPerPixel))
xglSyncBits (&pGC->tile.pixmap->drawable, NULL);
}
if (changes & GCStipple)
{
if (pGC->stipple)
@ -530,16 +537,45 @@ xglValidateGC (GCPtr pGC,
if (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
{
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if (pPixmapPriv->format)
pGCPriv->flags &= ~xglGCSoftwareDrawableFlag;
if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
{
glitz_format_t *format;
format = pPixmapPriv->pVisual->format.surface;
if (format->id != pGCPriv->id)
{
XGL_SCREEN_PRIV (pDrawable->pScreen);
pGCPriv->flags |= xglGCSoftwareDrawableFlag;
if (pGCPriv->fg)
glitz_surface_destroy (pGCPriv->fg);
pGCPriv->fg = glitz_surface_create (pScreenPriv->drawable,
format, 1, 1, 0, NULL);
if (pGCPriv->fg)
glitz_surface_set_fill (pGCPriv->fg, GLITZ_FILL_REPEAT);
if (pGCPriv->bg)
glitz_surface_destroy (pGCPriv->bg);
pGCPriv->bg = glitz_surface_create (pScreenPriv->drawable,
format, 1, 1, 0, NULL);
if (pGCPriv->bg)
glitz_surface_set_fill (pGCPriv->bg, GLITZ_FILL_REPEAT);
pGCPriv->id = format->id;
if (pGCPriv->fg && pGCPriv->bg)
{
changes |= (GCForeground | GCBackground);
pGCPriv->flags &= ~xglGCSoftwareDrawableFlag;
}
}
}
else
pGCPriv->flags |= xglGCSoftwareDrawableFlag;
if (pPixmapPriv->target)
pGCPriv->flags &= ~xglGCReadOnlyDrawableFlag;
else
pGCPriv->flags |= xglGCReadOnlyDrawableFlag;
}
if (changes & GCFunction)
@ -568,21 +604,45 @@ xglValidateGC (GCPtr pGC,
FbBits mask;
mask = FbFullMask (pDrawable->depth);
if ((pGC->planemask & mask) != mask)
pGCPriv->flags |= xglGCPlaneMaskFlag;
else
pGCPriv->flags &= ~xglGCPlaneMaskFlag;
}
if (changes & (GCForeground | GCBackground))
if (!(pGCPriv->flags & xglGCSoftwareDrawableFlag))
{
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if (pPixmapPriv->pPixel)
if (changes & (GCForeground | GCBackground))
{
xglPixelToColor (pPixmapPriv->pPixel, pGC->fgPixel, &pGCPriv->fg);
xglPixelToColor (pPixmapPriv->pPixel, pGC->bgPixel, &pGCPriv->bg);
glitz_pixel_format_t format;
glitz_buffer_t *buffer;
CARD32 pixel;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
format.fourcc = GLITZ_FOURCC_RGB;
format.masks = pPixmapPriv->pVisual->pPixel->masks;
format.xoffset = 0;
format.skip_lines = 0;
format.bytes_per_line = sizeof (CARD32);
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
buffer = glitz_buffer_create_for_data (&pixel);
if (changes & GCForeground)
{
pixel = pGC->fgPixel;
glitz_set_pixels (pGCPriv->fg, 0, 0, 1, 1, &format, buffer);
}
if (changes & GCBackground)
{
pixel = pGC->bgPixel;
glitz_set_pixels (pGCPriv->bg, 0, 0, 1, 1, &format, buffer);
}
glitz_buffer_destroy (buffer);
}
}
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -44,7 +44,7 @@ xglGeometryResize (ScreenPtr pScreen,
int size)
{
XGL_SCREEN_PRIV (pScreen);
if (size == pGeometry->size)
return;
@ -54,12 +54,12 @@ xglGeometryResize (ScreenPtr pScreen,
if (pGeometry->usage == GEOMETRY_USAGE_SYSMEM)
{
pGeometry->data = xrealloc (pGeometry->data, size);
if (pGeometry->buffer)
glitz_buffer_destroy (pGeometry->buffer);
pGeometry->buffer = NULL;
if (pGeometry->data)
{
pGeometry->buffer = glitz_buffer_create_for_data (pGeometry->data);
@ -78,6 +78,7 @@ xglGeometryResize (ScreenPtr pScreen,
else
{
glitz_buffer_t *newBuffer;
if (size)
{
newBuffer =
@ -90,29 +91,29 @@ xglGeometryResize (ScreenPtr pScreen,
}
} else
newBuffer = NULL;
if (pGeometry->buffer && newBuffer)
{
void *oldData, *newData;
oldData = glitz_buffer_map (pGeometry->buffer,
GLITZ_BUFFER_ACCESS_READ_ONLY);
newData = glitz_buffer_map (newBuffer,
GLITZ_BUFFER_ACCESS_WRITE_ONLY);
if (oldData && newData)
memcpy (newData, oldData, MIN (size, pGeometry->size));
glitz_buffer_unmap (pGeometry->buffer);
glitz_buffer_unmap (newBuffer);
glitz_buffer_destroy (pGeometry->buffer);
}
pGeometry->buffer = newBuffer;
}
pGeometry->size = size;
if (pGeometry->endOffset > size)
pGeometry->endOffset = size;
}
@ -149,7 +150,7 @@ xglGeometryResize (ScreenPtr pScreen,
(pGeometry)->count = (pGeometry)->endOffset / \
(2 * xglGeometryDataTypes[(pGeometry)->dataType].size); \
}
/*
* Adds a number of boxes as GL_QUAD primitives
*/
@ -167,7 +168,7 @@ xglGeometryAddBox (ScreenPtr pScreen,
return;
MAP_GEOMETRY (pScreen, pGeometry, offset, nBox * 8, ptr, size);
switch (pGeometry->dataType) {
case GEOMETRY_DATA_TYPE_SHORT:
{
@ -190,7 +191,7 @@ xglGeometryAddBox (ScreenPtr pScreen,
case GEOMETRY_DATA_TYPE_FLOAT:
{
glitz_float_t *data = (glitz_float_t *) ptr;
while (nBox--)
{
*data++ = (glitz_float_t) pBox->x1;
@ -228,7 +229,7 @@ xglGeometryAddSpan (ScreenPtr pScreen,
return;
MAP_GEOMETRY (pScreen, pGeometry, offset, n * 4, ptr, size);
switch (pGeometry->dataType) {
case GEOMETRY_DATA_TYPE_SHORT:
{
@ -240,7 +241,7 @@ xglGeometryAddSpan (ScreenPtr pScreen,
*data++ = (glitz_short_t) ppt->y;
*data++ = (glitz_short_t) (ppt->x + *pwidth);
*data++ = (glitz_short_t) ppt->y;
ppt++;
pwidth++;
}
@ -255,13 +256,13 @@ xglGeometryAddSpan (ScreenPtr pScreen,
*data++ = (glitz_float_t) ppt->y;
*data++ = (glitz_float_t) (ppt->x + *pwidth);
*data++ = (glitz_float_t) ppt->y;
ppt++;
pwidth++;
}
} break;
}
UNMAP_GEOMETRY (pGeometry, offset, size);
}
@ -298,7 +299,7 @@ xglGeometryAddLine (ScreenPtr pScreen,
pt.x = 0;
pt.y = 0;
switch (pGeometry->dataType) {
case GEOMETRY_DATA_TYPE_SHORT:
{
@ -329,7 +330,7 @@ xglGeometryAddLine (ScreenPtr pScreen,
ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
*data++ = (glitz_short_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
}
ppt++;
}
} break;
@ -362,7 +363,7 @@ xglGeometryAddLine (ScreenPtr pScreen,
ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
*data++ = (glitz_float_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
}
ppt++;
}
} break;
@ -403,7 +404,7 @@ xglGeometryAddSegment (ScreenPtr pScreen,
pSegInit->y1 == pSegInit->y2);
*data++ = (glitz_short_t)
ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
pSegInit++;
}
} break;
@ -420,12 +421,12 @@ xglGeometryAddSegment (ScreenPtr pScreen,
pSegInit->y1 == pSegInit->y2);
*data++ = (glitz_float_t)
ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
pSegInit++;
}
} break;
}
UNMAP_GEOMETRY (pGeometry, offset, size);
}
@ -449,7 +450,7 @@ xglGeometryForGlyph (ScreenPtr pScreen,
ppci = ppciInit;
n = nGlyph;
while (n--)
{
pglyph = FONTGLYPHBITS (pglyphBase, *ppci++);
@ -482,7 +483,7 @@ xglGeometryForGlyph (ScreenPtr pScreen,
pglyph = FONTGLYPHBITS (pglyphBase, pci);
gWidth = GLYPHWIDTHPIXELS (pci);
gHeight = GLYPHHEIGHTPIXELS (pci);
if (gWidth && gHeight)
{
gx = x + pci->metrics.leftSideBearing;
@ -513,8 +514,8 @@ xglGeometryForGlyph (ScreenPtr pScreen,
(((glitz_float_t) \
((line).p1.x + (xFixed_16_16) \
(((((line).p2.y - (line).p1.y) - 1) + \
((xFixed_32_32) ((v) - (line).p1.y) * \
((line).p2.x - (line).p1.x))) / \
((xFixed_32_32) ((v) - (line).p1.y) * \
((line).p2.x - (line).p1.x))) / \
((line).p2.y - (line).p1.y)))) / 65536)
/*
@ -549,7 +550,7 @@ xglGeometryAddTrapezoid (ScreenPtr pScreen,
{
top = FIXED_TO_FLOAT (pTrap->top);
bottom = FIXED_TO_FLOAT (pTrap->bottom);
*data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->top);
*data++ = top;
*data++ = FIXED_LINE_X_CEIL_TO_FLOAT (pTrap->right, pTrap->top);
@ -599,7 +600,7 @@ xglGeometryAddTrap (ScreenPtr pScreen,
{
top = FIXED_TO_FLOAT (pTrap->top.y);
bottom = FIXED_TO_FLOAT (pTrap->bot.y);
*data++ = FIXED_TO_FLOAT (pTrap->top.l);
*data++ = top;
*data++ = FIXED_TO_FLOAT (pTrap->top.r);
@ -626,9 +627,9 @@ xglGetScratchGeometryWithSize (ScreenPtr pScreen,
xglGeometryPtr pGeometry;
XGL_SCREEN_PRIV (pScreen);
pGeometry = &pScreenPriv->scratchGeometry;
if (pGeometry->broken || pGeometry->size < size)
{
GEOMETRY_UNINIT (pGeometry);
@ -649,7 +650,7 @@ xglGetScratchGeometryWithSize (ScreenPtr pScreen,
pGeometry->count = 0;
pGeometry->width = 2;
}
return pGeometry;
}
@ -662,17 +663,17 @@ xglGetScratchVertexGeometryWithType (ScreenPtr pScreen,
int stride;
stride = 2 * xglGeometryDataTypes[type].size;
pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride);
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
pGeometry->dataType = type;
pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS;
pGeometry->f.vertex.type = xglGeometryDataTypes[type].type;
pGeometry->f.vertex.bytes_per_vertex = stride;
pGeometry->f.vertex.attributes = 0;
return pGeometry;
}
@ -692,22 +693,22 @@ xglGetScratchVertexGeometry (ScreenPtr pScreen,
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
pGeometry->dataType = type;
pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS;
pGeometry->f.vertex.type = xglGeometryDataTypes[type].type;
pGeometry->f.vertex.bytes_per_vertex = stride;
pGeometry->f.vertex.attributes = 0;
return pGeometry;
}
Bool
xglSetGeometry (xglGeometryPtr pGeometry,
xglSetGeometry (xglGeometryPtr pGeometry,
glitz_surface_t *surface)
{
if (pGeometry->broken)
return FALSE;
glitz_set_geometry (surface, pGeometry->type, &pGeometry->f,
pGeometry->buffer);
@ -718,6 +719,6 @@ xglSetGeometry (xglGeometryPtr pGeometry,
glitz_set_array (surface,
pGeometry->first, pGeometry->width, pGeometry->count,
pGeometry->xOff, pGeometry->yOff);
return TRUE;
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -39,10 +39,10 @@ xglGetImage (DrawablePtr pDrawable,
glitz_surface_t *surface;
int xOff, yOff;
BoxRec box;
XGL_SCREEN_PRIV (pScreen);
/* Many apps use GetImage to sync with the visable frame buffer */
/* Many apps use GetImage to sync with the visible frame buffer */
if (pDrawable->type == DRAWABLE_WINDOW)
{
if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
@ -61,27 +61,27 @@ xglGetImage (DrawablePtr pDrawable,
if (!xglSyncBits (pDrawable, &box))
FatalError (XGL_SW_FAILURE_STRING);
XGL_SCREEN_UNWRAP (GetImage);
(*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d);
XGL_SCREEN_WRAP (GetImage, xglGetImage);
}
void
xglGetSpans (DrawablePtr pDrawable,
int wMax,
DDXPointPtr ppt,
int *pwidth,
int nspans,
xglGetSpans (DrawablePtr pDrawable,
int wMax,
DDXPointPtr ppt,
int *pwidth,
int nspans,
char *pchardstStart)
{
ScreenPtr pScreen = pDrawable->pScreen;
XGL_SCREEN_PRIV (pScreen);
if (!xglSyncBits (pDrawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING);
XGL_SCREEN_UNWRAP (GetSpans);
(*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
XGL_SCREEN_WRAP (GetSpans, xglGetSpans);

View File

@ -23,62 +23,27 @@
* Author: David Reveman <davidr@novell.com>
*/
#include "xgl.h"
#include "xglglx.h"
#ifdef GLXEXT
#include "glxserver.h"
#include "glxscreens.h"
#include "glxext.h"
#ifdef XGL_MODULAR
#include <dlfcn.h>
#endif
typedef struct _xglGLXFunc {
void (*extensionInit) (void);
void (*setVisualConfigs) (int nconfigs,
__GLXvisualConfig *configs,
void **privates);
void (*wrapInitVisuals) (miInitVisualsProcPtr *initVisuals);
int (*initVisuals) (VisualPtr *visualp,
DepthPtr *depthp,
int *nvisualp,
int *ndepthp,
int *rootDepthp,
VisualID *defaultVisp,
unsigned long sizes,
int bitsPerRGB,
int preferredVis);
xglGLXFuncRec __xglGLXFunc;
void (*flushContextCache) (void);
void (*setRenderTables) (__glProcTable *table,
__glProcTableEXT *tableEXT);
} xglGLXFuncRec;
static xglGLXFuncRec __glXFunc;
#ifndef NGLXEXTLOG
FILE *__xglGLXLogFp;
#endif
static void *glXHandle = 0;
static void *glCoreHandle = 0;
#define SYM(ptr, name) { (void **) &(ptr), (name) }
__GLXextensionInfo __glDDXExtensionInfo = {
GL_CORE_MESA,
NULL,
NULL,
NULL
};
__GLXscreenInfo __glDDXScreenInfo = {
NULL,
NULL,
NULL,
NULL,
NULL,
0,
0,
"Vendor String",
"Version String",
"Extensions String",
NULL
};
__GLXextensionInfo *__xglExtensionInfo;
__GLXscreenInfo *__xglScreenInfoPtr;
void
GlxSetVisualConfigs (int nconfigs,
@ -86,21 +51,21 @@ GlxSetVisualConfigs (int nconfigs,
void **privates)
{
if (glXHandle && glCoreHandle)
(*__glXFunc.setVisualConfigs) (nconfigs, configs, privates);
(*__xglGLXFunc.setVisualConfigs) (nconfigs, configs, privates);
}
void
GlxExtensionInit (void)
{
if (glXHandle && glCoreHandle)
(*__glXFunc.extensionInit) ();
(*__xglGLXFunc.extensionInit) ();
}
void
GlxWrapInitVisuals (miInitVisualsProcPtr *initVisuals)
{
if (glXHandle && glCoreHandle)
(*__glXFunc.wrapInitVisuals) (initVisuals);
(*__xglGLXFunc.wrapInitVisuals) (initVisuals);
}
int
@ -115,9 +80,9 @@ GlxInitVisuals (VisualPtr *visualp,
int preferredVis)
{
if (glXHandle && glCoreHandle)
return (*__glXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp,
rootDepthp, defaultVisp, sizes,
bitsPerRGB, preferredVis);
return (*__xglGLXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp,
rootDepthp, defaultVisp, sizes,
bitsPerRGB, preferredVis);
return 0;
}
@ -125,16 +90,59 @@ GlxInitVisuals (VisualPtr *visualp,
void
GlxFlushContextCache (void)
{
(*__glXFunc.flushContextCache) ();
(*__xglGLXFunc.flushContextCache) ();
}
void
GlxSetRenderTables (__glProcTable *table,
__glProcTableEXT *tableEXT)
GlxSetRenderTables (struct _glapi_table *table)
{
(*__glXFunc.setRenderTables) (table, tableEXT);
(*__xglGLXFunc.setRenderTables) (table);
}
struct _glapi_table *_mglapi_Dispatch;
void *(*__glcore_DDXScreenInfo)(void);
void *__glXglDDXScreenInfo(void)
{
return __xglScreenInfoPtr;
}
void *(*__glcore_DDXExtensionInfo)(void);
void *__glXglDDXExtensionInfo(void)
{
return __xglExtensionInfo;
}
void _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
const __GLXvisualConfig * config )
{
(*__xglGLXFunc.copy_visual_to_context_mode)(mode, config);
}
__GLcontextModes *_gl_context_modes_create( unsigned count, size_t minimum_size )
{
return (*__xglGLXFunc.context_modes_create)(count, minimum_size);
}
void _gl_context_modes_destroy( __GLcontextModes * modes )
{
(*__xglGLXFunc.context_modes_destroy)(modes);
}
GLint _gl_convert_from_x_visual_type( int visualType )
{
return (*__xglGLXFunc.convert_from_x_visual_type)(visualType);
}
GLint _gl_convert_to_x_visual_type( int visualType )
{
return (*__xglGLXFunc.convert_to_x_visual_type)(visualType);
}
Bool
xglLoadGLXModules (void)
{
@ -143,15 +151,20 @@ xglLoadGLXModules (void)
if (!glXHandle)
{
xglSymbolRec sym[] = {
SYM (__glXFunc.extensionInit, "GlxExtensionInit"),
SYM (__glXFunc.setVisualConfigs, "GlxSetVisualConfigs"),
SYM (__glXFunc.wrapInitVisuals, "GlxWrapInitVisuals"),
SYM (__glXFunc.initVisuals, "GlxInitVisuals"),
SYM (__glXFunc.flushContextCache, "GlxFlushContextCache"),
SYM (__glXFunc.setRenderTables, "GlxSetRenderTables")
SYM (__xglGLXFunc.extensionInit, "GlxExtensionInit"),
SYM (__xglGLXFunc.setVisualConfigs, "GlxSetVisualConfigs"),
SYM (__xglGLXFunc.wrapInitVisuals, "GlxWrapInitVisuals"),
SYM (__xglGLXFunc.initVisuals, "GlxInitVisuals"),
SYM (__xglGLXFunc.flushContextCache, "__glXFlushContextCache"),
SYM (__xglGLXFunc.setRenderTables, "GlxSetRenderTables"),
SYM (__xglGLXFunc.copy_visual_to_context_mode, "_gl_copy_visual_to_context_mode"),
SYM (__xglGLXFunc.context_modes_create, "_gl_context_modes_create"),
SYM (__xglGLXFunc.context_modes_destroy, "_gl_context_modes_destroy"),
SYM (__xglGLXFunc.convert_from_x_visual_type, "_gl_convert_from_x_visual_type"),
SYM (__xglGLXFunc.convert_to_x_visual_type, "_gl_convert_to_x_visual_type"),
};
glXHandle = xglLoadModule ("glx");
glXHandle = xglLoadModule ("glx", RTLD_NOW | RTLD_LOCAL);
if (!glXHandle)
return FALSE;
@ -166,27 +179,48 @@ xglLoadGLXModules (void)
if (!glCoreHandle)
{
xglSymbolRec sym[] = {
SYM (__glDDXScreenInfo.screenProbe, "__MESA_screenProbe"),
SYM (__glDDXScreenInfo.createContext, "__MESA_createContext"),
SYM (__glDDXScreenInfo.createBuffer, "__MESA_createBuffer"),
xglSymbolRec ddxsym[] = {
SYM (__glcore_DDXExtensionInfo, "__glXglDDXExtensionInfo"),
SYM (__glcore_DDXScreenInfo, "__glXglDDXScreenInfo")
};
SYM (__glDDXExtensionInfo.resetExtension, "__MESA_resetExtension"),
SYM (__glDDXExtensionInfo.initVisuals, "__MESA_initVisuals"),
SYM (__glDDXExtensionInfo.setVisualConfigs,
"__MESA_setVisualConfigs")
};
glCoreHandle = xglLoadModule ("glcore");
glCoreHandle = xglLoadModule ("glcore", RTLD_NOW | RTLD_LOCAL);
if (!glCoreHandle)
return FALSE;
if (!xglLookupSymbols (glCoreHandle, sym, sizeof (sym) / sizeof (sym[0])))
if (!xglLookupSymbols (glCoreHandle, ddxsym,
sizeof (ddxsym) / sizeof(ddxsym[0])))
{
xglUnloadModule (glCoreHandle);
glCoreHandle = 0;
return FALSE;
}
__xglScreenInfoPtr = __glcore_DDXScreenInfo();
__xglExtensionInfo = __glcore_DDXExtensionInfo();
{
xglSymbolRec sym[] = {
SYM (__xglScreenInfoPtr->screenProbe, "__MESA_screenProbe"),
SYM (__xglScreenInfoPtr->createContext, "__MESA_createContext"),
SYM (__xglScreenInfoPtr->createBuffer, "__MESA_createBuffer"),
SYM (__xglExtensionInfo->resetExtension,
"__MESA_resetExtension"),
SYM (__xglExtensionInfo->initVisuals, "__MESA_initVisuals"),
SYM (__xglExtensionInfo->setVisualConfigs,
"__MESA_setVisualConfigs"),
};
if (!xglLookupSymbols (glCoreHandle, sym,
sizeof (sym) / sizeof (sym[0])))
{
xglUnloadModule (glCoreHandle);
glCoreHandle = 0;
return FALSE;
}
}
if (!xglLoadHashFuncs (glCoreHandle))

79
hw/xgl/xglglx.h Normal file
View File

@ -0,0 +1,79 @@
/*
* Copyright © 2005 Novell, Inc.
*
* 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
* Novell, Inc. not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
* Novell, Inc. makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. 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 "xgl.h"
#ifdef GLXEXT
#include "glxserver.h"
#include "glxscreens.h"
#include "glxext.h"
#include "glapitable.h"
typedef struct _xglGLXFunc {
void (*extensionInit) (void);
void (*setVisualConfigs) (int nconfigs,
__GLXvisualConfig *configs,
void **privates);
void (*wrapInitVisuals) (miInitVisualsProcPtr *initVisuals);
int (*initVisuals) (VisualPtr *visualp,
DepthPtr *depthp,
int *nvisualp,
int *ndepthp,
int *rootDepthp,
VisualID *defaultVisp,
unsigned long sizes,
int bitsPerRGB,
int preferredVis);
void (*flushContextCache) (void);
void *(*DDXExtensionInfo) (void);
void *(*DDXScreenInfo) (void);
void (*setRenderTables) (struct _glapi_table *table);
void (*copy_visual_to_context_mode)( __GLcontextModes *mode, const __GLXvisualConfig *config );
__GLcontextModes *(*context_modes_create)( unsigned count, size_t minimum_size );
void (*context_modes_destroy)( __GLcontextModes * modes );
GLint (*convert_from_x_visual_type)( int visualType );
GLint (*convert_to_x_visual_type)( int visualType );
} xglGLXFuncRec, *xglGLXFuncPtr;
extern xglGLXFuncRec __xglGLXFunc;
#ifndef NGLXEXTLOG
extern FILE *__xglGLXLogFp;
#endif
/* xglglx.c */
Bool
xglLoadGLXModules (void);
void
xglUnloadGLXModules (void);
#endif

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2005 Novell, Inc.
*
*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. 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,
* 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.
*
@ -163,9 +163,9 @@ xglRealizeGlyph (ScreenPtr pScreen,
XGL_PICTURE_SCREEN_UNWRAP (RealizeGlyph);
ret = (*pPictureScreen->RealizeGlyph) (pScreen, pGlyph);
XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph);
pGlyphPriv->pArea = NULL;
return ret;
}
@ -205,7 +205,7 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
if (pCache->depth == 1)
{
int stride;
GEOMETRY_INIT (pScreen, &pCache->u.geometry,
GLITZ_GEOMETRY_TYPE_VERTEX,
GEOMETRY_USAGE_STATIC, BITMAP_CACHE_SIZE);
@ -228,9 +228,14 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
{
xglGlyphTexturePtr pTexture = &pCache->u.texture;
glitz_surface_t *mask;
glitz_surface_attributes_t attr;
xglPixmapFormatPtr pFormat;
glitz_vertex_format_t *vertex;
xglVisualPtr pVisual;
pVisual = xglFindVisualWithDepth (pScreen, format->depth);
if (!pVisual)
return FALSE;
if (!xglRootAreaInit (&pCache->rootArea,
TEXTURE_CACHE_MAX_LEVEL,
@ -240,39 +245,46 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
(pointer) pCache))
return FALSE;
pFormat = &pScreenPriv->pixmapFormats[format->depth];
if (pScreenPriv->geometryDataType == GEOMETRY_DATA_TYPE_SHORT)
{
attr.unnormalized = 1;
pTexture->mask =
glitz_surface_create (pScreenPriv->drawable, pFormat->format,
TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE,
GLITZ_SURFACE_UNNORMALIZED_MASK, &attr);
} else
pTexture->mask = NULL;
if (!pTexture->mask)
mask = glitz_surface_create (pScreenPriv->drawable,
pVisual->format.surface,
TEXTURE_CACHE_SIZE,
TEXTURE_CACHE_SIZE,
GLITZ_SURFACE_UNNORMALIZED_MASK,
&attr);
}
else
mask = NULL;
if (!mask)
{
pTexture->mask =
glitz_surface_create (pScreenPriv->drawable, pFormat->format,
TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE,
0, NULL);
if (!pTexture->mask)
mask = glitz_surface_create (pScreenPriv->drawable,
pVisual->format.surface,
TEXTURE_CACHE_SIZE,
TEXTURE_CACHE_SIZE,
0, NULL);
if (!mask)
return FALSE;
pTexture->geometryDataType = GEOMETRY_DATA_TYPE_FLOAT;
} else
}
else
pTexture->geometryDataType = GEOMETRY_DATA_TYPE_SHORT;
if (NEEDS_COMPONENT (format->format))
glitz_surface_set_component_alpha (pTexture->mask, 1);
glitz_surface_set_component_alpha (mask, 1);
pTexture->pMask = xglCreateDevicePicture (mask);
if (!pTexture->pMask)
return FALSE;
vertex = &pCache->u.texture.format.vertex;
vertex->primitive = GLITZ_PRIMITIVE_QUADS;
vertex->mask.size = GLITZ_COORDINATE_SIZE_XY;
vertex->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK;
if (pTexture->geometryDataType == GEOMETRY_DATA_TYPE_FLOAT)
{
vertex->type = GLITZ_DATA_TYPE_FLOAT;
@ -288,13 +300,14 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
vertex->mask.type = GLITZ_DATA_TYPE_SHORT;
}
pTexture->pixel.masks = pFormat->pPixel->masks;
pTexture->pixel.fourcc = GLITZ_FOURCC_RGB;
pTexture->pixel.masks = pVisual->pPixel->masks;
pTexture->pixel.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
pTexture->pixel.bytes_per_line = 0;
pTexture->pixel.xoffset = 0;
pTexture->pixel.skip_lines = 0;
}
pCache->pScreen = pScreen;
return TRUE;
@ -306,17 +319,17 @@ xglFiniGlyphCache (xglGlyphCachePtr pCache)
if (pCache->pScreen)
{
xglRootAreaFini (&pCache->rootArea);
if (pCache->depth == 1)
{
GEOMETRY_UNINIT (&pCache->u.geometry);
}
else
{
if (pCache->u.texture.mask)
glitz_surface_destroy (pCache->u.texture.mask);
if (pCache->u.texture.pMask)
FreePicture ((pointer) pCache->u.texture.pMask, 0);
}
pCache->pScreen = NULL;
}
}
@ -326,24 +339,24 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
GlyphPtr pGlyph)
{
ScreenPtr pScreen = pCache->pScreen;
XGL_GLYPH_PRIV (pScreen, pGlyph);
if (pCache->depth == 1)
{
PixmapPtr pPixmap;
RegionPtr pRegion;
int nBox;
pPixmap = GetScratchPixmapHeader (pScreen,
pGlyph->info.width,
pGlyph->info.height,
pGlyph->info.height,
pCache->depth, pCache->depth, 0,
(pointer) (pGlyph + 1));
if (!pPixmap)
return NULL;
(*pScreen->ModifyPixmapHeader) (pPixmap,
(*pScreen->ModifyPixmapHeader) (pPixmap,
pGlyph->info.width,
pGlyph->info.height,
0, 0, -1, (pointer) (pGlyph + 1));
@ -366,7 +379,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
/* Find available area */
if (!xglFindArea (pCache->rootArea.pArea, nBox, 0,
FALSE, (pointer) pGlyph))
{
{
/* Kicking out area with lower score */
xglFindArea (pCache->rootArea.pArea, nBox, 0,
TRUE, (pointer) pGlyph);
@ -375,7 +388,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
if (pGlyphPriv->pArea)
{
int stride;
GLYPH_AREA_PRIV (pGlyphPriv->pArea);
pAreaPriv->serial = glyphSerialNumber;
@ -388,7 +401,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
}
} else
pGlyphPriv->pArea = &zeroSizeArea;
REGION_DESTROY (pScreen, pRegion);
}
else
@ -398,11 +411,11 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
if (pGlyph->info.width > TEXTURE_CACHE_MAX_WIDTH ||
pGlyph->info.height > TEXTURE_CACHE_MAX_HEIGHT)
return NULL;
if (pGlyph->info.width > 0 && pGlyph->info.height > 0)
{
glitz_buffer_t *buffer;
buffer = glitz_buffer_create_for_data (pGlyph + 1);
if (!buffer)
return NULL;
@ -417,19 +430,22 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
pGlyph->info.width, pGlyph->info.height,
TRUE, (pointer) pGlyph);
}
if (pGlyphPriv->pArea)
{
glitz_surface_t *surface;
glitz_point_fixed_t p1, p2;
glitz_pixel_format_t pixel;
GLYPH_AREA_PRIV (pGlyphPriv->pArea);
pixel = pTexture->pixel;
pixel.bytes_per_line =
PixmapBytePad (pGlyph->info.width, pCache->depth);
glitz_set_pixels (pTexture->mask,
surface = pTexture->pMask->pSourcePict->source.devPrivate.ptr;
glitz_set_pixels (surface,
pGlyphPriv->pArea->x,
pGlyphPriv->pArea->y,
pGlyph->info.width,
@ -441,10 +457,10 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
p1.y = pGlyphPriv->pArea->y << 16;
p2.x = (pGlyphPriv->pArea->x + pGlyph->info.width) << 16;
p2.y = (pGlyphPriv->pArea->y + pGlyph->info.height) << 16;
glitz_surface_translate_point (pTexture->mask, &p1, &p1);
glitz_surface_translate_point (pTexture->mask, &p2, &p2);
glitz_surface_translate_point (surface, &p1, &p1);
glitz_surface_translate_point (surface, &p2, &p2);
pAreaPriv->serial = glyphSerialNumber;
if (pTexture->geometryDataType)
{
@ -465,7 +481,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
} else
pGlyphPriv->pArea = &zeroSizeArea;
}
return pGlyphPriv->pArea;
}
@ -499,7 +515,7 @@ xglUncachedGlyphs (CARD8 op,
usingCache = FALSE;
}
}
while (pOp->nGlyphs)
{
glyph = *pOp->ppGlyphs;
@ -511,7 +527,7 @@ xglUncachedGlyphs (CARD8 op,
pOp->xOff += pOp->pLists->xOff;
pOp->yOff += pOp->pLists->yOff;
}
xOff = pOp->xOff;
yOff = pOp->yOff;
@ -523,7 +539,7 @@ xglUncachedGlyphs (CARD8 op,
{
if (!pArea)
pArea = xglCacheGlyph (pCache, glyph);
if (pArea)
break;
}
@ -533,26 +549,26 @@ xglUncachedGlyphs (CARD8 op,
pOp->listLen--;
pOp->nGlyphs--;
pOp->ppGlyphs++;
pOp->xOff += glyph->info.xOff;
pOp->yOff += glyph->info.yOff;
if (pArea)
continue;
if (!pPicture)
{
CARD32 componentAlpha;
int error;
XID componentAlpha;
int error;
pPixmap = GetScratchPixmapHeader (pScreen,
glyph->info.width,
glyph->info.height,
glyph->info.height,
depth, depth,
0, (pointer) (glyph + 1));
if (!pPixmap)
return;
componentAlpha = NEEDS_COMPONENT (pOp->pLists->format->format);
pPicture = CreatePicture (0, &pPixmap->drawable,
pOp->pLists->format,
@ -564,8 +580,8 @@ xglUncachedGlyphs (CARD8 op,
return;
}
}
(*pScreen->ModifyPixmapHeader) (pPixmap,
(*pScreen->ModifyPixmapHeader) (pPixmap,
glyph->info.width, glyph->info.height,
0, 0, -1, (pointer) (glyph + 1));
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
@ -594,7 +610,7 @@ xglUncachedGlyphs (CARD8 op,
glyph->info.width,
glyph->info.height);
}
if (pPicture)
{
FreeScratchPixmapHeader (pPixmap);
@ -624,10 +640,10 @@ xglCachedGlyphs (CARD8 op,
int depth = pOp->pLists->format->depth;
int i, remaining = pOp->nGlyphs;
int nGlyph = 0;
glitz_surface_t *mask = NULL;
PicturePtr pMaskPicture = NULL;
XGL_SCREEN_PRIV (pScreen);
pCache = &pScreenPriv->glyphCache[depth];
if (!pCache->pScreen)
{
@ -663,23 +679,23 @@ xglCachedGlyphs (CARD8 op,
else if (pSrc)
break;
}
if (nGlyph)
{
if (depth == 1)
{
glitz_multi_array_t *multiArray;
pGeometry = &pCache->u.geometry;
pGeometry->xOff = pGeometry->yOff = 0;
multiArray = glitz_multi_array_create (nGlyph);
if (!multiArray)
return 1;
GEOMETRY_SET_MULTI_ARRAY (pGeometry, multiArray);
glitz_multi_array_destroy (multiArray);
vData.array.lastX = 0;
vData.array.lastY = 0;
}
@ -687,11 +703,11 @@ xglCachedGlyphs (CARD8 op,
{
i = 4 * pCache->u.texture.format.vertex.bytes_per_vertex * nGlyph;
pGeometry = xglGetScratchGeometryWithSize (pScreen, i);
pGeometry->f = pCache->u.texture.format;
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
mask = pCache->u.texture.mask;
pMaskPicture = pCache->u.texture.pMask;
vData.list.s = glitz_buffer_map (pGeometry->buffer,
GLITZ_BUFFER_ACCESS_WRITE_ONLY);
}
@ -714,7 +730,7 @@ xglCachedGlyphs (CARD8 op,
pOp->xOff += pOp->pLists->xOff;
pOp->yOff += pOp->pLists->yOff;
}
xOff = pOp->xOff;
yOff = pOp->yOff;
@ -726,7 +742,7 @@ xglCachedGlyphs (CARD8 op,
pOp->listLen--;
pOp->nGlyphs--;
pOp->ppGlyphs++;
pOp->xOff += glyph->info.xOff;
pOp->yOff += glyph->info.yOff;
@ -739,7 +755,7 @@ xglCachedGlyphs (CARD8 op,
extents.x1 = x1;
if (x2 > extents.x2)
extents.x2 = x2;
y1 = yOff - glyph->info.y;
y2 = y1 + glyph->info.height;
if (y1 < extents.y1)
@ -786,7 +802,7 @@ xglCachedGlyphs (CARD8 op,
glitz_buffer_unmap (pGeometry->buffer);
pGeometry->count = nGlyph * 4;
}
xSrc += extents.x1;
ySrc += extents.y1;
@ -794,27 +810,26 @@ xglCachedGlyphs (CARD8 op,
{
op = PictOpAdd;
pSrc = pScreenPriv->pSolidAlpha;
if (remaining)
*pOp = opSave;
*pOp = opSave;
}
GEOMETRY_TRANSLATE (pGeometry,
pDst->pDrawable->x,
pDst->pDrawable->y);
if (xglComp (op,
pSrc,
NULL,
pDst,
xSrc, ySrc,
0, 0,
pDst->pDrawable->x + extents.x1,
pDst->pDrawable->y + extents.y1,
extents.x2 - extents.x1,
extents.y2 - extents.y1,
pGeometry,
mask))
if (xglCompositeGeneral (op,
pSrc,
pMaskPicture,
pDst,
pGeometry,
xSrc, ySrc,
0, 0,
pDst->pDrawable->x + extents.x1,
pDst->pDrawable->y + extents.y1,
extents.x2 - extents.x1,
extents.y2 - extents.y1))
{
xglAddCurrentBitDamage (pDst->pDrawable);
return remaining;
@ -857,7 +872,7 @@ xglGlyphExtents (PicturePtr pDst,
extents->x1 = MAXSHORT;
extents->x2 = MINSHORT;
extents->y1 = MAXSHORT;
extents->y2 = MINSHORT;
extents->y2 = MINSHORT;
while (!list->len)
{
@ -892,7 +907,7 @@ xglGlyphExtents (PicturePtr pDst,
y += list->yOff;
n = list->len;
list++;
while (n--)
{
glyph = *glyphs++;
@ -945,7 +960,7 @@ xglGlyphExtents (PicturePtr pDst,
extents->y1 = line.y1;
if (line.y2 > extents->y2)
extents->y2 = line.y2;
overlap = TRUE;
}
@ -959,7 +974,7 @@ xglGlyphExtents (PicturePtr pDst,
line.x2 = x2;
line.y2 = y2;
}
x += glyph->info.xOff;
y += glyph->info.yOff;
}
@ -983,15 +998,15 @@ xglGlyphExtents (PicturePtr pDst,
extents->y1 = line.y1;
if (line.y2 > extents->y2)
extents->y2 = line.y2;
overlap = TRUE;
}
if (line.x1 < extents->x1)
extents->x1 = line.x1;
if (line.x2 > extents->x2)
extents->x2 = line.x2;
xglPictureClipExtents (pDst, extents);
return overlap;
@ -1006,7 +1021,7 @@ xglGlyphListFormatId (GlyphListPtr list,
nlist--;
list++;
while (nlist--)
{
if (list->format->id != id)
@ -1037,20 +1052,18 @@ xglGlyphs (CARD8 op,
int overlap;
int target;
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
overlap = xglGlyphExtents (pDst, nlist, list, glyphs, &extents);
if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
return;
target = xglPrepareTarget (pDst->pDrawable);
if (op != PictOpAdd && maskFormat &&
(overlap || op != PictOpOver ||
(!target || overlap || op != PictOpOver ||
xglGlyphListFormatId (list, nlist) != maskFormat->id))
{
PixmapPtr pPixmap;
CARD32 componentAlpha;
XID componentAlpha;
GCPtr pGC;
xRectangle rect;
int error;
@ -1065,7 +1078,7 @@ xglGlyphs (CARD8 op,
maskFormat->depth);
if (!pPixmap)
return;
componentAlpha = NEEDS_COMPONENT (maskFormat->format);
pMask = CreatePicture (0, &pPixmap->drawable,
maskFormat, CPComponentAlpha, &componentAlpha,
@ -1076,12 +1089,11 @@ xglGlyphs (CARD8 op,
return;
}
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
/* lock mask if we are not doing accelerated drawing to destination */
if (!target)
XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1;
{
/* make sure we don't do accelerated drawing to mask */
xglSetPixmapVisual (pPixmap, NULL);
}
ValidatePicture (pMask);
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
@ -1092,7 +1104,7 @@ xglGlyphs (CARD8 op,
(*pScreen->DestroyPixmap) (pPixmap);
target = xglPrepareTarget (pMask->pDrawable);
glyphOp.xOff = -extents.x1;
glyphOp.yOff = -extents.y1;
pSrcPicture = NULL;
@ -1100,9 +1112,6 @@ xglGlyphs (CARD8 op,
}
else
{
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
glyphOp.xOff = 0;
glyphOp.yOff = 0;
pSrcPicture = pSrc;
@ -1119,12 +1128,12 @@ xglGlyphs (CARD8 op,
glyphOp.listLen = list->len;
glyphOp.nGlyphs = list->len;
glyphOp.pLists = list++;
for (; nlist; nlist--, list++)
{
if (list->format->id != glyphOp.pLists->format->id)
break;
glyphOp.nGlyphs += list->len;
}
@ -1142,26 +1151,19 @@ xglGlyphs (CARD8 op,
&glyphOp);
}
}
if (pMask)
{
CompositePicture (op,
pSrc,
pMask,
pDst,
CompositePicture (op, pSrc, pMask, pDst,
xSrc + extents.x1 - xDst,
ySrc + extents.y1 - yDst,
0, 0,
extents.x1, extents.y1,
extents.x2 - extents.x1,
extents.y2 - extents.y1);
FreePicture ((pointer) pMask, (XID) 0);
}
/* release destination drawable lock */
pPixmapPriv->lock--;
}
#endif

View File

@ -24,26 +24,41 @@
*/
#include "xgl.h"
#include "xglglx.h"
#include "micmap.h"
#include "mipointer.h"
#include "fb.h"
#define DEAFULT_DDX_MODULE_NAME "xglx"
#ifdef XGL_MODULAR
#include <dlfcn.h>
#endif
static char *ddxModuleName = DEAFULT_DDX_MODULE_NAME;
#define DEFAULT_DDX_MODULE_NAME "xglx"
static char *ddxModuleName = DEFAULT_DDX_MODULE_NAME;
xglScreenInfoRec xglScreenInfo = {
NULL, 0, 0, 0, 0,
NULL, 0, 0, 0, 0, 0,
DEFAULT_GEOMETRY_DATA_TYPE,
DEFAULT_GEOMETRY_USAGE,
FALSE,
XGL_DEFAULT_PBO_MASK,
FALSE,
FALSE
{
{ FALSE, FALSE, { 0, 0, 0, 0 } },
{ FALSE, FALSE, { 0, 0, 0, 0 } },
{ FALSE, FALSE, { 0, 0, 0, 0 } },
{ FALSE, FALSE, { 0, 0, 0, 0 } }
}
};
#ifdef GLXEXT
static Bool loadGlx = TRUE;
#ifndef NGLXEXTLOG
static char *glxExtLogFile = 0;
#endif
#endif
typedef struct _xglDDXFunc {
@ -105,6 +120,29 @@ xglEnsureDDXModule (void)
if (!status)
return FALSE;
#ifdef GLXEXT
/* GLX and GLcore modules must be loaded with RTLD_NOW and RTLD_LOCAL
flags before DDX module which is linked to libGL and should be
loaded with RTLD_GLOBAL. */
if (loadGlx)
{
if (!xglLoadGLXModules ())
FatalError ("No GLX modules loaded");
#ifndef NGLXEXTLOG
if (glxExtLogFile)
{
__xglGLXLogFp = fopen (glxExtLogFile, "w");
if (!__xglGLXLogFp)
perror ("InitOutput");
}
else
__xglGLXLogFp = 0;
#endif
}
#endif
if (!ddxHandle)
{
xglSymbolRec sym[] = {
@ -119,7 +157,7 @@ xglEnsureDDXModule (void)
SYM (__ddxFunc.osVendorInit, "OsVendorInit")
};
ddxHandle = xglLoadModule (ddxModuleName);
ddxHandle = xglLoadModule (ddxModuleName, RTLD_NOW | RTLD_GLOBAL);
if (!ddxHandle)
return (status = FALSE);
@ -149,14 +187,6 @@ InitOutput (ScreenInfo *pScreenInfo,
if (!xglEnsureDDXModule ())
FatalError ("No DDX module loaded");
#ifdef GLXEXT
if (loadGlx)
{
if (!xglLoadGLXModules ())
FatalError ("No GLX modules loaded");
}
#endif
(*__ddxFunc.initOutput) (pScreenInfo, argc, argv);
}
@ -191,68 +221,83 @@ ddxUseMsg (void)
#ifdef GLXEXT
ErrorF ("-noglx don't load glx extension\n");
#ifndef NGLXEXTLOG
ErrorF ("-glxlog file glx extension log file\n");
#endif
#endif
xglUseMsg ();
if (xglEnsureDDXModule ())
(*__ddxFunc.useMsg) ();
}
#define LOPT(s, l) { (s), (l) }
#define OPT(s) LOPT (s, 0)
int
ddxProcessArgument (int argc,
char **argv,
int i)
{
struct _option {
char *name;
int length;
} commonOption[] = {
LOPT (":", 1), OPT ("-a"), OPT ("-ac"), OPT ("-audit"), OPT ("-auth"),
OPT ("bc"), OPT ("-br"), OPT ("+bs"), OPT ("-bs"), OPT ("c"), OPT ("-c"),
OPT ("-cc"), OPT ("-co"), OPT ("-core"), OPT ("-dpi"),
OPT ("-deferglyphs"), OPT ("-f"), OPT ("-fc"), OPT ("-fn"), OPT ("-fp"),
OPT ("-help"), OPT ("-nolisten"), OPT ("-noreset"), OPT ("-p"),
OPT ("-pn"), OPT ("-nopn"), OPT ("r"), OPT ("-r"), OPT ("-s"),
OPT ("-su"), OPT ("-t"), OPT ("-terminate"), OPT ("-to"), OPT ("-tst"),
OPT ("v"), OPT ("-v"), OPT ("-wm"), OPT ("-x"), OPT ("-I"),
LOPT ("tty", 3)
};
int skip, j;
static Bool checkDDX = FALSE;
int skip;
for (j = 0; j < sizeof (commonOption) / sizeof (commonOption[0]); j++)
if (!checkDDX)
{
if (commonOption[j].length)
int j;
for (j = i; j < argc; j++)
{
if (!strncmp (argv[i], commonOption[j].name, commonOption[j].length))
return 0;
}
else
{
if (!strcmp (argv[i], commonOption[j].name))
return 0;
if (!strcmp (argv[j], "-ddx"))
{
if (++j < argc)
ddxModuleName = argv[j];
}
#ifdef GLXEXT
else if (!strcmp (argv[j], "-noglx"))
{
loadGlx = FALSE;
}
#ifndef NGLXEXTLOG
else if (!strcmp (argv[j], "-glxlog"))
{
if (++j < argc)
glxExtLogFile = argv[j];
}
#endif
#endif
}
checkDDX = TRUE;
}
if (!strcmp (argv[i], "-ddx"))
{
if ((i + 1) < argc)
{
ddxModuleName = argv[i + 1];
}
else
return 1;
return 2;
return 2;
return 1;
}
#ifdef GLXEXT
else if (!strcmp (argv[i], "-noglx"))
{
loadGlx = FALSE;
return 1;
}
#ifndef NGLXEXTLOG
else if (!strcmp (argv[i], "-glxlog"))
{
if ((i + 1) < argc)
return 2;
return 1;
}
#endif
#endif
skip = xglProcessArgument (argc, argv, i);
@ -286,6 +331,6 @@ OsVendorInit (void)
(*__ddxFunc.osVendorInit) ();
}
void ddxInitGlobals(void)
void ddxInitGlobals()
{
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -47,7 +47,7 @@ xglMouseProc (DeviceIntPtr pDevice,
case DEVICE_INIT:
for (i = 1; i <= NUM_BUTTONS; i++)
map[i] = i;
InitPointerDeviceStruct (pDev,
map,
NUM_BUTTONS,
@ -63,7 +63,7 @@ xglMouseProc (DeviceIntPtr pDevice,
pDev->on = FALSE;
break;
}
return Success;
}
@ -226,7 +226,7 @@ xglKeybdProc (DeviceIntPtr pDevice,
case DEVICE_INIT:
if (pDev != LookupKeyboardDevice ())
return !Success;
ret = InitKeyboardDeviceStruct (pDev,
&xglKeySyms,
xglModMap,
@ -243,7 +243,7 @@ xglKeybdProc (DeviceIntPtr pDevice,
pDev->on = FALSE;
break;
}
return Success;
}
@ -251,13 +251,13 @@ void
xglInitInput (int argc, char **argv)
{
DeviceIntPtr pKeyboard, pPointer;
pPointer = AddInputDevice (xglMouseProc, TRUE);
pKeyboard = AddInputDevice (xglKeybdProc, TRUE);
RegisterPointerDevice (pPointer);
RegisterKeyboardDevice (pKeyboard);
miRegisterPointerDevice (screenInfo.screens[0], pPointer);
mieqInit (&pKeyboard->public, &pPointer->public);
}

View File

@ -33,7 +33,8 @@
#define SYM(ptr, name) { (void **) &(ptr), (name) }
void *
xglLoadModule (const char *name)
xglLoadModule (const char *name,
int flag)
{
ModuleVersionProcPtr moduleVersion;
ModuleInitProcPtr moduleInit;
@ -50,7 +51,7 @@ xglLoadModule (const char *name)
sprintf (module, XGL_MODULE_PATH "/lib%s.so", name);
handle = dlopen (module, RTLD_NOW);
handle = dlopen (module, flag);
if (handle)
{
if (xglLookupSymbols (handle, mSym, sizeof (mSym) / sizeof (mSym[0])))

View File

@ -31,6 +31,8 @@
#include <X11/Xdefs.h>
#include "misc.h"
#define VERSION "0.0.1"
typedef const char *(*ModuleVersionProcPtr) (void);
typedef Bool (*ModuleInitProcPtr) (const char *module);

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -25,6 +25,9 @@
#include "xgl.h"
#include <mivalidate.h>
#include <dixstruct.h>
typedef struct _xglDepth {
CARD8 depth;
CARD8 bpp;
@ -46,20 +49,167 @@ void
xglSetPixmapFormats (ScreenInfo *pScreenInfo)
{
int i;
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
pScreenInfo->numPixmapFormats = 0;
for (i = 0; i < NUM_XGL_DEPTHS; i++) {
for (i = 0; i < NUM_XGL_DEPTHS; i++)
{
PixmapFormatRec *format;
format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
format->depth = xglDepths[i].depth;
format->bitsPerPixel = xglDepths[i].bpp;
format->scanlinePad = BITMAP_SCANLINE_PAD;
}
}
void
xglSetRootClip (ScreenPtr pScreen,
Bool enable)
{
WindowPtr pWin = WindowTable[pScreen->myNum];
WindowPtr pChild;
Bool wasViewable;
Bool anyMarked = FALSE;
RegionPtr pOldClip = 0, bsExposed;
#ifdef DO_SAVE_UNDERS
Bool dosave = FALSE;
#endif
WindowPtr pLayerWin;
BoxRec box;
if (!pWin)
return;
wasViewable = (Bool) (pWin->viewable);
if (wasViewable)
{
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
{
(void) (*pScreen->MarkOverlappedWindows) (pChild,
pChild,
&pLayerWin);
}
(*pScreen->MarkWindow) (pWin);
anyMarked = TRUE;
if (pWin->valdata)
{
if (HasBorder (pWin))
{
RegionPtr borderVisible;
borderVisible = REGION_CREATE (pScreen, NullBox, 1);
REGION_SUBTRACT (pScreen, borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
pWin->valdata->before.resized = TRUE;
}
}
if (enable)
{
box.x1 = 0;
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
pWin->drawable.width = pScreen->width;
pWin->drawable.height = pScreen->height;
REGION_INIT (pScreen, &pWin->winSize, &box, 1);
REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
REGION_RESET (pScreen, &pWin->borderClip, &box);
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
}
else
{
REGION_EMPTY (pScreen, &pWin->borderClip);
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
}
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
if (wasViewable)
{
if (pWin->backStorage)
{
pOldClip = REGION_CREATE (pScreen, NullBox, 1);
REGION_COPY (pScreen, pOldClip, &pWin->clipList);
}
if (pWin->firstChild)
{
anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin->firstChild,
pWin->firstChild,
(WindowPtr *) 0);
}
else
{
(*pScreen->MarkWindow) (pWin);
anyMarked = TRUE;
}
#ifdef DO_SAVE_UNDERS
if (DO_SAVE_UNDERS (pWin))
dosave = (*pScreen->ChangeSaveUnder) (pLayerWin, pLayerWin);
#endif
if (anyMarked)
(*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
}
if (pWin->backStorage && ((pWin->backingStore == Always) || wasViewable))
{
if (!wasViewable)
pOldClip = &pWin->clipList; /* a convenient empty region */
bsExposed = (*pScreen->TranslateBackingStore) (pWin, 0, 0, pOldClip,
pWin->drawable.x,
pWin->drawable.y);
if (wasViewable)
REGION_DESTROY(pScreen, pOldClip);
if (bsExposed)
{
RegionPtr valExposed = NullRegion;
if (pWin->valdata)
valExposed = &pWin->valdata->after.exposed;
(*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
if (valExposed)
REGION_EMPTY (pScreen, valExposed);
REGION_DESTROY (pScreen, bsExposed);
}
}
if (wasViewable)
{
if (anyMarked)
(*pScreen->HandleExposures) (pWin);
#ifdef DO_SAVE_UNDERS
if (dosave)
(*pScreen->PostChangeSaveUnder) (pLayerWin, pLayerWin);
#endif
if (anyMarked && pScreen->PostValidateTree)
(*pScreen->PostValidateTree) (pWin, NullWindow, VTOther);
}
if (pWin->realized)
WindowsRestructured ();
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -33,13 +33,13 @@ xglParseFindNext (char *cur,
{
while (*cur && !strchr (delim, *cur))
*save++ = *cur++;
*save = 0;
*last = *cur;
if (*cur)
cur++;
return cur;
}
@ -57,28 +57,28 @@ xglParseScreen (char *arg)
if (!arg)
return;
if (strlen (arg) >= sizeof (save))
return;
for (i = 0; i < 2; i++)
{
arg = xglParseFindNext (arg, "x/@XY", save, &delim);
arg = xglParseFindNext (arg, "x/", save, &delim);
if (!save[0])
return;
pixels = atoi (save);
mm = 0;
if (delim == '/')
{
arg = xglParseFindNext (arg, "x@XY", save, &delim);
arg = xglParseFindNext (arg, "x", save, &delim);
if (!save[0])
return;
mm = atoi (save);
}
if (i == 0)
{
xglScreenInfo.width = pixels;
@ -89,12 +89,98 @@ xglParseScreen (char *arg)
xglScreenInfo.height = pixels;
xglScreenInfo.heightMm = mm;
}
if (delim != 'x')
return;
}
}
static void
xglParseAccel (char *arg)
{
xglAccelInfoPtr pAccel;
char delim;
char save[1024];
if (!arg)
return;
if (strlen (arg) >= sizeof (save))
return;
arg = xglParseFindNext (arg, "@:", save, &delim);
if (!save[0])
return;
if (strcasecmp (save, "pixmap") == 0)
pAccel = &xglScreenInfo.accel.pixmap;
else if (strcasecmp (save, "window") == 0)
pAccel = &xglScreenInfo.accel.window;
else if (strcasecmp (save, "glx") == 0)
pAccel = &xglScreenInfo.accel.glx;
else if (strcasecmp (save, "xv") == 0)
pAccel = &xglScreenInfo.accel.xv;
else
return;
if (delim == '@')
{
arg = xglParseFindNext (arg, "/x:", save, &delim);
if (!save[0])
return;
pAccel->size.aboveWidth = pAccel->size.minWidth = atoi (save);
if (delim == '/')
{
arg = xglParseFindNext (arg, "x:", save, &delim);
if (!save[0])
return;
pAccel->size.aboveWidth = atoi (save);
}
if (delim == 'x')
{
arg = xglParseFindNext (arg, "/:", save, &delim);
if (!save[0])
return;
pAccel->size.aboveHeight = pAccel->size.minHeight = atoi (save);
if (delim == '/')
{
arg = xglParseFindNext (arg, ":", save, &delim);
if (!save[0])
return;
pAccel->size.aboveHeight = atoi (save);
}
}
}
pAccel->enabled = TRUE;
pAccel->pbuffer = FALSE;
if (delim == ':')
{
if (strcasecmp (arg, "fbo") == 0)
;
else if (strcasecmp (arg, "off") == 0 ||
strncasecmp (arg, "0", 1) == 0 ||
strncasecmp (arg, "f", 1) == 0 ||
strncasecmp (arg, "n", 1) == 0)
{
pAccel->enabled = FALSE;
pAccel->pbuffer = FALSE;
}
else if (strcasecmp (arg, "pbuffer") == 0)
{
pAccel->pbuffer = TRUE;
}
}
}
void
xglUseMsg (void)
{
@ -106,8 +192,8 @@ xglUseMsg (void)
"use vertex buffer objects for streaming of vertex data\n");
ErrorF ("-pbomask [1|4|8|16|32] "
"set bpp's to use with pixel buffer objects\n");
ErrorF ("-fbo "
"use frame buffer objects for accelerate offscreen drawing\n");
ErrorF ("-accel TYPE[@WIDTH[/MIN]xHEIGHT[/MIN]][:METHOD] "
"offscreen acceleration\n");
}
int
@ -126,7 +212,7 @@ xglProcessArgument (int argc,
}
else
return 1;
return 2;
}
else if (!strcmp (argv[i], "-yinverted"))
@ -152,14 +238,20 @@ xglProcessArgument (int argc,
}
else
return 1;
return 2;
}
else if (!strcmp (argv[i], "-fbo"))
else if (!strcmp (argv[i], "-accel"))
{
xglScreenInfo.fbo = TRUE;
return 1;
if ((i + 1) < argc)
{
xglParseAccel (argv[i + 1]);
}
else
return 1;
return 2;
}
return 0;
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -28,6 +28,8 @@
#ifdef RENDER
#include "fbpict.h"
#define XGL_PICTURE_FALLBACK_PROLOGUE(pPicture, func) \
xglSyncDamageBoxBits (pPicture->pDrawable); \
XGL_PICTURE_SCREEN_UNWRAP (func)
@ -55,18 +57,18 @@ xglComposite (CARD8 op,
XGL_SCREEN_PRIV (pScreen);
if (xglComp (op,
pSrc, pMask, pDst,
xSrc, ySrc,
xMask, yMask,
xDst + pDst->pDrawable->x, yDst + pDst->pDrawable->y,
width, height,
NULL, NULL))
if (xglCompositeGeneral (op,
pSrc, pMask, pDst, NULL,
xSrc, ySrc,
xMask, yMask,
xDst + pDst->pDrawable->x,
yDst + pDst->pDrawable->y,
width, height))
{
xglAddCurrentBitDamage (pDst->pDrawable);
return;
}
pPictureScreen = GetPictureScreen (pScreen);
if (pSrc->pDrawable)
@ -74,7 +76,7 @@ xglComposite (CARD8 op,
if (!xglSyncBits (pSrc->pDrawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING);
}
if (pMask && pMask->pDrawable)
{
if (!xglSyncBits (pMask->pDrawable, NullBox))
@ -84,12 +86,12 @@ xglComposite (CARD8 op,
if (op == PictOpSrc)
{
XGL_DRAWABLE_PIXMAP (pDst->pDrawable);
if (!xglMapPixmapBits (pPixmap))
FatalError (XGL_SW_FAILURE_STRING);
} else
xglSyncDamageBoxBits (pDst->pDrawable);
XGL_PICTURE_SCREEN_UNWRAP (Composite);
(*pPictureScreen->Composite) (op, pSrc, pMask, pDst,
xSrc, ySrc, xMask, yMask, xDst, yDst,
@ -103,16 +105,19 @@ xglComposite (CARD8 op,
xDst += pDst->pDrawable->x;
yDst += pDst->pDrawable->y;
xSrc += pSrc->pDrawable->x;
ySrc += pSrc->pDrawable->y;
if (pSrc->pDrawable)
{
xSrc += pSrc->pDrawable->x;
ySrc += pSrc->pDrawable->y;
}
if (pMask)
if (pMask && pMask->pDrawable)
{
xMask += pMask->pDrawable->x;
yMask += pMask->pDrawable->y;
}
if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
xSrc, ySrc, xMask, yMask, xDst, yDst,
width, height))
return;
@ -130,7 +135,7 @@ xglAddTriangles (PicturePtr pDst,
int ntri,
xTriangle *tris)
{
PictureScreenPtr pPictureScreen;
PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pDst->pDrawable->pScreen;
XGL_SCREEN_PRIV (pScreen);
@ -153,7 +158,7 @@ void
xglChangePicture (PicturePtr pPicture,
Mask mask)
{
PictureScreenPtr pPictureScreen;
PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
XGL_SCREEN_PRIV (pScreen);
@ -179,7 +184,7 @@ int
xglChangePictureTransform (PicturePtr pPicture,
PictTransform *transform)
{
PictureScreenPtr pPictureScreen;
PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
int ret;
@ -187,14 +192,17 @@ xglChangePictureTransform (PicturePtr pPicture,
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
pPictureScreen = GetPictureScreen (pScreen);
pPixmapPriv->pictureMask |= xglPCTransformMask;
if (transform != pPicture->transform ||
(transform && memcmp (transform, &pPicture->transform,
sizeof (PictTransform))))
pPixmapPriv->pictureMask |= xglPCTransformMask;
XGL_PICTURE_SCREEN_UNWRAP (ChangePictureTransform);
ret = (*pPictureScreen->ChangePictureTransform) (pPicture, transform);
XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform,
xglChangePictureTransform);
return ret;
}
@ -204,7 +212,7 @@ xglChangePictureFilter (PicturePtr pPicture,
xFixed *params,
int nparams)
{
PictureScreenPtr pPictureScreen;
PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
int ret;
@ -212,7 +220,7 @@ xglChangePictureFilter (PicturePtr pPicture,
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
pPictureScreen = GetPictureScreen (pScreen);
pPixmapPriv->pictureMask |= xglPCFilterMask;
XGL_PICTURE_SCREEN_UNWRAP (ChangePictureFilter);
@ -223,21 +231,48 @@ xglChangePictureFilter (PicturePtr pPicture,
return ret;
}
void
static void
xglDestroyDevicePicture (PicturePtr pPicture)
{
if (pPicture->pSourcePict->source.devPrivate.ptr)
glitz_surface_destroy (pPicture->pSourcePict->source.devPrivate.ptr);
}
PicturePtr
xglCreateDevicePicture (pointer data)
{
PicturePtr pPicture;
int error;
pPicture = CreateDevicePicture (0, &error);
if (!pPicture)
return 0;
pPicture->pSourcePict->source.devPrivate.ptr = data;
pPicture->pSourcePict->source.Destroy = xglDestroyDevicePicture;
return pPicture;
}
static int fillMode[] = {
GLITZ_FILL_TRANSPARENT, /* RepeatNone */
GLITZ_FILL_REPEAT, /* RepeatNormal */
GLITZ_FILL_NEAREST, /* RepeatPad */
GLITZ_FILL_REFLECT /* RepeatReflect */
};
static void
xglUpdatePicture (PicturePtr pPicture)
{
glitz_surface_t *surface;
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
surface = pPixmapPriv->surface;
if (pPixmapPriv->pictureMask & xglPCFillMask)
{
if (pPicture->repeat)
glitz_surface_set_fill (surface, GLITZ_FILL_REPEAT);
else
glitz_surface_set_fill (surface, GLITZ_FILL_TRANSPARENT);
glitz_surface_set_fill (surface, fillMode[pPicture->repeat]);
}
if (pPixmapPriv->pictureMask & xglPCFilterMask)
@ -269,23 +304,263 @@ xglUpdatePicture (PicturePtr pPicture)
if (pPixmapPriv->pictureMask & xglPCComponentAlphaMask)
{
if (pPicture->componentAlpha)
glitz_surface_set_component_alpha (surface, 1);
else
glitz_surface_set_component_alpha (surface, 0);
glitz_surface_set_component_alpha (surface, pPicture->componentAlpha);
}
if (pPixmapPriv->pictureMask & xglPCDitherMask)
{
if (pPicture->dither)
glitz_surface_set_dither (surface, 1);
else
glitz_surface_set_dither (surface, 0);
glitz_surface_set_dither (surface, pPicture->dither);
}
pPixmapPriv->pictureMask &= ~XGL_PICTURE_CHANGES (~0);
}
#define N_STACK_PARAM 256
static int gradientNParam[] = {
0, /* SourcePictTypeSolidFill */
4, /* SourcePictTypeLinear */
6, /* SourcePictTypeRadial */
4, /* SourcePictTypeConical */
};
Bool
xglSyncPicture (ScreenPtr pScreen,
PicturePtr pPicture,
INT16 x,
INT16 y,
CARD16 width,
CARD16 height,
INT16 *xOff,
INT16 *yOff)
{
xglPixmapPtr pPixmapPriv;
XGL_SCREEN_PRIV (pScreen);
*xOff = *yOff = 0;
if (pPicture->pSourcePict)
{
if (pPicture->pSourcePict->source.devPrivate.ptr)
return TRUE;
if (pPicture->pDrawable)
{
(*pScreen->DestroyPixmap) ((PixmapPtr) pPicture->pDrawable);
pPicture->pDrawable = (DrawablePtr) 0;
}
switch (pPicture->pSourcePict->source.type) {
case SourcePictTypeSolidFill:
x = y = 0;
width = height = 1;
break;
case SourcePictTypeLinear:
case SourcePictTypeRadial: {
glitz_fixed16_16_t stackParam[N_STACK_PARAM];
glitz_fixed16_16_t *param;
int nParam, nStop, size, i;
CARD32 *pixel;
PictGradientStopPtr pStop;
glitz_buffer_t *buffer;
glitz_format_t *format;
glitz_surface_t *surface;
static glitz_pixel_format_t pixelFormat = {
GLITZ_FOURCC_RGB,
{
32,
0xff000000,
0x00ff0000,
0x0000ff00,
0x000000ff
},
0, 0, 0,
GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
};
if (!(pScreenPriv->features & GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK))
break;
format = glitz_find_standard_format (pScreenPriv->drawable,
GLITZ_STANDARD_ARGB32);
if (!format)
break;
nParam = gradientNParam[pPicture->pSourcePict->gradient.type];
pStop = pPicture->pSourcePict->gradient.stops;
nStop = pPicture->pSourcePict->gradient.nstops;
size = nParam + nStop * 4;
if (size > N_STACK_PARAM)
{
param = malloc (sizeof (xFixed) * size);
if (!param)
break;
}
else
{
param = stackParam;
}
pixel = (CARD32 *) (param + nParam + nStop * 3);
buffer = glitz_buffer_create_for_data (pixel);
if (!buffer)
{
if (size > N_STACK_PARAM)
free (param);
break;
}
surface = glitz_surface_create (pScreenPriv->drawable,
format, nStop, 1, 0, NULL);
if (!surface)
{
glitz_buffer_destroy (buffer);
if (size > N_STACK_PARAM)
free (param);
break;
}
for (i = 0; i < nStop; i++)
{
pixel[i] = pStop[i].color;
param[nParam + 3 * i + 0] = pStop[i].x;
param[nParam + 3 * i + 1] = i << 16;
param[nParam + 3 * i + 2] = 0;
}
glitz_set_pixels (surface, 0, 0, nStop, 1, &pixelFormat, buffer);
glitz_buffer_destroy (buffer);
switch (pPicture->pSourcePict->source.type) {
case SourcePictTypeLinear:
param[0] = pPicture->pSourcePict->linear.p1.x;
param[1] = pPicture->pSourcePict->linear.p1.y;
param[2] = pPicture->pSourcePict->linear.p2.x;
param[3] = pPicture->pSourcePict->linear.p2.y;
glitz_surface_set_filter (surface,
GLITZ_FILTER_LINEAR_GRADIENT,
param, nParam + nStop * 3);
break;
case SourcePictTypeRadial:
param[0] = pPicture->pSourcePict->radial.inner.x;
param[1] = pPicture->pSourcePict->radial.inner.y;
param[2] = pPicture->pSourcePict->radial.inner_radius;
param[3] = pPicture->pSourcePict->radial.outer.x;
param[4] = pPicture->pSourcePict->radial.outer.y;
param[5] = pPicture->pSourcePict->radial.outer_radius;
glitz_surface_set_filter (surface,
GLITZ_FILTER_RADIAL_GRADIENT,
param, nParam + nStop * 3);
break;
}
glitz_surface_set_fill (surface, fillMode[pPicture->repeat]);
glitz_surface_set_transform (surface, (glitz_transform_t *)
pPicture->transform);
pPicture->pSourcePict->gradient.devPrivate.ptr = surface;
pPicture->pSourcePict->gradient.Destroy = xglDestroyDevicePicture;
if (size > N_STACK_PARAM)
free (param);
return TRUE;
} break;
case SourcePictTypeConical:
default:
break;
}
if (!pPicture->pDrawable)
{
PictFormatPtr pFormat;
PixmapPtr pPixmap;
PicturePtr pTmp;
RegionRec region;
BoxRec box;
int error;
pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
if (!pFormat)
return FALSE;
pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
pFormat->depth);
if (!pPixmap)
return FALSE;
pTmp = CreatePicture (0, &pPixmap->drawable, pFormat, 0, NULL,
serverClient, &error);
if (!pTmp)
{
(*pScreen->DestroyPixmap) (pPixmap);
return FALSE;
}
ValidatePicture (pTmp);
if (!xglSyncBits (pTmp->pDrawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING);
fbCompositeGeneral (PictOpSrc,
pPicture, 0, pTmp,
x, y, 0, 0, 0, 0,
width, height);
FreePicture ((pointer) pTmp, (XID) 0);
box.x1 = 0;
box.y1 = 0;
box.x2 = width;
box.y2 = height;
REGION_INIT (pScreen, &region, &box, 1);
xglAddSurfaceDamage (&pPixmap->drawable, &region);
REGION_UNINIT (pDrawable->pScreen, &region);
pPicture->pDrawable = &pPixmap->drawable;
*xOff = x;
*yOff = y;
XGL_GET_PIXMAP_PRIV (pPixmap)->pictureMask &=
~(xglPCFillMask | xglPCFilterMask | xglPCTransformMask);
}
}
#ifdef XV
switch (pPicture->format) {
case PICT_yuy2:
xglSetPixmapVisual ((PixmapPtr) pPicture->pDrawable,
&pScreenPriv->pXvVisual[XGL_XV_FORMAT_YUY2]);
break;
case PICT_yv12:
xglSetPixmapVisual ((PixmapPtr) pPicture->pDrawable,
&pScreenPriv->pXvVisual[XGL_XV_FORMAT_YV12]);
default:
break;
}
#endif
if (!xglSyncSurface (pPicture->pDrawable))
return FALSE;
pPixmapPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pPicture->pDrawable);
if (XGL_PICTURE_CHANGES (pPixmapPriv->pictureMask))
xglUpdatePicture (pPicture);
return TRUE;
}
static int
xglVisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
{
@ -299,7 +574,7 @@ xglVisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
if (pDepth->vids[v] == pVisual->vid)
return pDepth->depth;
}
return 0;
}
@ -319,10 +594,10 @@ xglAddFormat (xglFormatInitPtr formats,
for (n = 0; n < nformat; n++)
if (formats[n].format == format && formats[n].depth == depth)
return nformat;
formats[nformat].format = format;
formats[nformat].depth = depth;
return ++nformat;
}
@ -342,7 +617,7 @@ xglPictureInit (ScreenPtr pScreen)
int r, g, b;
int d;
DepthPtr pDepth;
/* formats required by protocol */
formats[nformats].format = PICT_a1;
formats[nformats].depth = 1;
@ -364,8 +639,8 @@ xglPictureInit (ScreenPtr pScreen)
depth = xglVisualDepth (pScreen, pVisual);
if (!depth)
continue;
bpp = BitsPerPixel (depth);
bpp = BitsPerPixel (depth);
switch (pVisual->class) {
case DirectColor:
case TrueColor:
@ -399,7 +674,7 @@ xglPictureInit (ScreenPtr pScreen)
if (pDepth->depth == 15)
nformats = xglAddFormat (formats, nformats,
PICT_x1r5g5b5, pDepth->depth);
if (pDepth->depth == 16)
if (pDepth->depth == 16)
nformats = xglAddFormat (formats, nformats,
PICT_r5g6b5, pDepth->depth);
break;
@ -416,42 +691,52 @@ xglPictureInit (ScreenPtr pScreen)
}
}
/* add YUV formats */
nformats = xglAddFormat (formats, nformats, PICT_yuy2, 16);
nformats = xglAddFormat (formats, nformats, PICT_yv12, 12);
pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
if (!pFormats)
return 0;
memset (pFormats, '\0', nformats * sizeof (PictFormatRec));
for (f = 0; f < nformats; f++)
{
pFormats[f].id = FakeClientID (0);
pFormats[f].id = FakeClientID (0);
pFormats[f].depth = formats[f].depth;
format = formats[f].format;
pFormats[f].format = format;
pFormats[f].type = PictTypeDirect;
switch (PICT_FORMAT_TYPE (format)) {
case PICT_TYPE_ARGB:
pFormats[f].type = PictTypeDirect;
pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
if (pFormats[f].direct.alphaMask)
pFormats[f].direct.alpha = (PICT_FORMAT_R (format) +
PICT_FORMAT_G (format) +
PICT_FORMAT_B (format));
pFormats[f].direct.redMask = Mask (PICT_FORMAT_R (format));
pFormats[f].direct.red = (PICT_FORMAT_G (format) +
pFormats[f].direct.red = (PICT_FORMAT_G (format) +
PICT_FORMAT_B (format));
pFormats[f].direct.greenMask = Mask (PICT_FORMAT_G (format));
pFormats[f].direct.green = PICT_FORMAT_B (format);
pFormats[f].direct.blueMask = Mask (PICT_FORMAT_B (format));
pFormats[f].direct.blue = 0;
break;
case PICT_TYPE_A:
pFormats[f].type = PictTypeDirect;
pFormats[f].direct.alpha = 0;
pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
break;
case PICT_TYPE_COLOR:
case PICT_TYPE_GRAY:
pFormats[f].type = PictTypeDirect;
break;
case PICT_TYPE_YUY2:
case PICT_TYPE_YV12:
pFormats[f].type = PictTypeOther;
break;
}
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -69,7 +69,8 @@ xglPixmapDamageReport (DamagePtr pDamage,
if (pExt->y2 > pPixmapPriv->damageBox.y2)
pPixmapPriv->damageBox.y2 = pExt->y2;
} else
}
else
pPixmapPriv->damageBox = *pExt;
}
@ -88,34 +89,119 @@ xglPixmapCreateDamage (PixmapPtr pPixmap)
return FALSE;
DamageRegister (&pPixmap->drawable, pPixmapPriv->pDamage);
return TRUE;
}
void
xglSetPixmapVisual (PixmapPtr pPixmap,
xglVisualPtr pVisual)
{
xglVisualPtr pOldVisual;
XGL_PIXMAP_PRIV (pPixmap);
pOldVisual = pPixmapPriv->pVisual;
if (pOldVisual && pVisual)
{
glitz_surface_t *surface;
if (pOldVisual->vid != pVisual->vid)
{
surface = pPixmapPriv->surface;
if (surface)
{
glitz_drawable_t *drawable;
drawable = glitz_surface_get_attached_drawable (surface);
if (drawable)
{
if (pOldVisual->format.drawable->id !=
pVisual->format.drawable->id)
{
glitz_surface_detach (pPixmapPriv->surface);
pPixmapPriv->target = xglPixmapTargetOut;
}
}
if (pOldVisual->format.surface->id != pVisual->format.surface->id)
{
xglSyncBits (&pPixmap->drawable, NULL);
glitz_surface_destroy (pPixmapPriv->surface);
pPixmapPriv->surface = 0;
}
}
}
}
else if (pOldVisual)
{
if (pPixmapPriv->surface)
{
xglSyncBits (&pPixmap->drawable, NULL);
glitz_surface_destroy (pPixmapPriv->surface);
pPixmapPriv->surface = 0;
}
pPixmapPriv->target = xglPixmapTargetNo;
}
pPixmapPriv->pVisual = pVisual;
if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
{
if (!pPixmapPriv->pDamage)
{
if (!xglPixmapCreateDamage (pPixmap))
FatalError (XGL_SW_FAILURE_STRING);
}
}
}
static Bool
xglPixmapSurfaceInit (PixmapPtr pPixmap,
unsigned long features,
int width,
int height)
{
BoxRec box;
XGL_PIXMAP_PRIV (pPixmap);
pPixmapPriv->surface = NULL;
pPixmapPriv->drawable = NULL;
pPixmapPriv->acceleratedTile = FALSE;
pPixmapPriv->pictureMask = ~0;
pPixmapPriv->target = xglPixmapTargetNo;
pPixmapPriv->lock = 0;
if (pPixmapPriv->format)
box.x1 = 0;
box.y1 = 0;
box.x2 = width;
box.y2 = height;
REGION_INIT (pScreen, &pPixmapPriv->bitRegion, &box, 1);
pPixmapPriv->pVisual = xglFindVisualWithDepth (pPixmap->drawable.pScreen,
pPixmap->drawable.depth);
if (pPixmapPriv->pVisual)
{
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
/* general pixmap acceleration */
if (pPixmapPriv->pVisual->format.drawable &&
pScreenPriv->accel.pixmap.enabled &&
xglCheckPixmapSize (pPixmap, &pScreenPriv->accel.pixmap.size))
pPixmapPriv->target = xglPixmapTargetOut;
}
if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
{
if (!pPixmapPriv->pDamage)
{
if (!xglPixmapCreateDamage (pPixmap))
FatalError (XGL_SW_FAILURE_STRING);
}
if (width && height)
{
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
if (width == 1 && height == 1)
{
pPixmapPriv->acceleratedTile = TRUE;
@ -126,28 +212,6 @@ xglPixmapSurfaceInit (PixmapPtr pPixmap,
(POWER_OF_TWO (width) && POWER_OF_TWO (height)))
pPixmapPriv->acceleratedTile = TRUE;
}
/*
* Accelerated drawing to pixmaps when using FBOs
*/
if (pScreenPriv->fbo)
{
pPixmapPriv->target = xglPixmapTargetOut;
/*
* Do not allow accelerated drawing to bitmaps.
*/
if (pPixmap->drawable.depth == 1)
pPixmapPriv->target = xglPixmapTargetNo;
/*
* Drawing to really small pixmaps is not worth accelerating.
*/
if (width < 8 && height < 8)
pPixmapPriv->target = xglPixmapTargetNo;
}
else
pPixmapPriv->target = xglPixmapTargetNo;
}
}
@ -157,7 +221,7 @@ xglPixmapSurfaceInit (PixmapPtr pPixmap,
PixmapPtr
xglCreatePixmap (ScreenPtr pScreen,
int width,
int height,
int height,
int depth)
{
xglPixmapPtr pPixmapPriv;
@ -180,37 +244,32 @@ xglCreatePixmap (ScreenPtr pScreen,
pPixmap->drawable.y = 0;
pPixmap->drawable.width = width;
pPixmap->drawable.height = height;
#ifdef COMPOSITE
pPixmap->screen_x = 0;
pPixmap->screen_y = 0;
#endif
pPixmap->devKind = 0;
pPixmap->refcnt = 1;
pPixmap->devPrivate.ptr = 0;
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
pPixmapPriv->format = pScreenPriv->pixmapFormats[depth].format;
pPixmapPriv->pPixel = pScreenPriv->pixmapFormats[depth].pPixel;
pPixmapPriv->pVisual = NULL;
pPixmapPriv->pDamage = NULL;
if (!xglPixmapSurfaceInit (pPixmap, pScreenPriv->features, width, height))
return NullPixmap;
pPixmapPriv->buffer = NULL;
pPixmapPriv->bits = (pointer) 0;
pPixmapPriv->stride = 0;
pPixmapPriv->pGeometry = NULL;
pPixmapPriv->allBits = TRUE;
pPixmapPriv->bitBox.x1 = 0;
pPixmapPriv->bitBox.y1 = 0;
pPixmapPriv->bitBox.x2 = 32767;
pPixmapPriv->bitBox.y2 = 32767;
pPixmapPriv->damageBox = miEmptyBox;
return pPixmap;
}
@ -218,7 +277,7 @@ void
xglFiniPixmap (PixmapPtr pPixmap)
{
XGL_PIXMAP_PRIV (pPixmap);
if (pPixmap->devPrivate.ptr)
{
if (pPixmapPriv->buffer)
@ -230,10 +289,15 @@ xglFiniPixmap (PixmapPtr pPixmap)
if (pPixmapPriv->buffer)
glitz_buffer_destroy (pPixmapPriv->buffer);
if (pPixmapPriv->bits)
xfree (pPixmapPriv->bits);
REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
if (pPixmapPriv->drawable)
glitz_drawable_destroy (pPixmapPriv->drawable);
if (pPixmapPriv->surface)
glitz_surface_destroy (pPixmapPriv->surface);
}
@ -247,7 +311,7 @@ xglDestroyPixmap (PixmapPtr pPixmap)
xglFiniPixmap (pPixmap);
xfree (pPixmap);
return TRUE;
}
@ -260,18 +324,16 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
int devKind,
pointer pPixData)
{
xglScreenPtr pScreenPriv;
xglPixmapPtr pPixmapPriv;
glitz_format_t *oldFormat;
int oldWidth, oldHeight;
xglScreenPtr pScreenPriv;
xglPixmapPtr pPixmapPriv;
int oldWidth, oldHeight;
if (!pPixmap)
return FALSE;
pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen);
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
oldFormat = pPixmapPriv->format;
oldWidth = pPixmap->drawable.width;
oldHeight = pPixmap->drawable.height;
@ -293,13 +355,13 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
{
if (width > 0)
pPixmap->drawable.width = width;
if (height > 0)
pPixmap->drawable.height = height;
if (depth > 0)
pPixmap->drawable.depth = depth;
if (bitsPerPixel > 0)
pPixmap->drawable.bitsPerPixel = bitsPerPixel;
else if ((bitsPerPixel < 0) && (depth > 0))
@ -312,18 +374,20 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
pPixmap->drawable.depth);
}
depth = pPixmap->drawable.depth;
pPixmapPriv->pPixel = pScreenPriv->pixmapFormats[depth].pPixel;
pPixmapPriv->format = pScreenPriv->pixmapFormats[depth].format;
if (pPixmapPriv->format != oldFormat ||
pPixmap->drawable.width != oldWidth ||
if (pPixmap->drawable.width != oldWidth ||
pPixmap->drawable.height != oldHeight)
{
pPixmapPriv->pVisual = NULL;
pPixmapPriv->target = xglPixmapTargetNo;
if (pPixmapPriv->drawable)
glitz_drawable_destroy (pPixmapPriv->drawable);
if (pPixmapPriv->surface)
glitz_surface_destroy (pPixmapPriv->surface);
REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
if (!xglPixmapSurfaceInit (pPixmap,
pScreenPriv->features,
pPixmap->drawable.width,
@ -333,6 +397,8 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
if (pPixData)
{
BoxRec box;
if (pPixmap->devPrivate.ptr)
{
if (pPixmapPriv->buffer)
@ -346,10 +412,10 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
pPixmapPriv->pGeometry = NULL;
}
if (pPixmapPriv->buffer)
glitz_buffer_destroy (pPixmapPriv->buffer);
if (pPixmapPriv->bits)
xfree (pPixmapPriv->bits);
@ -359,36 +425,54 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
return FALSE;
pPixmapPriv->allBits = TRUE;
pPixmapPriv->bitBox.x1 = 0;
pPixmapPriv->bitBox.y1 = 0;
pPixmapPriv->bitBox.x2 = pPixmap->drawable.width;
pPixmapPriv->bitBox.y2 = pPixmap->drawable.height;
box.x1 = 0;
box.y1 = 0;
box.x2 = pPixmap->drawable.width;
box.y2 = pPixmap->drawable.height;
REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
REGION_INIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion,
&box, 1);
if (pPixmapPriv->pDamage)
{
RegionPtr pRegion;
pRegion = DamageRegion (pPixmapPriv->pDamage);
REGION_UNINIT (pPixmap->drawable.pScreen, pRegion);
REGION_INIT (pPixmap->drawable.pScreen, pRegion,
&pPixmapPriv->bitBox, 1);
REGION_INIT (pPixmap->drawable.pScreen, pRegion, NullBox, 0);
REGION_SUBTRACT (pPixmap->drawable.pScreen, pRegion,
&pPixmapPriv->bitRegion, pRegion);
}
}
/*
* Maybe there's a nicer way to detect if this is the screen pixmap.
* Screen pixmap
*/
if (!pScreenPriv->pScreenPixmap)
if (!pScreenPriv->pScreenPixmap || pScreenPriv->pScreenPixmap == pPixmap)
{
glitz_surface_reference (pScreenPriv->surface);
pPixmapPriv->surface = pScreenPriv->surface;
if (!pPixmapPriv->drawable)
{
glitz_drawable_reference (pScreenPriv->drawable);
pPixmapPriv->drawable = pScreenPriv->drawable;
}
if (!pPixmapPriv->surface)
{
glitz_surface_reference (pScreenPriv->surface);
pPixmapPriv->surface = pScreenPriv->surface;
}
pPixmapPriv->pVisual = pScreenPriv->rootVisual;
pPixmapPriv->target = xglPixmapTargetIn;
pScreenPriv->pScreenPixmap = pPixmap;
if (!pScreenPriv->pScreenPixmap)
pScreenPriv->pScreenPixmap = pPixmap;
}
return TRUE;
}
@ -397,12 +481,12 @@ xglPixmapToRegion (PixmapPtr pPixmap)
{
ScreenPtr pScreen = pPixmap->drawable.pScreen;
RegionPtr pRegion;
XGL_SCREEN_PRIV (pScreen);
if (!xglSyncBits (&pPixmap->drawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING);
XGL_SCREEN_UNWRAP (BitmapToRegion);
pRegion = (*pScreen->BitmapToRegion) (pPixmap);
XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion);
@ -423,14 +507,14 @@ xglPixmapToGeometry (PixmapPtr pPixmap,
if (!pPixmapPriv->pGeometry)
{
xglGeometryPtr pGeometry;
if (!pPixmapPriv->buffer)
{
if (!xglAllocatePixmapBits (pPixmap,
XGL_PIXMAP_USAGE_HINT_DEFAULT))
return NULL;
}
pGeometry = xalloc (sizeof (xglGeometryRec));
if (!pGeometry)
return NULL;
@ -453,7 +537,7 @@ xglPixmapToGeometry (PixmapPtr pPixmap,
pGeometry->f.bitmap.scanline_order =
GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
}
pGeometry->f.bitmap.pad = ((1 + FB_MASK) >> FB_SHIFT) *
sizeof (FbBits);
pGeometry->width = pPixmap->drawable.width;
@ -473,27 +557,28 @@ xglCreatePixmapSurface (PixmapPtr pPixmap)
{
XGL_PIXMAP_PRIV (pPixmap);
if (!pPixmapPriv->format)
return FALSE;
if (!pPixmapPriv->surface)
{
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
if (!pPixmapPriv->pVisual || !pPixmapPriv->pVisual->format.surface)
return FALSE;
pPixmapPriv->surface =
glitz_surface_create (pScreenPriv->drawable,
pPixmapPriv->format,
pPixmapPriv->pVisual->format.surface,
pPixmap->drawable.width,
pPixmap->drawable.height,
0, NULL);
if (!pPixmapPriv->surface)
{
pPixmapPriv->format = NULL;
pPixmapPriv->target = xglPixmapTargetNo;
pPixmapPriv->pVisual = NULL;
pPixmapPriv->target = xglPixmapTargetNo;
return FALSE;
}
}
return TRUE;
}
@ -501,20 +586,20 @@ Bool
xglAllocatePixmapBits (PixmapPtr pPixmap, int hint)
{
int width, height, bpp, stride;
XGL_PIXMAP_PRIV (pPixmap);
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
width = pPixmap->drawable.width;
height = pPixmap->drawable.height;
bpp = pPixmap->drawable.bitsPerPixel;
stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
if (stride)
{
glitz_buffer_t *buffer;
if ((pScreenPriv->pboMask & bpp) && hint)
{
buffer = glitz_pixel_buffer_create (pScreenPriv->drawable,
@ -544,7 +629,7 @@ xglAllocatePixmapBits (PixmapPtr pPixmap, int hint)
pPixmapPriv->stride = stride;
else
pPixmapPriv->stride = -stride;
return TRUE;
}
@ -554,14 +639,14 @@ xglMapPixmapBits (PixmapPtr pPixmap)
if (!pPixmap->devPrivate.ptr)
{
CARD8 *bits;
XGL_PIXMAP_PRIV (pPixmap);
if (!pPixmapPriv->buffer)
if (!xglAllocatePixmapBits (pPixmap,
XGL_PIXMAP_USAGE_HINT_DEFAULT))
return FALSE;
bits = glitz_buffer_map (pPixmapPriv->buffer,
GLITZ_BUFFER_ACCESS_READ_WRITE);
if (!bits)
@ -578,7 +663,7 @@ xglMapPixmapBits (PixmapPtr pPixmap)
pPixmap->devPrivate.ptr = bits;
}
}
return TRUE;
}
@ -589,10 +674,68 @@ xglUnmapPixmapBits (PixmapPtr pPixmap)
pPixmap->devKind = 0;
pPixmap->devPrivate.ptr = 0;
if (pPixmapPriv->buffer)
if (glitz_buffer_unmap (pPixmapPriv->buffer))
return FALSE;
return TRUE;
}
Bool
xglCheckPixmapSize (PixmapPtr pPixmap,
xglSizeConstraintPtr pSize)
{
if (pPixmap->drawable.width < pSize->minWidth ||
pPixmap->drawable.height < pSize->minHeight)
return FALSE;
if (pPixmap->drawable.width > pSize->aboveWidth ||
pPixmap->drawable.height > pSize->aboveHeight)
return TRUE;
return FALSE;
}
void
xglEnablePixmapAccel (PixmapPtr pPixmap,
xglAccelInfoPtr pAccel)
{
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
XGL_PIXMAP_PRIV (pPixmap);
if (pAccel->enabled && xglCheckPixmapSize (pPixmap, &pAccel->size))
{
xglVisualPtr v;
if (pAccel->pbuffer)
{
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->pPixel->depth != pPixmap->drawable.depth)
continue;
if (v->format.drawable && v->pbuffer)
break;
}
}
else
{
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->pPixel->depth != pPixmap->drawable.depth)
continue;
if (v->format.drawable && !v->pbuffer)
break;
}
}
if (v)
{
xglSetPixmapVisual (pPixmap, v);
if (!pPixmapPriv->target)
pPixmapPriv->target = xglPixmapTargetOut;
}
}
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -60,27 +60,6 @@ int xglGlyphPrivateIndex;
#define xglRecolorCursor (void *) NoopDDA
#define xglSetCursorPosition (void *) NoopDDA
static PixmapPtr
xglGetWindowPixmap (WindowPtr pWin)
{
return XGL_GET_WINDOW_PIXMAP (pWin);
}
static void
xglSetWindowPixmap (WindowPtr pWin,
PixmapPtr pPixmap)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
XGL_SCREEN_PRIV (pScreen);
XGL_SCREEN_UNWRAP (SetWindowPixmap);
(*pScreen->SetWindowPixmap) (pWin, pPixmap);
XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
XGL_GET_WINDOW_PRIV(pWin)->pPixmap = pPixmap;
}
static Bool
xglAllocatePrivates (ScreenPtr pScreen)
{
@ -91,7 +70,7 @@ xglAllocatePrivates (ScreenPtr pScreen)
xglScreenPrivateIndex = AllocateScreenPrivateIndex ();
if (xglScreenPrivateIndex < 0)
return FALSE;
xglGCPrivateIndex = AllocateGCPrivateIndex ();
if (xglGCPrivateIndex < 0)
return FALSE;
@ -104,13 +83,13 @@ xglAllocatePrivates (ScreenPtr pScreen)
if (xglWinPrivateIndex < 0)
return FALSE;
#ifdef RENDER
#ifdef RENDER
xglGlyphPrivateIndex = AllocateGlyphPrivateIndex ();
if (xglGlyphPrivateIndex < 0)
return FALSE;
#endif
xglScreenGeneration = serverGeneration;
#endif
xglScreenGeneration = serverGeneration;
}
if (!AllocateGCPrivate (pScreen, xglGCPrivateIndex, sizeof (xglGCRec)))
@ -127,66 +106,74 @@ xglAllocatePrivates (ScreenPtr pScreen)
pScreenPriv = xalloc (sizeof (xglScreenRec));
if (!pScreenPriv)
return FALSE;
XGL_SET_SCREEN_PRIV (pScreen, pScreenPriv);
return TRUE;
}
Bool
xglScreenInit (ScreenPtr pScreen)
xglScreenInit (ScreenPtr pScreen)
{
xglScreenPtr pScreenPriv;
int depth, bpp;
xglVisualPtr v;
int i, depth, bpp = 0;
#ifdef RENDER
PictureScreenPtr pPictureScreen;
#endif
depth = xglScreenInfo.depth;
for (v = xglVisuals; v; v = v->next)
{
if (v->pPixel->depth == depth)
{
bpp = v->pPixel->masks.bpp;
break;
}
}
if (!bpp)
return FALSE;
if (!xglAllocatePrivates (pScreen))
return FALSE;
pScreenPriv = XGL_GET_SCREEN_PRIV (pScreen);
pScreenPriv->pScreenPixmap = NULL;
pScreenPriv->pVisual = &xglVisuals[0];
/* Add any unlisted depths from the pixmap formats */
for (i = 0; i < screenInfo.numPixmapFormats; i++)
{
if (!xglHasVisualTypes (xglVisuals, screenInfo.formats[i].depth))
xglSetVisualTypes (screenInfo.formats[i].depth, 0, 0, 0, 0);
}
pScreenPriv->pVisual = 0;
#ifdef GLXEXT
pScreenPriv->pGlxVisual = 0;
#endif
pScreenPriv->rootVisual = 0;
pScreenPriv->drawable = xglScreenInfo.drawable;
pScreenPriv->features =
glitz_drawable_get_features (xglScreenInfo.drawable);
glitz_drawable_get_features (xglScreenInfo.drawable);
depth = pScreenPriv->pVisual->pPixel->depth;
bpp = pScreenPriv->pVisual->pPixel->masks.bpp;
GEOMETRY_INIT (pScreen, &pScreenPriv->scratchGeometry,
GLITZ_GEOMETRY_TYPE_VERTEX,
pScreenPriv->geometryUsage, 0);
xglInitPixmapFormats (pScreen);
if (!pScreenPriv->pixmapFormats[depth].format)
return FALSE;
pScreenPriv->geometryDataType = xglScreenInfo.geometryDataType;
pScreenPriv->geometryUsage = xglScreenInfo.geometryUsage;
pScreenPriv->yInverted = xglScreenInfo.yInverted;
pScreenPriv->pboMask = xglScreenInfo.pboMask;
pScreenPriv->lines = xglScreenInfo.lines;
pScreenPriv->fbo = xglScreenInfo.fbo;
pScreenPriv->accel = xglScreenInfo.accel;
GEOMETRY_INIT (pScreen, &pScreenPriv->scratchGeometry,
GLITZ_GEOMETRY_TYPE_VERTEX,
pScreenPriv->geometryUsage, 0);
pScreenPriv->surface =
glitz_surface_create (pScreenPriv->drawable,
pScreenPriv->pixmapFormats[depth].format,
xglScreenInfo.width, xglScreenInfo.height,
0, NULL);
if (!pScreenPriv->surface)
return FALSE;
glitz_surface_attach (pScreenPriv->surface,
pScreenPriv->drawable,
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
pScreenPriv->backSurface = NULL;
if (monitorResolution == 0)
monitorResolution = XGL_DEFAULT_DPI;
@ -197,7 +184,7 @@ xglScreenInit (ScreenPtr pScreen)
return FALSE;
pScreen->SaveScreen = xglSaveScreen;
pScreen->CreatePixmap = xglCreatePixmap;
pScreen->DestroyPixmap = xglDestroyPixmap;
@ -218,9 +205,10 @@ xglScreenInit (ScreenPtr pScreen)
XGL_SCREEN_WRAP (GetImage, xglGetImage);
XGL_SCREEN_WRAP (GetSpans, xglGetSpans);
XGL_SCREEN_WRAP (CopyWindow, xglCopyWindow);
XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
XGL_SCREEN_WRAP (PaintWindowBackground, xglPaintWindowBackground);
XGL_SCREEN_WRAP (PaintWindowBorder, xglPaintWindowBorder);
@ -234,13 +222,13 @@ xglScreenInit (ScreenPtr pScreen)
pScreen->UnrealizeCursor = xglUnrealizeCursor;
pScreen->RecolorCursor = xglRecolorCursor;
pScreen->SetCursorPosition = xglSetCursorPosition;
pScreen->ModifyPixmapHeader = xglModifyPixmapHeader;
XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion);
pScreen->GetWindowPixmap = xglGetWindowPixmap;
XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
#ifdef RENDER
@ -250,7 +238,7 @@ xglScreenInit (ScreenPtr pScreen)
if (!AllocateGlyphPrivate (pScreen, xglGlyphPrivateIndex,
sizeof (xglGlyphRec)))
return FALSE;
XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph);
XGL_PICTURE_SCREEN_WRAP (UnrealizeGlyph, xglUnrealizeGlyph);
XGL_PICTURE_SCREEN_WRAP (Composite, xglComposite);
@ -272,6 +260,7 @@ xglScreenInit (ScreenPtr pScreen)
return FALSE;
#ifdef COMPOSITE
#warning "composite building"
if (!compScreenInit (pScreen))
return FALSE;
#endif
@ -287,7 +276,8 @@ xglScreenInit (ScreenPtr pScreen)
Bool
xglFinishScreenInit (ScreenPtr pScreen)
{
xglVisualPtr v;
#ifdef RENDER
glitz_vertex_format_t *format;
static glitz_color_t clearBlack = { 0x0, 0x0, 0x0, 0x0 };
@ -296,38 +286,67 @@ xglFinishScreenInit (ScreenPtr pScreen)
#endif
XGL_SCREEN_PRIV (pScreen);
pScreenPriv->solid =
glitz_surface_create (pScreenPriv->drawable,
pScreenPriv->pixmapFormats[32].format,
1, 1, 0, NULL);
if (!pScreenPriv->solid)
xglInitVisuals (pScreen);
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->vid == pScreen->rootVisual)
pScreenPriv->rootVisual = v;
}
if (!pScreenPriv->rootVisual || !pScreenPriv->rootVisual->format.surface)
return FALSE;
glitz_surface_set_fill (pScreenPriv->solid, GLITZ_FILL_REPEAT);
pScreenPriv->surface =
glitz_surface_create (pScreenPriv->drawable,
pScreenPriv->rootVisual->format.surface,
xglScreenInfo.width, xglScreenInfo.height,
0, NULL);
if (!pScreenPriv->surface)
return FALSE;
glitz_surface_attach (pScreenPriv->surface,
pScreenPriv->drawable,
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
#ifdef RENDER
for (i = 0; i < 33; i++)
pScreenPriv->glyphCache[i].pScreen = NULL;
pScreenPriv->pSolidAlpha = NULL;
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->pPixel->depth == 8)
break;
}
pScreenPriv->trapInfo.mask =
glitz_surface_create (pScreenPriv->drawable,
pScreenPriv->pixmapFormats[8].format,
2, 1, 0, NULL);
if (!pScreenPriv->trapInfo.mask)
return FALSE;
pScreenPriv->pSolidAlpha = 0;
pScreenPriv->trapInfo.pMask = 0;
glitz_set_rectangle (pScreenPriv->trapInfo.mask, &clearBlack, 0, 0, 1, 1);
glitz_set_rectangle (pScreenPriv->trapInfo.mask, &solidWhite, 1, 0, 1, 1);
glitz_surface_set_fill (pScreenPriv->trapInfo.mask, GLITZ_FILL_NEAREST);
glitz_surface_set_filter (pScreenPriv->trapInfo.mask,
GLITZ_FILTER_BILINEAR,
NULL, 0);
/* An accelerated alpha only Xgl visual is required for trapezoid
acceleration */
if (v && v->format.surface)
{
glitz_surface_t *mask;
format = &pScreenPriv->trapInfo.format.vertex;
mask = glitz_surface_create (pScreenPriv->drawable,
v->format.surface,
2, 1, 0, NULL);
if (mask)
{
glitz_set_rectangle (mask, &clearBlack, 0, 0, 1, 1);
glitz_set_rectangle (mask, &solidWhite, 1, 0, 1, 1);
glitz_surface_set_fill (mask, GLITZ_FILL_NEAREST);
glitz_surface_set_filter (mask, GLITZ_FILTER_BILINEAR, NULL, 0);
pScreenPriv->trapInfo.pMask = xglCreateDevicePicture (mask);
if (!pScreenPriv->trapInfo.pMask)
return FALSE;
}
}
format = &pScreenPriv->trapInfo.format.vertex;
format->primitive = GLITZ_PRIMITIVE_QUADS;
format->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK;
@ -348,7 +367,12 @@ xglFinishScreenInit (ScreenPtr pScreen)
format->mask.offset = 2 * sizeof (glitz_short_t);
}
#endif
#ifdef XV
if (!xglXvScreenInit (pScreen))
return FALSE;
#endif
return TRUE;
}
@ -356,37 +380,49 @@ Bool
xglCloseScreen (int index,
ScreenPtr pScreen)
{
xglVisualPtr v;
XGL_SCREEN_PRIV (pScreen);
XGL_PIXMAP_PRIV (pScreenPriv->pScreenPixmap);
#ifdef RENDER
int i;
for (i = 0; i < 33; i++)
xglFiniGlyphCache (&pScreenPriv->glyphCache[i]);
if (pScreenPriv->pSolidAlpha)
FreePicture ((pointer) pScreenPriv->pSolidAlpha, 0);
if (pScreenPriv->trapInfo.mask)
glitz_surface_destroy (pScreenPriv->trapInfo.mask);
if (pScreenPriv->trapInfo.pMask)
FreePicture ((pointer) pScreenPriv->trapInfo.pMask, 0);
#endif
xglFiniPixmap (pScreenPriv->pScreenPixmap);
if (pPixmapPriv->pDamage)
DamageDestroy (pPixmapPriv->pDamage);
if (pScreenPriv->solid)
glitz_surface_destroy (pScreenPriv->solid);
if (pScreenPriv->backSurface)
glitz_surface_destroy (pScreenPriv->backSurface);
if (pScreenPriv->surface)
glitz_surface_destroy (pScreenPriv->surface);
GEOMETRY_UNINIT (&pScreenPriv->scratchGeometry);
while (pScreenPriv->pVisual)
{
v = pScreenPriv->pVisual;
pScreenPriv->pVisual = v->next;
xfree (v);
}
#ifdef GLXEXT
while (pScreenPriv->pGlxVisual)
{
v = pScreenPriv->pGlxVisual;
pScreenPriv->pGlxVisual = v->next;
xfree (v);
}
#endif
XGL_SCREEN_UNWRAP (CloseScreen);
xfree (pScreenPriv);
@ -404,7 +440,7 @@ xglCreateSolidAlphaPicture (ScreenPtr pScreen)
int error;
Pixel pixel;
GCPtr pGC;
CARD32 tmpval[2];
XID tmpval[2];
XGL_SCREEN_PRIV (pScreen);
@ -415,25 +451,24 @@ xglCreateSolidAlphaPicture (ScreenPtr pScreen)
pGC = GetScratchGC (pFormat->depth, pScreen);
if (!pGC)
return;
pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1, pFormat->depth);
if (!pPixmap)
return;
miRenderColorToPixel (pFormat, &solidWhite, &pixel);
tmpval[0] = GXcopy;
tmpval[1] = pixel;
ChangeGC (pGC, GCFunction | GCForeground, tmpval);
ValidateGC (&pPixmap->drawable, pGC);
ValidateGC (&pPixmap->drawable, pGC);
(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
FreeScratchGC (pGC);
tmpval[0] = xTrue;
pScreenPriv->pSolidAlpha =
CreatePicture (0, &pPixmap->drawable, pFormat,
CPRepeat, tmpval, 0, &error);
pScreenPriv->pSolidAlpha = CreatePicture (0, &pPixmap->drawable, pFormat,
CPRepeat, tmpval, 0, &error);
(*pScreen->DestroyPixmap) (pPixmap);
if (pScreenPriv->pSolidAlpha)

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2005 Novell, Inc.
*
*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. 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,
* 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.
*
@ -56,9 +56,11 @@ xglShmPutImage (DrawablePtr pDrawable,
GetScratchPixmapHeader (pScreen, w, h, depth,
BitsPerPixel (depth),
PixmapBytePad (w, depth),
(pointer) data);
(pointer) data);
/* disable any possible acceleration of this pixmap */
if (pPixmap)
XGL_GET_PIXMAP_PRIV (pPixmap)->format = NULL;
xglSetPixmapVisual (pPixmap, 0);
}
else
{
@ -67,24 +69,22 @@ xglShmPutImage (DrawablePtr pDrawable,
{
GCPtr pScratchGC;
XGL_PIXMAP_PRIV (pPixmap);
if (!xglAllocatePixmapBits (pPixmap,
XGL_PIXMAP_USAGE_HINT_DEFAULT))
{
(*pScreen->DestroyPixmap) (pPixmap);
return;
}
pPixmapPriv->format = NULL;
pPixmapPriv->target = xglPixmapTargetNo;
xglSetPixmapVisual (pPixmap, 0);
pScratchGC = GetScratchGC (depth, pScreen);
if (!pScratchGC)
{
(*pScreen->DestroyPixmap) (pPixmap);
return;
}
ValidateGC ((DrawablePtr) pPixmap, pScratchGC);
(*pGC->ops->PutImage) ((DrawablePtr) pPixmap, pScratchGC, depth,
-sx, -sy, w, h, 0,
@ -96,7 +96,7 @@ xglShmPutImage (DrawablePtr pDrawable,
sx = sy = 0;
}
}
if (!pPixmap)
return;
@ -112,7 +112,7 @@ xglShmPutImage (DrawablePtr pDrawable,
sx, sy, sw, sh, dx, dy);
pPixmapPriv->target = saveTarget;
if (pPixmapHeader)
FreeScratchPixmapHeader (pPixmapHeader);
else

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -31,7 +31,7 @@
Bool
xglSolid (DrawablePtr pDrawable,
glitz_operator_t op,
glitz_color_t *color,
glitz_surface_t *solid,
xglGeometryPtr pGeometry,
int x,
int y,
@ -42,18 +42,14 @@ xglSolid (DrawablePtr pDrawable,
{
glitz_surface_t *surface;
int xOff, yOff;
XGL_SCREEN_PRIV (pDrawable->pScreen);
if (nBox < 1)
return TRUE;
if (!xglPrepareTarget (pDrawable))
return FALSE;
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
glitz_set_rectangle (pScreenPriv->solid, color, 0, 0, 1, 1);
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
if (pGeometry)
{
@ -67,12 +63,12 @@ xglSolid (DrawablePtr pDrawable,
}
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
if (!GEOMETRY_ENABLE (pGeometry, surface))
return FALSE;
glitz_composite (op,
pScreenPriv->solid, NULL, surface,
solid, NULL, surface,
0, 0,
0, 0,
x + xOff,
@ -80,7 +76,7 @@ xglSolid (DrawablePtr pDrawable,
width, height);
glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
if (glitz_surface_get_status (surface))
return FALSE;
@ -104,7 +100,7 @@ xglSolidGlyph (DrawablePtr pDrawable,
x += pDrawable->x;
y += pDrawable->y;
GEOMETRY_INIT (pDrawable->pScreen, &geometry,
GLITZ_GEOMETRY_TYPE_BITMAP,
GEOMETRY_USAGE_SYSMEM, 0);
@ -116,11 +112,11 @@ xglSolidGlyph (DrawablePtr pDrawable,
pglyphBase);
GEOMETRY_TRANSLATE (&geometry, x, y);
widthBack = 0;
while (nGlyph--)
widthBack += (*ppci++)->metrics.characterWidth;
xBack = x;
if (widthBack < 0)
{
@ -129,10 +125,10 @@ xglSolidGlyph (DrawablePtr pDrawable,
}
yBack = y - FONTASCENT (pGC->font);
heightBack = FONTASCENT (pGC->font) + FONTDESCENT (pGC->font);
if (xglSolid (pDrawable,
pGCPriv->op,
&pGCPriv->bg,
pGCPriv->bg,
NULL,
xBack,
yBack,
@ -143,7 +139,7 @@ xglSolidGlyph (DrawablePtr pDrawable,
{
if (xglSolid (pDrawable,
pGCPriv->op,
&pGCPriv->fg,
pGCPriv->fg,
&geometry,
xBack,
yBack,
@ -153,10 +149,11 @@ xglSolidGlyph (DrawablePtr pDrawable,
REGION_NUM_RECTS (pGC->pCompositeClip)))
{
GEOMETRY_UNINIT (&geometry);
xglAddCurrentBitDamage (pDrawable);
return TRUE;
}
}
GEOMETRY_UNINIT (&geometry);
return FALSE;
}

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -25,49 +25,11 @@
#include "xgl.h"
/*
* A pixmap may exist both in hardware and in software. Synchronization
* is handled as follows:
*
* Regions modified by software and hardware needs to be tracked.
* A software operation requires that a rectangle of pixels matching the
* extents of the operation is synchronized. A hardware operation
* requires that all pixels are synchronized. If the bounds of a
* hardware operation intersects the bounds of a currently synchronized
* software rectangle, the software rectangle will be discarded and the
* next software operation will require re-synchronization.
*
* A software rectangle of pixels is synchronized as follows. If a
* previously synchronized rectangle exists, then if this previous
* rectangle subsumes our new rectangle no pixels are fetched from
* hardware as all pixels that need to be synchronized are already up to
* date. If a previously synchronized rectangle exists and it intersects
* with our new rectangle, then both these rectangles are merged into a
* larger rectangle and pixels not part of the previous rectangle are
* fetched form hardware. If a previously synchronized rectangle exists
* and it doesn't intersect with our new rectangle, then the previous
* rectangle is discarded and pixels are fetched from hardware so that
* our new rectangle becomes synchronized.
*
* If the pixmap exists in hardware and if it can be a target of a
* drawing operation, then it is kept synchronized all the time, any
* pixels modified by software will be transfered to hardware right
* away. If the pixmap exists in hardware but it can only be used as
* source of a drawing operation, then synchronization is performed
* only when needed.
*/
#define ALL_BITS(pPixmap, pBox) \
((pBox)->x1 <= 0 && (pBox)->y1 <= 0 && \
(pBox)->x2 >= (pPixmap)->drawable.width && \
(pBox)->y2 >= (pPixmap)->drawable.height)
Bool
xglSyncBits (DrawablePtr pDrawable,
BoxPtr pExtents)
{
RegionRec region;
BoxPtr pBitBox;
BoxRec box;
XGL_DRAWABLE_PIXMAP (pDrawable);
@ -76,53 +38,66 @@ xglSyncBits (DrawablePtr pDrawable,
if (pPixmapPriv->allBits)
return xglMapPixmapBits (pPixmap);
pBitBox = &pPixmapPriv->bitBox;
if (pPixmapPriv->target == xglPixmapTargetIn && pExtents)
{
box.x1 = MAX (0, pExtents->x1);
box.y1 = MAX (0, pExtents->y1);
box.x2 = MAX (0, MIN (pPixmap->drawable.width, pExtents->x2));
box.y2 = MAX (0, MIN (pPixmap->drawable.height, pExtents->y2));
box.x1 = 0;
box.y1 = 0;
box.x2 = pPixmap->drawable.width;
box.y2 = pPixmap->drawable.height;
if (pExtents->x1 > box.x1)
box.x1 = pExtents->x1;
if (pExtents->y1 > box.y1)
box.y1 = pExtents->y1;
if (pExtents->x2 < box.x2)
box.x2 = pExtents->x2;
if (pExtents->y2 < box.y2)
box.y2 = pExtents->y2;
if (!BOX_NOTEMPTY (&box))
if (box.x2 <= box.x1 || box.y2 <= box.y1)
return xglMapPixmapBits (pPixmap);
if (BOX_NOTEMPTY (pBitBox))
if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
{
RegionRec bitRegion;
REGION_INIT (pDrawable->pScreen, &bitRegion, pBitBox, 1);
switch (RECT_IN_REGION (pDrawable->pScreen, &bitRegion, &box)) {
switch (RECT_IN_REGION (pDrawable->pScreen,
&pPixmapPriv->bitRegion,
&box)) {
case rgnIN:
REGION_NULL (pDrawable->pScreen, &region);
REGION_INIT (pDrawable->pScreen, &region, NullBox, 0);
break;
case rgnOUT:
REGION_INIT (pDrawable->pScreen, &region, &box, 1);
*pBitBox = box;
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox);
REGION_UNION (pDrawable->pScreen,
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
&region);
break;
case rgnPART:
pBitBox->x1 = MIN (pBitBox->x1, box.x1);
pBitBox->y1 = MIN (pBitBox->y1, box.y1);
pBitBox->x2 = MAX (pBitBox->x2, box.x2);
pBitBox->y2 = MAX (pBitBox->y2, box.y2);
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox);
REGION_INIT (pDrawable->pScreen, &region, pBitBox, 1);
REGION_INIT (pDrawable->pScreen, &region, &box, 1);
REGION_SUBTRACT (pDrawable->pScreen, &region, &region,
&bitRegion);
&pPixmapPriv->bitRegion);
REGION_UNION (pDrawable->pScreen,
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
&region);
break;
}
REGION_UNINIT (pDrawable->pScreen, &bitRegion);
}
else
{
REGION_INIT (pDrawable->pScreen, &region, &box, 1);
*pBitBox = box;
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox);
REGION_SUBTRACT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
&region, &pPixmapPriv->bitRegion);
}
if (REGION_NUM_RECTS (&pPixmapPriv->bitRegion) == 1)
{
BoxPtr pBox;
pBox = REGION_RECTS (&pPixmapPriv->bitRegion);
if (pBox->x1 <= 0 &&
pBox->y1 <= 0 &&
pBox->x2 >= pPixmap->drawable.width &&
pBox->y2 >= pPixmap->drawable.height)
pPixmapPriv->allBits = TRUE;
}
}
else
@ -133,17 +108,9 @@ xglSyncBits (DrawablePtr pDrawable,
box.y2 = pPixmap->drawable.height;
REGION_INIT (pDrawable->pScreen, &region, &box, 1);
if (BOX_NOTEMPTY (pBitBox))
{
RegionRec bitRegion;
REGION_INIT (pDrawable->pScreen, &bitRegion, pBitBox, 1);
REGION_SUBTRACT (pDrawable->pScreen, &region, &region, &bitRegion);
REGION_UNINIT (pDrawable->pScreen, &bitRegion);
}
*pBitBox = box;
REGION_SUBTRACT (pDrawable->pScreen, &region, &region,
&pPixmapPriv->bitRegion);
pPixmapPriv->allBits = TRUE;
}
@ -151,62 +118,66 @@ xglSyncBits (DrawablePtr pDrawable,
if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
return FALSE;
if (pPixmapPriv->pDamage)
{
RegionPtr pRegion;
pRegion = DamageRegion (pPixmapPriv->pDamage);
REGION_SUBTRACT (pDrawable->pScreen, &region, &region, pRegion);
}
if (REGION_NOTEMPTY (pDrawable->pScreen, &region) && pPixmapPriv->surface)
{
glitz_pixel_format_t format;
BoxPtr pBox;
BoxPtr pExt;
int nBox;
if (!xglSyncSurface (pDrawable))
FatalError (XGL_SW_FAILURE_STRING);
xglUnmapPixmapBits (pPixmap);
pBox = REGION_RECTS (&region);
nBox = REGION_NUM_RECTS (&region);
pExt = REGION_EXTENTS (pDrawable->pScreen, &region);
format.fourcc = GLITZ_FOURCC_RGB;
format.masks = pPixmapPriv->pPixel->masks;
while (nBox--)
format.fourcc = GLITZ_FOURCC_RGB;
format.masks = pPixmapPriv->pVisual->pPixel->masks;
format.xoffset = pExt->x1;
if (pPixmapPriv->stride < 0)
{
format.xoffset = pBox->x1;
if (pPixmapPriv->stride < 0)
{
format.skip_lines = pPixmap->drawable.height - pBox->y2;
format.bytes_per_line = -pPixmapPriv->stride;
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
}
else
{
format.skip_lines = pBox->y1;
format.bytes_per_line = pPixmapPriv->stride;
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
}
glitz_get_pixels (pPixmapPriv->surface,
pBox->x1,
pBox->y1,
pBox->x2 - pBox->x1,
pBox->y2 - pBox->y1,
&format,
pPixmapPriv->buffer);
pBox++;
format.skip_lines = pPixmap->drawable.height - pExt->y2;
format.bytes_per_line = -pPixmapPriv->stride;
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
}
else
{
format.skip_lines = pExt->y1;
format.bytes_per_line = pPixmapPriv->stride;
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
}
glitz_surface_set_clip_region (pPixmapPriv->surface,
0, 0, (glitz_box_t *) pBox, nBox);
glitz_get_pixels (pPixmapPriv->surface,
pExt->x1,
pExt->y1,
pExt->x2 - pExt->x1,
pExt->y2 - pExt->y1,
&format,
pPixmapPriv->buffer);
glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0);
}
REGION_UNINIT (pDrawable->pScreen, &region);
if (pPixmapPriv->allBits)
{
box.x1 = 0;
box.y1 = 0;
box.x2 = pPixmap->drawable.width;
box.y2 = pPixmap->drawable.height;
REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion);
REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion, &box, 1);
}
return xglMapPixmapBits (pPixmap);
}
@ -229,9 +200,6 @@ xglSyncSurface (DrawablePtr pDrawable)
if (!pPixmapPriv->surface)
{
if (!pPixmapPriv->format)
return FALSE;
if (!xglCreatePixmapSurface (pPixmap))
return FALSE;
}
@ -239,20 +207,20 @@ xglSyncSurface (DrawablePtr pDrawable)
pRegion = DamageRegion (pPixmapPriv->pDamage);
if (REGION_NOTEMPTY (pDrawable->pScreen, pRegion))
{
{
glitz_pixel_format_t format;
BoxPtr pBox;
BoxPtr pExt;
int nBox;
xglUnmapPixmapBits (pPixmap);
nBox = REGION_NUM_RECTS (pRegion);
pBox = REGION_RECTS (pRegion);
pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
format.fourcc = GLITZ_FOURCC_RGB;
format.masks = pPixmapPriv->pPixel->masks;
format.fourcc = pPixmapPriv->pVisual->format.surface->color.fourcc;
format.masks = pPixmapPriv->pVisual->pPixel->masks;
format.xoffset = pExt->x1;
if (pPixmapPriv->stride < 0)
@ -299,16 +267,51 @@ xglPrepareTarget (DrawablePtr pDrawable)
case xglPixmapTargetOut:
if (xglSyncSurface (pDrawable))
{
pPixmapPriv->target = xglPixmapTargetIn;
return TRUE;
glitz_drawable_format_t *format;
XGL_SCREEN_PRIV (pDrawable->pScreen);
if (!pPixmapPriv->drawable)
{
unsigned int width, height;
format = pPixmapPriv->pVisual->format.drawable;
width = pPixmap->drawable.width;
height = pPixmap->drawable.height;
if (pPixmapPriv->pVisual->pbuffer)
{
pPixmapPriv->drawable =
glitz_create_pbuffer_drawable (pScreenPriv->drawable,
format, width, height);
}
else
{
pPixmapPriv->drawable =
glitz_create_drawable (pScreenPriv->drawable,
format, width, height);
}
}
if (pPixmapPriv->drawable)
{
glitz_surface_attach (pPixmapPriv->surface,
pPixmapPriv->drawable,
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
pPixmapPriv->target = xglPixmapTargetIn;
return TRUE;
}
}
pPixmapPriv->target = xglPixmapTargetNo;
break;
case xglPixmapTargetIn:
if (xglSyncSurface (pDrawable))
return TRUE;
break;
}
return FALSE;
}
@ -316,52 +319,65 @@ void
xglAddSurfaceDamage (DrawablePtr pDrawable,
RegionPtr pRegion)
{
RegionPtr pDamageRegion;
glitz_surface_t *surface;
int xOff, yOff;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
pPixmapPriv->damageBox = miEmptyBox;
if (!pPixmapPriv->format)
return;
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
if (xOff || yOff)
REGION_TRANSLATE (pDrawable->pScreen, pRegion, xOff, yOff);
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
if (pPixmapPriv->pDamage)
{
RegionPtr pDamageRegion;
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
REGION_UNION (pDrawable->pScreen,
pDamageRegion, pDamageRegion,
pRegion);
}
REGION_UNION (pDrawable->pScreen,
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
pRegion);
REGION_UNION (pDrawable->pScreen, pDamageRegion, pDamageRegion, pRegion);
if (xOff || yOff)
REGION_TRANSLATE (pDrawable->pScreen, pRegion, -xOff, -yOff);
}
void
xglAddCurrentSurfaceDamage (DrawablePtr pDrawable)
{
{
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if (!pPixmapPriv->format)
{
pPixmapPriv->damageBox = miEmptyBox;
return;
}
if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
{
RegionPtr pDamageRegion;
RegionRec region;
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
REGION_INIT (pDrawable->pScreen, &region, &pPixmapPriv->damageBox, 1);
if (pPixmapPriv->pDamage)
{
RegionPtr pDamageRegion;
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
REGION_UNION (pDrawable->pScreen,
pDamageRegion, pDamageRegion,
&region);
}
REGION_UNION (pDrawable->pScreen,
pDamageRegion, pDamageRegion, &region);
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
&region);
REGION_UNINIT (pDrawable->pScreen, &region);
pPixmapPriv->damageBox = miEmptyBox;
}
}
@ -370,34 +386,42 @@ void
xglAddBitDamage (DrawablePtr pDrawable,
RegionPtr pRegion)
{
BoxPtr pBox;
BoxPtr pExt;
int nBox;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
pBox = REGION_RECTS (pRegion);
pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
nBox = REGION_NUM_RECTS (pRegion);
if (pExt->x1 < pPixmapPriv->bitBox.x2 &&
pExt->y1 < pPixmapPriv->bitBox.y2 &&
pExt->x2 > pPixmapPriv->bitBox.x1 &&
pExt->y2 > pPixmapPriv->bitBox.y1)
if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
{
while (nBox--)
BoxPtr pBox;
BoxPtr pExt, pBitExt;
int nBox;
pBox = REGION_RECTS (pRegion);
pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
nBox = REGION_NUM_RECTS (pRegion);
pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);
if (pExt->x1 < pBitExt->x2 &&
pExt->y1 < pBitExt->y2 &&
pExt->x2 > pBitExt->x1 &&
pExt->y2 > pBitExt->y1)
{
if (pBox->x1 < pPixmapPriv->bitBox.x2 &&
pBox->y1 < pPixmapPriv->bitBox.y2 &&
pBox->x2 > pPixmapPriv->bitBox.x1 &&
pBox->y2 > pPixmapPriv->bitBox.y1)
while (nBox--)
{
pPixmapPriv->bitBox = miEmptyBox;
pPixmapPriv->allBits = FALSE;
return;
if (pBox->x1 < pBitExt->x2 &&
pBox->y1 < pBitExt->y2 &&
pBox->x2 > pBitExt->x1 &&
pBox->y2 > pBitExt->y1)
{
REGION_UNINIT (pDrawable->pScreen,
&pPixmapPriv->bitRegion);
REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
NullBox, 0);
pPixmapPriv->allBits = FALSE;
return;
}
pBox++;
}
pBox++;
}
}
}
@ -407,13 +431,22 @@ xglAddCurrentBitDamage (DrawablePtr pDrawable)
{
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if (pPixmapPriv->damageBox.x1 < pPixmapPriv->bitBox.x2 &&
pPixmapPriv->damageBox.y1 < pPixmapPriv->bitBox.y2 &&
pPixmapPriv->damageBox.x2 > pPixmapPriv->bitBox.x1 &&
pPixmapPriv->damageBox.y2 > pPixmapPriv->bitBox.y1)
if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
{
pPixmapPriv->bitBox = miEmptyBox;
pPixmapPriv->allBits = FALSE;
BoxPtr pBitExt;
pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);
if (pPixmapPriv->damageBox.x1 < pBitExt->x2 &&
pPixmapPriv->damageBox.y1 < pBitExt->y2 &&
pPixmapPriv->damageBox.x2 > pBitExt->x1 &&
pPixmapPriv->damageBox.y2 > pBitExt->y1)
{
REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion);
REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
NullBox, 0);
pPixmapPriv->allBits = FALSE;
}
}
pPixmapPriv->damageBox = miEmptyBox;

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -63,7 +63,7 @@ xglTiledBoxGeometry (PixmapPtr pTile,
tileWidth = pTile->drawable.width;
tileHeight = pTile->drawable.height;
for (i = 0; i < nBox; i++)
size +=
(((pBox[i].x2 - pBox[i].x1) / tileWidth) + 2) *
@ -75,7 +75,7 @@ xglTiledBoxGeometry (PixmapPtr pTile,
data = glitz_buffer_map (pGeometry->buffer,
GLITZ_BUFFER_ACCESS_WRITE_ONLY);
while (nBox--)
{
x = pBox->x1;
@ -87,19 +87,19 @@ xglTiledBoxGeometry (PixmapPtr pTile,
yTile = MOD (tileY + y, tileHeight);
yTmp = y;
while (height)
{
heightTile = MIN (tileHeight - yTile, height);
xTileTmp = xTile;
widthTmp = width;
xTmp = x;
while (widthTmp)
{
widthTile = MIN (tileWidth - xTileTmp, widthTmp);
p1.x = xTileTmp << 16;
p1.y = yTile << 16;
p2.x = (xTileTmp + widthTile) << 16;
@ -107,7 +107,7 @@ xglTiledBoxGeometry (PixmapPtr pTile,
glitz_surface_translate_point (pPixmapPriv->surface, &p1, &p1);
glitz_surface_translate_point (pPixmapPriv->surface, &p2, &p2);
x1 = FIXED_TO_FLOAT (p1.x);
y1 = FIXED_TO_FLOAT (p1.y);
x2 = FIXED_TO_FLOAT (p2.x);
@ -122,29 +122,29 @@ xglTiledBoxGeometry (PixmapPtr pTile,
*data++ = (glitz_float_t) yTmp;
*data++ = x2;
*data++ = y1;
*data++ = (glitz_float_t) (xTmp + widthTile);
*data++ = (glitz_float_t) (yTmp + heightTile);
*data++ = x2;
*data++ = y2;
*data++ = (glitz_float_t) xTmp;
*data++ = (glitz_float_t) (yTmp + heightTile);
*data++ = x1;
*data++ = y2;
pGeometry->endOffset += sizeof (glitz_float_t) * 16;
xTileTmp = 0;
xTmp += widthTile;
widthTmp -= widthTile;
}
yTile = 0;
yTmp += heightTile;
height -= heightTile;
}
pBox++;
}
@ -197,7 +197,7 @@ xglTile (DrawablePtr pDrawable,
GLITZ_FILTER_NEAREST,
NULL, 0);
glitz_surface_set_transform (pTilePriv->surface, NULL);
if (pTilePriv->acceleratedTile)
{
if (pGeometry)
@ -212,9 +212,9 @@ xglTile (DrawablePtr pDrawable,
4 * nBox);
GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
}
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
if (!GEOMETRY_ENABLE (pGeometry, surface))
return FALSE;
@ -231,7 +231,7 @@ xglTile (DrawablePtr pDrawable,
width, height);
glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
if (!glitz_surface_get_status (surface))
return TRUE;
@ -249,10 +249,10 @@ xglTile (DrawablePtr pDrawable,
return FALSE;
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
if (!GEOMETRY_ENABLE (pGeometry, surface))
return FALSE;
glitz_composite (op,
pTilePriv->surface, NULL, surface,
0, 0,
@ -260,9 +260,9 @@ xglTile (DrawablePtr pDrawable,
x + xOff,
y + yOff,
width, height);
if (glitz_surface_get_status (surface))
return FALSE;
return TRUE;
}

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2005 Novell, Inc.
*
*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. 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,
* 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.
*
@ -74,15 +74,15 @@ xglTrapezoidExtents (PicturePtr pDst,
extents->y1 = xFixedToInt (traps->top);
extents->y2 = xFixedToInt (xFixedCeil (traps->bottom));
LINE_FIXED_X (&traps->left, traps->top, top);
LINE_FIXED_X (&traps->left, traps->bottom, bottom);
extents->x1 = xFixedToInt (MIN (top, bottom));
LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
extents->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
ntrap--;
traps++;
@ -95,15 +95,15 @@ xglTrapezoidExtents (PicturePtr pDst,
y1 = xFixedToInt (traps->top);
y2 = xFixedToInt (xFixedCeil (traps->bottom));
LINE_FIXED_X (&traps->left, traps->top, top);
LINE_FIXED_X (&traps->left, traps->bottom, bottom);
x1 = xFixedToInt (MIN (top, bottom));
LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
x_overlap = FALSE;
if (x1 >= extents->x2)
extents->x2 = x2;
@ -117,18 +117,18 @@ xglTrapezoidExtents (PicturePtr pDst,
if (x2 > extents->x2)
extents->x2 = x2;
}
if (y1 >= extents->y2)
extents->y2 = y2;
else if (y2 <= extents->y1)
extents->y1 = y1;
extents->y1 = y1;
else
{
if (y1 < extents->y1)
extents->y1 = y1;
if (y2 > extents->y2)
extents->y2 = y2;
if (x_overlap)
overlap = TRUE;
}
@ -151,21 +151,20 @@ xglTrapezoids (CARD8 op,
{
ScreenPtr pScreen = pDst->pDrawable->pScreen;
PicturePtr pMask = NULL, pSrcPicture, pDstPicture;
PicturePtr pMaskPicture = NULL;
xglGeometryPtr pGeometry = NULL;
glitz_surface_t *mask = NULL;
unsigned int polyEdge = pDst->polyEdge;
INT16 xDst, yDst;
INT16 xOff, yOff;
BoxRec extents;
Bool overlap;
Bool target;
XGL_SCREEN_PRIV (pScreen);
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
xDst = traps[0].left.p1.x >> 16;
yDst = traps[0].left.p1.y >> 16;
overlap = xglTrapezoidExtents (pDst, nTrap, traps, &extents);
if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
return;
@ -180,7 +179,7 @@ xglTrapezoids (CARD8 op,
xRectangle rect;
int error;
int area;
if (!pScreenPriv->pSolidAlpha)
{
xglCreateSolidAlphaPicture (pScreen);
@ -194,11 +193,11 @@ xglTrapezoids (CARD8 op,
rect.height = extents.y2 - extents.y1;
pPixmap = (*pScreen->CreatePixmap) (pScreen,
rect.width, rect.height,
rect.width, rect.height,
maskFormat->depth);
if (!pPixmap)
return;
pMask = CreatePicture (0, &pPixmap->drawable, maskFormat,
0, 0, serverClient, &error);
if (!pMask)
@ -206,15 +205,17 @@ xglTrapezoids (CARD8 op,
(*pScreen->DestroyPixmap) (pPixmap);
return;
}
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
/* lock mask if we are not doing accelerated drawing to destination */
if (!target)
{
/* make sure we don't do accelerated drawing to mask */
xglSetPixmapVisual (pPixmap, NULL);
}
area = rect.width * rect.height;
if (!target || (SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1;
if ((SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
XGL_GET_PIXMAP_PRIV (pPixmap)->target = xglPixmapTargetNo;
ValidatePicture (pMask);
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
ValidateGC (&pPixmap->drawable, pGC);
@ -224,7 +225,7 @@ xglTrapezoids (CARD8 op,
(*pScreen->DestroyPixmap) (pPixmap);
target = xglPrepareTarget (pMask->pDrawable);
xOff = -extents.x1;
yOff = -extents.y1;
pSrcPicture = pScreenPriv->pSolidAlpha;
@ -232,9 +233,6 @@ xglTrapezoids (CARD8 op,
}
else
{
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
if (maskFormat)
{
if (maskFormat->depth == 1)
@ -242,7 +240,7 @@ xglTrapezoids (CARD8 op,
else
polyEdge = PolyEdgeSmooth;
}
xOff = 0;
yOff = 0;
pSrcPicture = pSrc;
@ -254,37 +252,38 @@ xglTrapezoids (CARD8 op,
if (maskFormat || polyEdge == PolyEdgeSmooth)
{
glitz_vertex_format_t *format;
glitz_surface_t *mask;
xTrapezoid *pTrap = traps;
int nAddedTrap, n = nTrap;
int offset = 0;
int size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
mask = pScreenPriv->trapInfo.mask;
pMaskPicture = pScreenPriv->trapInfo.pMask;
format = &pScreenPriv->trapInfo.format.vertex;
mask = pMaskPicture->pSourcePict->source.devPrivate.ptr;
size *= format->bytes_per_vertex;
pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
while (n)
{
if (pGeometry->size < size)
GEOMETRY_RESIZE (pScreen, pGeometry, size);
if (!pGeometry->buffer)
{
if (pMask)
FreePicture (pMask, 0);
pPixmapPriv->lock--;
return;
}
offset +=
glitz_add_trapezoids (pGeometry->buffer,
offset, size - offset, format->type,
mask, (glitz_trapezoid_t *) pTrap, n,
&nAddedTrap);
n -= nAddedTrap;
pTrap += nAddedTrap;
size *= 2;
@ -304,10 +303,9 @@ xglTrapezoids (CARD8 op,
if (pMask)
FreePicture (pMask, 0);
pPixmapPriv->lock--;
return;
}
GEOMETRY_ADD_TRAPEZOID (pScreen, pGeometry, traps, nTrap);
}
@ -317,19 +315,18 @@ xglTrapezoids (CARD8 op,
}
if (pGeometry &&
xglComp (pMask ? PictOpAdd : op,
pSrcPicture,
NULL,
pDstPicture,
extents.x1 + xOff + xSrc - xDst,
extents.y1 + yOff + ySrc - yDst,
0, 0,
pDstPicture->pDrawable->x + extents.x1 + xOff,
pDstPicture->pDrawable->y + extents.y1 + yOff,
extents.x2 - extents.x1,
extents.y2 - extents.y1,
pGeometry,
mask))
xglCompositeGeneral (pMask ? PictOpAdd : op,
pSrcPicture,
pMaskPicture,
pDstPicture,
pGeometry,
extents.x1 + xOff + xSrc - xDst,
extents.y1 + yOff + ySrc - yDst,
0, 0,
pDstPicture->pDrawable->x + extents.x1 + xOff,
pDstPicture->pDrawable->y + extents.y1 + yOff,
extents.x2 - extents.x1,
extents.y2 - extents.y1))
{
/* no intermediate mask? we need to register damage from here as
CompositePicture will never be called. */
@ -340,12 +337,12 @@ xglTrapezoids (CARD8 op,
REGION_INIT (pScreen, &region, &extents, 1);
REGION_TRANSLATE (pScreen, &region,
pDst->pDrawable->x, pDst->pDrawable->y);
DamageDamageRegion (pDst->pDrawable, &region);
REGION_UNINIT (pScreen, &region);
}
xglAddCurrentBitDamage (pDstPicture->pDrawable);
}
else
@ -363,16 +360,17 @@ xglTrapezoids (CARD8 op,
op == PictOpAdd && miIsSolidAlpha (pSrc)))
{
PictureScreenPtr ps = GetPictureScreen (pScreen);
for (; nTrap; nTrap--, traps++)
(*ps->RasterizeTrapezoid) (pDstPicture, traps, xOff, yOff);
xglAddCurrentSurfaceDamage (pDstPicture->pDrawable);
} else
miTrapezoids (op, pSrc, pDstPicture, NULL,
}
else
miTrapezoids (op, pSrc, pDstPicture, maskFormat,
xSrc, ySrc, nTrap, traps);
}
if (pMask)
{
CompositePicture (op, pSrc, pMask, pDst,
@ -382,12 +380,9 @@ xglTrapezoids (CARD8 op,
extents.x1, extents.y1,
extents.x2 - extents.x1,
extents.y2 - extents.y1);
FreePicture (pMask, 0);
}
/* release destination drawable lock */
pPixmapPriv->lock--;
}
void
@ -397,9 +392,9 @@ xglAddTraps (PicturePtr pDst,
int nTrap,
xTrap *traps)
{
PictureScreenPtr pPictureScreen;
PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pDst->pDrawable->pScreen;
XGL_SCREEN_PRIV (pScreen);
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
@ -417,33 +412,36 @@ xglAddTraps (PicturePtr pDst,
if (xglPrepareTarget (pDst->pDrawable))
{
PicturePtr pMask;
glitz_vertex_format_t *format;
glitz_surface_t *mask;
xglGeometryPtr pGeometry;
xTrap *pTrap = traps;
int nAddedTrap, n = nTrap;
int offset = 0;
int size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
pMask = pScreenPriv->trapInfo.pMask;
format = &pScreenPriv->trapInfo.format.vertex;
mask = pMask->pSourcePict->source.devPrivate.ptr;
size *= format->bytes_per_vertex;
pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
while (n)
{
if (pGeometry->size < size)
GEOMETRY_RESIZE (pScreen, pGeometry, size);
if (!pGeometry->buffer)
return;
offset +=
glitz_add_traps (pGeometry->buffer,
offset, size - offset, format->type,
pScreenPriv->trapInfo.mask,
offset, size - offset, format->type, mask,
(glitz_trap_t *) pTrap, n,
&nAddedTrap);
n -= nAddedTrap;
pTrap += nAddedTrap;
size *= 2;
@ -455,17 +453,17 @@ xglAddTraps (PicturePtr pDst,
GEOMETRY_TRANSLATE (pGeometry,
pDst->pDrawable->x + xOff,
pDst->pDrawable->y + yOff);
if (xglComp (PictOpAdd,
pScreenPriv->pSolidAlpha,
NULL,
pDst,
0, 0,
0, 0,
pDst->pDrawable->x, pDst->pDrawable->y,
pDst->pDrawable->width, pDst->pDrawable->height,
pGeometry,
pScreenPriv->trapInfo.mask))
if (xglCompositeGeneral (PictOpAdd,
pScreenPriv->pSolidAlpha,
pMask,
pDst,
pGeometry,
0, 0,
0, 0,
pDst->pDrawable->x, pDst->pDrawable->y,
pDst->pDrawable->width,
pDst->pDrawable->height))
{
xglAddCurrentBitDamage (pDst->pDrawable);
return;

View File

@ -1,6 +1,6 @@
/*
* 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
@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* 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,
* 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.
*
@ -40,7 +40,7 @@ xglCreateWindow (WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
Bool ret;
XGL_SCREEN_PRIV (pScreen);
XGL_WINDOW_PRIV (pWin);
@ -53,6 +53,21 @@ xglCreateWindow (WindowPtr pWin)
return ret;
}
Bool
xglDestroyWindow (WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
Bool ret;
XGL_SCREEN_PRIV (pScreen);
XGL_SCREEN_UNWRAP (DestroyWindow);
ret = (*pScreen->DestroyWindow) (pWin);
XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
return ret;
}
Bool
xglChangeWindowAttributes (WindowPtr pWin,
unsigned long mask)
@ -60,9 +75,9 @@ xglChangeWindowAttributes (WindowPtr pWin,
ScreenPtr pScreen = pWin->drawable.pScreen;
PixmapPtr pPixmap;
Bool ret;
XGL_SCREEN_PRIV (pScreen);
if (mask & CWBackPixmap)
{
if (pWin->backgroundState == BackgroundPixmap)
@ -74,7 +89,7 @@ xglChangeWindowAttributes (WindowPtr pWin,
xglSyncBits (&pPixmap->drawable, NULL);
}
}
if (mask & CWBorderPixmap)
{
if (pWin->borderIsPixel == FALSE)
@ -90,12 +105,12 @@ xglChangeWindowAttributes (WindowPtr pWin,
XGL_SCREEN_UNWRAP (ChangeWindowAttributes);
ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
return ret;
}
void
xglCopyWindow (WindowPtr pWin,
void
xglCopyWindow (WindowPtr pWin,
DDXPointRec ptOldOrg,
RegionPtr prgnSrc)
{
@ -111,18 +126,18 @@ xglCopyWindow (WindowPtr pWin,
box.y1 = pExtent->y1;
box.x2 = pExtent->x2;
box.y2 = pExtent->y2;
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
REGION_TRANSLATE (pWin->drawable.pScreen, prgnSrc, -dx, -dy);
REGION_NULL (pWin->drawable.pScreen, &rgnDst);
REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
REGION_INTERSECT (pWin->drawable.pScreen,
&rgnDst, &pWin->borderClip, prgnSrc);
fbCopyRegion (&pWin->drawable, &pWin->drawable,
0, &rgnDst, dx, dy, xglCopyProc, 0, (void *) &box);
REGION_UNINIT (pWin->drawable.pScreen, &rgnDst);
}
@ -131,29 +146,53 @@ xglFillRegionSolid (DrawablePtr pDrawable,
RegionPtr pRegion,
Pixel pixel)
{
glitz_color_t color;
BoxPtr pExtent;
glitz_pixel_format_t format;
glitz_surface_t *solid;
glitz_buffer_t *buffer;
BoxPtr pExtent;
Bool ret;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
XGL_SCREEN_PRIV (pDrawable->pScreen);
if (!pPixmapPriv->target)
if (!xglPrepareTarget (pDrawable))
return FALSE;
solid = glitz_surface_create (pScreenPriv->drawable,
pPixmapPriv->pVisual->format.surface,
1, 1, 0, NULL);
if (!solid)
return FALSE;
glitz_surface_set_fill (solid, GLITZ_FILL_REPEAT);
format.fourcc = GLITZ_FOURCC_RGB;
format.masks = pPixmapPriv->pVisual->pPixel->masks;
format.xoffset = 0;
format.skip_lines = 0;
format.bytes_per_line = sizeof (CARD32);
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
buffer = glitz_buffer_create_for_data (&pixel);
glitz_set_pixels (solid, 0, 0, 1, 1, &format, buffer);
glitz_buffer_destroy (buffer);
pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
xglPixelToColor (pPixmapPriv->pPixel, pixel, &color);
if (xglSolid (pDrawable,
GLITZ_OPERATOR_SRC,
&color,
NULL,
pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
REGION_RECTS (pRegion),
REGION_NUM_RECTS (pRegion)))
return TRUE;
return FALSE;
ret = xglSolid (pDrawable,
GLITZ_OPERATOR_SRC,
solid,
NULL,
pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
REGION_RECTS (pRegion),
REGION_NUM_RECTS (pRegion));
glitz_surface_destroy (solid);
return ret;
}
static Bool
@ -164,11 +203,6 @@ xglFillRegionTiled (DrawablePtr pDrawable,
int tileY)
{
BoxPtr pExtent;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if (!pPixmapPriv->target)
return FALSE;
pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
@ -182,7 +216,7 @@ xglFillRegionTiled (DrawablePtr pDrawable,
REGION_RECTS (pRegion),
REGION_NUM_RECTS (pRegion)))
return TRUE;
return FALSE;
}
@ -194,7 +228,7 @@ xglPaintWindowBackground (WindowPtr pWin,
ScreenPtr pScreen = pWin->drawable.pScreen;
XGL_SCREEN_PRIV (pScreen);
switch (pWin->backgroundState) {
case None:
return;
@ -202,7 +236,7 @@ xglPaintWindowBackground (WindowPtr pWin,
do {
pWin = pWin->parent;
} while (pWin->backgroundState == ParentRelative);
(*pScreen->PaintWindowBackground) (pWin, pRegion, what);
return;
case BackgroundPixmap:
@ -215,7 +249,7 @@ xglPaintWindowBackground (WindowPtr pWin,
xglAddCurrentBitDamage (&pWin->drawable);
return;
}
if (!xglSyncBits (&pWin->background.pixmap->drawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING);
break;
@ -258,7 +292,7 @@ xglPaintWindowBorder (WindowPtr pWin,
else
{
WindowPtr pBgWin = pWin;
while (pBgWin->backgroundState == ParentRelative)
pBgWin = pBgWin->parent;
@ -271,7 +305,7 @@ xglPaintWindowBorder (WindowPtr pWin,
xglAddCurrentBitDamage (&pWin->drawable);
return;
}
if (!xglSyncBits (&pWin->border.pixmap->drawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING);
}
@ -281,3 +315,27 @@ xglPaintWindowBorder (WindowPtr pWin,
XGL_WINDOW_FALLBACK_EPILOGUE (pWin, pRegion, PaintWindowBorder,
xglPaintWindowBorder);
}
PixmapPtr
xglGetWindowPixmap (WindowPtr pWin)
{
return XGL_GET_WINDOW_PIXMAP (pWin);
}
void
xglSetWindowPixmap (WindowPtr pWin,
PixmapPtr pPixmap)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
XGL_SCREEN_PRIV (pScreen);
XGL_SCREEN_UNWRAP (SetWindowPixmap);
(*pScreen->SetWindowPixmap) (pWin, pPixmap);
XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
XGL_GET_WINDOW_PRIV (pWin)->pPixmap = pPixmap;
if (pPixmap != pScreenPriv->pScreenPixmap)
xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.window);
}

634
hw/xgl/xglxv.c Normal file
View File

@ -0,0 +1,634 @@
/*
* Copyright © 2005 Novell, Inc.
*
* 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
* Novell, Inc. not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
* Novell, Inc. makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. 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.
*
* Authors: David Reveman <davidr@novell.com>
* Matthias Hopf <mhopf@suse.de>
*/
#include "xgl.h"
#ifdef XV
#include "xvdix.h"
#include "gcstruct.h"
#include "dixstruct.h"
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
static unsigned int xglXvScreenIndex = 0;
static unsigned long portResource = 0;
#define XGL_GET_XV_SCREEN(pScreen) \
((XvScreenPtr) ((pScreen)->devPrivates[xglXvScreenIndex].ptr))
#define XGL_XV_SCREEN(pScreen) \
XvScreenPtr pXvScreen = XGL_GET_XV_SCREEN (pScreen)
#define XGL_GET_XV_SCREEN_PRIV(pScreen) \
((xglXvScreenPtr) (GET_XV_SCREEN (pScreen)->devPriv.ptr))
#define XGL_XV_SCREEN_PRIV(pScreen) \
xglXvScreenPtr pXvScreenPriv = XGL_GET_XV_SCREEN_PRIV (pScreen)
#define XGL_GET_XV_PORT_PRIV(pPort) \
((xglXvPortPtr) ((pPort)->devPriv.ptr))
#define XGL_XV_PORT_PRIV(pPort) \
xglXvPortPtr pPortPriv = XGL_GET_XV_PORT_PRIV (pPort)
#define XGL_XV_NUM_PORTS 32
#define XGL_XV_IMAGE_MAX_WIDTH 2048
#define XGL_XV_IMAGE_MAX_HEIGHT 2048
static XvImageRec xvImages[] = {
{
GLITZ_FOURCC_YUY2, XvYUV, BITMAP_BIT_ORDER,
{
'Y','U','Y','2',
0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
},
16, XvPacked, 1,
0, 0, 0, 0,
8, 8, 8, 1, 2, 2, 1, 1, 1,
{
'Y', 'U', 'Y', 'V',
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
XvTopToBottom
}, {
GLITZ_FOURCC_YV12, XvYUV, BITMAP_BIT_ORDER,
{
'Y', 'V', '1', '2',
0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
},
12, XvPlanar, 3,
0, 0, 0, 0,
8, 8, 8, 1, 2, 2, 1, 2, 2,
{
'Y', 'V', 'U', 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
XvTopToBottom
}, {
GLITZ_FOURCC_RGB, XvRGB, BITMAP_BIT_ORDER,
{
0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
},
32, XvPacked, 1,
24, 0xff0000, 0xff00, 0xff,
0, 0, 0, 0, 0, 0, 0, 0, 0,
{
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
XvTopToBottom
}
};
static struct _xglXvFormat {
CARD32 format;
glitz_fourcc_t fourcc;
xglPixelFormatRec pixel;
} xglXvFormat[XGL_XV_FORMAT_NUM] = {
{
PICT_yuy2,
GLITZ_FOURCC_YUY2,
{
16, 6,
{
16,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
}
}
}, {
PICT_yv12,
GLITZ_FOURCC_YV12,
{
12, 4,
{
12,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
}
}
}, {
PICT_x8r8g8b8,
GLITZ_FOURCC_RGB,
{
24, 8,
{
32,
0x00000000,
0x00ff0000,
0x0000ff00,
0x000000ff,
}
}
}
};
static int
xglXvQueryAdaptors (ScreenPtr pScreen,
XvAdaptorPtr *pAdaptors,
int *nAdaptors)
{
XGL_XV_SCREEN (pScreen);
*nAdaptors = pXvScreen->nAdaptors;
*pAdaptors = pXvScreen->pAdaptors;
return Success;
}
static int
xglXvAllocatePort (unsigned long port,
XvPortPtr pPort,
XvPortPtr *ppPort)
{
*ppPort = pPort;
return Success;
}
static int
xglXvFreePort (XvPortPtr pPort)
{
XGL_XV_PORT_PRIV (pPort);
if (pPortPriv->pDst)
{
FreePicture ((pointer) pPortPriv->pDst, 0);
pPortPriv->pDst = (PicturePtr) 0;
}
if (pPortPriv->pSrc)
{
FreePicture ((pointer) pPortPriv->pSrc, 0);
pPortPriv->pSrc = (PicturePtr) 0;
}
if (pPortPriv->pPixmap)
{
ScreenPtr pScreen;
pScreen = pPortPriv->pPixmap->drawable.pScreen;
(*pScreen->DestroyPixmap) (pPortPriv->pPixmap);
pPortPriv->pPixmap = (PixmapPtr) 0;
}
return Success;
}
static int
xglXvQueryBestSize (ClientPtr client,
XvPortPtr pPort,
CARD8 motion,
CARD16 srcWidth,
CARD16 srcHeight,
CARD16 dstWidth,
CARD16 dstHeight,
unsigned int *pWidth,
unsigned int *pHeight)
{
*pWidth = dstWidth;
*pHeight = dstHeight;
return Success;
}
static int
xglXvStopVideo (ClientPtr client,
XvPortPtr pPort,
DrawablePtr pDrawable)
{
xglXvFreePort (pPort);
return Success;
}
static int
xglXvPutImage (ClientPtr client,
DrawablePtr pDrawable,
XvPortPtr pPort,
GCPtr pGC,
INT16 srcX,
INT16 srcY,
CARD16 srcWidth,
CARD16 srcHeight,
INT16 dstX,
INT16 dstY,
CARD16 dstWidth,
CARD16 dstHeight,
XvImagePtr pImage,
unsigned char *data,
Bool sync,
CARD16 width,
CARD16 height)
{
ScreenPtr pScreen = pDrawable->pScreen;
PictTransform transform;
int depth, bpp;
CARD32 format;
XGL_SCREEN_PRIV (pScreen);
XGL_XV_PORT_PRIV (pPort);
XGL_DRAWABLE_PIXMAP (pDrawable);
XGL_PIXMAP_PRIV (pPixmap);
switch (pImage->id) {
case GLITZ_FOURCC_YUY2:
bpp = depth = 16;
format = PICT_yuy2;
break;
case GLITZ_FOURCC_YV12:
depth = bpp = 12;
format = PICT_yv12;
break;
case GLITZ_FOURCC_RGB:
depth = 24;
bpp = 32;
format = PICT_x8r8g8b8;
break;
default:
return BadImplementation;
}
pPort->pDraw = pDrawable;
if (!pPortPriv->pPixmap)
{
pPortPriv->pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth);
if (!pPortPriv->pPixmap)
return BadAlloc;
}
(*pScreen->ModifyPixmapHeader) (pPortPriv->pPixmap,
srcWidth, srcHeight,
depth, bpp, -1, (pointer) data);
XGL_GET_PIXMAP_PRIV (pPortPriv->pPixmap)->stride = -srcWidth;
pPortPriv->pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
if (!pPortPriv->pSrc || pPortPriv->pSrc->format != format)
{
PictFormatPtr pFormat;
int error;
static XID value = RepeatPad;
pFormat = PictureMatchFormat (pScreen, depth, format);
if (!pFormat)
return BadImplementation;
if (pPortPriv->pSrc)
FreePicture ((pointer) pPortPriv->pSrc, 0);
pPortPriv->pSrc = CreatePicture (0, &pPortPriv->pPixmap->drawable,
pFormat, CPRepeat, &value,
serverClient, &error);
if (!pPortPriv->pSrc)
{
xglXvFreePort (pPort);
return error;
}
SetPictureFilter (pPortPriv->pSrc,
FilterBilinear, strlen (FilterBilinear),
0, 0);
}
if (!pPortPriv->pDst || pPortPriv->pDst->pDrawable != pDrawable)
{
PictFormatPtr pFormat = 0;
int i, error;
for (i = 0; i < pScreen->numVisuals; i++)
{
if (pScreen->visuals[i].nplanes == pDrawable->depth)
{
pFormat = PictureMatchVisual (pScreen, pDrawable->depth,
&pScreen->visuals[i]);
break;
}
}
if (!pFormat)
return BadImplementation;
if (pPortPriv->pDst)
FreePicture ((pointer) pPortPriv->pDst, 0);
pPortPriv->pDst = CreatePicture (0, pDrawable,
pFormat, 0, 0, serverClient,
&error);
if (!pPortPriv->pDst)
{
xglXvFreePort (pPort);
return error;
}
}
transform.matrix[0][0] = ((srcWidth << 16) + (dstWidth >> 1))
/ dstWidth;
transform.matrix[0][1] = 0;
transform.matrix[0][2] = 0;
/* flip Y */
transform.matrix[1][0] = 0;
transform.matrix[1][1] = -((srcHeight << 16) + (dstHeight >> 1))
/ dstHeight;
transform.matrix[1][2] = (srcHeight << 16);
transform.matrix[2][0] = 0;
transform.matrix[2][1] = 0;
transform.matrix[2][2] = 1 << 16;
SetPictureTransform (pPortPriv->pSrc, &transform);
if (pPixmap != pScreenPriv->pScreenPixmap && !pPixmapPriv->target)
xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.xv);
CompositePicture (PictOpSrc,
pPortPriv->pSrc,
(PicturePtr) 0,
pPortPriv->pDst,
srcX, srcY,
0, 0,
dstX, dstY,
dstWidth, dstHeight);
return Success;
}
static int
xglXvQueryImageAttributes (ClientPtr client,
XvPortPtr pPort,
XvImagePtr pImage,
CARD16 *width,
CARD16 *height,
int *pitches,
int *offsets)
{
if (*width > XGL_XV_IMAGE_MAX_WIDTH)
*width = XGL_XV_IMAGE_MAX_WIDTH;
if (*height > XGL_XV_IMAGE_MAX_HEIGHT)
*height = XGL_XV_IMAGE_MAX_HEIGHT;
*width = (*width + 7) & ~7;
switch (pImage->id) {
case GLITZ_FOURCC_YUY2:
if (offsets)
offsets[0] = 0;
if (pitches)
pitches[0] = *width * 2;
return *width * *height * 2;
case GLITZ_FOURCC_YV12:
*height = (*height + 1) & ~1;
if (offsets)
{
offsets[0] = 0;
offsets[1] = *width * *height;
offsets[2] = *width * *height + (*width >> 1) * (*height >> 1);
}
if (pitches)
{
pitches[0] = *width;
pitches[1] = pitches[2] = *width >> 1;
}
return *width * *height + (*width >> 1) * *height;
case GLITZ_FOURCC_RGB:
if (offsets)
offsets[0] = 0;
if (pitches)
pitches[0] = *width * 4;
return *width * *height * 4;
default:
return 0;
}
}
static void
xglXvFreeAdaptor (XvAdaptorPtr pAdaptor)
{
xfree (pAdaptor->pEncodings);
xfree (pAdaptor->pFormats);
if (pAdaptor->pPorts)
xfree (pAdaptor->pPorts);
}
static Bool
xglXvInitAdaptors (ScreenPtr pScreen)
{
XvAdaptorPtr pAdaptor;
xglXvPortPtr pPortPriv;
XvPortPtr pPort;
XvFormatPtr pFormat;
XvEncodingPtr pEncoding;
int i;
XGL_XV_SCREEN (pScreen);
pXvScreen->nAdaptors = 0;
pXvScreen->pAdaptors = NULL;
pAdaptor = xcalloc (1, sizeof (XvAdaptorRec));
if (!pAdaptor)
return FALSE;
pAdaptor->type = XvInputMask | XvImageMask;
pAdaptor->pScreen = pScreen;
pAdaptor->ddAllocatePort = xglXvAllocatePort;
pAdaptor->ddFreePort = xglXvFreePort;
pAdaptor->ddStopVideo = xglXvStopVideo;
pAdaptor->ddPutImage = xglXvPutImage;
pAdaptor->ddQueryBestSize = xglXvQueryBestSize;
pAdaptor->ddQueryImageAttributes = xglXvQueryImageAttributes;
pAdaptor->name = "Xgl Generic Texture Video";
pEncoding = xcalloc (1, sizeof (XvEncodingRec));
if (!pEncoding)
return FALSE;
pEncoding->id = 0;
pEncoding->pScreen = pScreen;
pEncoding->name = "XV_IMAGE";
pEncoding->width = XGL_XV_IMAGE_MAX_WIDTH;
pEncoding->height = XGL_XV_IMAGE_MAX_HEIGHT;
pEncoding->rate.numerator = 1;
pEncoding->rate.denominator = 1;
pAdaptor->nEncodings = 1;
pAdaptor->pEncodings = pEncoding;
pAdaptor->nImages = sizeof (xvImages) / sizeof (XvImageRec);
pAdaptor->pImages = xvImages;
/* TODO: Currently no attributes */
pAdaptor->nAttributes = 0;
pAdaptor->pAttributes = 0;
pFormat = xcalloc (pScreen->numVisuals, sizeof (XvFormatRec));
if (!pFormat)
return FALSE;
for (i = 0; i < pScreen->numVisuals; i++)
{
pFormat[i].depth = pScreen->visuals[i].nplanes;
pFormat[i].visual = pScreen->visuals[i].vid;
}
/* All visuals allowed */
pAdaptor->nFormats = pScreen->numVisuals;
pAdaptor->pFormats = pFormat;
pPort = xcalloc (XGL_XV_NUM_PORTS,
sizeof (XvPortRec) + sizeof (xglXvPortRec));
pPortPriv = (xglXvPortPtr) (pPort + XGL_XV_NUM_PORTS);
if (!pPort)
return FALSE;
for (i = 0; i < XGL_XV_NUM_PORTS; i++)
{
pPort[i].id = FakeClientID (0);
if (!pPort[i].id)
return FALSE;
if (!AddResource (pPort[i].id, portResource, &pPort[i]))
return FALSE;
pPort[i].pAdaptor = pAdaptor;
pPort[i].pNotify = (XvPortNotifyPtr) 0;
pPort[i].pDraw = (DrawablePtr) 0;
pPort[i].client = (ClientPtr) 0;
pPort[i].grab.client = (ClientPtr) 0;
pPort[i].time = currentTime;
pPort[i].devPriv.ptr = pPortPriv + i;
}
pAdaptor->nPorts = XGL_XV_NUM_PORTS;
pAdaptor->pPorts = pPort;
pAdaptor->base_id = pPort->id;
pXvScreen->pAdaptors = pAdaptor;
pXvScreen->nAdaptors = 1;
return TRUE;
}
static Bool
xglXvCloseScreen (int i, ScreenPtr pScreen)
{
int j;
XGL_XV_SCREEN (pScreen);
for (j = 0; j < pXvScreen->nAdaptors; j++)
xglXvFreeAdaptor (&pXvScreen->pAdaptors[j]);
if (pXvScreen->pAdaptors)
xfree (pXvScreen->pAdaptors);
return TRUE;
}
Bool
xglXvScreenInit (ScreenPtr pScreen)
{
XvScreenPtr pXvScreen;
xglVisualPtr v;
int i, status, vid = 0;
XGL_SCREEN_PRIV (pScreen);
status = XvScreenInit (pScreen);
if (status != Success)
return FALSE;
xglXvScreenIndex = XvGetScreenIndex ();
portResource = XvGetRTPort ();
pXvScreen = XGL_GET_XV_SCREEN (pScreen);
/* Anyone initializing the Xv layer must provide these two.
The Xv di layer calls them without even checking if they exist! */
pXvScreen->ddCloseScreen = xglXvCloseScreen;
pXvScreen->ddQueryAdaptors = xglXvQueryAdaptors;
pXvScreen->devPriv.ptr = (pointer) 0;
if (!xglXvInitAdaptors (pScreen))
return FALSE;
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->vid > vid)
vid = v->vid;
}
memset (pScreenPriv->pXvVisual, 0, sizeof (pScreenPriv->pXvVisual));
for (i = 0; i < XGL_XV_FORMAT_NUM; i++)
{
glitz_format_t templ;
templ.color.fourcc = xglXvFormat[i].fourcc;
pScreenPriv->pXvVisual[i].vid = ++vid;
pScreenPriv->pXvVisual[i].pPixel = &xglXvFormat[i].pixel;
pScreenPriv->pXvVisual[i].format.surface =
glitz_find_format (pScreenPriv->drawable,
GLITZ_FORMAT_FOURCC_MASK,
&templ, 0);
}
return TRUE;
}
#endif