📄 indirect.c
字号:
/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script *//* * (C) Copyright IBM Corporation 2004, 2005 * 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 * IBM, * AND/OR THEIR 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. */#include <GL/gl.h>#include "indirect.h"#include "glxclient.h"#include "indirect_size.h"#include <GL/glxproto.h>#ifdef USE_XCB#include <X11/xcl.h>#include <X11/XCB/xcb.h>#include <X11/XCB/glx.h>#endif /* USE_XCB */#define __GLX_PAD(n) (((n) + 3) & ~3)# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)# define FASTCALL __attribute__((fastcall))# else# define FASTCALL# endif# if defined(__GNUC__)# define NOINLINE __attribute__((noinline))# else# define NOINLINE# endif#if !defined __GNUC__ || __GNUC__ < 3# define __builtin_expect(x, y) x#endif/* If the size and opcode values are known at compile-time, this will, on * x86 at least, emit them with a single instruction. */#define emit_header(dest, op, size) \ do { union { short s[2]; int i; } temp; \ temp.s[0] = (size); temp.s[1] = (op); \ *((int *)(dest)) = temp.i; } while(0)NOINLINE CARD32__glXReadReply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_array ){ xGLXSingleReply reply; (void) _XReply(dpy, (xReply *) & reply, 0, False); if (size != 0) { if ((reply.length > 0) || reply_is_always_array) { const GLint bytes = (reply_is_always_array) ? (4 * reply.length) : (reply.size * size); const GLint extra = 4 - (bytes & 3); _XRead(dpy, dest, bytes); if ( extra < 4 ) { _XEatData(dpy, extra); } } else { (void) memcpy( dest, &(reply.pad3), size); } } return reply.retval;}NOINLINE void__glXReadPixelReply( Display *dpy, __GLXcontext * gc, unsigned max_dim, GLint width, GLint height, GLint depth, GLenum format, GLenum type, void * dest, GLboolean dimensions_in_reply ){ xGLXSingleReply reply; GLint size; (void) _XReply(dpy, (xReply *) & reply, 0, False); if ( dimensions_in_reply ) { width = reply.pad3; height = reply.pad4; depth = reply.pad5; if ((height == 0) || (max_dim < 2)) { height = 1; } if ((depth == 0) || (max_dim < 3)) { depth = 1; } } size = reply.length * 4; if (size != 0) { void * buf = Xmalloc( size ); if ( buf == NULL ) { _XEatData(dpy, size); __glXSetError(gc, GL_OUT_OF_MEMORY); } else { const GLint extra = 4 - (size & 3); _XRead(dpy, buf, size); if ( extra < 4 ) { _XEatData(dpy, extra); } __glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest); Xfree(buf); } }}#define X_GLXSingle 0NOINLINE FASTCALL GLubyte *__glXSetupSingleRequest( __GLXcontext * gc, GLint sop, GLint cmdlen ){ xGLXSingleReq * req; Display * const dpy = gc->currentDpy; (void) __glXFlushRenderBuffer(gc, gc->pc); LockDisplay(dpy); GetReqExtra(GLXSingle, cmdlen, req); req->reqType = gc->majorOpcode; req->contextTag = gc->currentContextTag; req->glxCode = sop; return (GLubyte *)(req) + sz_xGLXSingleReq;}NOINLINE FASTCALL GLubyte *__glXSetupVendorRequest( __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen ){ xGLXVendorPrivateReq * req; Display * const dpy = gc->currentDpy; (void) __glXFlushRenderBuffer(gc, gc->pc); LockDisplay(dpy); GetReqExtra(GLXVendorPrivate, cmdlen, req); req->reqType = gc->majorOpcode; req->glxCode = code; req->vendorCode = vop; req->contextTag = gc->currentContextTag; return (GLubyte *)(req) + sz_xGLXVendorPrivateReq;}const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };#define zero (__glXDefaultPixelStore+0)#define one (__glXDefaultPixelStore+8)#define default_pixel_store_1D (__glXDefaultPixelStore+4)#define default_pixel_store_1D_size 20#define default_pixel_store_2D (__glXDefaultPixelStore+4)#define default_pixel_store_2D_size 20#define default_pixel_store_3D (__glXDefaultPixelStore+0)#define default_pixel_store_3D_size 36#define default_pixel_store_4D (__glXDefaultPixelStore+0)#define default_pixel_store_4D_size 36static FASTCALL NOINLINE voidgeneric_3_byte( GLint rop, const void * ptr ){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint cmdlen = 8; emit_header(gc->pc, rop, cmdlen); (void) memcpy((void *)(gc->pc + 4), ptr, 4); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }}static FASTCALL NOINLINE voidgeneric_4_byte( GLint rop, const void * ptr ){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint cmdlen = 8; emit_header(gc->pc, rop, cmdlen); (void) memcpy((void *)(gc->pc + 4), ptr, 4); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }}static FASTCALL NOINLINE voidgeneric_6_byte( GLint rop, const void * ptr ){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint cmdlen = 12; emit_header(gc->pc, rop, cmdlen); (void) memcpy((void *)(gc->pc + 4), ptr, 8); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }}static FASTCALL NOINLINE voidgeneric_8_byte( GLint rop, const void * ptr ){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint cmdlen = 12; emit_header(gc->pc, rop, cmdlen); (void) memcpy((void *)(gc->pc + 4), ptr, 8); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }}static FASTCALL NOINLINE voidgeneric_12_byte( GLint rop, const void * ptr ){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint cmdlen = 16; emit_header(gc->pc, rop, cmdlen); (void) memcpy((void *)(gc->pc + 4), ptr, 12); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }}static FASTCALL NOINLINE voidgeneric_16_byte( GLint rop, const void * ptr ){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint cmdlen = 20; emit_header(gc->pc, rop, cmdlen); (void) memcpy((void *)(gc->pc + 4), ptr, 16); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }}static FASTCALL NOINLINE voidgeneric_24_byte( GLint rop, const void * ptr ){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint cmdlen = 28; emit_header(gc->pc, rop, cmdlen); (void) memcpy((void *)(gc->pc + 4), ptr, 24); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }}static FASTCALL NOINLINE voidgeneric_32_byte( GLint rop, const void * ptr ){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint cmdlen = 36; emit_header(gc->pc, rop, cmdlen); (void) memcpy((void *)(gc->pc + 4), ptr, 32); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }}#define X_GLsop_NewList 101void__indirect_glNewList(GLuint list, GLenum mode){ __GLXcontext * const gc = __glXGetCurrentContext(); Display * const dpy = gc->currentDpy; const GLuint cmdlen = 8; if (__builtin_expect(dpy != NULL, 1)) {#ifdef USE_XCB XCBConnection *c = XCBConnectionOfDisplay(dpy); (void) __glXFlushRenderBuffer(gc, gc->pc); XCBGlxNewList(c, gc->currentContextTag, list, mode);#else GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_NewList, cmdlen); (void) memcpy((void *)(pc + 0), (void *)(&list), 4); (void) memcpy((void *)(pc + 4), (void *)(&mode), 4); UnlockDisplay(dpy); SyncHandle();#endif /* USE_XCB */ } return;}#define X_GLsop_EndList 102void__indirect_glEndList(void){ __GLXcontext * const gc = __glXGetCurrentContext(); Display * const dpy = gc->currentDpy; const GLuint cmdlen = 0; if (__builtin_expect(dpy != NULL, 1)) {#ifdef USE_XCB XCBConnection *c = XCBConnectionOfDisplay(dpy); (void) __glXFlushRenderBuffer(gc, gc->pc); XCBGlxEndList(c, gc->currentContextTag);#else (void) __glXSetupSingleRequest(gc, X_GLsop_EndList, cmdlen); UnlockDisplay(dpy); SyncHandle();#endif /* USE_XCB */ } return;}#define X_GLrop_CallList 1void__indirect_glCallList(GLuint list){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint cmdlen = 8; emit_header(gc->pc, X_GLrop_CallList, cmdlen); (void) memcpy((void *)(gc->pc + 4), (void *)(&list), 4); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }}#define X_GLrop_CallLists 2void__indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists){ __GLXcontext * const gc = __glXGetCurrentContext(); const GLuint compsize = __glCallLists_size(type); const GLuint cmdlen = 12 + __GLX_PAD((compsize * n)); if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) { if (cmdlen <= gc->maxSmallRenderCommandSize) { if ( (gc->pc + cmdlen) > gc->bufEnd ) { (void) __glXFlushRenderBuffer(gc, gc->pc); } emit_header(gc->pc, X_GLrop_CallLists, cmdlen); (void) memcpy((void *)(gc->pc + 4), (void *)(&n), 4); (void) memcpy((void *)(gc->pc + 8), (void *)(&type), 4); (void) memcpy((void *)(gc->pc + 12), (void *)(lists), (compsize * n)); gc->pc += cmdlen; if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); } } else { const GLint op = X_GLrop_CallLists; const GLuint cmdlenLarge = cmdlen + 4; GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc); (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4); (void) memcpy((void *)(pc + 4), (void *)(&op), 4); (void) memcpy((void *)(pc + 8), (void *)(&n), 4); (void) memcpy((void *)(pc + 12), (void *)(&type), 4); __glXSendLargeCommand(gc, pc, 16, lists, (compsize * n)); } }}#define X_GLsop_DeleteLists 103void__indirect_glDeleteLists(GLuint list, GLsizei range){ __GLXcontext * const gc = __glXGetCurrentContext(); Display * const dpy = gc->currentDpy; const GLuint cmdlen = 8; if (__builtin_expect(dpy != NULL, 1)) {#ifdef USE_XCB XCBConnection *c = XCBConnectionOfDisplay(dpy); (void) __glXFlushRenderBuffer(gc, gc->pc); XCBGlxDeleteLists(c, gc->currentContextTag, list, range);#else GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_DeleteLists, cmdlen); (void) memcpy((void *)(pc + 0), (void *)(&list), 4); (void) memcpy((void *)(pc + 4), (void *)(&range), 4); UnlockDisplay(dpy); SyncHandle();#endif /* USE_XCB */ } return;}#define X_GLsop_GenLists 104GLuint__indirect_glGenLists(GLsizei range){ __GLXcontext * const gc = __glXGetCurrentContext(); Display * const dpy = gc->currentDpy; GLuint retval = (GLuint) 0; const GLuint cmdlen = 4; if (__builtin_expect(dpy != NULL, 1)) {#ifdef USE_XCB XCBConnection *c = XCBConnectionOfDisplay(dpy); (void) __glXFlushRenderBuffer(gc, gc->pc); XCBGlxGenListsRep *reply = XCBGlxGenListsReply(c, XCBGlxGenLists(c, gc->currentContextTag, range), NULL); retval = reply->ret_val; free(reply);#else GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GenLists, cmdlen); (void) memcpy((void *)(pc + 0), (void *)(&range), 4); retval = (GLuint) __glXReadReply(dpy, 0, NULL, GL_FALSE); UnlockDisplay(dpy); SyncHandle();#endif /* USE_XCB */ }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -