Removed a bunch of X11 support that we no longer need.
This commit is contained in:
parent
3bcc4afe75
commit
31f1dceb0c
15 changed files with 0 additions and 2176 deletions
64
configure.in
64
configure.in
|
@ -1118,7 +1118,6 @@ AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=ma
|
|||
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_X11)
|
||||
SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
|
||||
SOURCES="$SOURCES $srcdir/src/video/Xext/XmuStdCmap/*.c"
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
|
||||
|
||||
if test x$enable_x11_shared = xmaybe; then
|
||||
|
@ -1261,69 +1260,6 @@ AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension
|
|||
if test x$definitely_enable_video_x11_scrnsaver = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_X11_SCRNSAVER)
|
||||
fi
|
||||
AC_ARG_ENABLE(video-x11-xrender,
|
||||
AC_HELP_STRING([--enable-video-x11-xrender], [enable X11 Xrender extension [[default=yes]]]),
|
||||
, enable_video_x11_xrender=yes)
|
||||
if test x$enable_video_x11_xrender = xyes; then
|
||||
AC_CHECK_HEADER(X11/extensions/Xrender.h,
|
||||
have_xrender_h_hdr=yes,
|
||||
have_xrender_h_hdr=no,
|
||||
[#include <X11/Xlib.h>
|
||||
])
|
||||
if test x$have_xrender_h_hdr = xyes; then
|
||||
if test x$enable_x11_shared = xyes && test x$xrender_lib != x ; then
|
||||
echo "-- dynamic libXrender -> $xrender_lib"
|
||||
AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, "$xrender_lib")
|
||||
definitely_enable_video_x11_xrender=yes
|
||||
else
|
||||
AC_CHECK_LIB(Xrender, XRenderQueryExtension, have_xrender_lib=yes)
|
||||
if test x$have_xrender_lib = xyes ; then
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrender"
|
||||
definitely_enable_video_x11_xrender=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test x$definitely_enable_video_x11_xrender = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRENDER)
|
||||
fi
|
||||
AC_ARG_ENABLE(video-x11-xdamage-xfixes,
|
||||
AC_HELP_STRING([--enable-video-x11-xdamage-xfixes], [enable X11 Xdamage and Xfixes extensions [[default=yes]]]),
|
||||
, enable_video_x11_xdamage=yes)
|
||||
if test x$enable_video_x11_xdamage = xyes && test x$definitely_enable_video_x11_xrender = xyes ; then
|
||||
AC_CHECK_HEADER(X11/extensions/Xdamage.h,
|
||||
have_xdamage_h_hdr=yes,
|
||||
have_xdamage_h_hdr=no,
|
||||
[#include <X11/Xlib.h>
|
||||
])
|
||||
AC_CHECK_HEADER(X11/extensions/Xfixes.h,
|
||||
have_xfixes_h_hdr=yes,
|
||||
have_xfixes_h_hdr=no,
|
||||
[#include <X11/Xlib.h>
|
||||
])
|
||||
if test x$have_xdamage_h_hdr = xyes && test x$have_xfixes_h_hdr = xyes ; then
|
||||
if test x$enable_x11_shared = xyes && test x$xdamage_lib != x && test x$xfixes_lib != x ; then
|
||||
echo "-- dynamic libXdamage -> $xdamage_lib"
|
||||
echo "-- dynamic libXfixes -> $xfixes_lib"
|
||||
AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XDAMAGE, "$xdamage_lib")
|
||||
AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES, "$xfixes_lib")
|
||||
definitely_enable_video_x11_xdamage=yes
|
||||
definitely_enable_video_x11_xfixes=yes
|
||||
else
|
||||
AC_CHECK_LIB(Xdamage, XDamageQueryExtension, have_xdamage_lib=yes)
|
||||
AC_CHECK_LIB(Xfixes, XFixesQueryExtension, have_xfixes_lib=yes)
|
||||
if test x$have_xdamage_lib = xyes && test x$have_xfixes_lib = xyes ; then
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXdamage -lXfixes"
|
||||
definitely_enable_video_x11_xdamage=yes
|
||||
definitely_enable_video_x11_xfixes=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test x$definitely_enable_video_x11_xdamage = xyes && test x$definitely_enable_video_x11_xfixes = xyes ; then
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_X11_XDAMAGE)
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_X11_XFIXES)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -266,20 +266,14 @@
|
|||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XDAMAGE
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES
|
||||
#undef SDL_VIDEO_DRIVER_X11_VIDMODE
|
||||
#undef SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
#undef SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
#undef SDL_VIDEO_DRIVER_X11_XINPUT
|
||||
#undef SDL_VIDEO_DRIVER_X11_SCRNSAVER
|
||||
#undef SDL_VIDEO_DRIVER_X11_XV
|
||||
#undef SDL_VIDEO_DRIVER_X11_XRENDER
|
||||
#undef SDL_VIDEO_DRIVER_X11_XDAMAGE
|
||||
#undef SDL_VIDEO_DRIVER_X11_XFIXES
|
||||
#undef SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
|
||||
#undef SDL_VIDEO_RENDER_D3D
|
||||
|
|
|
@ -1,159 +0,0 @@
|
|||
/* $Xorg: AllCmap.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1989, 1998 The Open Group
|
||||
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/lib/Xmu/AllCmap.c,v 1.7 2001/01/17 19:42:53 dawes Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../extensions/StdCmap.h"
|
||||
|
||||
static XVisualInfo *getDeepestVisual(int, XVisualInfo *, int);
|
||||
|
||||
/*
|
||||
* To create all of the appropriate standard colormaps for every visual of
|
||||
* every screen on a given display, use XmuAllStandardColormaps.
|
||||
*
|
||||
* Define and retain as permanent resources all standard colormaps which are
|
||||
* meaningful for the visuals of each screen of the display. Return 0 on
|
||||
* failure, non-zero on success. If the property of any standard colormap
|
||||
* is already defined, redefine it.
|
||||
*
|
||||
* This interface is intended to be used by window managers or a client
|
||||
* upon start-up of a session.
|
||||
*
|
||||
* The standard colormaps of a screen are defined by properties associated
|
||||
* with the screen's root window. Each screen has exactly one root window.
|
||||
* The property names of standard colormaps are predefined, and each property
|
||||
* name may describe at most one colormap.
|
||||
*
|
||||
* The standard colormaps are
|
||||
* RGB_BEST_MAP
|
||||
* RGB_RED_MAP
|
||||
* RGB_GREEN_MAP
|
||||
* RGB_BLUE_MAP
|
||||
* RGB_DEFAULT_MAP
|
||||
* RGB_GRAY_MAP
|
||||
*
|
||||
* Therefore a screen may have at most 6 standard colormap properties defined.
|
||||
*
|
||||
* A standard colormap is associated with a particular visual of the screen.
|
||||
* A screen may have multiple visuals defined, including visuals of the same
|
||||
* class at different depths. Note that a visual id might be repeated for
|
||||
* more than one depth, so the visual id and the depth of a visual identify
|
||||
* the visual. The characteristics of the visual will determine which
|
||||
* standard colormaps are meaningful under that visual, and will determine
|
||||
* how the standard colormap is defined. Because a standard colormap is
|
||||
* associated with a specific visual, there must be a method of determining
|
||||
* which visuals take precedence in defining standard colormaps.
|
||||
*
|
||||
* The method used here is: for the visual of greatest depth, define all
|
||||
* standard colormaps meaningful to that visual class, according to this
|
||||
* order of (descending) precedence:
|
||||
* 1. DirectColor
|
||||
* 2. PseudoColor
|
||||
* 3. TrueColor and GrayScale
|
||||
* 4. StaticColor and StaticGray
|
||||
*
|
||||
* Allows partial success by screenful. For example, if a map on screen 1
|
||||
* fails, the maps on screen 0, created earlier, will remain. However,
|
||||
* none on screen 1 will remain. If a map on 0 fails, none will remain.
|
||||
*
|
||||
* See the comments under XmuVisualStandardColormaps() for notes on which
|
||||
* standard colormaps are meaningful under these classes of visuals.
|
||||
*/
|
||||
|
||||
Status
|
||||
XmuAllStandardColormaps(Display * dpy)
|
||||
{
|
||||
int nvisuals, scr;
|
||||
Status status;
|
||||
long vinfo_mask;
|
||||
XVisualInfo template, *vinfo, *v1, *v2;
|
||||
|
||||
status = 0;
|
||||
/* for each screen, determine all visuals of this server */
|
||||
for (scr = 0; scr < ScreenCount(dpy); scr++) {
|
||||
template.screen = scr;
|
||||
vinfo_mask = VisualScreenMask;
|
||||
vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals);
|
||||
if (vinfo == NULL) /* unexpected: a screen with no visuals */
|
||||
continue;
|
||||
|
||||
v1 = getDeepestVisual(DirectColor, vinfo, nvisuals);
|
||||
v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals);
|
||||
|
||||
if (v2 &&
|
||||
(!v1 || (v2->colormap_size >=
|
||||
((v1->red_mask | v1->green_mask | v1->blue_mask) + 1))))
|
||||
status = XmuVisualStandardColormaps(dpy, scr, v2->visualid,
|
||||
(unsigned) v2->depth, 1, 1);
|
||||
else if (v1)
|
||||
status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
|
||||
(unsigned) v1->depth, 1, 1);
|
||||
|
||||
else {
|
||||
if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL)
|
||||
|| ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) !=
|
||||
NULL))
|
||||
status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
|
||||
(unsigned) v1->depth, 1,
|
||||
1);
|
||||
if (status
|
||||
&&
|
||||
(((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL)
|
||||
|| ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) !=
|
||||
NULL)))
|
||||
status =
|
||||
XmuVisualStandardColormaps(dpy, scr, v1->visualid,
|
||||
(unsigned) v1->depth, 1, 1);
|
||||
}
|
||||
XFree((char *) vinfo);
|
||||
if (!status)
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static XVisualInfo *
|
||||
getDeepestVisual(int visual_class, XVisualInfo * vinfo, int nvisuals)
|
||||
{
|
||||
register int i;
|
||||
register int maxdepth = 0;
|
||||
XVisualInfo *v = NULL;
|
||||
|
||||
for (i = 0; i < nvisuals; i++, vinfo++)
|
||||
if (vinfo->class == visual_class && vinfo->depth > maxdepth) {
|
||||
maxdepth = vinfo->depth;
|
||||
v = vinfo;
|
||||
}
|
||||
return (v);
|
||||
}
|
|
@ -1,337 +0,0 @@
|
|||
/* $Xorg: CmapAlloc.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1989, 1994, 1998 The Open Group
|
||||
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/lib/Xmu/CmapAlloc.c,v 1.6 2001/01/17 19:42:53 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Donna Converse, MIT X Consortium
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../extensions/StdCmap.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define lowbit(x) ((x) & (~(x) + 1))
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
static void best_allocation(XVisualInfo *, unsigned long *, unsigned long *,
|
||||
unsigned long *);
|
||||
static int default_allocation(XVisualInfo *, unsigned long *,
|
||||
unsigned long *, unsigned long *);
|
||||
static void gray_allocation(int, unsigned long *, unsigned long *,
|
||||
unsigned long *);
|
||||
static int icbrt(int);
|
||||
static int icbrt_with_bits(int, int);
|
||||
static int icbrt_with_guess(int, int);
|
||||
|
||||
/* To determine the best allocation of reds, greens, and blues in a
|
||||
* standard colormap, use XmuGetColormapAllocation.
|
||||
* vinfo specifies visual information for a chosen visual
|
||||
* property specifies one of the standard colormap property names
|
||||
* red_max returns maximum red value
|
||||
* green_max returns maximum green value
|
||||
* blue_max returns maximum blue value
|
||||
*
|
||||
* XmuGetColormapAllocation returns 0 on failure, non-zero on success.
|
||||
* It is assumed that the visual is appropriate for the colormap property.
|
||||
*/
|
||||
|
||||
Status
|
||||
XmuGetColormapAllocation(XVisualInfo * vinfo, Atom property,
|
||||
unsigned long *red_max,
|
||||
unsigned long *green_max, unsigned long *blue_max)
|
||||
{
|
||||
Status status = 1;
|
||||
|
||||
if (vinfo->colormap_size <= 2)
|
||||
return 0;
|
||||
|
||||
switch (property) {
|
||||
case XA_RGB_DEFAULT_MAP:
|
||||
status = default_allocation(vinfo, red_max, green_max, blue_max);
|
||||
break;
|
||||
case XA_RGB_BEST_MAP:
|
||||
best_allocation(vinfo, red_max, green_max, blue_max);
|
||||
break;
|
||||
case XA_RGB_GRAY_MAP:
|
||||
gray_allocation(vinfo->colormap_size, red_max, green_max, blue_max);
|
||||
break;
|
||||
case XA_RGB_RED_MAP:
|
||||
*red_max = vinfo->colormap_size - 1;
|
||||
*green_max = *blue_max = 0;
|
||||
break;
|
||||
case XA_RGB_GREEN_MAP:
|
||||
*green_max = vinfo->colormap_size - 1;
|
||||
*red_max = *blue_max = 0;
|
||||
break;
|
||||
case XA_RGB_BLUE_MAP:
|
||||
*blue_max = vinfo->colormap_size - 1;
|
||||
*red_max = *green_max = 0;
|
||||
break;
|
||||
default:
|
||||
status = 0;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Determine the appropriate color allocations of a gray scale.
|
||||
*
|
||||
* Keith Packard, MIT X Consortium
|
||||
*/
|
||||
|
||||
static void
|
||||
gray_allocation(int n, unsigned long *red_max, unsigned long *green_max,
|
||||
unsigned long *blue_max)
|
||||
{
|
||||
*red_max = (n * 30) / 100;
|
||||
*green_max = (n * 59) / 100;
|
||||
*blue_max = (n * 11) / 100;
|
||||
*green_max += ((n - 1) - (*red_max + *green_max + *blue_max));
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Determine an appropriate color allocation for the RGB_DEFAULT_MAP.
|
||||
* If a map has less than a minimum number of definable entries, we do not
|
||||
* produce an allocation for an RGB_DEFAULT_MAP.
|
||||
*
|
||||
* For 16 planes, the default colormap will have 27 each RGB; for 12 planes,
|
||||
* 12 each. For 8 planes, let n = the number of colormap entries, which may
|
||||
* be 256 or 254. Then, maximum red value = floor(cube_root(n - 125)) - 1.
|
||||
* Maximum green and maximum blue values are identical to maximum red.
|
||||
* This leaves at least 125 cells which clients can allocate.
|
||||
*
|
||||
* Return 0 if an allocation has been determined, non-zero otherwise.
|
||||
*/
|
||||
|
||||
static int
|
||||
default_allocation(XVisualInfo * vinfo, unsigned long *red,
|
||||
unsigned long *green, unsigned long *blue)
|
||||
{
|
||||
int ngrays; /* number of gray cells */
|
||||
|
||||
switch (vinfo->class) {
|
||||
case PseudoColor:
|
||||
|
||||
if (vinfo->colormap_size > 65000)
|
||||
/* intended for displays with 16 planes */
|
||||
*red = *green = *blue = (unsigned long) 27;
|
||||
else if (vinfo->colormap_size > 4000)
|
||||
/* intended for displays with 12 planes */
|
||||
*red = *green = *blue = (unsigned long) 12;
|
||||
else if (vinfo->colormap_size < 250)
|
||||
return 0;
|
||||
else
|
||||
/* intended for displays with 8 planes */
|
||||
*red = *green = *blue = (unsigned long)
|
||||
(icbrt(vinfo->colormap_size - 125) - 1);
|
||||
break;
|
||||
|
||||
case DirectColor:
|
||||
|
||||
if (vinfo->colormap_size < 10)
|
||||
return 0;
|
||||
*red = *green = *blue = vinfo->colormap_size / 2 - 1;
|
||||
break;
|
||||
|
||||
case TrueColor:
|
||||
|
||||
*red = vinfo->red_mask / lowbit(vinfo->red_mask);
|
||||
*green = vinfo->green_mask / lowbit(vinfo->green_mask);
|
||||
*blue = vinfo->blue_mask / lowbit(vinfo->blue_mask);
|
||||
break;
|
||||
|
||||
case GrayScale:
|
||||
|
||||
if (vinfo->colormap_size > 65000)
|
||||
ngrays = 4096;
|
||||
else if (vinfo->colormap_size > 4000)
|
||||
ngrays = 512;
|
||||
else if (vinfo->colormap_size < 250)
|
||||
return 0;
|
||||
else
|
||||
ngrays = 12;
|
||||
gray_allocation(ngrays, red, green, blue);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Determine an appropriate color allocation for the RGB_BEST_MAP.
|
||||
*
|
||||
* For a DirectColor or TrueColor visual, the allocation is determined
|
||||
* by the red_mask, green_mask, and blue_mask members of the visual info.
|
||||
*
|
||||
* Otherwise, if the colormap size is an integral power of 2, determine
|
||||
* the allocation according to the number of bits given to each color,
|
||||
* with green getting more than red, and red more than blue, if there
|
||||
* are to be inequities in the distribution. If the colormap size is
|
||||
* not an integral power of 2, let n = the number of colormap entries.
|
||||
* Then maximum red value = floor(cube_root(n)) - 1;
|
||||
* maximum blue value = floor(cube_root(n)) - 1;
|
||||
* maximum green value = n / ((# red values) * (# blue values)) - 1;
|
||||
* Which, on a GPX, allows for 252 entries in the best map, out of 254
|
||||
* defineable colormap entries.
|
||||
*/
|
||||
|
||||
static void
|
||||
best_allocation(XVisualInfo * vinfo, unsigned long *red, unsigned long *green,
|
||||
unsigned long *blue)
|
||||
{
|
||||
|
||||
if (vinfo->class == DirectColor || vinfo->class == TrueColor) {
|
||||
*red = vinfo->red_mask;
|
||||
while ((*red & 01) == 0)
|
||||
*red >>= 1;
|
||||
*green = vinfo->green_mask;
|
||||
while ((*green & 01) == 0)
|
||||
*green >>= 1;
|
||||
*blue = vinfo->blue_mask;
|
||||
while ((*blue & 01) == 0)
|
||||
*blue >>= 1;
|
||||
} else {
|
||||
register int bits, n;
|
||||
|
||||
/* Determine n such that n is the least integral power of 2 which is
|
||||
* greater than or equal to the number of entries in the colormap.
|
||||
*/
|
||||
n = 1;
|
||||
bits = 0;
|
||||
while (vinfo->colormap_size > n) {
|
||||
n = n << 1;
|
||||
bits++;
|
||||
}
|
||||
|
||||
/* If the number of entries in the colormap is a power of 2, determine
|
||||
* the allocation by "dealing" the bits, first to green, then red, then
|
||||
* blue. If not, find the maximum integral red, green, and blue values
|
||||
* which, when multiplied together, do not exceed the number of
|
||||
|
||||
* colormap entries.
|
||||
*/
|
||||
if (n == vinfo->colormap_size) {
|
||||
register int r, g, b;
|
||||
b = bits / 3;
|
||||
g = b + ((bits % 3) ? 1 : 0);
|
||||
r = b + (((bits % 3) == 2) ? 1 : 0);
|
||||
*red = 1 << r;
|
||||
*green = 1 << g;
|
||||
*blue = 1 << b;
|
||||
} else {
|
||||
*red = icbrt_with_bits(vinfo->colormap_size, bits);
|
||||
*blue = *red;
|
||||
*green = (vinfo->colormap_size / ((*red) * (*blue)));
|
||||
}
|
||||
(*red)--;
|
||||
(*green)--;
|
||||
(*blue)--;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* integer cube roots by Newton's method
|
||||
*
|
||||
* Stephen Gildea, MIT X Consortium, July 1991
|
||||
*/
|
||||
|
||||
static int
|
||||
icbrt(int a)
|
||||
{
|
||||
register int bits = 0;
|
||||
register unsigned n = a;
|
||||
|
||||
while (n) {
|
||||
bits++;
|
||||
n >>= 1;
|
||||
}
|
||||
return icbrt_with_bits(a, bits);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
icbrt_with_bits(int a, int bits)
|
||||
/* bits - log 2 of a */
|
||||
{
|
||||
return icbrt_with_guess(a, a >> 2 * bits / 3);
|
||||
}
|
||||
|
||||
#ifdef _X_ROOT_STATS
|
||||
int icbrt_loopcount;
|
||||
#endif
|
||||
|
||||
/* Newton's Method: x_n+1 = x_n - ( f(x_n) / f'(x_n) ) */
|
||||
|
||||
/* for cube roots, x^3 - a = 0, x_new = x - 1/3 (x - a/x^2) */
|
||||
|
||||
/*
|
||||
* Quick and dirty cube roots. Nothing fancy here, just Newton's method.
|
||||
* Only works for positive integers (since that's all we need).
|
||||
* We actually return floor(cbrt(a)) because that's what we need here, too.
|
||||
*/
|
||||
|
||||
static int
|
||||
icbrt_with_guess(int a, int guess)
|
||||
{
|
||||
register int delta;
|
||||
|
||||
#ifdef _X_ROOT_STATS
|
||||
icbrt_loopcount = 0;
|
||||
#endif
|
||||
if (a <= 0)
|
||||
return 0;
|
||||
if (guess < 1)
|
||||
guess = 1;
|
||||
|
||||
do {
|
||||
#ifdef _X_ROOT_STATS
|
||||
icbrt_loopcount++;
|
||||
#endif
|
||||
delta = (guess - a / (guess * guess)) / 3;
|
||||
#ifdef DEBUG
|
||||
printf("pass %d: guess=%d, delta=%d\n", icbrt_loopcount, guess,
|
||||
delta);
|
||||
#endif
|
||||
guess -= delta;
|
||||
} while (delta != 0);
|
||||
|
||||
if (guess * guess * guess > a)
|
||||
guess--;
|
||||
|
||||
return guess;
|
||||
}
|
|
@ -1,531 +0,0 @@
|
|||
/* $Xorg: CrCmap.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1989, 1998 The Open Group
|
||||
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/lib/Xmu/CrCmap.c,v 3.6 2001/01/17 19:42:53 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Donna Converse, MIT X Consortium
|
||||
*/
|
||||
|
||||
/*
|
||||
* CreateCmap.c - given a standard colormap description, make the map.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../extensions/StdCmap.h"
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
/* allocate entire map Read Only */
|
||||
static int ROmap(Display *, Colormap, unsigned long[], int, int);
|
||||
|
||||
/* allocate a cell, prefer Read Only */
|
||||
static Status ROorRWcell(Display *, Colormap, unsigned long[], int,
|
||||
XColor *, unsigned long);
|
||||
|
||||
/* allocate a cell Read Write */
|
||||
static Status RWcell(Display *, Colormap, XColor *, XColor *,
|
||||
unsigned long *);
|
||||
|
||||
/* for quicksort */
|
||||
static int compare(_Xconst void *, _Xconst void *);
|
||||
|
||||
/* find contiguous sequence of cells */
|
||||
static Status contiguous(unsigned long[], int, int, unsigned long, int *,
|
||||
int *);
|
||||
|
||||
/* frees resources before quitting */
|
||||
static void free_cells(Display *, Colormap, unsigned long[], int, int);
|
||||
|
||||
/* create a map in a RO visual type */
|
||||
static Status readonly_map(Display *, XVisualInfo *, XStandardColormap *);
|
||||
|
||||
/* create a map in a RW visual type */
|
||||
static Status readwrite_map(Display *, XVisualInfo *, XStandardColormap *);
|
||||
|
||||
#define lowbit(x) ((x) & (~(x) + 1))
|
||||
#define TRUEMATCH(mult,max,mask) \
|
||||
(colormap->max * colormap->mult <= vinfo->mask && \
|
||||
lowbit(vinfo->mask) == colormap->mult)
|
||||
|
||||
/*
|
||||
* To create any one colormap which is described by an XStandardColormap
|
||||
* structure, use XmuCreateColormap().
|
||||
*
|
||||
* Return 0 on failure, non-zero on success.
|
||||
* Resources created by this function are not made permanent.
|
||||
* No argument error checking is provided. Use at your own risk.
|
||||
*
|
||||
* All colormaps are created with read only allocations, with the exception
|
||||
* of read only allocations of colors in the default map or otherwise
|
||||
* which fail to return the expected pixel value, and these are individually
|
||||
* defined as read/write allocations. This is done so that all the cells
|
||||
* defined in the default map are contiguous, for use in image processing.
|
||||
* This typically happens with White and Black in the default map.
|
||||
*
|
||||
* Colormaps of static visuals are considered to be successfully created if
|
||||
* the map of the static visual matches the definition given in the
|
||||
* standard colormap structure.
|
||||
*/
|
||||
|
||||
Status
|
||||
XmuCreateColormap(Display * dpy, XStandardColormap * colormap)
|
||||
/* dpy - specifies the connection under which the map is created
|
||||
* colormap - specifies the map to be created, and returns, particularly
|
||||
* if the map is created as a subset of the default colormap
|
||||
* of the screen, the base_pixel of the map.
|
||||
*/
|
||||
{
|
||||
XVisualInfo vinfo_template; /* template visual information */
|
||||
XVisualInfo *vinfo; /* matching visual information */
|
||||
XVisualInfo *vpointer; /* for freeing the entire list */
|
||||
long vinfo_mask; /* specifies the visual mask value */
|
||||
int n; /* number of matching visuals */
|
||||
int status;
|
||||
|
||||
vinfo_template.visualid = colormap->visualid;
|
||||
vinfo_mask = VisualIDMask;
|
||||
if ((vinfo =
|
||||
XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
|
||||
return 0;
|
||||
|
||||
/* A visual id may be valid on multiple screens. Also, there may
|
||||
* be multiple visuals with identical visual ids at different depths.
|
||||
* If the colormap is the Default Colormap, use the Default Visual.
|
||||
* Otherwise, arbitrarily, use the deepest visual.
|
||||
*/
|
||||
vpointer = vinfo;
|
||||
if (n > 1) {
|
||||
register int i;
|
||||
register int screen_number;
|
||||
Bool def_cmap;
|
||||
|
||||
def_cmap = False;
|
||||
for (screen_number = ScreenCount(dpy); --screen_number >= 0;)
|
||||
if (colormap->colormap == DefaultColormap(dpy, screen_number)) {
|
||||
def_cmap = True;
|
||||
break;
|
||||
}
|
||||
|
||||
if (def_cmap) {
|
||||
for (i = 0; i < n; i++, vinfo++) {
|
||||
if (vinfo->visual == DefaultVisual(dpy, screen_number))
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
int maxdepth = 0;
|
||||
XVisualInfo *v = NULL;
|
||||
|
||||
for (i = 0; i < n; i++, vinfo++)
|
||||
if (vinfo->depth > maxdepth) {
|
||||
maxdepth = vinfo->depth;
|
||||
v = vinfo;
|
||||
}
|
||||
vinfo = v;
|
||||
}
|
||||
}
|
||||
|
||||
if (vinfo->class == PseudoColor || vinfo->class == DirectColor ||
|
||||
vinfo->class == GrayScale)
|
||||
status = readwrite_map(dpy, vinfo, colormap);
|
||||
else if (vinfo->class == TrueColor)
|
||||
status = TRUEMATCH(red_mult, red_max, red_mask) &&
|
||||
TRUEMATCH(green_mult, green_max, green_mask) &&
|
||||
TRUEMATCH(blue_mult, blue_max, blue_mask);
|
||||
else
|
||||
status = readonly_map(dpy, vinfo, colormap);
|
||||
|
||||
XFree((char *) vpointer);
|
||||
return status;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
static Status
|
||||
readwrite_map(Display * dpy, XVisualInfo * vinfo,
|
||||
XStandardColormap * colormap)
|
||||
{
|
||||
register unsigned long i, n; /* index counters */
|
||||
unsigned long ncolors; /* number of colors to be defined */
|
||||
int npixels; /* number of pixels allocated R/W */
|
||||
int first_index; /* first index of pixels to use */
|
||||
int remainder; /* first index of remainder */
|
||||
XColor color; /* the definition of a color */
|
||||
unsigned long *pixels; /* array of colormap pixels */
|
||||
unsigned long delta;
|
||||
|
||||
|
||||
/* Determine ncolors, the number of colors to be defined.
|
||||
* Insure that 1 < ncolors <= the colormap size.
|
||||
*/
|
||||
if (vinfo->class == DirectColor) {
|
||||
ncolors = colormap->red_max;
|
||||
if (colormap->green_max > ncolors)
|
||||
ncolors = colormap->green_max;
|
||||
if (colormap->blue_max > ncolors)
|
||||
ncolors = colormap->blue_max;
|
||||
ncolors++;
|
||||
delta = lowbit(vinfo->red_mask) +
|
||||
lowbit(vinfo->green_mask) + lowbit(vinfo->blue_mask);
|
||||
} else {
|
||||
ncolors = colormap->red_max * colormap->red_mult +
|
||||
colormap->green_max * colormap->green_mult +
|
||||
colormap->blue_max * colormap->blue_mult + 1;
|
||||
delta = 1;
|
||||
}
|
||||
if (ncolors <= 1 || (int) ncolors > vinfo->colormap_size)
|
||||
return 0;
|
||||
|
||||
/* Allocate Read/Write as much of the colormap as we can possibly get.
|
||||
* Then insure that the pixels we were allocated are given in
|
||||
* monotonically increasing order, using a quicksort. Next, insure
|
||||
* that our allocation includes a subset of contiguous pixels at least
|
||||
* as long as the number of colors to be defined. Now we know that
|
||||
* these conditions are met:
|
||||
* 1) There are no free cells in the colormap.
|
||||
* 2) We have a contiguous sequence of pixels, monotonically
|
||||
* increasing, of length >= the number of colors requested.
|
||||
*
|
||||
* One cell at a time, we will free, compute the next color value,
|
||||
* then allocate read only. This takes a long time.
|
||||
* This is done to insure that cells are allocated read only in the
|
||||
* contiguous order which we prefer. If the server has a choice of
|
||||
* cells to grant to an allocation request, the server may give us any
|
||||
* cell, so that is why we do these slow gymnastics.
|
||||
*/
|
||||
|
||||
if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size,
|
||||
sizeof(unsigned long))) == NULL)
|
||||
return 0;
|
||||
|
||||
if ((npixels = ROmap(dpy, colormap->colormap, pixels,
|
||||
vinfo->colormap_size, ncolors)) == 0) {
|
||||
free((char *) pixels);
|
||||
return 0;
|
||||
}
|
||||
|
||||
qsort((char *) pixels, npixels, sizeof(unsigned long), compare);
|
||||
|
||||
if (!contiguous
|
||||
(pixels, npixels, ncolors, delta, &first_index, &remainder)) {
|
||||
/* can't find enough contiguous cells, give up */
|
||||
XFreeColors(dpy, colormap->colormap, pixels, npixels,
|
||||
(unsigned long) 0);
|
||||
free((char *) pixels);
|
||||
return 0;
|
||||
}
|
||||
colormap->base_pixel = pixels[first_index];
|
||||
|
||||
/* construct a gray map */
|
||||
if (colormap->red_mult == 1 && colormap->green_mult == 1 &&
|
||||
colormap->blue_mult == 1)
|
||||
for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) {
|
||||
color.pixel = n;
|
||||
color.blue = color.green = color.red =
|
||||
(unsigned short) ((i * 65535) / (colormap->red_max +
|
||||
colormap->green_max +
|
||||
colormap->blue_max));
|
||||
|
||||
if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||
first_index + i))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* construct a red ramp map */
|
||||
else if (colormap->green_max == 0 && colormap->blue_max == 0)
|
||||
for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) {
|
||||
color.pixel = n;
|
||||
color.red = (unsigned short) ((i * 65535) / colormap->red_max);
|
||||
color.green = color.blue = 0;
|
||||
|
||||
if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||
first_index + i))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* construct a green ramp map */
|
||||
else if (colormap->red_max == 0 && colormap->blue_max == 0)
|
||||
for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) {
|
||||
color.pixel = n;
|
||||
color.green =
|
||||
(unsigned short) ((i * 65535) / colormap->green_max);
|
||||
color.red = color.blue = 0;
|
||||
|
||||
if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||
first_index + i))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* construct a blue ramp map */
|
||||
else if (colormap->red_max == 0 && colormap->green_max == 0)
|
||||
for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) {
|
||||
color.pixel = n;
|
||||
color.blue = (unsigned short) ((i * 65535) / colormap->blue_max);
|
||||
color.red = color.green = 0;
|
||||
|
||||
if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||
first_index + i))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* construct a standard red green blue cube map */
|
||||
else {
|
||||
#define calc(max,mult) (((n / colormap->mult) % \
|
||||
(colormap->max + 1)) * 65535) / colormap->max
|
||||
|
||||
for (n = 0, i = 0; i < ncolors; i++, n += delta) {
|
||||
color.pixel = n + colormap->base_pixel;
|
||||
color.red = calc(red_max, red_mult);
|
||||
color.green = calc(green_max, green_mult);
|
||||
color.blue = calc(blue_max, blue_mult);
|
||||
if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||
first_index + i))
|
||||
return 0;
|
||||
}
|
||||
#undef calc
|
||||
}
|
||||
/* We have a read-only map defined. Now free unused cells,
|
||||
* first those occuring before the contiguous sequence begins,
|
||||
* then any following the contiguous sequence.
|
||||
*/
|
||||
|
||||
if (first_index)
|
||||
XFreeColors(dpy, colormap->colormap, pixels, first_index,
|
||||
(unsigned long) 0);
|
||||
if (remainder)
|
||||
XFreeColors(dpy, colormap->colormap,
|
||||
&(pixels[first_index + ncolors]), remainder,
|
||||
(unsigned long) 0);
|
||||
|
||||
free((char *) pixels);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
static int
|
||||
ROmap(Display * dpy, Colormap cmap, unsigned long pixels[], int m, int n)
|
||||
/*
|
||||
* dpy - the X server connection
|
||||
* cmap - specifies colormap ID
|
||||
* pixels - returns pixel allocations
|
||||
* m - specifies colormap size
|
||||
* n - specifies number of colors
|
||||
*/
|
||||
{
|
||||
register int p;
|
||||
|
||||
/* first try to allocate the entire colormap */
|
||||
if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
|
||||
(unsigned) 0, pixels, (unsigned) m))
|
||||
return m;
|
||||
|
||||
/* Allocate all available cells in the colormap, using a binary
|
||||
* algorithm to discover how many cells we can allocate in the colormap.
|
||||
*/
|
||||
m--;
|
||||
while (n <= m) {
|
||||
p = n + ((m - n + 1) / 2);
|
||||
if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
|
||||
(unsigned) 0, pixels, (unsigned) p)) {
|
||||
if (p == m)
|
||||
return p;
|
||||
else {
|
||||
XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
|
||||
n = p;
|
||||
}
|
||||
} else
|
||||
m = p - 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
static Status
|
||||
contiguous(unsigned long pixels[], int npixels, int ncolors,
|
||||
unsigned long delta, int *first, int *rem)
|
||||
/* pixels - specifies allocated pixels
|
||||
* npixels - specifies count of alloc'd pixels
|
||||
* ncolors - specifies needed sequence length
|
||||
* delta - between pixels
|
||||
* first - returns first index of sequence
|
||||
* rem - returns first index after sequence, or 0, if none follow
|
||||
*/
|
||||
{
|
||||
register int i = 1; /* walking index into the pixel array */
|
||||
register int count = 1; /* length of sequence discovered so far */
|
||||
|
||||
*first = 0;
|
||||
if (npixels == ncolors) {
|
||||
*rem = 0;
|
||||
return 1;
|
||||
}
|
||||
*rem = npixels - 1;
|
||||
while (count < ncolors && ncolors - count <= *rem) {
|
||||
if (pixels[i - 1] + delta == pixels[i])
|
||||
count++;
|
||||
else {
|
||||
count = 1;
|
||||
*first = i;
|
||||
}
|
||||
i++;
|
||||
(*rem)--;
|
||||
}
|
||||
if (count != ncolors)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
static Status
|
||||
ROorRWcell(Display * dpy, Colormap cmap, unsigned long pixels[],
|
||||
int npixels, XColor * color, unsigned long p)
|
||||
{
|
||||
unsigned long pixel;
|
||||
XColor request;
|
||||
|
||||
/* Free the read/write allocation of one cell in the colormap.
|
||||
* Request a read only allocation of one cell in the colormap.
|
||||
* If the read only allocation cannot be granted, give up, because
|
||||
* there must be no free cells in the colormap.
|
||||
* If the read only allocation is granted, but gives us a cell which
|
||||
* is not the one that we just freed, it is probably the case that
|
||||
* we are trying allocate White or Black or some other color which
|
||||
* already has a read-only allocation in the map. So we try to
|
||||
* allocate the previously freed cell with a read/write allocation,
|
||||
* because we want contiguous cells for image processing algorithms.
|
||||
*/
|
||||
|
||||
pixel = color->pixel;
|
||||
request.red = color->red;
|
||||
request.green = color->green;
|
||||
request.blue = color->blue;
|
||||
|
||||
XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0);
|
||||
if (!XAllocColor(dpy, cmap, color)
|
||||
|| (color->pixel != pixel &&
|
||||
(!RWcell(dpy, cmap, color, &request, &pixel)))) {
|
||||
free_cells(dpy, cmap, pixels, npixels, (int) p);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
static void
|
||||
free_cells(Display * dpy, Colormap cmap, unsigned long pixels[],
|
||||
int npixels, int p)
|
||||
/*
|
||||
* pixels - to be freed
|
||||
* npixels - original number allocated
|
||||
*/
|
||||
{
|
||||
/* One of the npixels allocated has already been freed.
|
||||
* p is the index of the freed pixel.
|
||||
* First free the pixels preceeding p, and there are p of them;
|
||||
* then free the pixels following p, there are npixels - p - 1 of them.
|
||||
*/
|
||||
XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
|
||||
XFreeColors(dpy, cmap, &(pixels[p + 1]), npixels - p - 1,
|
||||
(unsigned long) 0);
|
||||
free((char *) pixels);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
static Status
|
||||
RWcell(Display * dpy, Colormap cmap, XColor * color, XColor * request,
|
||||
unsigned long *pixel)
|
||||
{
|
||||
unsigned long n = *pixel;
|
||||
|
||||
XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long) 0);
|
||||
if (!XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL,
|
||||
(unsigned) 0, pixel, (unsigned) 1))
|
||||
return 0;
|
||||
if (*pixel != n) {
|
||||
XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0);
|
||||
return 0;
|
||||
}
|
||||
color->pixel = *pixel;
|
||||
color->flags = DoRed | DoGreen | DoBlue;
|
||||
color->red = request->red;
|
||||
color->green = request->green;
|
||||
color->blue = request->blue;
|
||||
XStoreColors(dpy, cmap, color, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
static int
|
||||
compare(_Xconst void *e1, _Xconst void *e2)
|
||||
{
|
||||
return ((int) (*(long *) e1 - *(long *) e2));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
static Status
|
||||
readonly_map(Display * dpy, XVisualInfo * vinfo, XStandardColormap * colormap)
|
||||
{
|
||||
int i, last_pixel;
|
||||
XColor color;
|
||||
|
||||
last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) *
|
||||
(colormap->blue_max + 1) + colormap->base_pixel - 1;
|
||||
|
||||
for (i = colormap->base_pixel; i <= last_pixel; i++) {
|
||||
|
||||
color.pixel = (unsigned long) i;
|
||||
color.red = (unsigned short)
|
||||
(((i / colormap->red_mult) * 65535) / colormap->red_max);
|
||||
|
||||
if (vinfo->class == StaticColor) {
|
||||
color.green = (unsigned short)
|
||||
((((i / colormap->green_mult) % (colormap->green_max + 1)) *
|
||||
65535) / colormap->green_max);
|
||||
color.blue = (unsigned short)
|
||||
(((i % colormap->green_mult) * 65535) / colormap->blue_max);
|
||||
} else /* vinfo->class == GrayScale, old style allocation XXX */
|
||||
color.green = color.blue = color.red;
|
||||
|
||||
XAllocColor(dpy, colormap->colormap, &color);
|
||||
if (color.pixel != (unsigned long) i)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/* $Xorg: DelCmap.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1989, 1998 The Open Group
|
||||
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/lib/Xmu/DelCmap.c,v 1.6 2001/01/17 19:42:54 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Donna Converse, MIT X Consortium
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../extensions/StdCmap.h"
|
||||
|
||||
/* To remove any standard colormap property, use XmuDeleteStandardColormap().
|
||||
* XmuDeleteStandardColormap() will remove the specified property from the
|
||||
* specified screen, releasing any resources used by the colormap(s) of the
|
||||
* property if possible.
|
||||
*/
|
||||
|
||||
void
|
||||
XmuDeleteStandardColormap(Display * dpy, int screen, Atom property)
|
||||
/* dpy; - specifies the X server to connect to
|
||||
* screen - specifies the screen of the display
|
||||
* property - specifies the standard colormap property
|
||||
*/
|
||||
{
|
||||
XStandardColormap *stdcmaps, *s;
|
||||
int count = 0;
|
||||
|
||||
if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count,
|
||||
property)) {
|
||||
for (s = stdcmaps; count > 0; count--, s++) {
|
||||
if ((s->killid == ReleaseByFreeingColormap) &&
|
||||
(s->colormap != None) &&
|
||||
(s->colormap != DefaultColormap(dpy, screen)))
|
||||
XFreeColormap(dpy, s->colormap);
|
||||
else if (s->killid != None)
|
||||
XKillClient(dpy, s->killid);
|
||||
}
|
||||
XDeleteProperty(dpy, RootWindow(dpy, screen), property);
|
||||
XFree((char *) stdcmaps);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/* $Xorg: Distinct.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1990, 1998 The Open Group
|
||||
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/lib/Xmu/Distinct.c,v 3.5 2001/07/25 15:04:50 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Keith Packard, MIT X Consortium
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../extensions/StdCmap.h"
|
||||
|
||||
/*
|
||||
* Distinguishable colors routine. Determines if two colors are
|
||||
* distinguishable or not. Somewhat arbitrary meaning.
|
||||
*/
|
||||
|
||||
#define MIN_DISTINGUISH 10000.0
|
||||
|
||||
Bool
|
||||
XmuDistinguishableColors(XColor * colors, int count)
|
||||
{
|
||||
double deltaRed, deltaGreen, deltaBlue;
|
||||
double dist;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < count - 1; i++)
|
||||
for (j = i + 1; j < count; j++) {
|
||||
deltaRed = (double) colors[i].red - (double) colors[j].red;
|
||||
deltaGreen = (double) colors[i].green - (double) colors[j].green;
|
||||
deltaBlue = (double) colors[i].blue - (double) colors[j].blue;
|
||||
dist = deltaRed * deltaRed +
|
||||
deltaGreen * deltaGreen + deltaBlue * deltaBlue;
|
||||
if (dist <= MIN_DISTINGUISH * MIN_DISTINGUISH)
|
||||
return False;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
Bool
|
||||
XmuDistinguishablePixels(Display * dpy, Colormap cmap,
|
||||
unsigned long *pixels, int count)
|
||||
{
|
||||
XColor *defs;
|
||||
int i, j;
|
||||
Bool ret;
|
||||
|
||||
for (i = 0; i < count - 1; i++)
|
||||
for (j = i + 1; j < count; j++)
|
||||
if (pixels[i] == pixels[j])
|
||||
return False;
|
||||
defs = (XColor *) malloc(count * sizeof(XColor));
|
||||
if (!defs)
|
||||
return False;
|
||||
for (i = 0; i < count; i++)
|
||||
defs[i].pixel = pixels[i];
|
||||
XQueryColors(dpy, cmap, defs, count);
|
||||
ret = XmuDistinguishableColors(defs, count);
|
||||
free((char *) defs);
|
||||
return ret;
|
||||
}
|
|
@ -1,323 +0,0 @@
|
|||
/* $Xorg: LookupCmap.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1989, 1998 The Open Group
|
||||
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/lib/Xmu/LookupCmap.c,v 1.7 2001/07/25 15:04:50 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Donna Converse, MIT X Consortium
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../extensions/StdCmap.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
static Status lookup(Display *, int, VisualID, Atom, XStandardColormap *,
|
||||
Bool);
|
||||
|
||||
/*
|
||||
* To create a standard colormap if one does not currently exist, or
|
||||
* replace the currently existing standard colormap, use
|
||||
* XmuLookupStandardColormap().
|
||||
*
|
||||
* Given a screen, a visual, and a property, XmuLookupStandardColormap()
|
||||
* will determine the best allocation for the property under the specified
|
||||
* visual, and determine the whether to create a new colormap or to use
|
||||
* the default colormap of the screen. It will call XmuStandardColormap()
|
||||
* to create the standard colormap.
|
||||
*
|
||||
* If replace is true, any previous definition of the property will be
|
||||
* replaced. If retain is true, the property and the colormap will be
|
||||
* made permanent for the duration of the server session. However,
|
||||
* pre-existing property definitions which are not replaced cannot be made
|
||||
* permanent by a call to XmuLookupStandardColormap(); a request to retain
|
||||
* resources pertains to newly created resources.
|
||||
*
|
||||
* Returns 0 on failure, non-zero on success. A request to create a
|
||||
* standard colormap upon a visual which cannot support such a map is
|
||||
* considered a failure. An example of this would be requesting any
|
||||
* standard colormap property on a monochrome visual, or, requesting an
|
||||
* RGB_BEST_MAP on a display whose colormap size is 16.
|
||||
*/
|
||||
|
||||
Status
|
||||
XmuLookupStandardColormap(Display * dpy, int screen, VisualID visualid,
|
||||
unsigned int depth, Atom property,
|
||||
Bool replace, Bool retain)
|
||||
/*
|
||||
* dpy - specifies X server connection
|
||||
* screen - specifies screen of display
|
||||
* visualid - specifies the visual type
|
||||
* depth - specifies the visual type
|
||||
* property - a standard colormap property
|
||||
* replace - specifies whether to replace
|
||||
* retain - specifies whether to retain
|
||||
*/
|
||||
{
|
||||
Display *odpy; /* original display connection */
|
||||
XStandardColormap *colormap;
|
||||
XVisualInfo vinfo_template, *vinfo; /* visual */
|
||||
long vinfo_mask;
|
||||
unsigned long r_max, g_max, b_max; /* allocation */
|
||||
int count;
|
||||
Colormap cmap; /* colormap ID */
|
||||
Status status = 0;
|
||||
|
||||
|
||||
/* Match the requested visual */
|
||||
|
||||
vinfo_template.visualid = visualid;
|
||||
vinfo_template.screen = screen;
|
||||
vinfo_template.depth = depth;
|
||||
vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
|
||||
if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &count)) ==
|
||||
NULL)
|
||||
return 0;
|
||||
|
||||
/* Monochrome visuals have no standard maps */
|
||||
|
||||
if (vinfo->colormap_size <= 2) {
|
||||
XFree((char *) vinfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If the requested property already exists on this screen, and,
|
||||
* if the replace flag has not been set to true, return success.
|
||||
* lookup() will remove a pre-existing map if replace is true.
|
||||
*/
|
||||
|
||||
if (lookup(dpy, screen, visualid, property, (XStandardColormap *) NULL,
|
||||
replace) && !replace) {
|
||||
XFree((char *) vinfo);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Determine the best allocation for this property under the requested
|
||||
* visualid and depth, and determine whether or not to use the default
|
||||
* colormap of the screen.
|
||||
*/
|
||||
|
||||
if (!XmuGetColormapAllocation(vinfo, property, &r_max, &g_max, &b_max)) {
|
||||
XFree((char *) vinfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmap = (property == XA_RGB_DEFAULT_MAP &&
|
||||
visualid == XVisualIDFromVisual(DefaultVisual(dpy, screen)))
|
||||
? DefaultColormap(dpy, screen) : None;
|
||||
|
||||
/* If retaining resources, open a new connection to the same server */
|
||||
|
||||
if (retain) {
|
||||
odpy = dpy;
|
||||
if ((dpy = XOpenDisplay(XDisplayString(odpy))) == NULL) {
|
||||
XFree((char *) vinfo);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the standard colormap */
|
||||
|
||||
colormap = XmuStandardColormap(dpy, screen, visualid, depth, property,
|
||||
cmap, r_max, g_max, b_max);
|
||||
|
||||
/* Set the standard colormap property */
|
||||
|
||||
if (colormap) {
|
||||
XGrabServer(dpy);
|
||||
|
||||
if (lookup(dpy, screen, visualid, property, colormap, replace) &&
|
||||
!replace) {
|
||||
/* Someone has defined the property since we last looked.
|
||||
* Since we will not replace it, release our own resources.
|
||||
* If this is the default map, our allocations will be freed
|
||||
* when this connection closes.
|
||||
*/
|
||||
if (colormap->killid == ReleaseByFreeingColormap)
|
||||
XFreeColormap(dpy, colormap->colormap);
|
||||
} else if (retain) {
|
||||
XSetCloseDownMode(dpy, RetainPermanent);
|
||||
}
|
||||
XUngrabServer(dpy);
|
||||
XFree((char *) colormap);
|
||||
status = 1;
|
||||
}
|
||||
|
||||
if (retain)
|
||||
XCloseDisplay(dpy);
|
||||
XFree((char *) vinfo);
|
||||
return status;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Lookup a standard colormap property. If the property is RGB_DEFAULT_MAP,
|
||||
* the visualid is used to determine whether the indicated standard colormap
|
||||
* exists. If the map exists and replace is true, delete the resources used
|
||||
* by the map and remove the property. Return true if the map exists,
|
||||
* or did exist and was deleted; return false if the map was not found.
|
||||
*
|
||||
* Note that this is not the way that a Status return is normally used.
|
||||
*
|
||||
* If new is not NULL, new points to an XStandardColormap structure which
|
||||
* describes a standard colormap of the specified property. It will be made
|
||||
* a standard colormap of the screen if none already exists, or if replace
|
||||
* is true.
|
||||
*/
|
||||
|
||||
static Status
|
||||
lookup(Display * dpy, int screen, VisualID visualid, Atom property,
|
||||
XStandardColormap * cnew, Bool replace)
|
||||
/*
|
||||
* dpy - specifies display connection
|
||||
* screen - specifies screen number
|
||||
* visualid - specifies visualid for std map
|
||||
* property - specifies colormap property name
|
||||
* cnew - specifies a standard colormap
|
||||
* replace - specifies whether to replace
|
||||
*/
|
||||
{
|
||||
register int i;
|
||||
int count;
|
||||
XStandardColormap *stdcmaps, *s;
|
||||
Window win = RootWindow(dpy, screen);
|
||||
|
||||
/* The property does not already exist */
|
||||
|
||||
if (!XGetRGBColormaps(dpy, win, &stdcmaps, &count, property)) {
|
||||
if (cnew)
|
||||
XSetRGBColormaps(dpy, win, cnew, 1, property);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The property exists and is not describing the RGB_DEFAULT_MAP */
|
||||
|
||||
if (property != XA_RGB_DEFAULT_MAP) {
|
||||
if (replace) {
|
||||
XmuDeleteStandardColormap(dpy, screen, property);
|
||||
if (cnew)
|
||||
XSetRGBColormaps(dpy, win, cnew, 1, property);
|
||||
}
|
||||
XFree((char *) stdcmaps);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* The property exists and is RGB_DEFAULT_MAP */
|
||||
|
||||
for (i = 0, s = stdcmaps; (i < count) && (s->visualid != visualid);
|
||||
i++, s++);
|
||||
|
||||
/* No RGB_DEFAULT_MAP property matches the given visualid */
|
||||
|
||||
if (i == count) {
|
||||
if (cnew) {
|
||||
XStandardColormap *m, *maps;
|
||||
|
||||
s = (XStandardColormap *) malloc((unsigned) ((count + 1) * sizeof
|
||||
(XStandardColormap)));
|
||||
|
||||
for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
|
||||
m->colormap = maps->colormap;
|
||||
m->red_max = maps->red_max;
|
||||
m->red_mult = maps->red_mult;
|
||||
m->green_max = maps->green_max;
|
||||
m->green_mult = maps->green_mult;
|
||||
m->blue_max = maps->blue_max;
|
||||
m->blue_mult = maps->blue_mult;
|
||||
m->base_pixel = maps->base_pixel;
|
||||
m->visualid = maps->visualid;
|
||||
m->killid = maps->killid;
|
||||
}
|
||||
m->colormap = cnew->colormap;
|
||||
m->red_max = cnew->red_max;
|
||||
m->red_mult = cnew->red_mult;
|
||||
m->green_max = cnew->green_max;
|
||||
m->green_mult = cnew->green_mult;
|
||||
m->blue_max = cnew->blue_max;
|
||||
m->blue_mult = cnew->blue_mult;
|
||||
m->base_pixel = cnew->base_pixel;
|
||||
m->visualid = cnew->visualid;
|
||||
m->killid = cnew->killid;
|
||||
|
||||
XSetRGBColormaps(dpy, win, s, ++count, property);
|
||||
free((char *) s);
|
||||
}
|
||||
XFree((char *) stdcmaps);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Found an RGB_DEFAULT_MAP property with a matching visualid */
|
||||
|
||||
if (replace) {
|
||||
/* Free old resources first - we may need them, particularly in
|
||||
* the default colormap of the screen. However, because of this,
|
||||
* it is possible that we will destroy the old resource and fail
|
||||
* to create a new one if XmuStandardColormap() fails.
|
||||
*/
|
||||
|
||||
if (count == 1) {
|
||||
XmuDeleteStandardColormap(dpy, screen, property);
|
||||
if (cnew)
|
||||
XSetRGBColormaps(dpy, win, cnew, 1, property);
|
||||
} else {
|
||||
XStandardColormap *map;
|
||||
|
||||
/* s still points to the matching standard colormap */
|
||||
|
||||
if (s->killid == ReleaseByFreeingColormap) {
|
||||
if ((s->colormap != None) &&
|
||||
(s->colormap != DefaultColormap(dpy, screen)))
|
||||
XFreeColormap(dpy, s->colormap);
|
||||
} else if (s->killid != None)
|
||||
XKillClient(dpy, s->killid);
|
||||
|
||||
map = (cnew) ? cnew : stdcmaps + --count;
|
||||
|
||||
s->colormap = map->colormap;
|
||||
s->red_max = map->red_max;
|
||||
s->red_mult = map->red_mult;
|
||||
s->green_max = map->green_max;
|
||||
s->green_mult = map->green_mult;
|
||||
s->blue_max = map->blue_max;
|
||||
s->blue_mult = map->blue_mult;
|
||||
s->visualid = map->visualid;
|
||||
s->killid = map->killid;
|
||||
|
||||
XSetRGBColormaps(dpy, win, stdcmaps, count, property);
|
||||
}
|
||||
}
|
||||
XFree((char *) stdcmaps);
|
||||
return 1;
|
||||
}
|
|
@ -1,236 +0,0 @@
|
|||
/* $Xorg: StdCmap.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1989, 1998 The Open Group
|
||||
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/lib/Xmu/StdCmap.c,v 1.5 2001/01/17 19:42:56 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Donna Converse, MIT X Consortium
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../extensions/StdCmap.h"
|
||||
|
||||
#define lowbit(x) ((x) & (~(x) + 1))
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
/* argument restrictions */
|
||||
static Status valid_args(XVisualInfo *, unsigned long, unsigned long,
|
||||
unsigned long, Atom);
|
||||
|
||||
/*
|
||||
* To create any one standard colormap, use XmuStandardColormap().
|
||||
*
|
||||
* Create a standard colormap for the given screen, visualid, and visual
|
||||
* depth, with the given red, green, and blue maximum values, with the
|
||||
* given standard property name. Return a pointer to an XStandardColormap
|
||||
* structure which describes the newly created colormap, upon success.
|
||||
* Upon failure, return NULL.
|
||||
*
|
||||
* XmuStandardColormap() calls XmuCreateColormap() to create the map.
|
||||
*
|
||||
* Resources created by this function are not made permanent; that is the
|
||||
* caller's responsibility.
|
||||
*/
|
||||
|
||||
XStandardColormap *
|
||||
XmuStandardColormap(Display * dpy, int screen, VisualID visualid,
|
||||
unsigned int depth, Atom property, Colormap cmap,
|
||||
unsigned long red_max, unsigned long green_max,
|
||||
unsigned long blue_max)
|
||||
/*
|
||||
* dpy - specifies X server connection
|
||||
* screen - specifies display screen
|
||||
* visualid - identifies the visual type
|
||||
* depth - identifies the visual type
|
||||
* property - a standard colormap property
|
||||
* cmap - specifies colormap ID or None
|
||||
* red_max, green_max, blue_max - allocations
|
||||
*/
|
||||
{
|
||||
XStandardColormap *stdcmap;
|
||||
Status status;
|
||||
XVisualInfo vinfo_template, *vinfo;
|
||||
long vinfo_mask;
|
||||
int n;
|
||||
|
||||
/* Match the required visual information to an actual visual */
|
||||
vinfo_template.visualid = visualid;
|
||||
vinfo_template.screen = screen;
|
||||
vinfo_template.depth = depth;
|
||||
vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
|
||||
if ((vinfo =
|
||||
XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
|
||||
return 0;
|
||||
|
||||
/* Check the validity of the combination of visual characteristics,
|
||||
* allocation, and colormap property. Create an XStandardColormap
|
||||
* structure.
|
||||
*/
|
||||
|
||||
if (!valid_args(vinfo, red_max, green_max, blue_max, property)
|
||||
|| ((stdcmap = XAllocStandardColormap()) == NULL)) {
|
||||
XFree((char *) vinfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Fill in the XStandardColormap structure */
|
||||
|
||||
if (cmap == DefaultColormap(dpy, screen)) {
|
||||
/* Allocating out of the default map, cannot use XFreeColormap() */
|
||||
Window win = XCreateWindow(dpy, RootWindow(dpy, screen), 1, 1, 1, 1,
|
||||
0, 0, InputOnly, vinfo->visual,
|
||||
(unsigned long) 0,
|
||||
(XSetWindowAttributes *) NULL);
|
||||
stdcmap->killid = (XID) XCreatePixmap(dpy, win, 1, 1, depth);
|
||||
XDestroyWindow(dpy, win);
|
||||
stdcmap->colormap = cmap;
|
||||
} else {
|
||||
stdcmap->killid = ReleaseByFreeingColormap;
|
||||
stdcmap->colormap = XCreateColormap(dpy, RootWindow(dpy, screen),
|
||||
vinfo->visual, AllocNone);
|
||||
}
|
||||
stdcmap->red_max = red_max;
|
||||
stdcmap->green_max = green_max;
|
||||
stdcmap->blue_max = blue_max;
|
||||
if (property == XA_RGB_GRAY_MAP)
|
||||
stdcmap->red_mult = stdcmap->green_mult = stdcmap->blue_mult = 1;
|
||||
else if (vinfo->class == TrueColor || vinfo->class == DirectColor) {
|
||||
stdcmap->red_mult = lowbit(vinfo->red_mask);
|
||||
stdcmap->green_mult = lowbit(vinfo->green_mask);
|
||||
stdcmap->blue_mult = lowbit(vinfo->blue_mask);
|
||||
} else {
|
||||
stdcmap->red_mult = (red_max > 0)
|
||||
? (green_max + 1) * (blue_max + 1) : 0;
|
||||
stdcmap->green_mult = (green_max > 0) ? blue_max + 1 : 0;
|
||||
stdcmap->blue_mult = (blue_max > 0) ? 1 : 0;
|
||||
}
|
||||
stdcmap->base_pixel = 0; /* base pixel may change */
|
||||
stdcmap->visualid = vinfo->visualid;
|
||||
|
||||
/* Make the colormap */
|
||||
|
||||
status = XmuCreateColormap(dpy, stdcmap);
|
||||
|
||||
/* Clean up */
|
||||
|
||||
XFree((char *) vinfo);
|
||||
if (!status) {
|
||||
|
||||
/* Free the colormap or the pixmap, if we created one */
|
||||
if (stdcmap->killid == ReleaseByFreeingColormap)
|
||||
XFreeColormap(dpy, stdcmap->colormap);
|
||||
else if (stdcmap->killid != None)
|
||||
XFreePixmap(dpy, stdcmap->killid);
|
||||
|
||||
XFree((char *) stdcmap);
|
||||
return (XStandardColormap *) NULL;
|
||||
}
|
||||
return stdcmap;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
static Status
|
||||
valid_args(XVisualInfo * vinfo, unsigned long red_max,
|
||||
unsigned long green_max, unsigned long blue_max, Atom property)
|
||||
/*
|
||||
* vinfo - specifies visual
|
||||
* red_max, green_max, blue_max - specifies alloc
|
||||
* property - specifies property name
|
||||
*/
|
||||
{
|
||||
unsigned long ncolors; /* number of colors requested */
|
||||
|
||||
/* Determine that the number of colors requested is <= map size */
|
||||
|
||||
if ((vinfo->class == DirectColor) || (vinfo->class == TrueColor)) {
|
||||
unsigned long mask;
|
||||
|
||||
mask = vinfo->red_mask;
|
||||
while (!(mask & 1))
|
||||
mask >>= 1;
|
||||
if (red_max > mask)
|
||||
return 0;
|
||||
mask = vinfo->green_mask;
|
||||
while (!(mask & 1))
|
||||
mask >>= 1;
|
||||
if (green_max > mask)
|
||||
return 0;
|
||||
mask = vinfo->blue_mask;
|
||||
while (!(mask & 1))
|
||||
mask >>= 1;
|
||||
if (blue_max > mask)
|
||||
return 0;
|
||||
} else if (property == XA_RGB_GRAY_MAP) {
|
||||
ncolors = red_max + green_max + blue_max + 1;
|
||||
if (ncolors > vinfo->colormap_size)
|
||||
return 0;
|
||||
} else {
|
||||
ncolors = (red_max + 1) * (green_max + 1) * (blue_max + 1);
|
||||
if (ncolors > vinfo->colormap_size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Determine that the allocation and visual make sense for the property */
|
||||
|
||||
switch (property) {
|
||||
case XA_RGB_DEFAULT_MAP:
|
||||
if (red_max == 0 || green_max == 0 || blue_max == 0)
|
||||
return 0;
|
||||
break;
|
||||
case XA_RGB_RED_MAP:
|
||||
if (red_max == 0)
|
||||
return 0;
|
||||
break;
|
||||
case XA_RGB_GREEN_MAP:
|
||||
if (green_max == 0)
|
||||
return 0;
|
||||
break;
|
||||
case XA_RGB_BLUE_MAP:
|
||||
if (blue_max == 0)
|
||||
return 0;
|
||||
break;
|
||||
case XA_RGB_BEST_MAP:
|
||||
if (red_max == 0 || green_max == 0 || blue_max == 0)
|
||||
return 0;
|
||||
break;
|
||||
case XA_RGB_GRAY_MAP:
|
||||
if (red_max == 0 || blue_max == 0 || green_max == 0)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
|
@ -1,184 +0,0 @@
|
|||
/* $Xorg: VisCmap.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1989, 1998 The Open Group
|
||||
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/lib/Xmu/VisCmap.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Donna Converse, MIT X Consortium
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../extensions/StdCmap.h"
|
||||
|
||||
/*
|
||||
* To create all of the appropriate standard colormaps for a given visual on
|
||||
* a given screen, use XmuVisualStandardColormaps.
|
||||
*
|
||||
* Define all appropriate standard colormap properties for the given visual.
|
||||
* If replace is true, any previous definition will be removed.
|
||||
* If retain is true, new properties will be retained for the duration of
|
||||
* the server session. Return 0 on failure, non-zero on success.
|
||||
* On failure, no new properties will be defined, and, old ones may have
|
||||
* been removed if replace was True.
|
||||
*
|
||||
* Not all standard colormaps are meaningful to all visual classes. This
|
||||
* routine will check and define the following properties for the following
|
||||
* classes, provided that the size of the colormap is not too small.
|
||||
*
|
||||
* DirectColor and PseudoColor
|
||||
* RGB_DEFAULT_MAP
|
||||
* RGB_BEST_MAP
|
||||
* RGB_RED_MAP
|
||||
* RGB_GREEN_MAP
|
||||
* RGB_BLUE_MAP
|
||||
* RGB_GRAY_MAP
|
||||
*
|
||||
* TrueColor and StaticColor
|
||||
* RGB_BEST_MAP
|
||||
*
|
||||
* GrayScale and StaticGray
|
||||
* RGB_GRAY_MAP
|
||||
*/
|
||||
|
||||
Status
|
||||
XmuVisualStandardColormaps(Display * dpy, int screen, VisualID visualid,
|
||||
unsigned int depth, Bool replace, Bool retain)
|
||||
/*
|
||||
* dpy - specifies server connection
|
||||
* screen - specifies screen number
|
||||
* visualid - specifies the visual
|
||||
* depth - specifies the visual
|
||||
* replace specifies - whether to replace
|
||||
* retain - specifies whether to retain
|
||||
*/
|
||||
{
|
||||
Status status;
|
||||
int n;
|
||||
long vinfo_mask;
|
||||
XVisualInfo vinfo_template, *vinfo;
|
||||
|
||||
status = 0;
|
||||
vinfo_template.screen = screen;
|
||||
vinfo_template.visualid = visualid;
|
||||
vinfo_template.depth = depth;
|
||||
vinfo_mask = VisualScreenMask | VisualIDMask | VisualDepthMask;
|
||||
if ((vinfo =
|
||||
XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
|
||||
return 0;
|
||||
|
||||
if (vinfo->colormap_size <= 2) {
|
||||
/* Monochrome visuals have no standard maps; considered successful */
|
||||
XFree((char *) vinfo);
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch (vinfo->class) {
|
||||
case PseudoColor:
|
||||
case DirectColor:
|
||||
status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
|
||||
XA_RGB_DEFAULT_MAP, replace,
|
||||
retain);
|
||||
if (!status)
|
||||
break;
|
||||
|
||||
status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
|
||||
XA_RGB_GRAY_MAP, replace, retain);
|
||||
if (!status) {
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
|
||||
break;
|
||||
}
|
||||
|
||||
status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
|
||||
XA_RGB_RED_MAP, replace, retain);
|
||||
if (!status) {
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
|
||||
break;
|
||||
}
|
||||
|
||||
status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
|
||||
XA_RGB_GREEN_MAP, replace, retain);
|
||||
if (!status) {
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
|
||||
break;
|
||||
}
|
||||
|
||||
status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
|
||||
XA_RGB_BLUE_MAP, replace, retain);
|
||||
if (!status) {
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
|
||||
case StaticColor:
|
||||
case TrueColor:
|
||||
|
||||
status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
|
||||
XA_RGB_BEST_MAP, replace, retain);
|
||||
if (!status && (vinfo->class == PseudoColor ||
|
||||
vinfo->class == DirectColor)) {
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_BLUE_MAP);
|
||||
}
|
||||
break;
|
||||
/* the end for PseudoColor, DirectColor, StaticColor, and TrueColor */
|
||||
|
||||
case GrayScale:
|
||||
status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
|
||||
XA_RGB_DEFAULT_MAP, replace,
|
||||
retain);
|
||||
if (!status)
|
||||
break;
|
||||
/*FALLTHROUGH*/ case StaticGray:
|
||||
|
||||
status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
|
||||
XA_RGB_GRAY_MAP, replace, retain);
|
||||
if (!status && vinfo->class == GrayScale) {
|
||||
XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XFree((char *) vinfo);
|
||||
return status;
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/* $Xorg: StdCmap.h,v 1.5 2001/02/09 02:03:53 xorgcvs Exp $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1988, 1998 The Open Group
|
||||
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/lib/Xmu/StdCmap.h,v 1.8 2001/01/23 17:38:14 keithp Exp $ */
|
||||
|
||||
/*
|
||||
* The interfaces described by this header file are for miscellaneous utilities
|
||||
* and are not part of the Xlib standard.
|
||||
*/
|
||||
|
||||
#ifndef _XMU_STDCMAP_H_
|
||||
#define _XMU_STDCMAP_H_
|
||||
|
||||
#include <X11/Xfuncproto.h>
|
||||
#include "SDL_name.h"
|
||||
|
||||
_XFUNCPROTOBEGIN extern Status XmuAllStandardColormaps(Display * dpy);
|
||||
|
||||
extern Status XmuCreateColormap(Display * dpy, XStandardColormap * colormap);
|
||||
|
||||
extern void XmuDeleteStandardColormap
|
||||
(Display * dpy, int screen, Atom property);
|
||||
|
||||
extern Status XmuGetColormapAllocation
|
||||
(XVisualInfo * vinfo,
|
||||
Atom property,
|
||||
unsigned long *red_max_return,
|
||||
unsigned long *green_max_return, unsigned long *blue_max_return);
|
||||
|
||||
extern Status XmuLookupStandardColormap
|
||||
(Display * dpy,
|
||||
int screen,
|
||||
VisualID visualid,
|
||||
unsigned int depth, Atom property, Bool replace, Bool retain);
|
||||
|
||||
extern XStandardColormap *XmuStandardColormap
|
||||
(Display * dpy,
|
||||
int screen,
|
||||
VisualID visualid,
|
||||
unsigned int depth,
|
||||
Atom property,
|
||||
Colormap cmap,
|
||||
unsigned long red_max, unsigned long green_max, unsigned long blue_max);
|
||||
|
||||
extern Status XmuVisualStandardColormaps
|
||||
(Display * dpy,
|
||||
int screen,
|
||||
VisualID visualid, unsigned int depth, Bool replace, Bool retain);
|
||||
|
||||
extern Bool XmuDistinguishableColors(XColor * colors, int count);
|
||||
|
||||
extern Bool XmuDistinguishablePixels
|
||||
(Display * dpy, Colormap cmap, unsigned long *pixels, int count);
|
||||
|
||||
_XFUNCPROTOEND
|
||||
#endif /* _XMU_STDCMAP_H_ */
|
|
@ -52,18 +52,6 @@
|
|||
#include <X11/extensions/XInput.h>
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XRENDER
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XDAMAGE
|
||||
#include <X11/extensions/Xdamage.h>
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XFIXES
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When using the "dynamic X11" functionality, we duplicate all the Xlib
|
||||
* symbols that would be referenced by SDL inside of SDL itself.
|
||||
|
|
|
@ -24,58 +24,38 @@
|
|||
|
||||
SDL_X11_MODULE(BASEXLIB)
|
||||
SDL_X11_SYM(XClassHint*,XAllocClassHint,(void),(),return)
|
||||
SDL_X11_SYM(Status,XAllocColor,(Display* a,Colormap b,XColor* c),(a,b,c),return)
|
||||
SDL_X11_SYM(Status,XAllocColorCells,(Display *a,Colormap b,Bool c,unsigned long d[],unsigned int e,unsigned long f[],unsigned int g),(a,b,c,d,e,f,g),return)
|
||||
SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void),(),return)
|
||||
SDL_X11_SYM(XStandardColormap *,XAllocStandardColormap,(void),(),return)
|
||||
SDL_X11_SYM(XWMHints*,XAllocWMHints,(void),(),return)
|
||||
SDL_X11_SYM(int,XAutoRepeatOn,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XAutoRepeatOff,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(int,XChangeProperty,(Display* a,Window b,Atom c,Atom d,int e,int f,_Xconst unsigned char* g,int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_X11_SYM(int,XChangeWindowAttributes,(Display* a,Window b,unsigned long c,XSetWindowAttributes* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Bool,XCheckWindowEvent,(Display* a,Window b,long c,XEvent* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return)
|
||||
SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(int,XCopyArea,(Display* a,Drawable b,Drawable c,GC d,int e,int f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
|
||||
SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *data,unsigned int width,unsigned int height),(dpy,d,data,width,height),return)
|
||||
SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
|
||||
SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
|
||||
SDL_X11_SYM(Pixmap,XCreatePixmap,(Display* a,Drawable b,unsigned int c,unsigned int d,unsigned int e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(Pixmap,XCreatePixmapFromBitmapData,(Display* a,Drawable b,char* c,unsigned int d,unsigned int e,unsigned long f,unsigned long g,unsigned int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_X11_SYM(Window,XCreateSimpleWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,unsigned long h,unsigned long i),(a,b,c,d,e,f,g,h,i),return)
|
||||
SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
|
||||
SDL_X11_SYM(int,XDefineCursor,(Display* a,Window b,Cursor c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XDeleteProperty,(Display* a,Window b,Atom c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return)
|
||||
SDL_X11_SYM(int,XDisplayKeycodes,(Display* a,int* b,int* c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XDrawLines,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(int,XDrawPoint,(Display* a, Drawable b, GC c, int d, int e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(int,XDrawPoints,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(int,XDrawRectangles,(Display* a,Drawable b,GC c,XRectangle* d,int e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(int,XFillRectangles,(Display* a,Drawable b,GC c,XRectangle* d,int e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(char*,XDisplayName,(_Xconst char* a),(a),return)
|
||||
SDL_X11_SYM(int,XEventsQueued,(Display* a,int b),(a,b),return)
|
||||
SDL_X11_SYM(Bool,XFilterEvent,(XEvent *event,Window w),(event,w),return)
|
||||
SDL_X11_SYM(int,XFlush,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XFree,(void*a),(a),return)
|
||||
SDL_X11_SYM(int,XFreeColormap,(Display* a,Colormap b),(a,b),return)
|
||||
SDL_X11_SYM(int,XFreeColors,(Display* a,Colormap b,unsigned long* c,int d,unsigned long e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return)
|
||||
SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return)
|
||||
SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return)
|
||||
SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return)
|
||||
SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return)
|
||||
SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(XImage*,XGetImage,(Display* a,Drawable b,int c,int d,unsigned int e,unsigned int f,unsigned long g, int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XGetRGBColormaps,(Display* a,Window b,XStandardColormap **c,int *d,Atom e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(Window,XGetSelectionOwner,(Display* a,Atom b),(a,b),return)
|
||||
SDL_X11_SYM(Status,XGetTextProperty,(Display *a,Window b,XTextProperty *c,Atom d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XGetWindowProperty,(Display* a,Window b,Atom c,long d,long e,Bool f,Atom g,Atom* h,int* i,unsigned long* j,unsigned long *k,unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
|
||||
|
@ -84,47 +64,34 @@ SDL_X11_SYM(int,XGrabKeyboard,(Display* a,Window b,Bool c,int d,int e,Time f),(a
|
|||
SDL_X11_SYM(int,XGrabPointer,(Display* a,Window b,Bool c,unsigned int d,int e,int f,Window g,Cursor h,Time i),(a,b,c,d,e,f,g,h,i),return)
|
||||
SDL_X11_SYM(int,XGrabServer,(Display* a),(a),return)
|
||||
SDL_X11_SYM(Status,XIconifyWindow,(Display* a,Window b,int c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return)
|
||||
SDL_X11_SYM(KeyCode,XKeysymToKeycode,(Display* a,KeySym b),(a,b),return)
|
||||
SDL_X11_SYM(char*,XKeysymToString,(KeySym a),(a),return)
|
||||
SDL_X11_SYM(int,XKillClient,(Display* a,XID b),(a,b),return)
|
||||
SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return)
|
||||
SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display* a,int* b),(a,b),return)
|
||||
SDL_X11_SYM(KeySym,XLookupKeysym,(XKeyEvent* a,int b),(a,b),return)
|
||||
SDL_X11_SYM(int,XLookupString,(XKeyEvent* a,char* b,int c,KeySym* d,XComposeStatus* e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(int,XMapRaised,(Display* a,Window b),(a,b),return)
|
||||
SDL_X11_SYM(int,XMapWindow,(Display* a,Window b),(a,b),return)
|
||||
SDL_X11_SYM(int,XMaskEvent,(Display* a,long b,XEvent* c),(a,b,c),return)
|
||||
SDL_X11_SYM(Status,XMatchVisualInfo,(Display* a,int b,int c,int d,XVisualInfo* e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(int,XMissingExtension,(Display* a,_Xconst char* b),(a,b),return)
|
||||
SDL_X11_SYM(int,XMoveResizeWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(int,XMoveWindow,(Display* a,Window b,int c,int d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XNextEvent,(Display* a,XEvent* b),(a,b),return)
|
||||
SDL_X11_SYM(Display*,XOpenDisplay,(_Xconst char* a),(a),return)
|
||||
SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return)
|
||||
SDL_X11_SYM(int,XPending,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return)
|
||||
SDL_X11_SYM(int,XQueryColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return)
|
||||
SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return)
|
||||
SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return)
|
||||
SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(int,XResetScreenSaver,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XResizeWindow,(Display* a,Window b,unsigned int c,unsigned int d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return)
|
||||
SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(int,XSetClassHint,(Display* a,Window b,XClassHint* c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XSetCloseDownMode,(Display *a, int b),(a,b),return)
|
||||
SDL_X11_SYM(int,XSetForeground,(Display* a,GC b,unsigned long c),(a,b,c),return)
|
||||
SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
|
||||
SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
|
||||
SDL_X11_SYM(void,XSetRGBColormaps,( Display *a,Window b,XStandardColormap *c,int d,Atom e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return)
|
||||
SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),)
|
||||
SDL_X11_SYM(int,XSetWindowBackground,(Display* a,Window b,unsigned long c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XSetWindowBackgroundPixmap,(Display* a,Window b,Pixmap c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XSetWindowColormap,(Display* a,Window b,Colormap c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return)
|
||||
SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),)
|
||||
SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return)
|
||||
|
@ -157,10 +124,6 @@ SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display* a,Bool b),(a,b),r
|
|||
SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return)
|
||||
SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return)
|
||||
SDL_X11_SYM(XExtensionErrorHandler,XSetExtensionErrorHandler,(XExtensionErrorHandler a),(a),return)
|
||||
SDL_X11_SYM(int,XFillRectangle,(Display *dpy,Drawable d,GC gc,int x,int y,unsigned int width,unsigned int height),(dpy,d,gc,x,y,width,height),return)
|
||||
SDL_X11_SYM(int,XSetBackground,(Display *dpy,GC gc,unsigned long background),(dpy,gc,background),return)
|
||||
SDL_X11_SYM(Status,XInitImage,(XImage *image),(image),return)
|
||||
SDL_X11_SYM(int,XSetClipMask,(Display *dpy,GC gc,Pixmap pixmap),(dpy,gc,pixmap),return)
|
||||
|
||||
#if NeedWidePrototypes
|
||||
SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return)
|
||||
|
@ -243,42 +206,6 @@ SDL_X11_SYM(Status,XScreenSaverQueryVersion,(Display *dpy,int *major_versionp,in
|
|||
SDL_X11_SYM(void,XScreenSaverSuspend,(Display *dpy,Bool suspend),(dpy,suspend),return)
|
||||
#endif
|
||||
|
||||
/* XRender support */
|
||||
#if SDL_VIDEO_DRIVER_X11_XRENDER
|
||||
SDL_X11_MODULE(XRENDER)
|
||||
SDL_X11_SYM(Bool,XRenderQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return)
|
||||
SDL_X11_SYM(Bool,XRenderQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
|
||||
SDL_X11_SYM(XRenderPictFormat*,XRenderFindVisualFormat,(Display *dpy,_Xconst Visual *visual),(dpy,visual),return)
|
||||
SDL_X11_SYM(XRenderPictFormat*,XRenderFindStandardFormat,(Display *dpy,int format),(dpy,format),return)
|
||||
SDL_X11_SYM(XRenderPictFormat*,XRenderFindFormat,(Display *dpy,unsigned long mask,_Xconst XRenderPictFormat* templ,int count),(dpy,mask,templ,count),return)
|
||||
SDL_X11_SYM(Picture,XRenderCreatePicture,(Display *dpy,Drawable drawable,_Xconst XRenderPictFormat* format,unsigned long valuemask,_Xconst XRenderPictureAttributes* attributes),(dpy,drawable,format,valuemask,attributes),return)
|
||||
SDL_X11_SYM(void,XRenderFreePicture,(Display *dpy,Picture picture),(dpy,picture),return)
|
||||
SDL_X11_SYM(void,XRenderChangePicture,(Display *dpy,Picture picture,unsigned long valuemask,_Xconst XRenderPictureAttributes* attributes),(dpy,picture,valuemask,attributes),return)
|
||||
SDL_X11_SYM(void,XRenderComposite,(Display *dpy,int op,Picture src,Picture mask,Picture dst,int src_x,int src_y,int mask_x,int mask_y,int dst_x,int dst_y,unsigned int width,unsigned int height),(dpy,op,src,mask,dst,src_x,src_y,mask_x,mask_y,dst_x,dst_y,width,height),return)
|
||||
SDL_X11_SYM(Picture,XRenderCreateSolidFill,(Display *dpy,const XRenderColor *color),(dpy,color),return)
|
||||
SDL_X11_SYM(void,XRenderSetPictureTransform,(Display *dpy,Picture picture,XTransform *transform),(dpy,picture,transform),return)
|
||||
SDL_X11_SYM(void,XRenderFillRectangle,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,int x,int y,unsigned int width,unsigned int height),(dpy,op,dst,color,x,y,width,height),return)
|
||||
SDL_X11_SYM(void,XRenderFillRectangles,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,_Xconst XRectangle *rectangles,int n_rects),(dpy,op,dst,color,rectangles,n_rects),return)
|
||||
SDL_X11_SYM(void,XRenderSetPictureFilter,(Display *dpy,Picture picture,const char *filter,XFixed *params,int nparams),(dpy,picture,filter,params,nparams),return)
|
||||
#endif
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
|
||||
SDL_X11_MODULE(XDAMAGE)
|
||||
SDL_X11_SYM(Bool,XDamageQueryExtension,(Display *dpy,int *event_base_return,int *error_base_return),(dpy,event_base_return,error_base_return),return)
|
||||
SDL_X11_SYM(Status,XDamageQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
|
||||
SDL_X11_SYM(Damage,XDamageCreate,(Display *dpy,Drawable d,int level),(dpy,d,level),return)
|
||||
SDL_X11_SYM(void,XDamageSubtract,(Display *dpy,Damage damage,XserverRegion repair,XserverRegion parts),(dpy,damage,repair,parts),return)
|
||||
SDL_X11_SYM(void,XDamageDestroy,(Display *dpy,Damage damage),(dpy,damage),return)
|
||||
#endif
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_X11_XFIXES
|
||||
SDL_X11_MODULE(XFIXES)
|
||||
SDL_X11_SYM(Bool,XFixesQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return)
|
||||
SDL_X11_SYM(Status,XFixesQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
|
||||
SDL_X11_SYM(void,XFixesSetGCClipRegion,(Display *dpy,GC gc,int clip_x,int clip_y,XserverRegion region),(dpy,gc,clip_x,clip_y,region),return)
|
||||
SDL_X11_SYM(void,XFixesSetPictureClipRegion,(Display *dpy,XID picture,int clip_x,int clip_y,XserverRegion region),(dpy,picture,clip_x,clip_y,region),return)
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
SDL_X11_MODULE(XSHAPE)
|
||||
SDL_X11_SYM(void,XShapeCombineMask,(Display *dpy,Window dest,int dest_kind,int x_off,int y_off,Pixmap src,int op),(dpy,dest,dest_kind,x_off,y_off,src,op),)
|
||||
|
|
|
@ -47,15 +47,6 @@
|
|||
#if SDL_VIDEO_DRIVER_X11_SCRNSAVER
|
||||
#include <X11/extensions/scrnsaver.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XRENDER
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XDAMAGE
|
||||
#include <X11/extensions/Xdamage.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XFIXES
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
#include <X11/extensions/shape.h>
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "SDL_x11mouse.h"
|
||||
#include "SDL_x11gamma.h"
|
||||
#include "SDL_x11shape.h"
|
||||
#include "../Xext/extensions/StdCmap.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_PANDORA
|
||||
#include "SDL_x11opengles.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue