Copy of xlib driver. This will get trimmed down a lot for Gallium.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.3
|
||||
*
|
||||
* 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
|
||||
* BRIAN PAUL 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 {
|
||||
Display *currentDpy;
|
||||
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);
|
||||
int (*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_SGIX_swap_group ***/
|
||||
void (*JoinSwapGroupSGIX)(Display *, GLXDrawable, GLXDrawable);
|
||||
|
||||
/*** GLX_SGIX_swap_barrier ***/
|
||||
void (*BindSwapBarrierSGIX)(Display *, GLXDrawable, int);
|
||||
Bool (*QueryMaxSwapBarriersSGIX)(Display *, int, int *);
|
||||
|
||||
/*** GLX_SUN_get_transparent_index ***/
|
||||
Status (*GetTransparentIndexSUN)(Display *, Window, Window, 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_MESA_set_3dfx_mode ***/
|
||||
Bool (*Set3DfxModeMESA)(int mode);
|
||||
|
||||
/*** GLX_NV_vertex_array_range ***/
|
||||
void * (*AllocateMemoryNV)( GLsizei size,
|
||||
GLfloat readFrequency,
|
||||
GLfloat writeFrequency,
|
||||
GLfloat priority );
|
||||
void (*FreeMemoryNV)( GLvoid *pointer );
|
||||
|
||||
/*** GLX_MESA_agp_offset ***/
|
||||
GLuint (*GetAGPOffsetMESA)( const GLvoid *pointer );
|
||||
|
||||
/*** 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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
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
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.1
|
||||
*
|
||||
* 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
|
||||
* BRIAN PAUL 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
|
||||
|
||||
#ifdef __VMS
|
||||
#include <GL/vms_x_fix.h>
|
||||
#endif
|
||||
|
||||
#include "glheader.h"
|
||||
|
||||
#ifdef XFree86Server
|
||||
|
||||
# include "resource.h"
|
||||
# include "windowstr.h"
|
||||
|
||||
#else
|
||||
|
||||
# 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>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* this silences a compiler warning on several systems */
|
||||
struct timespec;
|
||||
struct itimerspec;
|
||||
|
||||
|
||||
#endif /*GLX_HEADER*/
|
||||
@@ -0,0 +1,180 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 5.1
|
||||
*
|
||||
* Copyright (C) 1999-2002 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
|
||||
* BRIAN PAUL 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.
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <GL/glx.h>
|
||||
#include "realglx.h"
|
||||
#include "glxapi.h"
|
||||
|
||||
|
||||
struct _glxapi_table *
|
||||
_real_GetGLXDispatchTable(void)
|
||||
{
|
||||
static struct _glxapi_table glx;
|
||||
|
||||
/* be sure our dispatch table size <= libGL's table */
|
||||
{
|
||||
GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
|
||||
(void) size;
|
||||
assert(_glxapi_get_dispatch_table_size() >= size);
|
||||
}
|
||||
|
||||
/* initialize the whole table to no-ops */
|
||||
_glxapi_set_no_op_table(&glx);
|
||||
|
||||
/* now initialize the table with the functions I implement */
|
||||
|
||||
/*** GLX_VERSION_1_0 ***/
|
||||
glx.ChooseVisual = _real_glXChooseVisual;
|
||||
glx.CopyContext = _real_glXCopyContext;
|
||||
glx.CreateContext = _real_glXCreateContext;
|
||||
glx.CreateGLXPixmap = _real_glXCreateGLXPixmap;
|
||||
glx.DestroyContext = _real_glXDestroyContext;
|
||||
glx.DestroyGLXPixmap = _real_glXDestroyGLXPixmap;
|
||||
glx.GetConfig = _real_glXGetConfig;
|
||||
/*glx.GetCurrentContext = _real_glXGetCurrentContext;*/
|
||||
/*glx.GetCurrentDrawable = _real_glXGetCurrentDrawable;*/
|
||||
glx.IsDirect = _real_glXIsDirect;
|
||||
glx.MakeCurrent = _real_glXMakeCurrent;
|
||||
glx.QueryExtension = _real_glXQueryExtension;
|
||||
glx.QueryVersion = _real_glXQueryVersion;
|
||||
glx.SwapBuffers = _real_glXSwapBuffers;
|
||||
glx.UseXFont = _real_glXUseXFont;
|
||||
glx.WaitGL = _real_glXWaitGL;
|
||||
glx.WaitX = _real_glXWaitX;
|
||||
|
||||
/*** GLX_VERSION_1_1 ***/
|
||||
glx.GetClientString = _real_glXGetClientString;
|
||||
glx.QueryExtensionsString = _real_glXQueryExtensionsString;
|
||||
glx.QueryServerString = _real_glXQueryServerString;
|
||||
|
||||
/*** GLX_VERSION_1_2 ***/
|
||||
/*glx.GetCurrentDisplay = _real_glXGetCurrentDisplay;*/
|
||||
|
||||
/*** GLX_VERSION_1_3 ***/
|
||||
glx.ChooseFBConfig = _real_glXChooseFBConfig;
|
||||
glx.CreateNewContext = _real_glXCreateNewContext;
|
||||
glx.CreatePbuffer = _real_glXCreatePbuffer;
|
||||
glx.CreatePixmap = _real_glXCreatePixmap;
|
||||
glx.CreateWindow = _real_glXCreateWindow;
|
||||
glx.DestroyPbuffer = _real_glXDestroyPbuffer;
|
||||
glx.DestroyPixmap = _real_glXDestroyPixmap;
|
||||
glx.DestroyWindow = _real_glXDestroyWindow;
|
||||
/*glx.GetCurrentReadDrawable = _real_glXGetCurrentReadDrawable;*/
|
||||
glx.GetFBConfigAttrib = _real_glXGetFBConfigAttrib;
|
||||
glx.GetFBConfigs = _real_glXGetFBConfigs;
|
||||
glx.GetSelectedEvent = _real_glXGetSelectedEvent;
|
||||
glx.GetVisualFromFBConfig = _real_glXGetVisualFromFBConfig;
|
||||
glx.MakeContextCurrent = _real_glXMakeContextCurrent;
|
||||
glx.QueryContext = _real_glXQueryContext;
|
||||
glx.QueryDrawable = _real_glXQueryDrawable;
|
||||
glx.SelectEvent = _real_glXSelectEvent;
|
||||
|
||||
/*** GLX_SGI_swap_control ***/
|
||||
glx.SwapIntervalSGI = _real_glXSwapIntervalSGI;
|
||||
|
||||
/*** GLX_SGI_video_sync ***/
|
||||
glx.GetVideoSyncSGI = _real_glXGetVideoSyncSGI;
|
||||
glx.WaitVideoSyncSGI = _real_glXWaitVideoSyncSGI;
|
||||
|
||||
/*** GLX_SGI_make_current_read ***/
|
||||
glx.MakeCurrentReadSGI = _real_glXMakeCurrentReadSGI;
|
||||
/*glx.GetCurrentReadDrawableSGI = _real_glXGetCurrentReadDrawableSGI;*/
|
||||
|
||||
#if defined(_VL_H)
|
||||
/*** GLX_SGIX_video_source ***/
|
||||
glx.CreateGLXVideoSourceSGIX = _real_glXCreateGLXVideoSourceSGIX;
|
||||
glx.DestroyGLXVideoSourceSGIX = _real_glXDestroyGLXVideoSourceSGIX;
|
||||
#endif
|
||||
|
||||
/*** GLX_EXT_import_context ***/
|
||||
glx.FreeContextEXT = _real_glXFreeContextEXT;
|
||||
/*glx.GetContextIDEXT = _real_glXGetContextIDEXT;*/
|
||||
/*glx.GetCurrentDisplayEXT = _real_glXGetCurrentDisplayEXT;*/
|
||||
glx.ImportContextEXT = _real_glXImportContextEXT;
|
||||
glx.QueryContextInfoEXT = _real_glXQueryContextInfoEXT;
|
||||
|
||||
/*** GLX_SGIX_fbconfig ***/
|
||||
glx.GetFBConfigAttribSGIX = _real_glXGetFBConfigAttribSGIX;
|
||||
glx.ChooseFBConfigSGIX = _real_glXChooseFBConfigSGIX;
|
||||
glx.CreateGLXPixmapWithConfigSGIX = _real_glXCreateGLXPixmapWithConfigSGIX;
|
||||
glx.CreateContextWithConfigSGIX = _real_glXCreateContextWithConfigSGIX;
|
||||
glx.GetVisualFromFBConfigSGIX = _real_glXGetVisualFromFBConfigSGIX;
|
||||
glx.GetFBConfigFromVisualSGIX = _real_glXGetFBConfigFromVisualSGIX;
|
||||
|
||||
/*** GLX_SGIX_pbuffer ***/
|
||||
glx.CreateGLXPbufferSGIX = _real_glXCreateGLXPbufferSGIX;
|
||||
glx.DestroyGLXPbufferSGIX = _real_glXDestroyGLXPbufferSGIX;
|
||||
glx.QueryGLXPbufferSGIX = _real_glXQueryGLXPbufferSGIX;
|
||||
glx.SelectEventSGIX = _real_glXSelectEventSGIX;
|
||||
glx.GetSelectedEventSGIX = _real_glXGetSelectedEventSGIX;
|
||||
|
||||
/*** GLX_SGI_cushion ***/
|
||||
glx.CushionSGI = _real_glXCushionSGI;
|
||||
|
||||
/*** GLX_SGIX_video_resize ***/
|
||||
glx.BindChannelToWindowSGIX = _real_glXBindChannelToWindowSGIX;
|
||||
glx.ChannelRectSGIX = _real_glXChannelRectSGIX;
|
||||
glx.QueryChannelRectSGIX = _real_glXQueryChannelRectSGIX;
|
||||
glx.QueryChannelDeltasSGIX = _real_glXQueryChannelDeltasSGIX;
|
||||
glx.ChannelRectSyncSGIX = _real_glXChannelRectSyncSGIX;
|
||||
|
||||
#if defined(_DM_BUFFER_H_)
|
||||
/*** (GLX_SGIX_dmbuffer ***/
|
||||
glx.AssociateDMPbufferSGIX = NULL;
|
||||
#endif
|
||||
|
||||
/*** GLX_SGIX_swap_group ***/
|
||||
glx.JoinSwapGroupSGIX = _real_glXJoinSwapGroupSGIX;
|
||||
|
||||
/*** GLX_SGIX_swap_barrier ***/
|
||||
glx.BindSwapBarrierSGIX = _real_glXBindSwapBarrierSGIX;
|
||||
glx.QueryMaxSwapBarriersSGIX = _real_glXQueryMaxSwapBarriersSGIX;
|
||||
|
||||
/*** GLX_SUN_get_transparent_index ***/
|
||||
glx.GetTransparentIndexSUN = _real_glXGetTransparentIndexSUN;
|
||||
|
||||
/*** GLX_MESA_copy_sub_buffer ***/
|
||||
glx.CopySubBufferMESA = _real_glXCopySubBufferMESA;
|
||||
|
||||
/*** GLX_MESA_release_buffers ***/
|
||||
glx.ReleaseBuffersMESA = _real_glXReleaseBuffersMESA;
|
||||
|
||||
/*** GLX_MESA_pixmap_colormap ***/
|
||||
glx.CreateGLXPixmapMESA = _real_glXCreateGLXPixmapMESA;
|
||||
|
||||
/*** GLX_MESA_set_3dfx_mode ***/
|
||||
glx.Set3DfxModeMESA = _real_glXSet3DfxModeMESA;
|
||||
|
||||
/*** GLX_NV_vertex_array_range ***/
|
||||
glx.AllocateMemoryNV = _real_glXAllocateMemoryNV;
|
||||
glx.FreeMemoryNV = _real_glXFreeMemoryNV;
|
||||
|
||||
/*** GLX_MESA_agp_offset ***/
|
||||
glx.GetAGPOffsetMESA = _real_glXGetAGPOffsetMESA;
|
||||
|
||||
return &glx;
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
*
|
||||
* Copyright (C) 1999-2001 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
|
||||
* BRIAN PAUL 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 REALGLX_H
|
||||
#define REALGLX_H
|
||||
|
||||
|
||||
extern struct _glxapi_table *
|
||||
_real_GetGLXDispatchTable(void);
|
||||
|
||||
|
||||
/*
|
||||
* Basically just need these to prevent compiler warnings.
|
||||
*/
|
||||
|
||||
|
||||
extern XVisualInfo *
|
||||
_real_glXChooseVisual( Display *dpy, int screen, int *list );
|
||||
|
||||
extern GLXContext
|
||||
_real_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
|
||||
GLXContext share_list, Bool direct );
|
||||
|
||||
extern GLXPixmap
|
||||
_real_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap );
|
||||
|
||||
extern GLXPixmap
|
||||
_real_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
|
||||
Pixmap pixmap, Colormap cmap );
|
||||
|
||||
extern void
|
||||
_real_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
|
||||
|
||||
extern void
|
||||
_real_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
|
||||
unsigned long mask );
|
||||
|
||||
extern Bool
|
||||
_real_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx );
|
||||
|
||||
extern Bool
|
||||
_real_glXQueryExtension( Display *dpy, int *errorb, int *event );
|
||||
|
||||
extern void
|
||||
_real_glXDestroyContext( Display *dpy, GLXContext ctx );
|
||||
|
||||
extern Bool
|
||||
_real_glXIsDirect( Display *dpy, GLXContext ctx );
|
||||
|
||||
extern void
|
||||
_real_glXSwapBuffers( Display *dpy, GLXDrawable drawable );
|
||||
|
||||
extern void
|
||||
_real_glXUseXFont( Font font, int first, int count, int listbase );
|
||||
|
||||
extern Bool
|
||||
_real_glXQueryVersion( Display *dpy, int *maj, int *min );
|
||||
|
||||
extern int
|
||||
_real_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
|
||||
int attrib, int *value );
|
||||
|
||||
extern void
|
||||
_real_glXWaitGL( void );
|
||||
|
||||
|
||||
extern void
|
||||
_real_glXWaitX( void );
|
||||
|
||||
/* GLX 1.1 and later */
|
||||
extern const char *
|
||||
_real_glXQueryExtensionsString( Display *dpy, int screen );
|
||||
|
||||
/* GLX 1.1 and later */
|
||||
extern const char *
|
||||
_real_glXQueryServerString( Display *dpy, int screen, int name );
|
||||
|
||||
/* GLX 1.1 and later */
|
||||
extern const char *
|
||||
_real_glXGetClientString( Display *dpy, int name );
|
||||
|
||||
|
||||
/*
|
||||
* GLX 1.3 and later
|
||||
*/
|
||||
|
||||
extern GLXFBConfig *
|
||||
_real_glXChooseFBConfig( Display *dpy, int screen,
|
||||
const int *attribList, int *nitems );
|
||||
|
||||
extern int
|
||||
_real_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
|
||||
int attribute, int *value );
|
||||
|
||||
extern GLXFBConfig *
|
||||
_real_glXGetFBConfigs( Display *dpy, int screen, int *nelements );
|
||||
|
||||
extern XVisualInfo *
|
||||
_real_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config );
|
||||
|
||||
extern GLXWindow
|
||||
_real_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
|
||||
const int *attribList );
|
||||
|
||||
extern void
|
||||
_real_glXDestroyWindow( Display *dpy, GLXWindow window );
|
||||
|
||||
extern GLXPixmap
|
||||
_real_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
|
||||
const int *attribList );
|
||||
|
||||
extern void
|
||||
_real_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
|
||||
|
||||
extern GLXPbuffer
|
||||
_real_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
|
||||
const int *attribList );
|
||||
|
||||
extern void
|
||||
_real_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
|
||||
|
||||
extern void
|
||||
_real_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
|
||||
unsigned int *value );
|
||||
|
||||
extern GLXContext
|
||||
_real_glXCreateNewContext( Display *dpy, GLXFBConfig config,
|
||||
int renderType, GLXContext shareList, Bool direct );
|
||||
|
||||
|
||||
extern Bool
|
||||
_real_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
|
||||
GLXDrawable read, GLXContext ctx );
|
||||
|
||||
extern int
|
||||
_real_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value );
|
||||
|
||||
extern void
|
||||
_real_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask );
|
||||
|
||||
extern void
|
||||
_real_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
|
||||
unsigned long *mask );
|
||||
|
||||
#ifdef GLX_SGI_swap_control
|
||||
extern int
|
||||
_real_glXSwapIntervalSGI(int interval);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef GLX_SGI_video_sync
|
||||
extern int
|
||||
_real_glXGetVideoSyncSGI(unsigned int *count);
|
||||
|
||||
extern int
|
||||
_real_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef GLX_SGI_make_current_read
|
||||
extern Bool
|
||||
_real_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
|
||||
|
||||
extern GLXDrawable
|
||||
_real_glXGetCurrentReadDrawableSGI(void);
|
||||
#endif
|
||||
|
||||
#if defined(_VL_H) && defined(GLX_SGIX_video_source)
|
||||
extern GLXVideoSourceSGIX
|
||||
_real_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
|
||||
|
||||
extern void
|
||||
_real_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_EXT_import_context
|
||||
extern void
|
||||
_real_glXFreeContextEXT(Display *dpy, GLXContext context);
|
||||
|
||||
extern GLXContextID
|
||||
_real_glXGetContextIDEXT(const GLXContext context);
|
||||
|
||||
extern Display *
|
||||
_real_glXGetCurrentDisplayEXT(void);
|
||||
|
||||
extern GLXContext
|
||||
_real_glXImportContextEXT(Display *dpy, GLXContextID contextID);
|
||||
|
||||
extern int
|
||||
_real_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_SGIX_fbconfig
|
||||
extern int
|
||||
_real_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
|
||||
|
||||
extern GLXFBConfigSGIX *
|
||||
_real_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements);
|
||||
|
||||
extern GLXPixmap
|
||||
_real_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
|
||||
|
||||
extern GLXContext
|
||||
_real_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
|
||||
|
||||
extern XVisualInfo *
|
||||
_real_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config);
|
||||
|
||||
extern GLXFBConfigSGIX
|
||||
_real_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_SGIX_pbuffer
|
||||
extern GLXPbufferSGIX
|
||||
_real_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
|
||||
|
||||
extern void
|
||||
_real_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf);
|
||||
|
||||
extern int
|
||||
_real_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
|
||||
|
||||
extern void
|
||||
_real_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask);
|
||||
|
||||
extern void
|
||||
_real_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_SGI_cushion
|
||||
extern void
|
||||
_real_glXCushionSGI(Display *dpy, Window win, float cushion);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_SGIX_video_resize
|
||||
extern int
|
||||
_real_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window);
|
||||
|
||||
extern int
|
||||
_real_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h);
|
||||
|
||||
extern int
|
||||
_real_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h);
|
||||
|
||||
extern int
|
||||
_real_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
|
||||
|
||||
extern int
|
||||
_real_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype);
|
||||
#endif
|
||||
|
||||
#if defined(_DM_BUFFER_H_) && defined(GLX_SGIX_dmbuffer)
|
||||
extern Bool
|
||||
_real_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_SGIX_swap_group
|
||||
extern void
|
||||
_real_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_SGIX_swap_barrier
|
||||
extern void
|
||||
_real_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier);
|
||||
|
||||
extern Bool
|
||||
_real_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_SUN_get_transparent_index
|
||||
extern Status
|
||||
_real_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_MESA_release_buffers
|
||||
extern Bool
|
||||
_real_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
|
||||
#endif
|
||||
|
||||
#ifdef GLX_MESA_set_3dfx_mode
|
||||
extern Bool
|
||||
_real_glXSet3DfxModeMESA( int mode );
|
||||
#endif
|
||||
|
||||
#ifdef GLX_NV_vertex_array_range
|
||||
extern void *
|
||||
_real_glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
|
||||
extern void
|
||||
_real_glXFreeMemoryNV(GLvoid *pointer);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_MESA_agp_offset
|
||||
extern GLuint
|
||||
_real_glXGetAGPOffsetMESA(const GLvoid *pointer);
|
||||
#endif
|
||||
|
||||
#ifdef GLX_MESA_copy_sub_buffer
|
||||
extern void
|
||||
_real_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
|
||||
int x, int y, int width, int height );
|
||||
#endif
|
||||
|
||||
#endif /* REALGLX_H */
|
||||
@@ -0,0 +1,377 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
*
|
||||
* 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
|
||||
* BRIAN PAUL 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
|
||||
*/
|
||||
|
||||
#ifdef __VMS
|
||||
#include <GL/vms_x_fix.h>
|
||||
#endif
|
||||
|
||||
#include "glxheader.h"
|
||||
#include "context.h"
|
||||
#include "imports.h"
|
||||
#include "xfonts.h"
|
||||
|
||||
|
||||
/* Some debugging info. */
|
||||
|
||||
#ifdef DEBUG
|
||||
#undef _R
|
||||
#undef _G
|
||||
#undef _B
|
||||
#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 = (GLubyte *) 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);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
*
|
||||
* 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
|
||||
* BRIAN PAUL 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
|
||||
|
||||
#ifdef __VMS
|
||||
#include <GL/vms_x_fix.h>
|
||||
#endif
|
||||
|
||||
#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
@@ -0,0 +1,503 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
*
|
||||
* 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
|
||||
* BRIAN PAUL 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 "GL/xmesa.h"
|
||||
#include "xmesaP.h"
|
||||
#include "imports.h"
|
||||
#include "framebuffer.h"
|
||||
#include "renderbuffer.h"
|
||||
#include "pipe/p_state.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_winsys.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
|
||||
|
||||
#if defined(USE_XSHM) && !defined(XFree86Server)
|
||||
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;
|
||||
}
|
||||
|
||||
b->shminfo.shmid = shmget(IPC_PRIVATE, b->backxrb->ximage->bytes_per_line
|
||||
* b->backxrb->ximage->height, IPC_CREAT|0777);
|
||||
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) && !defined(XFree86Server)
|
||||
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. */
|
||||
#ifdef XFree86Server
|
||||
b->backxrb->ximage = XMesaCreateImage(b->xm_visual->BitsPerPixel,
|
||||
width, height, NULL);
|
||||
#else
|
||||
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 */
|
||||
#endif
|
||||
if (!b->backxrb->ximage) {
|
||||
_mesa_warning(NULL, "alloc_back_buffer: XCreateImage failed.\n");
|
||||
return;
|
||||
}
|
||||
b->backxrb->ximage->data = (char *) 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
xmesa_delete_renderbuffer(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().
|
||||
*/
|
||||
_mesa_free(rb);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finish_surface_init(GLcontext *ctx, struct xmesa_renderbuffer *xrb)
|
||||
{
|
||||
struct pipe_context *pipe = ctx->st->pipe;
|
||||
if (!xrb->St.surface->region) {
|
||||
int w = 1, h = 1;
|
||||
xrb->St.surface->region = pipe->winsys->region_alloc(pipe->winsys,
|
||||
1, w, h, 0x0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reallocate renderbuffer storage for front color buffer.
|
||||
* Called via gl_renderbuffer::AllocStorage()
|
||||
*/
|
||||
static GLboolean
|
||||
xmesa_alloc_front_storage(GLcontext *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->origin1 = NULL;
|
||||
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;
|
||||
|
||||
if (!xrb->St.surface || !xrb->St.surface->region)
|
||||
finish_surface_init(ctx, xrb);
|
||||
|
||||
xrb->St.surface->width = width;
|
||||
xrb->St.surface->height = height;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reallocate renderbuffer storage for back color buffer.
|
||||
* Called via gl_renderbuffer::AllocStorage()
|
||||
*/
|
||||
static GLboolean
|
||||
xmesa_alloc_back_storage(GLcontext *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 PIXELADDR1 macro */
|
||||
xrb->width1 = xrb->ximage->bytes_per_line;
|
||||
xrb->origin1 = (GLubyte *) xrb->ximage->data + xrb->width1 * (height - 1);
|
||||
|
||||
/* 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->width1 = xrb->width2 = xrb->width3 = xrb->width4 = 0;
|
||||
xrb->origin1 = NULL;
|
||||
xrb->origin2 = NULL;
|
||||
xrb->origin3 = NULL;
|
||||
xrb->origin4 = NULL;
|
||||
}
|
||||
|
||||
if (!xrb->St.surface || !xrb->St.surface->region)
|
||||
finish_surface_init(ctx, xrb);
|
||||
|
||||
xrb->St.surface->width = width;
|
||||
xrb->St.surface->height = height;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called to create the front/back color renderbuffers, not user-created
|
||||
* renderbuffers.
|
||||
*/
|
||||
struct xmesa_renderbuffer *
|
||||
xmesa_create_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
|
||||
GLboolean backBuffer)
|
||||
{
|
||||
struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
|
||||
struct pipe_context *pipe = NULL;/*ctx->st->pipe;*/
|
||||
if (xrb) {
|
||||
GLuint name = 0;
|
||||
GLuint pipeFormat = 0;
|
||||
struct xmesa_surface *xms;
|
||||
|
||||
_mesa_init_renderbuffer(&xrb->St.Base, name);
|
||||
|
||||
xrb->St.Base.Delete = xmesa_delete_renderbuffer;
|
||||
if (backBuffer)
|
||||
xrb->St.Base.AllocStorage = xmesa_alloc_back_storage;
|
||||
else
|
||||
xrb->St.Base.AllocStorage = xmesa_alloc_front_storage;
|
||||
|
||||
if (visual->rgbMode) {
|
||||
xrb->St.Base.InternalFormat = GL_RGBA;
|
||||
xrb->St.Base._BaseFormat = GL_RGBA;
|
||||
xrb->St.Base.DataType = GL_UNSIGNED_BYTE;
|
||||
xrb->St.Base.RedBits = visual->redBits;
|
||||
xrb->St.Base.GreenBits = visual->greenBits;
|
||||
xrb->St.Base.BlueBits = visual->blueBits;
|
||||
xrb->St.Base.AlphaBits = visual->alphaBits;
|
||||
pipeFormat = PIPE_FORMAT_U_A8_R8_G8_B8;
|
||||
}
|
||||
else {
|
||||
xrb->St.Base.InternalFormat = GL_COLOR_INDEX;
|
||||
xrb->St.Base._BaseFormat = GL_COLOR_INDEX;
|
||||
xrb->St.Base.DataType = GL_UNSIGNED_INT;
|
||||
xrb->St.Base.IndexBits = visual->indexBits;
|
||||
}
|
||||
/* only need to set Red/Green/EtcBits fields for user-created RBs */
|
||||
|
||||
xrb->St.surface = xmesa_new_color_surface(pipe, pipeFormat);
|
||||
xms = (struct xmesa_surface *) xrb->St.surface;
|
||||
xms->xrb = xrb;
|
||||
}
|
||||
return xrb;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
struct gl_renderbuffer *
|
||||
xmesa_new_renderbuffer(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLenum internalFormat, GLuint width, GLuint height)
|
||||
{
|
||||
struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
|
||||
if (xrb) {
|
||||
GLuint name = 0;
|
||||
_mesa_init_renderbuffer(&xrb->St.Base, name);
|
||||
|
||||
xrb->St.Base.Delete = xmesa_delete_renderbuffer;
|
||||
if (backBuffer)
|
||||
xrb->St.Base.AllocStorage = xmesa_alloc_back_storage;
|
||||
else
|
||||
xrb->St.Base.AllocStorage = xmesa_alloc_front_storage;
|
||||
|
||||
if (visual->rgbMode) {
|
||||
xrb->St.Base.InternalFormat = GL_RGBA;
|
||||
xrb->St.Base._BaseFormat = GL_RGBA;
|
||||
xrb->St.Base.DataType = GL_UNSIGNED_BYTE;
|
||||
xrb->St.Base.RedBits = visual->redBits;
|
||||
xrb->St.Base.GreenBits = visual->greenBits;
|
||||
xrb->St.Base.BlueBits = visual->blueBits;
|
||||
xrb->St.Base.AlphaBits = visual->alphaBits;
|
||||
}
|
||||
else {
|
||||
xrb->St.Base.InternalFormat = GL_COLOR_INDEX;
|
||||
xrb->St.Base._BaseFormat = GL_COLOR_INDEX;
|
||||
xrb->St.Base.DataType = GL_UNSIGNED_INT;
|
||||
xrb->St.Base.IndexBits = visual->indexBits;
|
||||
}
|
||||
/* only need to set Red/Green/EtcBits fields for user-created RBs */
|
||||
}
|
||||
return xrb;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* 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)) {
|
||||
#ifdef XFree86Server
|
||||
int client = 0;
|
||||
if (b->frontxrb->drawable)
|
||||
client = CLIENT_ID(b->frontxrb->drawable->id);
|
||||
(void)FreeColors(b->cmap, client,
|
||||
b->num_alloced, b->alloced_colors, 0);
|
||||
#else
|
||||
XFreeColors(b->display, b->cmap,
|
||||
b->alloced_colors, b->num_alloced, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
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) && !defined(XFree86Server)
|
||||
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 );
|
||||
if (b->xm_visual->hpcr_clear_flag) {
|
||||
XMesaFreePixmap( b->display,
|
||||
b->xm_visual->hpcr_clear_pixmap );
|
||||
XMesaDestroyImage( b->xm_visual->hpcr_clear_ximage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (b->rowimage) {
|
||||
_mesa_free( b->rowimage->data );
|
||||
b->rowimage->data = NULL;
|
||||
XMesaDestroyImage( b->rowimage );
|
||||
}
|
||||
|
||||
_mesa_free_framebuffer_data(fb);
|
||||
_mesa_free(fb);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,133 @@
|
||||
/**************************************************************************
|
||||
|
||||
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>
|
||||
* Brian Paul <brian@precisioninsight.com>
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xmd.h>
|
||||
|
||||
#include "glxheader.h"
|
||||
#include "xmesaP.h"
|
||||
|
||||
#ifdef XFree86Server
|
||||
|
||||
#ifdef ROUNDUP
|
||||
#undef ROUNDUP
|
||||
#endif
|
||||
|
||||
#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3))
|
||||
|
||||
XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height, char *data)
|
||||
{
|
||||
XMesaImage *image;
|
||||
|
||||
image = (XMesaImage *)xalloc(sizeof(XMesaImage));
|
||||
|
||||
if (image) {
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->data = data;
|
||||
/* Always pad to 32 bits */
|
||||
image->bytes_per_line = ROUNDUP((bitsPerPixel * width), 32);
|
||||
image->bits_per_pixel = bitsPerPixel;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
void XMesaDestroyImage(XMesaImage *image)
|
||||
{
|
||||
if (image->data)
|
||||
free(image->data);
|
||||
xfree(image);
|
||||
}
|
||||
|
||||
unsigned long XMesaGetPixel(XMesaImage *image, int x, int y)
|
||||
{
|
||||
CARD8 *row = (CARD8 *)(image->data + y*image->bytes_per_line);
|
||||
CARD8 *i8;
|
||||
CARD16 *i16;
|
||||
CARD32 *i32;
|
||||
switch (image->bits_per_pixel) {
|
||||
case 8:
|
||||
i8 = (CARD8 *)row;
|
||||
return i8[x];
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
i16 = (CARD16 *)row;
|
||||
return i16[x];
|
||||
break;
|
||||
case 24: /* WARNING: architecture specific code */
|
||||
i8 = (CARD8 *)row;
|
||||
return (((CARD32)i8[x*3]) |
|
||||
(((CARD32)i8[x*3+1])<<8) |
|
||||
(((CARD32)i8[x*3+2])<<16));
|
||||
break;
|
||||
case 32:
|
||||
i32 = (CARD32 *)row;
|
||||
return i32[x];
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef XMESA_USE_PUTPIXEL_MACRO
|
||||
void XMesaPutPixel(XMesaImage *image, int x, int y, unsigned long pixel)
|
||||
{
|
||||
CARD8 *row = (CARD8 *)(image->data + y*image->bytes_per_line);
|
||||
CARD8 *i8;
|
||||
CARD16 *i16;
|
||||
CARD32 *i32;
|
||||
switch (image->bits_per_pixel) {
|
||||
case 8:
|
||||
i8 = (CARD8 *)row;
|
||||
i8[x] = (CARD8)pixel;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
i16 = (CARD16 *)row;
|
||||
i16[x] = (CARD16)pixel;
|
||||
break;
|
||||
case 24: /* WARNING: architecture specific code */
|
||||
i8 = (CARD8 *)__row;
|
||||
i8[x*3] = (CARD8)(p);
|
||||
i8[x*3+1] = (CARD8)(p>>8);
|
||||
i8[x*3+2] = (CARD8)(p>>16);
|
||||
case 32:
|
||||
i32 = (CARD32 *)row;
|
||||
i32[x] = (CARD32)pixel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* XFree86Server */
|
||||
@@ -0,0 +1,77 @@
|
||||
/**************************************************************************
|
||||
|
||||
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>
|
||||
* Brian Paul <brian@precisioninsight.com>
|
||||
*/
|
||||
|
||||
#ifndef _XM_IMAGE_H_
|
||||
#define _XM_IMAGE_H_
|
||||
|
||||
#define XMESA_USE_PUTPIXEL_MACRO
|
||||
|
||||
extern XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height,
|
||||
char *data);
|
||||
extern void XMesaDestroyImage(XMesaImage *image);
|
||||
extern unsigned long XMesaGetPixel(XMesaImage *image, int x, int y);
|
||||
#ifdef XMESA_USE_PUTPIXEL_MACRO
|
||||
#define XMesaPutPixel(__i,__x,__y,__p) \
|
||||
{ \
|
||||
CARD8 *__row = (CARD8 *)(__i->data + __y*__i->bytes_per_line); \
|
||||
CARD8 *__i8; \
|
||||
CARD16 *__i16; \
|
||||
CARD32 *__i32; \
|
||||
switch (__i->bits_per_pixel) { \
|
||||
case 8: \
|
||||
__i8 = (CARD8 *)__row; \
|
||||
__i8[__x] = (CARD8)__p; \
|
||||
break; \
|
||||
case 15: \
|
||||
case 16: \
|
||||
__i16 = (CARD16 *)__row; \
|
||||
__i16[__x] = (CARD16)__p; \
|
||||
break; \
|
||||
case 24: /* WARNING: architecture specific code */ \
|
||||
__i8 = (CARD8 *)__row; \
|
||||
__i8[__x*3] = (CARD8)(__p); \
|
||||
__i8[__x*3+1] = (CARD8)(__p>>8); \
|
||||
__i8[__x*3+2] = (CARD8)(__p>>16); \
|
||||
break; \
|
||||
case 32: \
|
||||
__i32 = (CARD32 *)__row; \
|
||||
__i32[__x] = (CARD32)__p; \
|
||||
break; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
extern void XMesaPutPixel(XMesaImage *image, int x, int y,
|
||||
unsigned long pixel);
|
||||
#endif
|
||||
|
||||
#endif /* _XM_IMAGE_H_ */
|
||||
@@ -0,0 +1,691 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
*
|
||||
* 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
|
||||
* BRIAN PAUL 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 "depth.h"
|
||||
#include "macros.h"
|
||||
#include "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( GLcontext *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( GLcontext *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._EnabledUnits
|
||||
&& 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][0]->Wrapped)
|
||||
|
||||
|
||||
/*
|
||||
* 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, PF_DITHER 8-bit line into an XImage.
|
||||
*/
|
||||
#define NAME flat_DITHER8_line
|
||||
#define SETUP_CODE \
|
||||
GET_XRB(xrb); \
|
||||
const GLubyte *color = vert1->color; \
|
||||
GLint r = color[0], g = color[1], b = color[2]; \
|
||||
DITHER_SETUP;
|
||||
#define PIXEL_TYPE GLubyte
|
||||
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
|
||||
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
|
||||
#define CLIP_HACK 1
|
||||
#define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
|
||||
#include "swrast/s_linetemp.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Draw a flat-shaded, PF_LOOKUP 8-bit line into an XImage.
|
||||
*/
|
||||
#define NAME flat_LOOKUP8_line
|
||||
#define SETUP_CODE \
|
||||
GET_XRB(xrb); \
|
||||
const GLubyte *color = vert1->color; \
|
||||
GLubyte pixel; \
|
||||
LOOKUP_SETUP; \
|
||||
pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
|
||||
#define PIXEL_TYPE GLubyte
|
||||
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
|
||||
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
|
||||
#define CLIP_HACK 1
|
||||
#define PLOT(X,Y) *pixelPtr = pixel;
|
||||
#include "swrast/s_linetemp.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Draw a flat-shaded, PF_HPCR line into an XImage.
|
||||
*/
|
||||
#define NAME flat_HPCR_line
|
||||
#define SETUP_CODE \
|
||||
GET_XRB(xrb); \
|
||||
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
|
||||
const GLubyte *color = vert1->color; \
|
||||
GLint r = color[0], g = color[1], b = color[2];
|
||||
#define PIXEL_TYPE GLubyte
|
||||
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
|
||||
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
|
||||
#define CLIP_HACK 1
|
||||
#define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
|
||||
#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 a flat-shaded, Z-less, PF_DITHER 8-bit line into an XImage.
|
||||
*/
|
||||
#define NAME flat_DITHER8_z_line
|
||||
#define SETUP_CODE \
|
||||
GET_XRB(xrb); \
|
||||
const GLubyte *color = vert1->color; \
|
||||
GLint r = color[0], g = color[1], b = color[2]; \
|
||||
DITHER_SETUP;
|
||||
#define INTERP_Z 1
|
||||
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
|
||||
#define PIXEL_TYPE GLubyte
|
||||
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
|
||||
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
|
||||
#define CLIP_HACK 1
|
||||
#define PLOT(X,Y) \
|
||||
if (Z < *zPtr) { \
|
||||
*zPtr = Z; \
|
||||
*pixelPtr = (GLubyte) DITHER( X, Y, r, g, b); \
|
||||
}
|
||||
#include "swrast/s_linetemp.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Draw a flat-shaded, Z-less, PF_LOOKUP 8-bit line into an XImage.
|
||||
*/
|
||||
#define NAME flat_LOOKUP8_z_line
|
||||
#define SETUP_CODE \
|
||||
GET_XRB(xrb); \
|
||||
const GLubyte *color = vert1->color; \
|
||||
GLubyte pixel; \
|
||||
LOOKUP_SETUP; \
|
||||
pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
|
||||
#define INTERP_Z 1
|
||||
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
|
||||
#define PIXEL_TYPE GLubyte
|
||||
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
|
||||
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(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_HPCR line into an XImage.
|
||||
*/
|
||||
#define NAME flat_HPCR_z_line
|
||||
#define SETUP_CODE \
|
||||
GET_XRB(xrb); \
|
||||
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
|
||||
const GLubyte *color = vert1->color; \
|
||||
GLint r = color[0], g = color[1], b = color[2];
|
||||
#define INTERP_Z 1
|
||||
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
|
||||
#define PIXEL_TYPE GLubyte
|
||||
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
|
||||
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
|
||||
#define CLIP_HACK 1
|
||||
#define PLOT(X,Y) \
|
||||
if (Z < *zPtr) { \
|
||||
*zPtr = Z; \
|
||||
*pixelPtr = (GLubyte) DITHER_HPCR( X, Y, r, g, b); \
|
||||
}
|
||||
#include "swrast/s_linetemp.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef XFree86Server
|
||||
/**
|
||||
* 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(GLcontext *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[FRAG_ATTRIB_WPOS][0];
|
||||
int y0 = YFLIP(xrb, (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][1]);
|
||||
int x1 = (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][0];
|
||||
int y1 = YFLIP(xrb, (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][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 /* XFree86Server */
|
||||
|
||||
|
||||
#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(GLcontext *ctx)
|
||||
{
|
||||
#if CHAN_BITS == 8
|
||||
SWcontext *swrast = SWRAST_CONTEXT(ctx);
|
||||
XMesaContext xmesa = XMESA_CONTEXT(ctx);
|
||||
XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
|
||||
const int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
|
||||
const struct xmesa_renderbuffer *xrb;
|
||||
|
||||
if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
|
||||
& (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
|
||||
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._EnabledUnits) 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;
|
||||
if (xmbuf->swAlpha) return (swrast_line_func) NULL;
|
||||
|
||||
xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
|
||||
|
||||
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;
|
||||
case PF_Dither:
|
||||
return (depth==8) ? flat_DITHER8_z_line : (swrast_line_func) NULL;
|
||||
case PF_Lookup:
|
||||
return (depth==8) ? flat_LOOKUP8_z_line : (swrast_line_func) NULL;
|
||||
case PF_HPCR:
|
||||
return flat_HPCR_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;
|
||||
case PF_Dither:
|
||||
return (depth==8) ? flat_DITHER8_line : (swrast_line_func) NULL;
|
||||
case PF_Lookup:
|
||||
return (depth==8) ? flat_LOOKUP8_line : (swrast_line_func) NULL;
|
||||
case PF_HPCR:
|
||||
return flat_HPCR_line;
|
||||
default:
|
||||
return (swrast_line_func)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef XFree86Server
|
||||
if (ctx->DrawBuffer->_NumColorDrawBuffers[0] == 1
|
||||
&& ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT
|
||||
&& swrast->_RasterMask == LOGIC_OP_BIT
|
||||
&& ctx->Color.LogicOp == GL_XOR
|
||||
&& !ctx->Line.StippleFlag
|
||||
&& !ctx->Line.SmoothFlag) {
|
||||
return xor_line;
|
||||
}
|
||||
#endif /* XFree86Server */
|
||||
|
||||
#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(GLcontext *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
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 7.1
|
||||
*
|
||||
* 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
|
||||
* BRIAN PAUL 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_surface.c
|
||||
* Code to allow the softpipe code to write to X windows/buffers.
|
||||
* This is a bit of a hack for now. We've basically got two different
|
||||
* abstractions for color buffers: gl_renderbuffer and pipe_surface.
|
||||
* They'll need to get merged someday...
|
||||
* For now, they're separate things that point to each other.
|
||||
*/
|
||||
|
||||
|
||||
#include "glxheader.h"
|
||||
#include "GL/xmesa.h"
|
||||
#include "xmesaP.h"
|
||||
#include "context.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "framebuffer.h"
|
||||
#include "renderbuffer.h"
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_winsys.h"
|
||||
#include "pipe/softpipe/sp_context.h"
|
||||
#include "pipe/softpipe/sp_clear.h"
|
||||
#include "pipe/softpipe/sp_tile_cache.h"
|
||||
#include "pipe/softpipe/sp_surface.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
|
||||
|
||||
#define CLIP_TILE \
|
||||
do { \
|
||||
if (x + w > ps->width) \
|
||||
w = ps->width - x; \
|
||||
if (y + h > ps->height) \
|
||||
h = ps->height -y; \
|
||||
} while(0)
|
||||
|
||||
|
||||
static INLINE struct xmesa_surface *
|
||||
xmesa_surface(struct pipe_surface *ps)
|
||||
{
|
||||
return (struct xmesa_surface *) ps;
|
||||
}
|
||||
|
||||
|
||||
static INLINE struct xmesa_renderbuffer *
|
||||
xmesa_rb(struct pipe_surface *ps)
|
||||
{
|
||||
struct xmesa_surface *xms = xmesa_surface(ps);
|
||||
return xms->xrb;
|
||||
}
|
||||
|
||||
|
||||
#define FLIP(Y) Y = xrb->St.Base.Height - (Y) - 1;
|
||||
|
||||
|
||||
void
|
||||
xmesa_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h, float *p)
|
||||
{
|
||||
struct xmesa_surface *xms = xmesa_surface(ps);
|
||||
struct xmesa_renderbuffer *xrb = xms->xrb;
|
||||
|
||||
if (xrb) {
|
||||
/* this is a front/back color buffer */
|
||||
GLubyte tmp[MAX_WIDTH * 4];
|
||||
GLuint i, j;
|
||||
uint w0 = w;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
FLIP(y);
|
||||
for (i = 0; i < h; i++) {
|
||||
xrb->St.Base.GetRow(ctx, &xrb->St.Base, w, x, y - i, tmp);
|
||||
for (j = 0; j < w * 4; j++) {
|
||||
p[j] = UBYTE_TO_FLOAT(tmp[j]);
|
||||
}
|
||||
p += w0 * 4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* other softpipe surface */
|
||||
softpipe_get_tile_rgba(pipe, ps, x, y, w, h, p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
xmesa_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h, const float *p)
|
||||
{
|
||||
struct xmesa_surface *xms = xmesa_surface(ps);
|
||||
struct xmesa_renderbuffer *xrb = xms->xrb;
|
||||
|
||||
if (xrb) {
|
||||
/* this is a front/back color buffer */
|
||||
GLubyte tmp[MAX_WIDTH * 4];
|
||||
GLuint i, j;
|
||||
uint w0 = w;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
CLIP_TILE;
|
||||
FLIP(y);
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w * 4; j++) {
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(tmp[j], p[j]);
|
||||
}
|
||||
xrb->St.Base.PutRow(ctx, &xrb->St.Base, w, x, y - i, tmp, NULL);
|
||||
p += w0 * 4;
|
||||
}
|
||||
#if 0 /* debug: flush */
|
||||
{
|
||||
XMesaContext xm = XMESA_CONTEXT(ctx);
|
||||
XSync(xm->display, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* other softpipe surface */
|
||||
softpipe_put_tile_rgba(pipe, ps, x, y, w, h, p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called to create a pipe_surface for each X renderbuffer.
|
||||
* Note: this is being used instead of pipe->surface_alloc() since we
|
||||
* have special/unique quad read/write functions for X.
|
||||
*/
|
||||
struct pipe_surface *
|
||||
xmesa_new_color_surface(struct pipe_context *pipe, GLuint pipeFormat)
|
||||
{
|
||||
struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
|
||||
|
||||
assert(pipeFormat);
|
||||
|
||||
xms->surface.format = pipeFormat;
|
||||
xms->surface.refcount = 1;
|
||||
|
||||
/* Note, the region we allocate doesn't actually have any storage
|
||||
* since we're drawing into an XImage or Pixmap.
|
||||
* The region's size will get set in the xmesa_alloc_front/back_storage()
|
||||
* functions.
|
||||
*/
|
||||
if (pipe)
|
||||
xms->surface.region = pipe->winsys->region_alloc(pipe->winsys,
|
||||
1, 0, 0, 0x0);
|
||||
|
||||
return &xms->surface;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->surface_alloc() to create new surfaces (textures,
|
||||
* renderbuffers, etc.
|
||||
*/
|
||||
struct pipe_surface *
|
||||
xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat)
|
||||
{
|
||||
struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
|
||||
|
||||
assert(pipe);
|
||||
assert(pipeFormat);
|
||||
|
||||
xms->surface.format = pipeFormat;
|
||||
xms->surface.refcount = 1;
|
||||
|
||||
return &xms->surface;
|
||||
}
|
||||
|
||||
|
||||
boolean
|
||||
xmesa_is_format_supported(struct pipe_context *pipe, uint format)
|
||||
{
|
||||
switch( format ) {
|
||||
case PIPE_FORMAT_U_A8_R8_G8_B8:
|
||||
case PIPE_FORMAT_S_R16_G16_B16_A16:
|
||||
case PIPE_FORMAT_S8_Z24:
|
||||
return TRUE;
|
||||
};
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->clear()
|
||||
*/
|
||||
void
|
||||
xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value)
|
||||
{
|
||||
struct xmesa_renderbuffer *xrb = xmesa_rb(ps);
|
||||
|
||||
/* XXX actually, we should just discard any cached tiles from this
|
||||
* surface since we don't want to accidentally re-use them after clearing.
|
||||
*/
|
||||
pipe->flush(pipe, 0);
|
||||
|
||||
{
|
||||
struct softpipe_context *sp = softpipe_context(pipe);
|
||||
if (ps == sp_tile_cache_get_surface(sp->cbuf_cache[0])) {
|
||||
float clear[4];
|
||||
clear[0] = 0.2; /* XXX hack */
|
||||
clear[1] = 0.2;
|
||||
clear[2] = 0.2;
|
||||
clear[3] = 0.2;
|
||||
sp_tile_cache_clear(sp->cbuf_cache[0], clear);
|
||||
}
|
||||
}
|
||||
|
||||
if (xrb && xrb->ximage) {
|
||||
/* clearing back color buffer */
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
xmesa_clear_buffers(ctx, BUFFER_BIT_BACK_LEFT);
|
||||
}
|
||||
else if (xrb && xrb->pixmap) {
|
||||
/* clearing front color buffer */
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
xmesa_clear_buffers(ctx, BUFFER_BIT_FRONT_LEFT);
|
||||
}
|
||||
else {
|
||||
/* clearing other buffer */
|
||||
softpipe_clear(pipe, ps, value);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,368 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
|
||||
* 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 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
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Keith Whitwell
|
||||
* Brian Paul
|
||||
*/
|
||||
|
||||
|
||||
#include "glxheader.h"
|
||||
#include "xmesaP.h"
|
||||
#include "main/macros.h"
|
||||
|
||||
#include "pipe/p_winsys.h"
|
||||
#include "pipe/softpipe/sp_winsys.h"
|
||||
|
||||
|
||||
/**
|
||||
* XMesa winsys, derived from softpipe winsys.
|
||||
* NOTE: there's nothing really X-specific in this winsys layer so
|
||||
* we could probably lift it up somewhere.
|
||||
*/
|
||||
struct xm_winsys
|
||||
{
|
||||
struct softpipe_winsys sws;
|
||||
int foo; /* placeholder */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Low-level OS/window system memory buffer
|
||||
*/
|
||||
struct xm_buffer
|
||||
{
|
||||
boolean userBuffer; /** Is this a user-space buffer? */
|
||||
int refcount;
|
||||
unsigned size;
|
||||
void *data;
|
||||
void *mapped;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Turn the softpipe opaque buffer pointer into a dri_bufmgr opaque
|
||||
* buffer pointer...
|
||||
*/
|
||||
static inline struct xm_buffer *
|
||||
xm_bo( struct pipe_buffer_handle *bo )
|
||||
{
|
||||
return (struct xm_buffer *) bo;
|
||||
}
|
||||
|
||||
static inline struct pipe_buffer_handle *
|
||||
pipe_bo( struct xm_buffer *bo )
|
||||
{
|
||||
return (struct pipe_buffer_handle *) bo;
|
||||
}
|
||||
|
||||
/* Turn a softpipe winsys into an xm/softpipe winsys:
|
||||
*/
|
||||
static inline struct xm_winsys *
|
||||
xm_winsys(struct softpipe_winsys *sws)
|
||||
{
|
||||
return (struct xm_winsys *) sws;
|
||||
}
|
||||
|
||||
|
||||
/* Most callbacks map direcly onto dri_bufmgr operations:
|
||||
*/
|
||||
static void *
|
||||
xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
|
||||
unsigned flags)
|
||||
{
|
||||
struct xm_buffer *xm_buf = xm_bo(buf);
|
||||
xm_buf->mapped = xm_buf->data;
|
||||
return xm_buf->mapped;
|
||||
}
|
||||
|
||||
static void
|
||||
xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
|
||||
{
|
||||
struct xm_buffer *xm_buf = xm_bo(buf);
|
||||
xm_buf->mapped = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
xm_buffer_reference(struct pipe_winsys *pws,
|
||||
struct pipe_buffer_handle **ptr,
|
||||
struct pipe_buffer_handle *buf)
|
||||
{
|
||||
if (*ptr) {
|
||||
struct xm_buffer *oldBuf = xm_bo(*ptr);
|
||||
oldBuf->refcount--;
|
||||
assert(oldBuf->refcount >= 0);
|
||||
if (oldBuf->refcount == 0) {
|
||||
if (oldBuf->data) {
|
||||
if (!oldBuf->userBuffer)
|
||||
free(oldBuf->data);
|
||||
oldBuf->data = NULL;
|
||||
}
|
||||
free(oldBuf);
|
||||
}
|
||||
*ptr = NULL;
|
||||
}
|
||||
|
||||
assert(!(*ptr));
|
||||
|
||||
if (buf) {
|
||||
struct xm_buffer *newBuf = xm_bo(buf);
|
||||
newBuf->refcount++;
|
||||
*ptr = buf;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
|
||||
unsigned size, const void *data )
|
||||
{
|
||||
struct xm_buffer *xm_buf = xm_bo(buf);
|
||||
assert(!xm_buf->userBuffer);
|
||||
if (xm_buf->size != size) {
|
||||
if (xm_buf->data)
|
||||
free(xm_buf->data);
|
||||
xm_buf->data = malloc(size);
|
||||
xm_buf->size = size;
|
||||
}
|
||||
if (data)
|
||||
memcpy(xm_buf->data, data, size);
|
||||
}
|
||||
|
||||
static void
|
||||
xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
|
||||
unsigned long offset, unsigned long size, const void *data)
|
||||
{
|
||||
struct xm_buffer *xm_buf = xm_bo(buf);
|
||||
GLubyte *b = (GLubyte *) xm_buf->data;
|
||||
assert(!xm_buf->userBuffer);
|
||||
assert(b);
|
||||
memcpy(b + offset, data, size);
|
||||
}
|
||||
|
||||
static void
|
||||
xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
|
||||
unsigned long offset, unsigned long size, void *data)
|
||||
{
|
||||
const struct xm_buffer *xm_buf = xm_bo(buf);
|
||||
const GLubyte *b = (GLubyte *) xm_buf->data;
|
||||
assert(!xm_buf->userBuffer);
|
||||
assert(b);
|
||||
memcpy(data, b + offset, size);
|
||||
}
|
||||
|
||||
static void
|
||||
xm_flush_frontbuffer(struct pipe_winsys *pws)
|
||||
{
|
||||
/*
|
||||
struct intel_context *intel = intel_pipe_winsys(sws)->intel;
|
||||
__DRIdrawablePrivate *dPriv = intel->driDrawable;
|
||||
|
||||
intelCopyBuffer(dPriv, NULL);
|
||||
*/
|
||||
}
|
||||
|
||||
static void
|
||||
xm_wait_idle(struct pipe_winsys *pws)
|
||||
{
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
static void
|
||||
xm_printf(struct pipe_winsys *pws, const char *fmtString, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, fmtString );
|
||||
vfprintf(stderr, fmtString, args);
|
||||
va_end( args );
|
||||
}
|
||||
|
||||
static const char *
|
||||
xm_get_name(struct pipe_winsys *pws)
|
||||
{
|
||||
return "Xlib";
|
||||
}
|
||||
|
||||
|
||||
static struct pipe_buffer_handle *
|
||||
xm_buffer_create(struct pipe_winsys *pws, unsigned alignment)
|
||||
{
|
||||
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
|
||||
buffer->refcount = 1;
|
||||
return pipe_bo(buffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create buffer which wraps user-space data.
|
||||
*/
|
||||
static struct pipe_buffer_handle *
|
||||
xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
|
||||
{
|
||||
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
|
||||
buffer->userBuffer = TRUE;
|
||||
buffer->refcount = 1;
|
||||
buffer->data = ptr;
|
||||
buffer->size = bytes;
|
||||
return pipe_bo(buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Round n up to next multiple.
|
||||
*/
|
||||
static INLINE unsigned
|
||||
round_up(unsigned n, unsigned multiple)
|
||||
{
|
||||
return (n + multiple - 1) & ~(multiple - 1);
|
||||
}
|
||||
|
||||
|
||||
static struct pipe_region *
|
||||
xm_region_alloc(struct pipe_winsys *winsys,
|
||||
unsigned cpp, unsigned width, unsigned height, unsigned flags)
|
||||
{
|
||||
struct pipe_region *region = CALLOC_STRUCT(pipe_region);
|
||||
const unsigned alignment = 64;
|
||||
|
||||
region->cpp = cpp;
|
||||
region->pitch = round_up(width, alignment / cpp);
|
||||
region->height = height;
|
||||
region->refcount = 1;
|
||||
|
||||
assert(region->pitch > 0);
|
||||
|
||||
region->buffer = winsys->buffer_create( winsys, alignment )
|
||||
;
|
||||
|
||||
/* NULL data --> just allocate the space */
|
||||
winsys->buffer_data( winsys,
|
||||
region->buffer,
|
||||
region->pitch * cpp * height,
|
||||
NULL );
|
||||
return region;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
xm_region_release(struct pipe_winsys *winsys, struct pipe_region **region)
|
||||
{
|
||||
if (!*region)
|
||||
return;
|
||||
|
||||
assert((*region)->refcount > 0);
|
||||
(*region)->refcount--;
|
||||
|
||||
if ((*region)->refcount == 0) {
|
||||
assert((*region)->map_refcount == 0);
|
||||
|
||||
winsys->buffer_reference( winsys, &((*region)->buffer), NULL );
|
||||
free(*region);
|
||||
}
|
||||
*region = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->surface_alloc() to create new surfaces (textures,
|
||||
* renderbuffers, etc.
|
||||
*/
|
||||
static struct pipe_surface *
|
||||
xm_surface_alloc(struct pipe_winsys *ws, GLuint pipeFormat)
|
||||
{
|
||||
struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
|
||||
|
||||
assert(ws);
|
||||
assert(pipeFormat);
|
||||
|
||||
xms->surface.format = pipeFormat;
|
||||
xms->surface.refcount = 1;
|
||||
#if 0
|
||||
/*
|
||||
* This is really just a softpipe surface, not an XImage/Pixmap surface.
|
||||
*/
|
||||
softpipe_init_surface_funcs(&xms->surface);
|
||||
#endif
|
||||
return &xms->surface;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct xmesa_pipe_winsys
|
||||
{
|
||||
struct pipe_winsys winsys;
|
||||
XMesaContext xmesa;
|
||||
};
|
||||
|
||||
static struct pipe_winsys *
|
||||
xmesa_create_pipe_winsys( XMesaContext xmesa )
|
||||
{
|
||||
struct xmesa_pipe_winsys *xws = CALLOC_STRUCT(xmesa_pipe_winsys);
|
||||
|
||||
/* Fill in this struct with callbacks that pipe will need to
|
||||
* communicate with the window system, buffer manager, etc.
|
||||
*
|
||||
* Pipe would be happy with a malloc based memory manager, but
|
||||
* the SwapBuffers implementation in this winsys driver requires
|
||||
* that rendering be done to an appropriate _DriBufferObject.
|
||||
*/
|
||||
xws->winsys.buffer_create = xm_buffer_create;
|
||||
xws->winsys.user_buffer_create = xm_user_buffer_create;
|
||||
xws->winsys.buffer_map = xm_buffer_map;
|
||||
xws->winsys.buffer_unmap = xm_buffer_unmap;
|
||||
xws->winsys.buffer_reference = xm_buffer_reference;
|
||||
xws->winsys.buffer_data = xm_buffer_data;
|
||||
xws->winsys.buffer_subdata = xm_buffer_subdata;
|
||||
xws->winsys.buffer_get_subdata = xm_buffer_get_subdata;
|
||||
|
||||
xws->winsys.region_alloc = xm_region_alloc;
|
||||
xws->winsys.region_release = xm_region_release;
|
||||
|
||||
xws->winsys.surface_alloc = xm_surface_alloc;
|
||||
|
||||
xws->winsys.flush_frontbuffer = xm_flush_frontbuffer;
|
||||
xws->winsys.wait_idle = xm_wait_idle;
|
||||
xws->winsys.printf = xm_printf;
|
||||
xws->winsys.get_name = xm_get_name;
|
||||
xws->xmesa = xmesa;
|
||||
|
||||
return &xws->winsys;
|
||||
}
|
||||
|
||||
|
||||
struct pipe_context *
|
||||
xmesa_create_softpipe(XMesaContext xmesa)
|
||||
{
|
||||
struct xm_winsys *xm_ws = CALLOC_STRUCT( xm_winsys );
|
||||
|
||||
/* Create the softpipe context:
|
||||
*/
|
||||
return softpipe_create( xmesa_create_pipe_winsys(xmesa), &xm_ws->sws );
|
||||
}
|
||||
@@ -0,0 +1,631 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 7.1
|
||||
*
|
||||
* 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
|
||||
* BRIAN PAUL 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 "GL/xmesa.h"
|
||||
#include "mtypes.h"
|
||||
#if defined(FX)
|
||||
#include "GL/fxmesa.h"
|
||||
#endif
|
||||
#ifdef XFree86Server
|
||||
#include "xm_image.h"
|
||||
#endif
|
||||
#include "state_tracker/st_cb_fbo.h"
|
||||
#include "pipe/softpipe/sp_context.h"
|
||||
#include "pipe/softpipe/sp_surface.h"
|
||||
|
||||
|
||||
extern _glthread_Mutex _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)( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
|
||||
GLint x, GLint y, GLint width, GLint height );
|
||||
|
||||
|
||||
|
||||
|
||||
/** Framebuffer pixel formats */
|
||||
enum pixel_format {
|
||||
PF_Index, /**< Color Index mode */
|
||||
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, /**< Color-mapped RGB with dither */
|
||||
PF_Lookup, /**< Color-mapped RGB without dither */
|
||||
PF_HPCR, /**< HP Color Recovery (ad@lms.be 30/08/95) */
|
||||
PF_1Bit, /**< monochrome dithering of RGB */
|
||||
PF_Grayscale, /**< Grayscale or StaticGray */
|
||||
PF_Dither_5R6G5B /**< 16-bit dithered TrueColor: 5-R, 6-G, 5-B */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Visual inforation, derived from GLvisual.
|
||||
* Basically corresponds to an XVisualInfo.
|
||||
*/
|
||||
struct xmesa_visual {
|
||||
GLvisual mesa_visual; /* Device independent visual parameters */
|
||||
XMesaDisplay *display; /* The X11 display */
|
||||
#ifdef XFree86Server
|
||||
GLint ColormapEntries;
|
||||
GLint nplanes;
|
||||
#else
|
||||
XMesaVisualInfo visinfo; /* X's visual info (pointer to private copy) */
|
||||
XVisualInfo *vishandle; /* Only used in fakeglx.c */
|
||||
#endif
|
||||
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];
|
||||
|
||||
/* For PF_HPCR */
|
||||
short hpcr_rgbTbl[3][256];
|
||||
GLboolean hpcr_clear_flag;
|
||||
GLubyte hpcr_clear_ximage_pattern[2][16];
|
||||
XMesaImage *hpcr_clear_ximage;
|
||||
XMesaPixmap hpcr_clear_pixmap;
|
||||
|
||||
/* For PF_1BIT */
|
||||
int bitFlip;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Context info, dDerived from GLcontext.
|
||||
* Basically corresponds to a GLXContext.
|
||||
*/
|
||||
struct xmesa_context {
|
||||
GLcontext 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
|
||||
{
|
||||
#if 0
|
||||
struct gl_renderbuffer Base; /* Base class */
|
||||
#else
|
||||
struct st_renderbuffer St; /**< Base class */
|
||||
#endif
|
||||
|
||||
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 */
|
||||
|
||||
GLubyte *origin1; /* used for PIXEL_ADDR1 macro */
|
||||
GLint width1;
|
||||
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;
|
||||
|
||||
void *pSurface; /** pipe surface */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Framebuffer information, derived from.
|
||||
* Basically corresponds to a GLXDrawable.
|
||||
*/
|
||||
struct xmesa_buffer {
|
||||
GLframebuffer 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 */
|
||||
|
||||
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 */
|
||||
GLboolean swAlpha;
|
||||
|
||||
GLuint shm; /* X Shared Memory extension status: */
|
||||
/* 0 = not available */
|
||||
/* 1 = XImage support available */
|
||||
/* 2 = Pixmap support available too */
|
||||
#if defined(USE_XSHM) && !defined(XFree86Server)
|
||||
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;
|
||||
#if defined(XFree86Server)
|
||||
Pixel alloced_colors[256];
|
||||
#else
|
||||
unsigned long alloced_colors[256];
|
||||
#endif
|
||||
|
||||
#if defined( FX )
|
||||
/* For 3Dfx Glide only */
|
||||
GLboolean FXisHackUsable; /* Can we render into window? */
|
||||
GLboolean FXwindowHack; /* Are we rendering into a window? */
|
||||
fxMesaContext FXctx;
|
||||
#endif
|
||||
|
||||
/* 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) )
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If pixelformat==PF_DITHER:
|
||||
*
|
||||
* Improved 8-bit RGB dithering code contributed by Bob Mercier
|
||||
* (mercier@hollywood.cinenet.net). Thanks Bob!
|
||||
*/
|
||||
#ifdef DITHER666
|
||||
# define DITH_R 6
|
||||
# define DITH_G 6
|
||||
# define DITH_B 6
|
||||
# define DITH_MIX(r,g,b) (((r) * DITH_G + (g)) * DITH_B + (b))
|
||||
#else
|
||||
# define DITH_R 5
|
||||
# define DITH_G 9
|
||||
# define DITH_B 5
|
||||
# define DITH_MIX(r,g,b) (((g) << 6) | ((b) << 3) | (r))
|
||||
#endif
|
||||
#define DITH_DX 4
|
||||
#define DITH_DY 4
|
||||
#define DITH_N (DITH_DX * DITH_DY)
|
||||
|
||||
#define _dither(C, c, d) (((unsigned)((DITH_N * (C - 1) + 1) * c + d)) >> 12)
|
||||
|
||||
#define MAXC 256
|
||||
extern const int xmesa_kernel8[DITH_DY * DITH_DX];
|
||||
|
||||
/* Dither for random X,Y */
|
||||
#define DITHER_SETUP \
|
||||
int __d; \
|
||||
unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table;
|
||||
|
||||
#define DITHER( X, Y, R, G, B ) \
|
||||
(__d = xmesa_kernel8[(((Y)&3)<<2) | ((X)&3)], \
|
||||
ctable[DITH_MIX(_dither(DITH_R, (R), __d), \
|
||||
_dither(DITH_G, (G), __d), \
|
||||
_dither(DITH_B, (B), __d))])
|
||||
|
||||
/* Dither for random X, fixed Y */
|
||||
#define XDITHER_SETUP(Y) \
|
||||
int __d; \
|
||||
unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \
|
||||
const int *kernel = &xmesa_kernel8[ ((Y)&3) << 2 ];
|
||||
|
||||
#define XDITHER( X, R, G, B ) \
|
||||
(__d = kernel[(X)&3], \
|
||||
ctable[DITH_MIX(_dither(DITH_R, (R), __d), \
|
||||
_dither(DITH_G, (G), __d), \
|
||||
_dither(DITH_B, (B), __d))])
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Dithering for flat-shaded triangles. Precompute all 16 possible
|
||||
* pixel values given the triangle's RGB color. Contributed by Martin Shenk.
|
||||
*/
|
||||
#define FLAT_DITHER_SETUP( R, G, B ) \
|
||||
GLushort ditherValues[16]; \
|
||||
{ \
|
||||
unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \
|
||||
int msdr = (DITH_N*((DITH_R)-1)+1) * (R); \
|
||||
int msdg = (DITH_N*((DITH_G)-1)+1) * (G); \
|
||||
int msdb = (DITH_N*((DITH_B)-1)+1) * (B); \
|
||||
int i; \
|
||||
for (i=0;i<16;i++) { \
|
||||
int k = xmesa_kernel8[i]; \
|
||||
int j = DITH_MIX( (msdr+k)>>12, (msdg+k)>>12, (msdb+k)>>12 );\
|
||||
ditherValues[i] = (GLushort) ctable[j]; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FLAT_DITHER_ROW_SETUP(Y) \
|
||||
GLushort *ditherRow = ditherValues + ( ((Y)&3) << 2);
|
||||
|
||||
#define FLAT_DITHER(X) ditherRow[(X)&3]
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If pixelformat==PF_LOOKUP:
|
||||
*/
|
||||
#define _dither_lookup(C, c) (((unsigned)((DITH_N * (C - 1) + 1) * c)) >> 12)
|
||||
|
||||
#define LOOKUP_SETUP \
|
||||
unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table
|
||||
|
||||
#define LOOKUP( R, G, B ) \
|
||||
ctable[DITH_MIX(_dither_lookup(DITH_R, (R)), \
|
||||
_dither_lookup(DITH_G, (G)), \
|
||||
_dither_lookup(DITH_B, (B)))]
|
||||
|
||||
|
||||
/**
|
||||
* If pixelformat==PF_HPCR:
|
||||
*
|
||||
* HP Color Recovery dithering (ad@lms.be 30/08/95)
|
||||
* HP has on it's 8-bit 700-series computers, a feature called
|
||||
* 'Color Recovery'. This allows near 24-bit output (so they say).
|
||||
* It is enabled by selecting the 8-bit TrueColor visual AND
|
||||
* corresponding colormap (see tkInitWindow) AND doing some special
|
||||
* dither.
|
||||
*/
|
||||
extern const short xmesa_HPCR_DRGB[3][2][16];
|
||||
|
||||
#define DITHER_HPCR( X, Y, R, G, B ) \
|
||||
( ((xmesa->xm_visual->hpcr_rgbTbl[0][R] + xmesa_HPCR_DRGB[0][(Y)&1][(X)&15]) & 0xE0) \
|
||||
|(((xmesa->xm_visual->hpcr_rgbTbl[1][G] + xmesa_HPCR_DRGB[1][(Y)&1][(X)&15]) & 0xE0)>>3) \
|
||||
| ((xmesa->xm_visual->hpcr_rgbTbl[2][B] + xmesa_HPCR_DRGB[2][(Y)&1][(X)&15])>>6) \
|
||||
)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If pixelformat==PF_1BIT:
|
||||
*/
|
||||
extern const int xmesa_kernel1[16];
|
||||
|
||||
#define SETUP_1BIT int bitFlip = xmesa->xm_visual->bitFlip
|
||||
#define DITHER_1BIT( X, Y, R, G, B ) \
|
||||
(( ((int)(R)+(int)(G)+(int)(B)) > xmesa_kernel1[(((Y)&3) << 2) | ((X)&3)] ) ^ bitFlip)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If pixelformat==PF_GRAYSCALE:
|
||||
*/
|
||||
#define GRAY_RGB( R, G, B ) XMESA_BUFFER(ctx->DrawBuffer)->color_table[((R) + (G) + (B))/3]
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts a GL window Y coord to an X window Y coord:
|
||||
*/
|
||||
#define YFLIP(XRB, Y) ((XRB)->bottom - (Y))
|
||||
|
||||
|
||||
/**
|
||||
* Return the address of a 1, 2 or 4-byte pixel in the buffer's XImage:
|
||||
* X==0 is left, Y==0 is bottom.
|
||||
*/
|
||||
#define PIXEL_ADDR1(XRB, X, Y) \
|
||||
( (XRB)->origin1 - (Y) * (XRB)->width1 + (X) )
|
||||
|
||||
#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_create_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
|
||||
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( GLcontext *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_update_state( GLcontext *ctx, GLbitfield new_state );
|
||||
|
||||
extern void
|
||||
xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb,
|
||||
enum pixel_format pixelformat, GLint depth);
|
||||
|
||||
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 GLcontext.
|
||||
* Since we're using structure containment, it's just a cast!.
|
||||
* XXX should use inlined function for better type safety.
|
||||
*/
|
||||
static INLINE XMesaContext
|
||||
XMESA_CONTEXT(GLcontext *ctx)
|
||||
{
|
||||
return (XMesaContext) ctx;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return pointer to XMesaBuffer corresponding to a Mesa GLframebuffer.
|
||||
* Since we're using structure containment, it's just a cast!.
|
||||
* XXX should use inlined function for better type safety.
|
||||
*/
|
||||
static INLINE XMesaBuffer
|
||||
XMESA_BUFFER(GLframebuffer *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( GLcontext *ctx );
|
||||
extern void xmesa_choose_line( GLcontext *ctx );
|
||||
extern void xmesa_choose_triangle( GLcontext *ctx );
|
||||
|
||||
|
||||
extern void xmesa_register_swrast_functions( GLcontext *ctx );
|
||||
|
||||
|
||||
|
||||
#define ENABLE_EXT_texure_compression_s3tc 0 /* SW texture compression */
|
||||
|
||||
#ifdef XFree86Server
|
||||
#define ENABLE_EXT_timer_query 0
|
||||
#elif 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
|
||||
|
||||
|
||||
struct pipe_surface;
|
||||
struct pipe_context;
|
||||
|
||||
struct xmesa_surface
|
||||
{
|
||||
struct pipe_surface surface;
|
||||
struct xmesa_renderbuffer *xrb;
|
||||
};
|
||||
|
||||
|
||||
extern void
|
||||
xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value);
|
||||
|
||||
extern void
|
||||
xmesa_clear_buffers(GLcontext *ctx, GLbitfield buffers);
|
||||
|
||||
extern struct pipe_context *
|
||||
xmesa_create_softpipe(XMesaContext xm);
|
||||
|
||||
extern struct pipe_surface *
|
||||
xmesa_surface_alloc(struct pipe_context *pipe, GLuint format);
|
||||
|
||||
extern struct pipe_surface *
|
||||
xmesa_new_color_surface(struct pipe_context *pipe, GLuint format);
|
||||
|
||||
extern boolean
|
||||
xmesa_is_format_supported(struct pipe_context *pipe, uint format);
|
||||
|
||||
extern void
|
||||
xmesa_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h, float *p);
|
||||
|
||||
extern void
|
||||
xmesa_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h, const float *p);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user