mesa/x11: Remove the swrast-classic-based fake libGL

If you want this you will almost certainly be happier with the gallium
version, giving you llvmpipe instead of swrast-classic.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10153>
This commit is contained in:
Adam Jackson 2021-04-15 10:07:40 -07:00 committed by Marge Bot
parent 901e0d6a11
commit 76791db088
19 changed files with 8 additions and 10714 deletions

View File

@ -562,16 +562,12 @@ endif
if with_glx != 'disabled'
if not (with_platform_x11 and with_any_opengl)
error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
elif with_glx == 'gallium-xlib'
if not with_gallium
error('Gallium-xlib based GLX requires at least one gallium driver')
elif not with_gallium_softpipe
error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
elif with_dri
error('gallium-xlib conflicts with any dri driver')
endif
elif with_glx == 'xlib'
if with_dri
if not with_gallium
error('xlib based GLX requires at least one gallium driver')
elif not with_gallium_softpipe
error('xlib based GLX requires softpipe or llvmpipe.')
elif with_dri
error('xlib conflicts with any dri driver')
endif
elif with_glx == 'dri'
@ -586,7 +582,7 @@ glvnd_vendor_name = get_option('glvnd-vendor-name')
if with_glvnd
if with_platform_windows
error('glvnd cannot be used on Windows')
elif with_glx == 'xlib' or with_glx == 'gallium-xlib'
elif with_glx == 'xlib'
error('Cannot build glvnd support for GLX that is not DRI based.')
elif with_glx == 'disabled' and not with_egl
error('glvnd requires DRI based GLX and/or EGL')
@ -2246,8 +2242,6 @@ if with_glx != 'disabled'
lines += 'GLX: DRI-based'
elif with_glx == 'xlib'
lines += 'GLX: Xlib-based'
elif with_glx == 'gallium-xlib'
lines += 'GLX: Xlib-based (Gallium)'
else
lines += 'GLX: ' + with_glx
endif

View File

@ -290,7 +290,7 @@ option(
'glx',
type : 'combo',
value : 'auto',
choices : ['auto', 'disabled', 'dri', 'xlib', 'gallium-xlib'],
choices : ['auto', 'disabled', 'dri', 'xlib'],
description : 'Build support for GLX platform'
)
option(

View File

@ -195,7 +195,7 @@ if with_osmesa
subdir('frontends/osmesa')
subdir('targets/osmesa')
endif
if with_glx == 'gallium-xlib'
if with_glx == 'xlib'
subdir('winsys/sw/xlib')
subdir('frontends/glx/xlib')
subdir('targets/libgl-xlib')

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,212 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
#ifndef _glxapi_h_
#define _glxapi_h_
#define GLX_GLXEXT_PROTOTYPES
#include "GL/glx.h"
/* The GLX API dispatcher (i.e. this code) is being built into stand-alone
* Mesa. We don't know anything about XFree86 or real GLX so we define a
* minimal __GLXContextRec here so some of the functions in this file can
* work properly.
*/
typedef struct __GLXcontextRec {
GLboolean isDirect;
GLXDrawable currentDrawable;
GLXDrawable currentReadable;
XID xid;
} __GLXcontext;
/*
* Almost all the GLX API functions get routed through this dispatch table.
* The exceptions are the glXGetCurrentXXX() functions.
*
* This dispatch table allows multiple GLX client-side modules to coexist.
* Specifically, a real GLX library (like SGI's or the Utah GLX) and Mesa's
* pseudo-GLX can be present at the same time. The former being used on
* GLX-enabled X servers and the later on non-GLX X servers.
*
* Red Hat has been using this since Red Hat Linux 7.0 (I think).
* This'll be a standard feature in XFree86 4.3. It basically allows one
* libGL to do both DRI-rendering and "fake GLX" rendering to X displays
* that lack the GLX extension.
*/
struct _glxapi_table {
/*** GLX_VERSION_1_0 ***/
XVisualInfo *(*ChooseVisual)(Display *dpy, int screen, int *list);
void (*CopyContext)(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
GLXContext (*CreateContext)(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct);
GLXPixmap (*CreateGLXPixmap)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap);
void (*DestroyContext)(Display *dpy, GLXContext ctx);
void (*DestroyGLXPixmap)(Display *dpy, GLXPixmap pixmap);
int (*GetConfig)(Display *dpy, XVisualInfo *visinfo, int attrib, int *value);
GLXContext (*GetCurrentContext)(void);
/*GLXDrawable (*GetCurrentDrawable)(void);*/
Bool (*IsDirect)(Display *dpy, GLXContext ctx);
Bool (*MakeCurrent)(Display *dpy, GLXDrawable drawable, GLXContext ctx);
Bool (*QueryExtension)(Display *dpy, int *errorb, int *event);
Bool (*QueryVersion)(Display *dpy, int *maj, int *min);
void (*SwapBuffers)(Display *dpy, GLXDrawable drawable);
void (*UseXFont)(Font font, int first, int count, int listBase);
void (*WaitGL)(void);
void (*WaitX)(void);
/*** GLX_VERSION_1_1 ***/
const char *(*GetClientString)(Display *dpy, int name);
const char *(*QueryExtensionsString)(Display *dpy, int screen);
const char *(*QueryServerString)(Display *dpy, int screen, int name);
/*** GLX_VERSION_1_2 ***/
/*Display *(*GetCurrentDisplay)(void);*/
/*** GLX_VERSION_1_3 ***/
GLXFBConfig *(*ChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems);
GLXContext (*CreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct);
GLXPbuffer (*CreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attribList);
GLXPixmap (*CreatePixmap)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList);
GLXWindow (*CreateWindow)(Display *dpy, GLXFBConfig config, Window win, const int *attribList);
void (*DestroyPbuffer)(Display *dpy, GLXPbuffer pbuf);
void (*DestroyPixmap)(Display *dpy, GLXPixmap pixmap);
void (*DestroyWindow)(Display *dpy, GLXWindow window);
/*GLXDrawable (*GetCurrentReadDrawable)(void);*/
int (*GetFBConfigAttrib)(Display *dpy, GLXFBConfig config, int attribute, int *value);
GLXFBConfig *(*GetFBConfigs)(Display *dpy, int screen, int *nelements);
void (*GetSelectedEvent)(Display *dpy, GLXDrawable drawable, unsigned long *mask);
XVisualInfo *(*GetVisualFromFBConfig)(Display *dpy, GLXFBConfig config);
Bool (*MakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
int (*QueryContext)(Display *dpy, GLXContext ctx, int attribute, int *value);
void (*QueryDrawable)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
void (*SelectEvent)(Display *dpy, GLXDrawable drawable, unsigned long mask);
/*** GLX_SGI_swap_control ***/
int (*SwapIntervalSGI)(int);
/*** GLX_SGI_video_sync ***/
int (*GetVideoSyncSGI)(unsigned int *count);
int (*WaitVideoSyncSGI)(int divisor, int remainder, unsigned int *count);
/*** GLX_SGI_make_current_read ***/
Bool (*MakeCurrentReadSGI)(Display *, GLXDrawable, GLXDrawable, GLXContext);
/*GLXDrawable (*GetCurrentReadDrawableSGI)(void);*/
/*** GLX_SGIX_video_source (needs video library) ***/
#if defined(_VL_H_)
GLXVideoSourceSGIX (*CreateGLXVideoSourceSGIX)(Display *, int, VLServer, VLPath, int, VLNode);
void (*DestroyGLXVideoSourceSGIX)(Display *, GLXVideoSourceSGIX);
#else
void *CreateGLXVideoSourceSGIX;
void *DestroyGLXVideoSourceSGIX;
#endif
/*** GLX_EXT_import_context ***/
void (*FreeContextEXT)(Display *dpy, GLXContext context);
GLXContextID (*GetContextIDEXT)(const GLXContext context);
/*Display *(*GetCurrentDisplayEXT)(void);*/
GLXContext (*ImportContextEXT)(Display *dpy, GLXContextID contextID);
int (*QueryContextInfoEXT)(Display *dpy, GLXContext context, int attribute,int *value);
/*** GLX_SGIX_fbconfig ***/
int (*GetFBConfigAttribSGIX)(Display *, GLXFBConfigSGIX, int, int *);
GLXFBConfigSGIX * (*ChooseFBConfigSGIX)(Display *, int, int *, int *);
GLXPixmap (*CreateGLXPixmapWithConfigSGIX)(Display *, GLXFBConfigSGIX, Pixmap);
GLXContext (*CreateContextWithConfigSGIX)(Display *, GLXFBConfigSGIX, int, GLXContext, Bool);
XVisualInfo * (*GetVisualFromFBConfigSGIX)(Display *, GLXFBConfigSGIX);
GLXFBConfigSGIX (*GetFBConfigFromVisualSGIX)(Display *, XVisualInfo *);
/*** GLX_SGIX_pbuffer ***/
GLXPbufferSGIX (*CreateGLXPbufferSGIX)(Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *);
void (*DestroyGLXPbufferSGIX)(Display *, GLXPbufferSGIX);
void (*QueryGLXPbufferSGIX)(Display *, GLXPbufferSGIX, int, unsigned int *);
void (*SelectEventSGIX)(Display *, GLXDrawable, unsigned long);
void (*GetSelectedEventSGIX)(Display *, GLXDrawable, unsigned long *);
/*** GLX_SGI_cushion ***/
void (*CushionSGI)(Display *, Window, float);
/*** GLX_SGIX_video_resize ***/
int (*BindChannelToWindowSGIX)(Display *, int, int, Window);
int (*ChannelRectSGIX)(Display *, int, int, int, int, int, int);
int (*QueryChannelRectSGIX)(Display *, int, int, int *, int *, int *, int *);
int (*QueryChannelDeltasSGIX)(Display *, int, int, int *, int *, int *, int *);
int (*ChannelRectSyncSGIX)(Display *, int, int, GLenum);
/*** GLX_SGIX_dmbuffer (needs dmedia library) ***/
#if defined (_DM_BUFFER_H_)
Bool (*AssociateDMPbufferSGIX)(Display *, GLXPbufferSGIX, DMparams *, DMbuffer);
#else
void *AssociciateDMPbufferSGIX;
#endif
/*** GLX_SUN_get_transparent_index ***/
Status (*GetTransparentIndexSUN)(Display *, Window, Window, unsigned long *);
/*** GLX_MESA_copy_sub_buffer ***/
void (*CopySubBufferMESA)(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
/*** GLX_MESA_release_buffers ***/
Bool (*ReleaseBuffersMESA)(Display *dpy, Window w);
/*** GLX_MESA_pixmap_colormap ***/
GLXPixmap (*CreateGLXPixmapMESA)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap);
/*** GLX_EXT_texture_from_pixmap ***/
void (*BindTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer,
const int *attrib_list);
void (*ReleaseTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer);
/*** GLX_ARB_create_context ***/
GLXContext (*CreateContextAttribs)(Display *dpy, GLXFBConfig config,
GLXContext share_context, Bool direct,
const int *attrib_list);
};
extern const char *
_glxapi_get_version(void);
extern const char **
_glxapi_get_extensions(void);
extern GLuint
_glxapi_get_dispatch_table_size(void);
extern void
_glxapi_set_no_op_table(struct _glxapi_table *t);
extern __GLXextFuncPtr
_glxapi_get_proc_address(const char *funcName);
#endif

View File

@ -1,51 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
#ifndef GLX_HEADER_H
#define GLX_HEADER_H
#include "main/glheader.h"
# include <X11/Xlib.h>
# include <X11/Xlibint.h>
# include <X11/Xutil.h>
# ifdef USE_XSHM /* was SHM */
# include <sys/ipc.h>
# include <sys/shm.h>
# include <X11/extensions/XShm.h>
# endif
# include <GL/glx.h>
# include <sys/time.h>
/* this silences a compiler warning on several systems */
struct timespec;
struct itimerspec;
#endif /*GLX_HEADER*/

View File

@ -1,39 +0,0 @@
# Copyright © 2017 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 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
# AUTHORS OR COPYRIGHT HOLDERS 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.
gl_link_with = []
if with_shared_glapi
gl_link_with += libglapi
endif
libgl = shared_library(
'GL',
files(
'fakeglx.c', 'glxapi.c', 'xfonts.c', 'xm_api.c', 'xm_buffer.c', 'xm_dd.c',
'xm_line.c', 'xm_tri.c',
),
include_directories : [
inc_include, inc_src, inc_mesa, inc_mapi, inc_gallium, inc_gallium_aux
],
link_with : [libmesa_classic, libglapi_static, gl_link_with],
dependencies : [idep_mesautil, dep_x11, dep_xext, dep_xcb, dep_thread],
version : '1.6.0',
install : true,
)

View File

@ -1,370 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/* xfonts.c -- glXUseXFont() for Mesa written by
* Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de
*/
#include <stdio.h>
#include "glxheader.h"
#include "main/context.h"
#include "xfonts.h"
/* Some debugging info. */
#ifdef DEBUG
#include <ctype.h>
int debug_xfonts = 0;
static void
dump_char_struct(XCharStruct * ch, char *prefix)
{
printf("%slbearing = %d, rbearing = %d, width = %d\n",
prefix, ch->lbearing, ch->rbearing, ch->width);
printf("%sascent = %d, descent = %d, attributes = %u\n",
prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes);
}
static void
dump_font_struct(XFontStruct * font)
{
printf("ascent = %d, descent = %d\n", font->ascent, font->descent);
printf("char_or_byte2 = (%u,%u)\n",
font->min_char_or_byte2, font->max_char_or_byte2);
printf("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
printf("all_chars_exist = %s\n", font->all_chars_exist ? "True" : "False");
printf("default_char = %c (\\%03o)\n",
(char) (isprint(font->default_char) ? font->default_char : ' '),
font->default_char);
dump_char_struct(&font->min_bounds, "min> ");
dump_char_struct(&font->max_bounds, "max> ");
#if 0
for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++) {
char prefix[8];
sprintf(prefix, "%d> ", c);
dump_char_struct(&font->per_char[c], prefix);
}
#endif
}
static void
dump_bitmap(unsigned int width, unsigned int height, GLubyte * bitmap)
{
unsigned int x, y;
printf(" ");
for (x = 0; x < 8 * width; x++)
printf("%o", 7 - (x % 8));
putchar('\n');
for (y = 0; y < height; y++) {
printf("%3o:", y);
for (x = 0; x < 8 * width; x++)
putchar((bitmap[width * (height - y - 1) + x / 8] & (1 << (7 - (x %
8))))
? '*' : '.');
printf(" ");
for (x = 0; x < width; x++)
printf("0x%02x, ", bitmap[width * (height - y - 1) + x]);
putchar('\n');
}
}
#endif /* DEBUG */
/* Implementation. */
/* Fill a BITMAP with a character C from thew current font
in the graphics context GC. WIDTH is the width in bytes
and HEIGHT is the height in bits.
Note that the generated bitmaps must be used with
glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
Possible optimizations:
* use only one reusable pixmap with the maximum dimensions.
* draw the entire font into a single pixmap (careful with
proportional fonts!).
*/
/*
* Generate OpenGL-compatible bitmap.
*/
static void
fill_bitmap(Display * dpy, Window win, GC gc,
unsigned int width, unsigned int height,
int x0, int y0, unsigned int c, GLubyte * bitmap)
{
XImage *image;
unsigned int x, y;
Pixmap pixmap;
XChar2b char2b;
pixmap = XCreatePixmap(dpy, win, 8 * width, height, 1);
XSetForeground(dpy, gc, 0);
XFillRectangle(dpy, pixmap, gc, 0, 0, 8 * width, height);
XSetForeground(dpy, gc, 1);
char2b.byte1 = (c >> 8) & 0xff;
char2b.byte2 = (c & 0xff);
XDrawString16(dpy, pixmap, gc, x0, y0, &char2b, 1);
image = XGetImage(dpy, pixmap, 0, 0, 8 * width, height, 1, XYPixmap);
if (image) {
/* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */
for (y = 0; y < height; y++)
for (x = 0; x < 8 * width; x++)
if (XGetPixel(image, x, y))
bitmap[width * (height - y - 1) + x / 8] |=
(1 << (7 - (x % 8)));
XDestroyImage(image);
}
XFreePixmap(dpy, pixmap);
}
/*
* determine if a given glyph is valid and return the
* corresponding XCharStruct.
*/
static XCharStruct *
isvalid(XFontStruct * fs, unsigned int which)
{
unsigned int rows, pages;
unsigned int byte1 = 0, byte2 = 0;
int i, valid = 1;
rows = fs->max_byte1 - fs->min_byte1 + 1;
pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
if (rows == 1) {
/* "linear" fonts */
if ((fs->min_char_or_byte2 > which) || (fs->max_char_or_byte2 < which))
valid = 0;
}
else {
/* "matrix" fonts */
byte2 = which & 0xff;
byte1 = which >> 8;
if ((fs->min_char_or_byte2 > byte2) ||
(fs->max_char_or_byte2 < byte2) ||
(fs->min_byte1 > byte1) || (fs->max_byte1 < byte1))
valid = 0;
}
if (valid) {
if (fs->per_char) {
if (rows == 1) {
/* "linear" fonts */
return (fs->per_char + (which - fs->min_char_or_byte2));
}
else {
/* "matrix" fonts */
i = ((byte1 - fs->min_byte1) * pages) +
(byte2 - fs->min_char_or_byte2);
return (fs->per_char + i);
}
}
else {
return (&fs->min_bounds);
}
}
return (NULL);
}
void
Fake_glXUseXFont(Font font, int first, int count, int listbase)
{
Display *dpy;
Window win;
Pixmap pixmap;
GC gc;
XGCValues values;
unsigned long valuemask;
XFontStruct *fs;
GLint swapbytes, lsbfirst, rowlength;
GLint skiprows, skippixels, alignment;
unsigned int max_width, max_height, max_bm_width, max_bm_height;
GLubyte *bm;
int i;
dpy = glXGetCurrentDisplay();
if (!dpy)
return; /* I guess glXMakeCurrent wasn't called */
win = RootWindow(dpy, DefaultScreen(dpy));
fs = XQueryFont(dpy, font);
if (!fs) {
_mesa_error(NULL, GL_INVALID_VALUE,
"Couldn't get font structure information");
return;
}
/* Allocate a bitmap that can fit all characters. */
max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
max_bm_width = (max_width + 7) / 8;
max_bm_height = max_height;
bm = malloc((max_bm_width * max_bm_height) * sizeof(GLubyte));
if (!bm) {
XFreeFontInfo(NULL, fs, 1);
_mesa_error(NULL, GL_OUT_OF_MEMORY,
"Couldn't allocate bitmap in glXUseXFont()");
return;
}
#if 0
/* get the page info */
pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
rows = fs->max_byte1 - fs->min_byte1 + 1;
unsigned int first_char, last_char, pages, rows;
#endif
/* Save the current packing mode for bitmaps. */
glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
/* Enforce a standard packing mode which is compatible with
fill_bitmap() from above. This is actually the default mode,
except for the (non)alignment. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
pixmap = XCreatePixmap(dpy, win, 10, 10, 1);
values.foreground = BlackPixel(dpy, DefaultScreen(dpy));
values.background = WhitePixel(dpy, DefaultScreen(dpy));
values.font = fs->fid;
valuemask = GCForeground | GCBackground | GCFont;
gc = XCreateGC(dpy, pixmap, valuemask, &values);
XFreePixmap(dpy, pixmap);
#ifdef DEBUG
if (debug_xfonts)
dump_font_struct(fs);
#endif
for (i = 0; i < count; i++) {
unsigned int width, height, bm_width, bm_height;
GLfloat x0, y0, dx, dy;
XCharStruct *ch;
int x, y;
unsigned int c = first + i;
int list = listbase + i;
int valid;
/* check on index validity and get the bounds */
ch = isvalid(fs, c);
if (!ch) {
ch = &fs->max_bounds;
valid = 0;
}
else {
valid = 1;
}
#ifdef DEBUG
if (debug_xfonts) {
char s[7];
sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c);
dump_char_struct(ch, s);
}
#endif
/* glBitmap()' parameters:
straight from the glXUseXFont(3) manpage. */
width = ch->rbearing - ch->lbearing;
height = ch->ascent + ch->descent;
x0 = -ch->lbearing;
y0 = ch->descent - 0; /* XXX used to subtract 1 here */
/* but that caused a conformace failure */
dx = ch->width;
dy = 0;
/* X11's starting point. */
x = -ch->lbearing;
y = ch->ascent;
/* Round the width to a multiple of eight. We will use this also
for the pixmap for capturing the X11 font. This is slightly
inefficient, but it makes the OpenGL part real easy. */
bm_width = (width + 7) / 8;
bm_height = height;
glNewList(list, GL_COMPILE);
if (valid && (bm_width > 0) && (bm_height > 0)) {
memset(bm, '\0', bm_width * bm_height);
fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, bm);
glBitmap(width, height, x0, y0, dx, dy, bm);
#ifdef DEBUG
if (debug_xfonts) {
printf("width/height = %u/%u\n", width, height);
printf("bm_width/bm_height = %u/%u\n", bm_width, bm_height);
dump_bitmap(bm_width, bm_height, bm);
}
#endif
}
else {
glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL);
}
glEndList();
}
free(bm);
XFreeFontInfo(NULL, fs, 1);
XFreeGC(dpy, gc);
/* Restore saved packing modes. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
}

View File

@ -1,37 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
#ifndef XFONTS_H
#define XFONTS_H
#include <X11/Xlib.h>
extern void Fake_glXUseXFont( Font font, int first, int count, int listbase );
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,560 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/**
* \file xm_buffer.h
* Framebuffer and renderbuffer-related functions.
*/
#include "glxheader.h"
#include "xmesaP.h"
#include "main/errors.h"
#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "swrast/s_renderbuffer.h"
#include "util/u_memory.h"
#define XMESA_RENDERBUFFER 0x1234
#if defined(USE_XSHM)
static volatile int mesaXErrorFlag = 0;
/**
* Catches potential Xlib errors.
*/
static int
mesaHandleXError(XMesaDisplay *dpy, XErrorEvent *event)
{
(void) dpy;
(void) event;
mesaXErrorFlag = 1;
return 0;
}
/**
* Allocate a shared memory XImage back buffer for the given XMesaBuffer.
* Return: GL_TRUE if success, GL_FALSE if error
*/
static GLboolean
alloc_back_shm_ximage(XMesaBuffer b, GLuint width, GLuint height)
{
/*
* We have to do a _lot_ of error checking here to be sure we can
* really use the XSHM extension. It seems different servers trigger
* errors at different points if the extension won't work. Therefore
* we have to be very careful...
*/
GC gc;
int (*old_handler)(XMesaDisplay *, XErrorEvent *);
if (width == 0 || height == 0) {
/* this will be true the first time we're called on 'b' */
return GL_FALSE;
}
b->backxrb->ximage = XShmCreateImage(b->xm_visual->display,
b->xm_visual->visinfo->visual,
b->xm_visual->visinfo->depth,
ZPixmap, NULL, &b->shminfo,
width, height);
if (b->backxrb->ximage == NULL) {
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (XShmCreateImage), disabling.\n");
b->shm = 0;
return GL_FALSE;
}
/* 0600 = user read+write */
b->shminfo.shmid = shmget(IPC_PRIVATE, b->backxrb->ximage->bytes_per_line
* b->backxrb->ximage->height, IPC_CREAT | 0600);
if (b->shminfo.shmid < 0) {
_mesa_warning(NULL, "shmget failed while allocating back buffer.\n");
XDestroyImage(b->backxrb->ximage);
b->backxrb->ximage = NULL;
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmget), disabling.\n");
b->shm = 0;
return GL_FALSE;
}
b->shminfo.shmaddr = b->backxrb->ximage->data
= (char*)shmat(b->shminfo.shmid, 0, 0);
if (b->shminfo.shmaddr == (char *) -1) {
_mesa_warning(NULL, "shmat() failed while allocating back buffer.\n");
XDestroyImage(b->backxrb->ximage);
shmctl(b->shminfo.shmid, IPC_RMID, 0);
b->backxrb->ximage = NULL;
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmat), disabling.\n");
b->shm = 0;
return GL_FALSE;
}
b->shminfo.readOnly = False;
mesaXErrorFlag = 0;
old_handler = XSetErrorHandler(mesaHandleXError);
/* This may trigger the X protocol error we're ready to catch: */
XShmAttach(b->xm_visual->display, &b->shminfo);
XSync(b->xm_visual->display, False);
if (mesaXErrorFlag) {
/* we are on a remote display, this error is normal, don't print it */
XFlush(b->xm_visual->display);
mesaXErrorFlag = 0;
XDestroyImage(b->backxrb->ximage);
shmdt(b->shminfo.shmaddr);
shmctl(b->shminfo.shmid, IPC_RMID, 0);
b->backxrb->ximage = NULL;
b->shm = 0;
(void) XSetErrorHandler(old_handler);
return GL_FALSE;
}
shmctl(b->shminfo.shmid, IPC_RMID, 0); /* nobody else needs it */
/* Finally, try an XShmPutImage to be really sure the extension works */
gc = XCreateGC(b->xm_visual->display, b->frontxrb->drawable, 0, NULL);
XShmPutImage(b->xm_visual->display, b->frontxrb->drawable, gc,
b->backxrb->ximage, 0, 0, 0, 0, 1, 1 /*one pixel*/, False);
XSync(b->xm_visual->display, False);
XFreeGC(b->xm_visual->display, gc);
(void) XSetErrorHandler(old_handler);
if (mesaXErrorFlag) {
XFlush(b->xm_visual->display);
mesaXErrorFlag = 0;
XDestroyImage(b->backxrb->ximage);
shmdt(b->shminfo.shmaddr);
shmctl(b->shminfo.shmid, IPC_RMID, 0);
b->backxrb->ximage = NULL;
b->shm = 0;
return GL_FALSE;
}
return GL_TRUE;
}
#else
static GLboolean
alloc_back_shm_ximage(XMesaBuffer b, GLuint width, GLuint height)
{
/* Can't compile XSHM support */
return GL_FALSE;
}
#endif
/**
* Setup an off-screen pixmap or Ximage to use as the back buffer.
* Input: b - the X/Mesa buffer
*/
static void
alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height)
{
if (b->db_mode == BACK_XIMAGE) {
/* Deallocate the old backxrb->ximage, if any */
if (b->backxrb->ximage) {
#if defined(USE_XSHM)
if (b->shm) {
XShmDetach(b->xm_visual->display, &b->shminfo);
XDestroyImage(b->backxrb->ximage);
shmdt(b->shminfo.shmaddr);
}
else
#endif
XMesaDestroyImage(b->backxrb->ximage);
b->backxrb->ximage = NULL;
}
if (width == 0 || height == 0)
return;
/* Allocate new back buffer */
if (b->shm == 0 || !alloc_back_shm_ximage(b, width, height)) {
/* Allocate a regular XImage for the back buffer. */
b->backxrb->ximage = XCreateImage(b->xm_visual->display,
b->xm_visual->visinfo->visual,
GET_VISUAL_DEPTH(b->xm_visual),
ZPixmap, 0, /* format, offset */
NULL,
width, height,
8, 0); /* pad, bytes_per_line */
if (!b->backxrb->ximage) {
_mesa_warning(NULL, "alloc_back_buffer: XCreateImage failed.\n");
return;
}
b->backxrb->ximage->data = malloc(b->backxrb->ximage->height
* b->backxrb->ximage->bytes_per_line);
if (!b->backxrb->ximage->data) {
_mesa_warning(NULL, "alloc_back_buffer: MALLOC failed.\n");
XMesaDestroyImage(b->backxrb->ximage);
b->backxrb->ximage = NULL;
}
}
b->backxrb->pixmap = None;
}
else if (b->db_mode == BACK_PIXMAP) {
/* Free the old back pixmap */
if (b->backxrb->pixmap) {
XMesaFreePixmap(b->xm_visual->display, b->backxrb->pixmap);
b->backxrb->pixmap = 0;
}
if (width > 0 && height > 0) {
/* Allocate new back pixmap */
b->backxrb->pixmap = XMesaCreatePixmap(b->xm_visual->display,
b->frontxrb->drawable,
width, height,
GET_VISUAL_DEPTH(b->xm_visual));
}
b->backxrb->ximage = NULL;
b->backxrb->drawable = b->backxrb->pixmap;
}
}
static void
xmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
/* XXX Note: the ximage or Pixmap attached to this renderbuffer
* should probably get freed here, but that's currently done in
* XMesaDestroyBuffer().
*/
free(rb);
}
/**
* Reallocate renderbuffer storage for front color buffer.
* Called via gl_renderbuffer::AllocStorage()
*/
static GLboolean
xmesa_alloc_front_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat, GLuint width, GLuint height)
{
struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb);
/* just clear these to be sure we don't accidentally use them */
xrb->origin2 = NULL;
xrb->origin3 = NULL;
xrb->origin4 = NULL;
/* for the FLIP macro: */
xrb->bottom = height - 1;
rb->Width = width;
rb->Height = height;
rb->InternalFormat = internalFormat;
return GL_TRUE;
}
/**
* Reallocate renderbuffer storage for back color buffer.
* Called via gl_renderbuffer::AllocStorage()
*/
static GLboolean
xmesa_alloc_back_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat, GLuint width, GLuint height)
{
struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb);
/* reallocate the back buffer XImage or Pixmap */
assert(xrb->Parent);
alloc_back_buffer(xrb->Parent, width, height);
/* same as front buffer */
/* XXX why is this here? */
(void) xmesa_alloc_front_storage(ctx, rb, internalFormat, width, height);
/* plus... */
if (xrb->ximage) {
/* Needed by PIXELADDR2 macro */
xrb->width2 = xrb->ximage->bytes_per_line / 2;
xrb->origin2 = (GLushort *) xrb->ximage->data + xrb->width2 * (height - 1);
/* Needed by PIXELADDR3 macro */
xrb->width3 = xrb->ximage->bytes_per_line;
xrb->origin3 = (GLubyte *) xrb->ximage->data + xrb->width3 * (height - 1);
/* Needed by PIXELADDR4 macro */
xrb->width4 = xrb->ximage->width;
xrb->origin4 = (GLuint *) xrb->ximage->data + xrb->width4 * (height - 1);
}
else {
/* out of memory or buffer size is 0 x 0 */
xrb->width2 = xrb->width3 = xrb->width4 = 0;
xrb->origin2 = NULL;
xrb->origin3 = NULL;
xrb->origin4 = NULL;
}
return GL_TRUE;
}
/**
* Used for allocating front/back renderbuffers for an X window.
*/
struct xmesa_renderbuffer *
xmesa_new_renderbuffer(struct gl_context *ctx, GLuint name,
const struct xmesa_visual *xmvis,
GLboolean backBuffer)
{
struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
if (xrb) {
GLuint name = 0;
_mesa_init_renderbuffer(&xrb->Base.Base, name);
xrb->Base.Base.Delete = xmesa_delete_renderbuffer;
if (backBuffer)
xrb->Base.Base.AllocStorage = xmesa_alloc_back_storage;
else
xrb->Base.Base.AllocStorage = xmesa_alloc_front_storage;
xrb->Base.Base.InternalFormat = GL_RGBA;
xrb->Base.Base._BaseFormat = GL_RGBA;
xrb->Base.Base.ClassID = XMESA_RENDERBUFFER;
switch (xmvis->undithered_pf) {
case PF_8R8G8B:
/* This will really only happen for pixmaps. We'll access the
* pixmap via a temporary XImage which will be 32bpp.
*/
xrb->Base.Base.Format = MESA_FORMAT_B8G8R8X8_UNORM;
break;
case PF_8A8R8G8B:
xrb->Base.Base.Format = MESA_FORMAT_B8G8R8A8_UNORM;
break;
case PF_8A8B8G8R:
xrb->Base.Base.Format = MESA_FORMAT_R8G8B8A8_UNORM;
break;
case PF_5R6G5B:
xrb->Base.Base.Format = MESA_FORMAT_B5G6R5_UNORM;
break;
default:
_mesa_warning(ctx, "Bad pixel format in xmesa_new_renderbuffer");
xrb->Base.Base.Format = MESA_FORMAT_B8G8R8A8_UNORM;
break;
}
/* only need to set Red/Green/EtcBits fields for user-created RBs */
}
return xrb;
}
/**
* Called via gl_framebuffer::Delete() method when this buffer
* is _really_ being deleted.
*/
void
xmesa_delete_framebuffer(struct gl_framebuffer *fb)
{
XMesaBuffer b = XMESA_BUFFER(fb);
if (b->num_alloced > 0) {
/* If no other buffer uses this X colormap then free the colors. */
if (!xmesa_find_buffer(b->display, b->cmap, b)) {
XFreeColors(b->display, b->cmap,
b->alloced_colors, b->num_alloced, 0);
}
}
if (b->gc)
XMesaFreeGC(b->display, b->gc);
if (b->cleargc)
XMesaFreeGC(b->display, b->cleargc);
if (b->swapgc)
XMesaFreeGC(b->display, b->swapgc);
if (fb->Visual.doubleBufferMode) {
/* free back ximage/pixmap/shmregion */
if (b->backxrb->ximage) {
#if defined(USE_XSHM)
if (b->shm) {
XShmDetach( b->display, &b->shminfo );
XDestroyImage( b->backxrb->ximage );
shmdt( b->shminfo.shmaddr );
}
else
#endif
XMesaDestroyImage( b->backxrb->ximage );
b->backxrb->ximage = NULL;
}
if (b->backxrb->pixmap) {
XMesaFreePixmap( b->display, b->backxrb->pixmap );
}
}
_mesa_free_framebuffer_data(fb);
free(fb);
}
/**
* Called via ctx->Driver.MapRenderbuffer()
*/
void
xmesa_MapRenderbuffer(struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLuint x, GLuint y, GLuint w, GLuint h,
GLbitfield mode,
GLubyte **mapOut, GLint *rowStrideOut,
bool flip_y)
{
struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb);
if (xrb->Base.Base.ClassID == XMESA_RENDERBUFFER) {
XImage *ximage = xrb->ximage;
assert(!xrb->map_mode); /* only a single mapping allowed */
xrb->map_mode = mode;
xrb->map_x = x;
xrb->map_y = y;
xrb->map_w = w;
xrb->map_h = h;
if (ximage) {
int y2 = rb->Height - y - 1;
*mapOut = (GLubyte *) ximage->data
+ y2 * ximage->bytes_per_line
+ x * ximage->bits_per_pixel / 8;
}
else {
/* this must be a pixmap/window renderbuffer */
int (*old_handler)(XMesaDisplay *, XErrorEvent *);
int y2 = rb->Height - y - h;
assert(xrb->pixmap);
/* Install error handler for XGetImage() in case the window
* isn't mapped. If we fail we'll create a temporary XImage.
*/
mesaXErrorFlag = 0;
old_handler = XSetErrorHandler(mesaHandleXError);
/* read pixel data out of the pixmap/window into an XImage */
ximage = XGetImage(xrb->Parent->display,
xrb->pixmap, x, y2, w, h,
AllPlanes, ZPixmap);
XSetErrorHandler(old_handler);
if (mesaXErrorFlag) {
/* create new, temporary XImage */
int bytes_per_line =
_mesa_format_row_stride(xrb->Base.Base.Format,
xrb->Base.Base.Width);
char *image = malloc(bytes_per_line *
xrb->Base.Base.Height);
ximage = XCreateImage(xrb->Parent->display,
xrb->Parent->xm_visual->visinfo->visual,
xrb->Parent->xm_visual->visinfo->depth,
ZPixmap, /* format */
0, /* offset */
image, /* data */
xrb->Base.Base.Width,
xrb->Base.Base.Height,
8, /* pad */
bytes_per_line);
}
if (!ximage) {
*mapOut = NULL;
*rowStrideOut = 0;
return;
}
xrb->map_ximage = ximage;
/* the first row of the OpenGL image is last row of the XImage */
*mapOut = (GLubyte *) ximage->data
+ (h - 1) * ximage->bytes_per_line;
}
/* We return a negative stride here since XImage data is upside down
* with respect to OpenGL images.
*/
*rowStrideOut = -ximage->bytes_per_line;
return;
}
/* otherwise, this is an ordinary malloc-based renderbuffer */
_swrast_map_soft_renderbuffer(ctx, rb, x, y, w, h, mode,
mapOut, rowStrideOut, false);
}
/**
* Called via ctx->Driver.UnmapRenderbuffer()
*/
void
xmesa_UnmapRenderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb);
if (xrb->Base.Base.ClassID == XMESA_RENDERBUFFER) {
XImage *ximage = xrb->ximage;
if (!ximage) {
/* this must be a pixmap/window renderbuffer */
assert(xrb->pixmap);
assert(xrb->map_ximage);
if (xrb->map_ximage) {
if (xrb->map_mode & GL_MAP_WRITE_BIT) {
/* put modified ximage data back into the pixmap/window */
int y2 = rb->Height - xrb->map_y - xrb->map_h;
GC gc = XCreateGC(xrb->Parent->display, xrb->pixmap, 0, NULL);
XPutImage(xrb->Parent->display,
xrb->pixmap, /* dest */
gc,
xrb->map_ximage, /* source */
0, 0, /* src x, y */
xrb->map_x, y2, /* dest x, y */
xrb->map_w, xrb->map_h); /* size */
XFreeGC(xrb->Parent->display, gc);
}
XMesaDestroyImage(xrb->map_ximage);
xrb->map_ximage = NULL;
}
}
xrb->map_mode = 0x0;
return;
}
/* otherwise, this is an ordinary malloc-based renderbuffer */
_swrast_unmap_soft_renderbuffer(ctx, rb);
}

View File

@ -1,921 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/**
* \file xm_dd.h
* General device driver functions for Xlib driver.
*/
#include "glxheader.h"
#include "main/bufferobj.h"
#include "main/context.h"
#include "main/colormac.h"
#include "main/fbobject.h"
#include "main/framebuffer.h"
#include "main/macros.h"
#include "main/mipmap.h"
#include "main/image.h"
#include "main/mtypes.h"
#include "main/pbo.h"
#include "main/texformat.h"
#include "swrast/swrast.h"
#include "swrast/s_context.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "drivers/common/meta.h"
#include "xmesaP.h"
#include "util/u_memory.h"
static void
finish(struct gl_context *ctx)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
if (xmesa) {
mtx_lock(&_xmesa_lock);
XSync( xmesa->display, False );
mtx_unlock(&_xmesa_lock);
}
}
static void
flush(struct gl_context *ctx, unsigned gallium_flush_flags)
{
finish(ctx);
}
/* Implements glColorMask() */
static void
color_mask(struct gl_context *ctx,
GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaBuffer xmbuf;
const int xclass = xmesa->xm_visual->visualType;
(void) amask;
if (_mesa_is_user_fbo(ctx->DrawBuffer))
return;
xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
if (xclass == GLX_TRUE_COLOR || xclass == GLX_DIRECT_COLOR) {
unsigned long m;
if (rmask && gmask && bmask) {
m = ((unsigned long)~0L);
}
else {
m = 0;
if (rmask) m |= GET_REDMASK(xmesa->xm_visual);
if (gmask) m |= GET_GREENMASK(xmesa->xm_visual);
if (bmask) m |= GET_BLUEMASK(xmesa->xm_visual);
}
XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m );
}
}
/**********************************************************************/
/*** glClear implementations ***/
/**********************************************************************/
/**
* Clear the front or back color buffer, if it's implemented with a pixmap.
*/
static void
clear_pixmap(struct gl_context *ctx, struct xmesa_renderbuffer *xrb,
GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
assert(xmbuf);
assert(xrb->pixmap);
assert(xmesa);
assert(xmesa->display);
assert(xrb->pixmap);
assert(xmbuf->cleargc);
XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc,
x, xrb->Base.Base.Height - y - height,
width, height );
}
static void
clear_16bit_ximage( struct gl_context *ctx, struct xmesa_renderbuffer *xrb,
GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
GLuint pixel = (GLuint) xmesa->clearpixel;
GLint i, j;
if (xmesa->swapbytes) {
pixel = ((pixel >> 8) & 0x00ff) | ((pixel << 8) & 0xff00);
}
for (j = 0; j < height; j++) {
GLushort *ptr2 = PIXEL_ADDR2(xrb, x, y + j);
for (i = 0; i < width; i++) {
ptr2[i] = pixel;
}
}
}
/* Optimized code provided by Nozomi Ytow <noz@xfree86.org> */
static void
clear_24bit_ximage(struct gl_context *ctx, struct xmesa_renderbuffer *xrb,
GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = xmesa->clearcolor[0];
const GLubyte g = xmesa->clearcolor[1];
const GLubyte b = xmesa->clearcolor[2];
if (r == g && g == b) {
/* same value for all three components (gray) */
GLint j;
for (j = 0; j < height; j++) {
bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
memset(ptr3, r, 3 * width);
}
}
else {
/* non-gray clear color */
GLint i, j;
for (j = 0; j < height; j++) {
bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
for (i = 0; i < width; i++) {
ptr3->r = r;
ptr3->g = g;
ptr3->b = b;
ptr3++;
}
}
}
}
static void
clear_32bit_ximage(struct gl_context *ctx, struct xmesa_renderbuffer *xrb,
GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint pixel = (GLuint) xmesa->clearpixel;
if (!xrb->ximage)
return;
if (xmesa->swapbytes) {
pixel = ((pixel >> 24) & 0x000000ff)
| ((pixel >> 8) & 0x0000ff00)
| ((pixel << 8) & 0x00ff0000)
| ((pixel << 24) & 0xff000000);
}
if (width == xrb->Base.Base.Width && height == xrb->Base.Base.Height) {
/* clearing whole buffer */
const GLuint n = xrb->Base.Base.Width * xrb->Base.Base.Height;
GLuint *ptr4 = (GLuint *) xrb->ximage->data;
if (pixel == 0) {
/* common case */
memset(ptr4, pixel, 4 * n);
}
else {
GLuint i;
for (i = 0; i < n; i++)
ptr4[i] = pixel;
}
}
else {
/* clearing scissored region */
GLint i, j;
for (j = 0; j < height; j++) {
GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y + j);
for (i = 0; i < width; i++) {
ptr4[i] = pixel;
}
}
}
}
static void
clear_nbit_ximage(struct gl_context *ctx, struct xmesa_renderbuffer *xrb,
GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaImage *img = xrb->ximage;
GLint i, j;
/* TODO: optimize this */
y = YFLIP(xrb, y);
for (j = 0; j < height; j++) {
for (i = 0; i < width; i++) {
XMesaPutPixel(img, x+i, y-j, xmesa->clearpixel);
}
}
}
static void
clear_buffers(struct gl_context *ctx, GLbitfield buffers)
{
if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
/* this is a window system framebuffer */
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaBuffer b = XMESA_BUFFER(ctx->DrawBuffer);
const GLint x = ctx->DrawBuffer->_Xmin;
const GLint y = ctx->DrawBuffer->_Ymin;
const GLint width = ctx->DrawBuffer->_Xmax - x;
const GLint height = ctx->DrawBuffer->_Ymax - y;
_mesa_unclamped_float_rgba_to_ubyte(xmesa->clearcolor,
ctx->Color.ClearColor.f);
xmesa->clearpixel = xmesa_color_to_pixel(ctx,
xmesa->clearcolor[0],
xmesa->clearcolor[1],
xmesa->clearcolor[2],
xmesa->clearcolor[3],
xmesa->xm_visual->undithered_pf);
XMesaSetForeground(xmesa->display, b->cleargc, xmesa->clearpixel);
/* we can't handle color or index masking */
if (GET_COLORMASK(ctx->Color.ColorMask, 0) == 0xf &&
ctx->Color.IndexMask == 0xffffffff) {
if (buffers & BUFFER_BIT_FRONT_LEFT) {
/* clear front color buffer */
struct gl_renderbuffer *frontRb
= ctx->DrawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
if (b->frontxrb == xmesa_renderbuffer(frontRb)) {
/* renderbuffer is not wrapped - great! */
b->frontxrb->clearFunc(ctx, b->frontxrb, x, y, width, height);
buffers &= ~BUFFER_BIT_FRONT_LEFT;
}
else {
/* we can't directly clear an alpha-wrapped color buffer */
}
}
if (buffers & BUFFER_BIT_BACK_LEFT) {
/* clear back color buffer */
struct gl_renderbuffer *backRb
= ctx->DrawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
if (b->backxrb == xmesa_renderbuffer(backRb)) {
/* renderbuffer is not wrapped - great! */
b->backxrb->clearFunc(ctx, b->backxrb, x, y, width, height);
buffers &= ~BUFFER_BIT_BACK_LEFT;
}
}
}
}
if (buffers)
_swrast_Clear(ctx, buffers);
}
/* XXX these functions haven't been tested in the Xserver environment */
/**
* Check if we can do an optimized glDrawPixels into an 8R8G8B visual.
*/
static GLboolean
can_do_DrawPixels_8R8G8B(struct gl_context *ctx, GLenum format, GLenum type)
{
if (format == GL_BGRA &&
type == GL_UNSIGNED_BYTE &&
ctx->DrawBuffer &&
_mesa_is_winsys_fbo(ctx->DrawBuffer) &&
ctx->Pixel.ZoomX == 1.0 && /* no zooming */
ctx->Pixel.ZoomY == 1.0 &&
ctx->_ImageTransferState == 0 /* no color tables, scale/bias, etc */) {
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (swrast->NewState)
_swrast_validate_derived( ctx );
if ((swrast->_RasterMask & ~CLIP_BIT) == 0) /* no blend, z-test, etc */ {
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
if (rb) {
struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb);
if (xrb &&
xrb->pixmap && /* drawing to pixmap or window */
_mesa_get_format_bits(xrb->Base.Base.Format, GL_ALPHA_BITS) == 0) {
return GL_TRUE;
}
}
}
}
return GL_FALSE;
}
/**
* This function implements glDrawPixels() with an XPutImage call when
* drawing to the front buffer (X Window drawable).
* The image format must be GL_BGRA to match the PF_8R8G8B pixel format.
*/
static void
xmesa_DrawPixels_8R8G8B( struct gl_context *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
if (can_do_DrawPixels_8R8G8B(ctx, format, type)) {
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
struct gl_pixelstore_attrib clippedUnpack = *unpack;
int dstX = x;
int dstY = y;
int w = width;
int h = height;
if (swrast->NewState)
_swrast_validate_derived( ctx );
if (unpack->BufferObj) {
/* unpack from PBO */
GLubyte *buf;
if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
format, type, INT_MAX, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawPixels(invalid PBO access)");
return;
}
buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
unpack->BufferObj->Size,
GL_MAP_READ_BIT,
unpack->BufferObj,
MAP_INTERNAL);
if (!buf) {
return; /* error */
}
pixels = ADD_POINTERS(buf, pixels);
}
if (_mesa_clip_drawpixels(ctx, &dstX, &dstY, &w, &h, &clippedUnpack)) {
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
const XMesaGC gc = xmbuf->cleargc; /* effected by glColorMask */
struct xmesa_renderbuffer *xrb
= xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
const int srcX = clippedUnpack.SkipPixels;
const int srcY = clippedUnpack.SkipRows;
const int rowLength = clippedUnpack.RowLength;
XMesaImage ximage;
assert(xmesa->xm_visual->dithered_pf == PF_8R8G8B);
assert(xmesa->xm_visual->undithered_pf == PF_8R8G8B);
assert(dpy);
assert(gc);
/* This is a little tricky since all coordinates up to now have
* been in the OpenGL bottom-to-top orientation. X is top-to-bottom
* so we have to carefully compute the Y coordinates/addresses here.
*/
memset(&ximage, 0, sizeof(XMesaImage));
ximage.width = width;
ximage.height = height;
ximage.format = ZPixmap;
ximage.data = (char *) pixels
+ ((srcY + h - 1) * rowLength + srcX) * 4;
ximage.byte_order = LSBFirst;
ximage.bitmap_unit = 32;
ximage.bitmap_bit_order = LSBFirst;
ximage.bitmap_pad = 32;
ximage.depth = 32;
ximage.bits_per_pixel = 32;
ximage.bytes_per_line = -rowLength * 4; /* negative to flip image */
/* it seems we don't need to set the ximage.red/green/blue_mask fields */
/* flip Y axis for dest position */
dstY = YFLIP(xrb, dstY) - h + 1;
XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
}
if (unpack->BufferObj) {
ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
}
}
else {
/* software fallback */
_swrast_DrawPixels(ctx, x, y, width, height,
format, type, unpack, pixels);
}
}
/**
* Check if we can do an optimized glDrawPixels into an 5R6G5B visual.
*/
static GLboolean
can_do_DrawPixels_5R6G5B(struct gl_context *ctx, GLenum format, GLenum type)
{
if (format == GL_RGB &&
type == GL_UNSIGNED_SHORT_5_6_5 &&
!ctx->Color.DitherFlag && /* no dithering */
ctx->DrawBuffer &&
_mesa_is_winsys_fbo(ctx->DrawBuffer) &&
ctx->Pixel.ZoomX == 1.0 && /* no zooming */
ctx->Pixel.ZoomY == 1.0 &&
ctx->_ImageTransferState == 0 /* no color tables, scale/bias, etc */) {
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (swrast->NewState)
_swrast_validate_derived( ctx );
if ((swrast->_RasterMask & ~CLIP_BIT) == 0) /* no blend, z-test, etc */ {
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
if (rb) {
struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb);
if (xrb &&
xrb->pixmap && /* drawing to pixmap or window */
_mesa_get_format_bits(xrb->Base.Base.Format, GL_ALPHA_BITS) == 0) {
return GL_TRUE;
}
}
}
}
return GL_FALSE;
}
/**
* This function implements glDrawPixels() with an XPutImage call when
* drawing to the front buffer (X Window drawable). The image format
* must be GL_RGB and image type must be GL_UNSIGNED_SHORT_5_6_5 to
* match the PF_5R6G5B pixel format.
*/
static void
xmesa_DrawPixels_5R6G5B( struct gl_context *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
if (can_do_DrawPixels_5R6G5B(ctx, format, type)) {
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
struct gl_pixelstore_attrib clippedUnpack = *unpack;
int dstX = x;
int dstY = y;
int w = width;
int h = height;
if (swrast->NewState)
_swrast_validate_derived( ctx );
if (unpack->BufferObj) {
/* unpack from PBO */
GLubyte *buf;
if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
format, type, INT_MAX, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawPixels(invalid PBO access)");
return;
}
buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
unpack->BufferObj->Size,
GL_MAP_READ_BIT,
unpack->BufferObj,
MAP_INTERNAL);
if (!buf) {
return; /* error */
}
pixels = ADD_POINTERS(buf, pixels);
}
if (_mesa_clip_drawpixels(ctx, &dstX, &dstY, &w, &h, &clippedUnpack)) {
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
const XMesaGC gc = xmbuf->cleargc; /* effected by glColorMask */
struct xmesa_renderbuffer *xrb
= xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
const int srcX = clippedUnpack.SkipPixels;
const int srcY = clippedUnpack.SkipRows;
const int rowLength = clippedUnpack.RowLength;
XMesaImage ximage;
assert(xmesa->xm_visual->undithered_pf == PF_5R6G5B);
assert(dpy);
assert(gc);
/* This is a little tricky since all coordinates up to now have
* been in the OpenGL bottom-to-top orientation. X is top-to-bottom
* so we have to carefully compute the Y coordinates/addresses here.
*/
memset(&ximage, 0, sizeof(XMesaImage));
ximage.width = width;
ximage.height = height;
ximage.format = ZPixmap;
ximage.data = (char *) pixels
+ ((srcY + h - 1) * rowLength + srcX) * 2;
ximage.byte_order = LSBFirst;
ximage.bitmap_unit = 16;
ximage.bitmap_bit_order = LSBFirst;
ximage.bitmap_pad = 16;
ximage.depth = 16;
ximage.bits_per_pixel = 16;
ximage.bytes_per_line = -rowLength * 2; /* negative to flip image */
/* it seems we don't need to set the ximage.red/green/blue_mask fields */
/* flip Y axis for dest position */
dstY = YFLIP(xrb, dstY) - h + 1;
XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
}
if (unpack->BufferObj) {
ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
}
}
else {
/* software fallback */
_swrast_DrawPixels(ctx, x, y, width, height,
format, type, unpack, pixels);
}
}
/**
* Determine if we can do an optimized glCopyPixels.
*/
static GLboolean
can_do_CopyPixels(struct gl_context *ctx, GLenum type)
{
if (type == GL_COLOR &&
ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
ctx->Pixel.ZoomX == 1.0 && /* no zooming */
ctx->Pixel.ZoomY == 1.0 &&
ctx->Color.DrawBuffer[0] == GL_FRONT && /* copy to front buf */
ctx->Pixel.ReadBuffer == GL_FRONT && /* copy from front buf */
ctx->ReadBuffer->_ColorReadBuffer &&
ctx->DrawBuffer->_ColorDrawBuffers[0]) {
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
if (swrast->NewState)
_swrast_validate_derived( ctx );
if ((swrast->_RasterMask & ~CLIP_BIT) == 0x0 &&
ctx->ReadBuffer &&
ctx->ReadBuffer->_ColorReadBuffer &&
ctx->DrawBuffer &&
ctx->DrawBuffer->_ColorDrawBuffers[0]) {
struct xmesa_renderbuffer *srcXrb
= xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
struct xmesa_renderbuffer *dstXrb
= xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
if (srcXrb->pixmap && dstXrb->pixmap) {
return GL_TRUE;
}
}
}
return GL_FALSE;
}
/**
* Implement glCopyPixels for the front color buffer (or back buffer Pixmap)
* for the color buffer. Don't support zooming, pixel transfer, etc.
* We do support copying from one window to another, ala glXMakeCurrentRead.
*/
static void
xmesa_CopyPixels( struct gl_context *ctx,
GLint srcx, GLint srcy, GLsizei width, GLsizei height,
GLint destx, GLint desty, GLenum type )
{
if (can_do_CopyPixels(ctx, type)) {
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
const XMesaGC gc = xmbuf->cleargc; /* effected by glColorMask */
struct xmesa_renderbuffer *srcXrb
= xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
struct xmesa_renderbuffer *dstXrb
= xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
assert(dpy);
assert(gc);
/* Note: we don't do any special clipping work here. We could,
* but X will do it for us.
*/
srcy = YFLIP(srcXrb, srcy) - height + 1;
desty = YFLIP(dstXrb, desty) - height + 1;
XCopyArea(dpy, srcXrb->pixmap, dstXrb->pixmap, gc,
srcx, srcy, width, height, destx, desty);
}
else {
_swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type );
}
}
/*
* Every driver should implement a GetString function in order to
* return a meaningful GL_RENDERER string.
*/
static const GLubyte *
get_string( struct gl_context *ctx, GLenum name )
{
(void) ctx;
switch (name) {
case GL_RENDERER:
return (const GLubyte *) "Mesa X11";
case GL_VENDOR:
return NULL;
default:
return NULL;
}
}
/*
* We implement the glEnable function only because we care about
* dither enable/disable.
*/
static void
enable( struct gl_context *ctx, GLenum pname, GLboolean state )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
switch (pname) {
case GL_DITHER:
if (state)
xmesa->pixelformat = xmesa->xm_visual->dithered_pf;
else
xmesa->pixelformat = xmesa->xm_visual->undithered_pf;
break;
default:
; /* silence compiler warning */
}
}
/**
* Called when the driver should update its state, based on the new_state
* flags.
*/
static void
xmesa_update_state(struct gl_context *ctx)
{
GLbitfield new_state = ctx->NewState;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
_mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
/* Propagate statechange information to swrast and swrast_setup
* modules. The X11 driver has no internal GL-dependent state.
*/
_swrast_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
if (_mesa_is_user_fbo(ctx->DrawBuffer))
return;
/*
* GL_DITHER, GL_READ/DRAW_BUFFER, buffer binding state, etc. effect
* renderbuffer span/clear funcs.
* Check _NEW_COLOR to detect dither enable/disable.
*/
if (new_state & (_NEW_COLOR | _NEW_BUFFERS)) {
XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
struct xmesa_renderbuffer *front_xrb, *back_xrb;
front_xrb = xmbuf->frontxrb;
if (front_xrb) {
front_xrb->clearFunc = clear_pixmap;
}
back_xrb = xmbuf->backxrb;
if (back_xrb) {
if (xmbuf->backxrb->pixmap) {
back_xrb->clearFunc = clear_pixmap;
}
else {
switch (xmesa->xm_visual->BitsPerPixel) {
case 16:
back_xrb->clearFunc = clear_16bit_ximage;
break;
case 24:
back_xrb->clearFunc = clear_24bit_ximage;
break;
case 32:
back_xrb->clearFunc = clear_32bit_ximage;
break;
default:
back_xrb->clearFunc = clear_nbit_ximage;
break;
}
}
}
}
}
/**
* Called by glViewport.
* This is a good time for us to poll the current X window size and adjust
* our renderbuffers to match the current window size.
* Remember, we have no opportunity to respond to conventional
* X Resize/StructureNotify events since the X driver has no event loop.
* Thus, we poll.
* Note that this trick isn't fool-proof. If the application never calls
* glViewport, our notion of the current window size may be incorrect.
* That problem led to the GLX_MESA_resize_buffers extension.
*/
static void
xmesa_viewport(struct gl_context *ctx)
{
XMesaContext xmctx = XMESA_CONTEXT(ctx);
XMesaBuffer xmdrawbuf = XMESA_BUFFER(ctx->WinSysDrawBuffer);
XMesaBuffer xmreadbuf = XMESA_BUFFER(ctx->WinSysReadBuffer);
xmesa_check_and_update_buffer_size(xmctx, xmdrawbuf);
xmesa_check_and_update_buffer_size(xmctx, xmreadbuf);
}
#if ENABLE_EXT_timer_query
/*
* The GL_EXT_timer_query extension is not enabled for the XServer
* indirect renderer. Not sure about how/if wrapping of gettimeofday()
* is done, etc.
*/
struct xmesa_query_object
{
struct gl_query_object Base;
struct timeval StartTime;
};
static struct gl_query_object *
xmesa_new_query_object(struct gl_context *ctx, GLuint id)
{
struct xmesa_query_object *q = CALLOC_STRUCT(xmesa_query_object);
if (q) {
q->Base.Id = id;
q->Base.Ready = GL_TRUE;
}
return &q->Base;
}
static void
xmesa_begin_query(struct gl_context *ctx, struct gl_query_object *q)
{
if (q->Target == GL_TIME_ELAPSED_EXT) {
struct xmesa_query_object *xq = (struct xmesa_query_object *) q;
(void) gettimeofday(&xq->StartTime, NULL);
}
}
/**
* Return the difference between the two given times in microseconds.
*/
static GLuint64EXT
time_diff(const struct timeval *t0, const struct timeval *t1)
{
GLuint64EXT seconds0 = t0->tv_sec & 0xff; /* 0 .. 255 seconds */
GLuint64EXT seconds1 = t1->tv_sec & 0xff; /* 0 .. 255 seconds */
GLuint64EXT nanosec0 = (seconds0 * 1000000 + t0->tv_usec) * 1000;
GLuint64EXT nanosec1 = (seconds1 * 1000000 + t1->tv_usec) * 1000;
return nanosec1 - nanosec0;
}
static void
xmesa_end_query(struct gl_context *ctx, struct gl_query_object *q)
{
if (q->Target == GL_TIME_ELAPSED_EXT) {
struct xmesa_query_object *xq = (struct xmesa_query_object *) q;
struct timeval endTime;
(void) gettimeofday(&endTime, NULL);
/* result is in nanoseconds! */
q->Result = time_diff(&xq->StartTime, &endTime);
}
q->Ready = GL_TRUE;
}
#endif /* ENABLE_timer_query */
/**
* Initialize the device driver function table with the functions
* we implement in this driver.
*/
void
xmesa_init_driver_functions( XMesaVisual xmvisual,
struct dd_function_table *driver )
{
driver->GetString = get_string;
driver->UpdateState = xmesa_update_state;
driver->Flush = flush;
driver->Finish = finish;
driver->ColorMask = color_mask;
driver->Enable = enable;
driver->Viewport = xmesa_viewport;
if (TEST_META_FUNCS) {
driver->Clear = _mesa_meta_Clear;
driver->CopyPixels = _mesa_meta_CopyPixels;
driver->BlitFramebuffer = _mesa_meta_and_swrast_BlitFramebuffer;
driver->DrawPixels = _mesa_meta_DrawPixels;
driver->Bitmap = _mesa_meta_Bitmap;
}
else {
driver->Clear = clear_buffers;
driver->CopyPixels = xmesa_CopyPixels;
if (xmvisual->undithered_pf == PF_8R8G8B &&
xmvisual->dithered_pf == PF_8R8G8B &&
xmvisual->BitsPerPixel == 32) {
driver->DrawPixels = xmesa_DrawPixels_8R8G8B;
}
else if (xmvisual->undithered_pf == PF_5R6G5B) {
driver->DrawPixels = xmesa_DrawPixels_5R6G5B;
}
}
driver->MapRenderbuffer = xmesa_MapRenderbuffer;
driver->UnmapRenderbuffer = xmesa_UnmapRenderbuffer;
driver->GenerateMipmap = _mesa_generate_mipmap;
#if ENABLE_EXT_timer_query
driver->NewQueryObject = xmesa_new_query_object;
driver->BeginQuery = xmesa_begin_query;
driver->EndQuery = xmesa_end_query;
#endif
}
#define XMESA_NEW_POINT (_NEW_POINT | \
_NEW_RENDERMODE | \
_SWRAST_NEW_RASTERMASK)
#define XMESA_NEW_LINE (_NEW_LINE | \
_NEW_TEXTURE | \
_NEW_LIGHT | \
_NEW_DEPTH | \
_NEW_RENDERMODE | \
_SWRAST_NEW_RASTERMASK)
#define XMESA_NEW_TRIANGLE (_NEW_POLYGON | \
_NEW_TEXTURE | \
_NEW_LIGHT | \
_NEW_DEPTH | \
_NEW_RENDERMODE | \
_SWRAST_NEW_RASTERMASK)
/**
* Extend the software rasterizer with our line/point/triangle
* functions.
* Called during context creation only.
*/
void xmesa_register_swrast_functions( struct gl_context *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT( ctx );
swrast->choose_point = xmesa_choose_point;
swrast->choose_line = xmesa_choose_line;
swrast->choose_triangle = xmesa_choose_triangle;
/* XXX these lines have no net effect. Remove??? */
swrast->InvalidatePointMask |= XMESA_NEW_POINT;
swrast->InvalidateLineMask |= XMESA_NEW_LINE;
swrast->InvalidateTriangleMask |= XMESA_NEW_TRIANGLE;
}

View File

@ -1,540 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/*
* This file contains "accelerated" point, line, and triangle functions.
* It should be fairly easy to write new special-purpose point, line or
* triangle functions and hook them into this module.
*/
#include "glxheader.h"
#include "main/macros.h"
#include "main/mtypes.h"
#include "xmesaP.h"
/* Internal swrast includes:
*/
#include "swrast/s_depth.h"
#include "swrast/s_points.h"
#include "swrast/s_lines.h"
#include "swrast/s_context.h"
/**********************************************************************/
/*** Point rendering ***/
/**********************************************************************/
/*
* Render an array of points into a pixmap, any pixel format.
*/
#if 000
/* XXX don't use this, it doesn't dither correctly */
static void draw_points_ANY_pixmap( struct gl_context *ctx, const SWvertex *vert )
{
XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
if (xmesa->xm_visual->mesa_visual.RGBAflag) {
register int x, y;
const GLubyte *color = vert->color;
unsigned long pixel = xmesa_color_to_pixel( xmesa,
color[0], color[1],
color[2], color[3],
xmesa->pixelformat);
XMesaSetForeground( dpy, gc, pixel );
x = (GLint) vert->win[0];
y = YFLIP( xrb, (GLint) vert->win[1] );
XMesaDrawPoint( dpy, buffer, gc, x, y);
}
else {
/* Color index mode */
register int x, y;
XMesaSetForeground( dpy, gc, vert->index );
x = (GLint) vert->win[0];
y = YFLIP( xrb, (GLint) vert->win[1] );
XMesaDrawPoint( dpy, buffer, gc, x, y);
}
}
#endif
/* Override the swrast point-selection function. Try to use one of
* our internal point functions, otherwise fall back to the standard
* swrast functions.
*/
void xmesa_choose_point( struct gl_context *ctx )
{
#if 0
XMesaContext xmesa = XMESA_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (ctx->RenderMode == GL_RENDER
&& ctx->Point.Size == 1.0F && !ctx->Point.SmoothFlag
&& swrast->_RasterMask == 0
&& ctx->Texture._MaxEnabledTexImageUnit == -1
&& xmesa->xm_buffer->buffer != XIMAGE) {
swrast->Point = draw_points_ANY_pixmap;
}
else {
_swrast_choose_point( ctx );
}
#else
_swrast_choose_point( ctx );
#endif
}
/**********************************************************************/
/*** Line rendering ***/
/**********************************************************************/
#if CHAN_BITS == 8
#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0])
/*
* Draw a flat-shaded, PF_TRUECOLOR line into an XImage.
*/
#define NAME flat_TRUECOLOR_line
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
unsigned long pixel; \
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
#define CLIP_HACK 1
#define PLOT(X,Y) XMesaPutPixel(xrb->ximage, X, YFLIP(xrb, Y), pixel );
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, PF_8A8B8G8R line into an XImage.
*/
#define NAME flat_8A8B8G8R_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8A8B8G8R(color[0], color[1], color[2], color[3]);
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, PF_8A8R8G8B line into an XImage.
*/
#define NAME flat_8A8R8G8B_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8A8R8G8B(color[0], color[1], color[2], color[3]);
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, PF_8R8G8B line into an XImage.
*/
#define NAME flat_8R8G8B_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, PF_8R8G8B24 line into an XImage.
*/
#define NAME flat_8R8G8B24_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color;
#define PIXEL_TYPE bgr_t
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) { \
pixelPtr->r = color[RCOMP]; \
pixelPtr->g = color[GCOMP]; \
pixelPtr->b = color[BCOMP]; \
}
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, PF_5R6G5B line into an XImage.
*/
#define NAME flat_5R6G5B_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, PF_DITHER_5R6G5B line into an XImage.
*/
#define NAME flat_DITHER_5R6G5B_line
#define SETUP_CODE \
GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color;
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, Z-less, PF_TRUECOLOR line into an XImage.
*/
#define NAME flat_TRUECOLOR_z_line
#define SETUP_CODE \
GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color; \
unsigned long pixel; \
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
*zPtr = Z; \
XMesaPutPixel(xrb->ximage, X, YFLIP(xrb, Y), pixel); \
}
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, Z-less, PF_8A8B8G8R line into an XImage.
*/
#define NAME flat_8A8B8G8R_z_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8A8B8G8R(color[0], color[1], color[2], color[3]);
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
*zPtr = Z; \
*pixelPtr = pixel; \
}
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, Z-less, PF_8A8R8G8B line into an XImage.
*/
#define NAME flat_8A8R8G8B_z_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8A8R8G8B(color[0], color[1], color[2], color[3]);
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
*zPtr = Z; \
*pixelPtr = pixel; \
}
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, Z-less, PF_8R8G8B line into an XImage.
*/
#define NAME flat_8R8G8B_z_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
*zPtr = Z; \
*pixelPtr = pixel; \
}
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, Z-less, PF_8R8G8B24 line into an XImage.
*/
#define NAME flat_8R8G8B24_z_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE bgr_t
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
*zPtr = Z; \
pixelPtr->r = color[RCOMP]; \
pixelPtr->g = color[GCOMP]; \
pixelPtr->b = color[BCOMP]; \
}
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, Z-less, PF_5R6G5B line into an XImage.
*/
#define NAME flat_5R6G5B_z_line
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
*zPtr = Z; \
*pixelPtr = pixel; \
}
#include "swrast/s_linetemp.h"
/*
* Draw a flat-shaded, Z-less, PF_DITHER_5R6G5B line into an XImage.
*/
#define NAME flat_DITHER_5R6G5B_z_line
#define SETUP_CODE \
GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
*zPtr = Z; \
PACK_TRUEDITHER(*pixelPtr, X, Y, color[0], color[1], color[2]); \
}
#include "swrast/s_linetemp.h"
/**
* Draw fast, XOR line with XDrawLine in front color buffer.
* WARNING: this isn't fully OpenGL conformant because different pixels
* will be hit versus using the other line functions.
* Don't use the code in X server GLcore module since we need a wrapper
* for the XSetLineAttributes() function call.
*/
static void
xor_line(struct gl_context *ctx, const SWvertex *vert0, const SWvertex *vert1)
{
XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaGC gc = xmesa->xm_buffer->gc;
GET_XRB(xrb);
unsigned long pixel = xmesa_color_to_pixel(ctx,
vert1->color[0], vert1->color[1],
vert1->color[2], vert1->color[3],
xmesa->pixelformat);
int x0 = (GLint) vert0->attrib[VARYING_SLOT_POS][0];
int y0 = YFLIP(xrb, (GLint) vert0->attrib[VARYING_SLOT_POS][1]);
int x1 = (GLint) vert1->attrib[VARYING_SLOT_POS][0];
int y1 = YFLIP(xrb, (GLint) vert1->attrib[VARYING_SLOT_POS][1]);
XMesaSetForeground(dpy, gc, pixel);
XMesaSetFunction(dpy, gc, GXxor);
XSetLineAttributes(dpy, gc, (int) ctx->Line.Width,
LineSolid, CapButt, JoinMiter);
XDrawLine(dpy, xrb->pixmap, gc, x0, y0, x1, y1);
XMesaSetFunction(dpy, gc, GXcopy); /* this gc is used elsewhere */
}
#endif /* CHAN_BITS == 8 */
/**
* Return pointer to line drawing function, or NULL if we should use a
* swrast fallback.
*/
static swrast_line_func
get_line_func(struct gl_context *ctx)
{
#if CHAN_BITS == 8
SWcontext *swrast = SWRAST_CONTEXT(ctx);
XMesaContext xmesa = XMESA_CONTEXT(ctx);
const struct xmesa_renderbuffer *xrb;
if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) &&
(ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT))
return (swrast_line_func) NULL;
if (ctx->RenderMode != GL_RENDER) return (swrast_line_func) NULL;
if (ctx->Line.SmoothFlag) return (swrast_line_func) NULL;
if (ctx->Texture._MaxEnabledTexImageUnit != -1) return (swrast_line_func) NULL;
if (ctx->Light.ShadeModel != GL_FLAT) return (swrast_line_func) NULL;
if (ctx->Line.StippleFlag) return (swrast_line_func) NULL;
if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
if (xrb->ximage
&& swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
&& ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& ctx->Line.Width==1.0F) {
switch (xmesa->pixelformat) {
case PF_Truecolor:
return flat_TRUECOLOR_z_line;
case PF_8A8B8G8R:
return flat_8A8B8G8R_z_line;
case PF_8A8R8G8B:
return flat_8A8R8G8B_z_line;
case PF_8R8G8B:
return flat_8R8G8B_z_line;
case PF_8R8G8B24:
return flat_8R8G8B24_z_line;
case PF_5R6G5B:
return flat_5R6G5B_z_line;
case PF_Dither_5R6G5B:
return flat_DITHER_5R6G5B_z_line;
default:
return (swrast_line_func)NULL;
}
}
if (xrb->ximage
&& swrast->_RasterMask==0
&& ctx->Line.Width==1.0F) {
switch (xmesa->pixelformat) {
case PF_Truecolor:
return flat_TRUECOLOR_line;
case PF_8A8B8G8R:
return flat_8A8B8G8R_line;
case PF_8A8R8G8B:
return flat_8A8R8G8B_line;
case PF_8R8G8B:
return flat_8R8G8B_line;
case PF_8R8G8B24:
return flat_8R8G8B24_line;
case PF_5R6G5B:
return flat_5R6G5B_line;
case PF_Dither_5R6G5B:
return flat_DITHER_5R6G5B_line;
default:
return (swrast_line_func)NULL;
}
}
if (ctx->DrawBuffer->_NumColorDrawBuffers == 1
&& ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT
&& swrast->_RasterMask == LOGIC_OP_BIT
&& ctx->Color.LogicOp == GL_XOR
&& !ctx->Line.StippleFlag
&& !ctx->Line.SmoothFlag) {
return xor_line;
}
#endif /* CHAN_BITS == 8 */
return (swrast_line_func) NULL;
}
/**
* Override for the swrast line-selection function. Try to use one
* of our internal line functions, otherwise fall back to the
* standard swrast functions.
*/
void
xmesa_choose_line(struct gl_context *ctx)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (!(swrast->Line = get_line_func( ctx )))
_swrast_choose_line( ctx );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,381 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/*
* Mesa/X11 interface. This header file serves as the documentation for
* the Mesa/X11 interface functions.
*
* Note: this interface isn't intended for user programs. It's primarily
* just for implementing the pseudo-GLX interface.
*/
/* Sample Usage:
In addition to the usual X calls to select a visual, create a colormap
and create a window, you must do the following to use the X/Mesa interface:
1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
the XMesaVisual.
3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
and XMesaVisual.
4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
to make the context the current one.
5. Make gl* calls to render your graphics.
6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
7. Before the X window is destroyed, call XMesaDestroyBuffer().
8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
*/
#ifndef XMESA_H
#define XMESA_H
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "xmesa_x.h"
#include "GL/gl.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XMESA_MAJOR_VERSION 6
#define XMESA_MINOR_VERSION 3
/*
* Values passed to XMesaGetString:
*/
#define XMESA_VERSION 1
#define XMESA_EXTENSIONS 2
typedef struct xmesa_context *XMesaContext;
typedef struct xmesa_visual *XMesaVisual;
typedef struct xmesa_buffer *XMesaBuffer;
/*
* Create a new X/Mesa visual.
* Input: display - X11 display
* visinfo - an XVisualInfo pointer
* rgb_flag - GL_TRUE = RGB mode,
* GL_FALSE = color index mode
* alpha_flag - alpha buffer requested?
* db_flag - GL_TRUE = double-buffered,
* GL_FALSE = single buffered
* stereo_flag - stereo visual?
* ximage_flag - GL_TRUE = use an XImage for back buffer,
* GL_FALSE = use an off-screen pixmap for back buffer
* depth_size - requested bits/depth values, or zero
* stencil_size - requested bits/stencil values, or zero
* accum_red_size - requested bits/red accum values, or zero
* accum_green_size - requested bits/green accum values, or zero
* accum_blue_size - requested bits/blue accum values, or zero
* accum_alpha_size - requested bits/alpha accum values, or zero
* num_samples - number of samples/pixel if multisampling, or zero
* level - visual level, usually 0
* visualCaveat - ala the GLX extension, usually GLX_NONE_EXT
* Return; a new XMesaVisual or 0 if error.
*/
extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
XMesaVisualInfo visinfo,
GLboolean rgb_flag,
GLboolean alpha_flag,
GLboolean db_flag,
GLboolean stereo_flag,
GLboolean ximage_flag,
GLint depth_size,
GLint stencil_size,
GLint accum_red_size,
GLint accum_green_size,
GLint accum_blue_size,
GLint accum_alpha_size,
GLint num_samples,
GLint level,
GLint visualCaveat );
/*
* Destroy an XMesaVisual, but not the associated XVisualInfo.
*/
extern void XMesaDestroyVisual( XMesaVisual v );
/*
* Create a new XMesaContext for rendering into an X11 window.
*
* Input: visual - an XMesaVisual
* share_list - another XMesaContext with which to share display
* lists or NULL if no sharing is wanted.
* Return: an XMesaContext or NULL if error.
*/
extern XMesaContext XMesaCreateContext( XMesaVisual v,
XMesaContext share_list );
/*
* Destroy a rendering context as returned by XMesaCreateContext()
*/
extern void XMesaDestroyContext( XMesaContext c );
/*
* Create an XMesaBuffer from an X window.
*/
extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w );
/*
* Create an XMesaBuffer from an X pixmap.
*/
extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
XMesaPixmap p,
XMesaColormap cmap );
/*
* Destroy an XMesaBuffer, but not the corresponding window or pixmap.
*/
extern void XMesaDestroyBuffer( XMesaBuffer b );
/*
* Return the XMesaBuffer handle which corresponds to an X drawable, if any.
*
* New in Mesa 2.3.
*/
extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
XMesaDrawable d );
/*
* Bind a buffer to a context and make the context the current one.
*/
extern GLboolean XMesaMakeCurrent( XMesaContext c,
XMesaBuffer b );
/*
* Bind two buffers (read and draw) to a context and make the
* context the current one.
* New in Mesa 3.3
*/
extern GLboolean XMesaMakeCurrent2( XMesaContext c,
XMesaBuffer drawBuffer,
XMesaBuffer readBuffer );
/*
* Unbind the current context from its buffer.
*/
extern GLboolean XMesaUnbindContext( XMesaContext c );
/*
* Return a handle to the current context.
*/
extern XMesaContext XMesaGetCurrentContext( void );
/*
* Return handle to the current (draw) buffer.
*/
extern XMesaBuffer XMesaGetCurrentBuffer( void );
/*
* Return handle to the current read buffer.
* New in Mesa 3.3
*/
extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
/*
* Return display of current context.
*/
extern Display *XMesaGetCurrentDisplay( void );
/*
* Swap the front and back buffers for the given buffer. No action is
* taken if the buffer is not double buffered.
*/
extern void XMesaSwapBuffers( XMesaBuffer b );
/*
* Copy a sub-region of the back buffer to the front buffer.
*
* New in Mesa 2.6
*/
extern void XMesaCopySubBuffer( XMesaBuffer b,
int x,
int y,
int width,
int height );
/*
* Return a pointer to the Pixmap or XImage being used as the back
* color buffer of an XMesaBuffer. This function is a way to get "under
* the hood" of X/Mesa so one can manipulate the back buffer directly.
* Input: b - the XMesaBuffer
* Output: pixmap - pointer to back buffer's Pixmap, or 0
* ximage - pointer to back buffer's XImage, or NULL
* Return: GL_TRUE = context is double buffered
* GL_FALSE = context is single buffered
*/
extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
XMesaPixmap *pixmap,
XMesaImage **ximage );
/*
* Return the depth buffer associated with an XMesaBuffer.
* Input: b - the XMesa buffer handle
* Output: width, height - size of buffer in pixels
* bytesPerValue - bytes per depth value (2 or 4)
* buffer - pointer to depth buffer values
* Return: GL_TRUE or GL_FALSE to indicate success or failure.
*
* New in Mesa 2.4.
*/
extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
GLint *width,
GLint *height,
GLint *bytesPerValue,
void **buffer );
/*
* Flush/sync a context
*/
extern void XMesaFlush( XMesaContext c );
/*
* Get an X/Mesa-specific string.
* Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
*/
extern const char *XMesaGetString( XMesaContext c, int name );
/*
* Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
* any memory used by that buffer.
*
* New in Mesa 2.3.
*/
extern void XMesaGarbageCollect( XMesaDisplay* dpy );
/*
* Return a dithered pixel value.
* Input: c - XMesaContext
* x, y - window coordinate
* red, green, blue, alpha - color components in [0,1]
* Return: pixel value
*
* New in Mesa 2.3.
*/
extern unsigned long XMesaDitherColor( XMesaContext xmesa,
GLint x,
GLint y,
GLfloat red,
GLfloat green,
GLfloat blue,
GLfloat alpha );
/*
* Reallocate the back/depth/stencil/accum/etc/ buffers associated with
* buffer <b> if its size has changed.
*
* New in Mesa 4.0.2
*/
extern void XMesaResizeBuffers( XMesaBuffer b );
/*
* Create a pbuffer.
* New in Mesa 4.1
*/
extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
unsigned int width, unsigned int height);
/*
* Texture from Pixmap
* New in Mesa 7.1
*/
extern void
XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer,
const int *attrib_list);
extern void
XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer);
extern XMesaBuffer
XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
XMesaColormap cmap,
int format, int target, int mipmap);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,425 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
#ifndef XMESAP_H
#define XMESAP_H
#include "c11/threads.h"
#include "xmesa.h"
#include "main/mtypes.h"
#include "swrast/s_context.h"
extern mtx_t _xmesa_lock;
extern XMesaBuffer XMesaBufferList;
/* for PF_8R8G8B24 pixel format */
typedef struct {
GLubyte b;
GLubyte g;
GLubyte r;
} bgr_t;
struct xmesa_renderbuffer;
/* Function pointer for clearing color buffers */
typedef void (*ClearFunc)( struct gl_context *ctx, struct xmesa_renderbuffer *xrb,
GLint x, GLint y, GLint width, GLint height );
/** Framebuffer pixel formats */
enum pixel_format {
PF_Truecolor, /**< TrueColor or DirectColor, any depth */
PF_Dither_True, /**< TrueColor with dithering */
PF_8A8R8G8B, /**< 32-bit TrueColor: 8-A, 8-R, 8-G, 8-B bits */
PF_8A8B8G8R, /**< 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R bits */
PF_8R8G8B, /**< 32-bit TrueColor: 8-R, 8-G, 8-B bits */
PF_8R8G8B24, /**< 24-bit TrueColor: 8-R, 8-G, 8-B bits */
PF_5R6G5B, /**< 16-bit TrueColor: 5-R, 6-G, 5-B bits */
PF_Dither_5R6G5B /**< 16-bit dithered TrueColor: 5-R, 6-G, 5-B */
};
/**
* Visual inforation, derived from struct gl_config.
* Basically corresponds to an XVisualInfo.
*/
struct xmesa_visual {
struct gl_config mesa_visual; /* Device independent visual parameters */
XMesaDisplay *display; /* The X11 display */
int screen, visualID;
int visualType;
XMesaVisualInfo visinfo; /* X's visual info (pointer to private copy) */
GLint BitsPerPixel; /* True bits per pixel for XImages */
GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */
enum pixel_format dithered_pf; /* Pixel format when dithering */
enum pixel_format undithered_pf;/* Pixel format when not dithering */
GLfloat RedGamma; /* Gamma values, 1.0 is default */
GLfloat GreenGamma;
GLfloat BlueGamma;
/* For PF_TRUECOLOR */
GLint rshift, gshift, bshift;/* Pixel color component shifts */
GLubyte Kernel[16]; /* Dither kernel */
unsigned long RtoPixel[512]; /* RGB to pixel conversion */
unsigned long GtoPixel[512];
unsigned long BtoPixel[512];
GLubyte PixelToR[256]; /* Pixel to RGB conversion */
GLubyte PixelToG[256];
GLubyte PixelToB[256];
};
/**
* Context info, derived from struct gl_context.
* Basically corresponds to a GLXContext.
*/
struct xmesa_context {
struct gl_context mesa; /* the core library context (containment) */
XMesaVisual xm_visual; /* Describes the buffers */
XMesaBuffer xm_buffer; /* current span/point/line/triangle buffer */
XMesaDisplay *display; /* == xm_visual->display */
GLboolean swapbytes; /* Host byte order != display byte order? */
GLboolean direct; /* Direct rendering context? */
enum pixel_format pixelformat;
GLubyte clearcolor[4]; /* current clearing color */
unsigned long clearpixel; /* current clearing pixel value */
};
/**
* Types of X/GLX drawables we might render into.
*/
typedef enum {
WINDOW, /* An X window */
GLXWINDOW, /* GLX window */
PIXMAP, /* GLX pixmap */
PBUFFER /* GLX Pbuffer */
} BufferType;
/** Values for db_mode: */
/*@{*/
#define BACK_PIXMAP 1
#define BACK_XIMAGE 2
/*@}*/
/**
* An xmesa_renderbuffer represents the back or front color buffer.
* For the front color buffer:
* <drawable> is the X window
* For the back color buffer:
* Either <ximage> or <pixmap> will be used, never both.
* In any case, <drawable> always equals <pixmap>.
* For stand-alone Mesa, we could merge <drawable> and <pixmap> into one
* field. We don't do that for the server-side GLcore module because
* pixmaps and drawables are different and we'd need a bunch of casts.
*/
struct xmesa_renderbuffer
{
struct swrast_renderbuffer Base; /* Base class */
XMesaBuffer Parent; /**< The XMesaBuffer this renderbuffer belongs to */
XMesaDrawable drawable; /* Usually the X window ID */
XMesaPixmap pixmap; /* Back color buffer */
XMesaImage *ximage; /* The back buffer, if not using a Pixmap */
GLushort *origin2; /* used for PIXEL_ADDR2 macro */
GLint width2;
GLubyte *origin3; /* used for PIXEL_ADDR3 macro */
GLint width3;
GLuint *origin4; /* used for PIXEL_ADDR4 macro */
GLint width4;
GLint bottom; /* used for FLIP macro, equals height - 1 */
ClearFunc clearFunc;
GLuint map_x, map_y, map_w, map_h;
GLbitfield map_mode;
XMesaImage *map_ximage;
};
/**
* Framebuffer information, derived from.
* Basically corresponds to a GLXDrawable.
*/
struct xmesa_buffer {
struct gl_framebuffer mesa_buffer; /* depth, stencil, accum, etc buffers */
/* This MUST BE FIRST! */
GLboolean wasCurrent; /* was ever the current buffer? */
XMesaVisual xm_visual; /* the X/Mesa visual */
XMesaDisplay *display;
BufferType type; /* window, pixmap, pbuffer or glxwindow */
GLboolean largestPbuffer; /**< for pbuffers */
GLboolean preservedContents; /**< for pbuffers */
struct xmesa_renderbuffer *frontxrb; /* front color renderbuffer */
struct xmesa_renderbuffer *backxrb; /* back color renderbuffer */
XMesaColormap cmap; /* the X colormap */
unsigned long selectedEvents;/* for pbuffers only */
GLint db_mode; /* 0 = single buffered */
/* BACK_PIXMAP = use Pixmap for back buffer */
/* BACK_XIMAGE = use XImage for back buffer */
GLuint shm; /* X Shared Memory extension status: */
/* 0 = not available */
/* 1 = XImage support available */
/* 2 = Pixmap support available too */
#if defined(USE_XSHM)
XShmSegmentInfo shminfo;
#endif
// XMesaImage *rowimage; /* Used for optimized span writing */
XMesaPixmap stipple_pixmap; /* For polygon stippling */
XMesaGC stipple_gc; /* For polygon stippling */
XMesaGC gc; /* scratch GC for span, line, tri drawing */
XMesaGC cleargc; /* GC for clearing the color buffer */
XMesaGC swapgc; /* GC for swapping the color buffers */
/* The following are here instead of in the XMesaVisual
* because they depend on the window's colormap.
*/
/* For PF_DITHER, PF_LOOKUP, PF_GRAYSCALE */
unsigned long color_table[576]; /* RGB -> pixel value */
/* For PF_DITHER, PF_LOOKUP, PF_GRAYSCALE */
GLubyte pixel_to_r[65536]; /* pixel value -> red */
GLubyte pixel_to_g[65536]; /* pixel value -> green */
GLubyte pixel_to_b[65536]; /* pixel value -> blue */
/* Used to do XAllocColor/XFreeColors accounting: */
int num_alloced;
unsigned long alloced_colors[256];
/* GLX_EXT_texture_from_pixmap */
GLint TextureTarget; /** GLX_TEXTURE_1D_EXT, for example */
GLint TextureFormat; /** GLX_TEXTURE_FORMAT_RGB_EXT, for example */
GLint TextureMipmap; /** 0 or 1 */
struct xmesa_buffer *Next; /* Linked list pointer: */
};
/**
* If pixelformat==PF_TRUECOLOR:
*/
#define PACK_TRUECOLOR( PIXEL, R, G, B ) \
PIXEL = xmesa->xm_visual->RtoPixel[R] \
| xmesa->xm_visual->GtoPixel[G] \
| xmesa->xm_visual->BtoPixel[B];
/**
* If pixelformat==PF_TRUEDITHER:
*/
#define PACK_TRUEDITHER( PIXEL, X, Y, R, G, B ) \
{ \
int d = xmesa->xm_visual->Kernel[((X)&3) | (((Y)&3)<<2)]; \
PIXEL = xmesa->xm_visual->RtoPixel[(R)+d] \
| xmesa->xm_visual->GtoPixel[(G)+d] \
| xmesa->xm_visual->BtoPixel[(B)+d]; \
}
/**
* If pixelformat==PF_8A8B8G8R:
*/
#define PACK_8A8B8G8R( R, G, B, A ) \
( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
/**
* Like PACK_8A8B8G8R() but don't use alpha. This is usually an acceptable
* shortcut.
*/
#define PACK_8B8G8R( R, G, B ) ( ((B) << 16) | ((G) << 8) | (R) )
/**
* If pixelformat==PF_8R8G8B:
*/
#define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) )
/**
* If pixelformat==PF_5R6G5B:
*/
#define PACK_5R6G5B( R, G, B) ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
/**
* If pixelformat==PF_8A8R8G8B:
*/
#define PACK_8A8R8G8B( R, G, B, A ) \
( ((A) << 24) | ((R) << 16) | ((G) << 8) | (B) )
/**
* Converts a GL window Y coord to an X window Y coord:
*/
#define YFLIP(XRB, Y) ((XRB)->bottom - (Y))
/**
* Return the address of a 2, 3 or 4-byte pixel in the buffer's XImage:
* X==0 is left, Y==0 is bottom.
*/
#define PIXEL_ADDR2(XRB, X, Y) \
( (XRB)->origin2 - (Y) * (XRB)->width2 + (X) )
#define PIXEL_ADDR3(XRB, X, Y) \
( (bgr_t *) ( (XRB)->origin3 - (Y) * (XRB)->width3 + 3 * (X) ))
#define PIXEL_ADDR4(XRB, X, Y) \
( (XRB)->origin4 - (Y) * (XRB)->width4 + (X) )
/*
* External functions:
*/
extern struct xmesa_renderbuffer *
xmesa_new_renderbuffer(struct gl_context *ctx, GLuint name,
const struct xmesa_visual *xmvis,
GLboolean backBuffer);
extern void
xmesa_delete_framebuffer(struct gl_framebuffer *fb);
extern XMesaBuffer
xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis);
extern unsigned long
xmesa_color_to_pixel( struct gl_context *ctx,
GLubyte r, GLubyte g, GLubyte b, GLubyte a,
GLuint pixelFormat );
extern void
xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
GLuint *width, GLuint *height);
extern void
xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer);
extern void
xmesa_init_driver_functions( XMesaVisual xmvisual,
struct dd_function_table *driver );
extern void
xmesa_MapRenderbuffer(struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLuint x, GLuint y, GLuint w, GLuint h,
GLbitfield mode,
GLubyte **mapOut, GLint *rowStrideOut,
bool flip_y);
extern void
xmesa_UnmapRenderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb);
extern void
xmesa_destroy_buffers_on_display(XMesaDisplay *dpy);
/**
* Using a function instead of an ordinary cast is safer.
*/
static inline struct xmesa_renderbuffer *
xmesa_renderbuffer(struct gl_renderbuffer *rb)
{
return (struct xmesa_renderbuffer *) rb;
}
/**
* Return pointer to XMesaContext corresponding to a Mesa struct gl_context.
* Since we're using structure containment, it's just a cast!.
*/
static inline XMesaContext
XMESA_CONTEXT(struct gl_context *ctx)
{
return (XMesaContext) ctx;
}
/**
* Return pointer to XMesaBuffer corresponding to a Mesa struct gl_framebuffer.
* Since we're using structure containment, it's just a cast!.
*/
static inline XMesaBuffer
XMESA_BUFFER(struct gl_framebuffer *b)
{
return (XMesaBuffer) b;
}
/* Plugged into the software rasterizer. Try to use internal
* swrast-style point, line and triangle functions.
*/
extern void xmesa_choose_point( struct gl_context *ctx );
extern void xmesa_choose_line( struct gl_context *ctx );
extern void xmesa_choose_triangle( struct gl_context *ctx );
extern void xmesa_register_swrast_functions( struct gl_context *ctx );
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define ENABLE_EXT_timer_query 1 /* should have 64-bit GLuint64EXT */
#else
#define ENABLE_EXT_timer_query 0 /* may not have 64-bit GLuint64EXT */
#endif
#define TEST_META_FUNCS 0
#endif

View File

@ -1,85 +0,0 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sub license, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) 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 NON-INFRINGEMENT.
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
**************************************************************************/
/*
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
*
* When we're building the XMesa driver for stand-alone Mesa we
* include this file when building the xm_*.c files.
* We need to define some types and macros differently when building
* in the Xserver vs. stand-alone Mesa.
*/
#ifndef _XMESA_X_H_
#define _XMESA_X_H_
typedef Display XMesaDisplay;
typedef Pixmap XMesaPixmap;
typedef Colormap XMesaColormap;
typedef Drawable XMesaDrawable;
typedef Window XMesaWindow;
typedef GC XMesaGC;
typedef XVisualInfo *XMesaVisualInfo;
typedef XImage XMesaImage;
typedef XPoint XMesaPoint;
typedef XColor XMesaColor;
#define XMesaDestroyImage XDestroyImage
#define XMesaPutPixel XPutPixel
#define XMesaGetPixel XGetPixel
#define XMesaSetForeground XSetForeground
#define XMesaSetBackground XSetBackground
#define XMesaSetPlaneMask XSetPlaneMask
#define XMesaSetFunction XSetFunction
#define XMesaSetFillStyle XSetFillStyle
#define XMesaSetTile XSetTile
#define XMesaDrawPoint XDrawPoint
#define XMesaDrawPoints XDrawPoints
#define XMesaDrawLine XDrawLine
#define XMesaFillRectangle XFillRectangle
#define XMesaGetImage XGetImage
#define XMesaPutImage XPutImage
#define XMesaCopyArea XCopyArea
#define XMesaCreatePixmap XCreatePixmap
#define XMesaFreePixmap XFreePixmap
#define XMesaFreeGC XFreeGC
#define GET_COLORMAP_SIZE(__v) __v->visinfo->colormap_size
#define GET_REDMASK(__v) __v->mesa_visual.redMask
#define GET_GREENMASK(__v) __v->mesa_visual.greenMask
#define GET_BLUEMASK(__v) __v->mesa_visual.blueMask
#define GET_VISUAL_DEPTH(__v) __v->visinfo->depth
#define GET_BLACK_PIXEL(__v) BlackPixel(__v->display, __v->screen)
#define CHECK_BYTE_ORDER(__v) host_byte_order()==ImageByteOrder(__v->display)
#endif

View File

@ -758,9 +758,6 @@ libmesa_gallium = static_library(
)
subdir('drivers/dri')
if with_glx == 'xlib'
subdir('drivers/x11')
endif
if with_tests
subdir('main/tests')
endif