aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/glx/extension_string.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
committermarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
commit3562e78743202e43aec8727005182a2558117eca (patch)
tree8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /xorg-server/glx/extension_string.c
downloadvcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz
vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2
vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip
Checked in the following released items:
xkeyboard-config-1.4.tar.gz ttf-bitstream-vera-1.10.tar.gz font-alias-1.0.1.tar.gz font-sun-misc-1.0.0.tar.gz font-sun-misc-1.0.0.tar.gz font-sony-misc-1.0.0.tar.gz font-schumacher-misc-1.0.0.tar.gz font-mutt-misc-1.0.0.tar.gz font-misc-misc-1.0.0.tar.gz font-misc-meltho-1.0.0.tar.gz font-micro-misc-1.0.0.tar.gz font-jis-misc-1.0.0.tar.gz font-isas-misc-1.0.0.tar.gz font-dec-misc-1.0.0.tar.gz font-daewoo-misc-1.0.0.tar.gz font-cursor-misc-1.0.0.tar.gz font-arabic-misc-1.0.0.tar.gz font-winitzki-cyrillic-1.0.0.tar.gz font-misc-cyrillic-1.0.0.tar.gz font-cronyx-cyrillic-1.0.0.tar.gz font-screen-cyrillic-1.0.1.tar.gz font-xfree86-type1-1.0.1.tar.gz font-adobe-utopia-type1-1.0.1.tar.gz font-ibm-type1-1.0.0.tar.gz font-bitstream-type1-1.0.0.tar.gz font-bitstream-speedo-1.0.0.tar.gz font-bh-ttf-1.0.0.tar.gz font-bh-type1-1.0.0.tar.gz font-bitstream-100dpi-1.0.0.tar.gz font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz font-bh-100dpi-1.0.0.tar.gz font-adobe-utopia-100dpi-1.0.1.tar.gz font-adobe-100dpi-1.0.0.tar.gz font-util-1.0.1.tar.gz font-bitstream-75dpi-1.0.0.tar.gz font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz font-adobe-utopia-75dpi-1.0.1.tar.gz font-bh-75dpi-1.0.0.tar.gz bdftopcf-1.0.1.tar.gz font-adobe-75dpi-1.0.0.tar.gz mkfontscale-1.0.6.tar.gz openssl-0.9.8k.tar.gz bigreqsproto-1.0.2.tar.gz xtrans-1.2.2.tar.gz resourceproto-1.0.2.tar.gz inputproto-1.4.4.tar.gz compositeproto-0.4.tar.gz damageproto-1.1.0.tar.gz zlib-1.2.3.tar.gz xkbcomp-1.0.5.tar.gz freetype-2.3.9.tar.gz pthreads-w32-2-8-0-release.tar.gz pixman-0.12.0.tar.gz kbproto-1.0.3.tar.gz evieext-1.0.2.tar.gz fixesproto-4.0.tar.gz recordproto-1.13.2.tar.gz randrproto-1.2.2.tar.gz scrnsaverproto-1.1.0.tar.gz renderproto-0.9.3.tar.gz xcmiscproto-1.1.2.tar.gz fontsproto-2.0.2.tar.gz xextproto-7.0.3.tar.gz xproto-7.0.14.tar.gz libXdmcp-1.0.2.tar.gz libxkbfile-1.0.5.tar.gz libfontenc-1.0.4.tar.gz libXfont-1.3.4.tar.gz libX11-1.1.5.tar.gz libXau-1.0.4.tar.gz libxcb-1.1.tar.gz xorg-server-1.5.3.tar.gz
Diffstat (limited to 'xorg-server/glx/extension_string.c')
-rw-r--r--xorg-server/glx/extension_string.c165
1 files changed, 165 insertions, 0 deletions
diff --git a/xorg-server/glx/extension_string.c b/xorg-server/glx/extension_string.c
new file mode 100644
index 000000000..a4b202af3
--- /dev/null
+++ b/xorg-server/glx/extension_string.c
@@ -0,0 +1,165 @@
+/*
+ * (C) Copyright IBM Corporation 2002-2006
+ * 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
+ * on 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
+ * THE COPYRIGHT HOLDERS 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.
+ */
+
+/**
+ * \file extension_string.c
+ * Routines to manage the GLX extension string and GLX version for AIGLX
+ * drivers. This code is loosely based on src/glx/x11/glxextensions.c from
+ * Mesa.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <string.h>
+#include "extension_string.h"
+
+#define SET_BIT(m,b) (m[ (b) / 8 ] |= (1U << ((b) % 8)))
+#define CLR_BIT(m,b) (m[ (b) / 8 ] &= ~(1U << ((b) % 8)))
+#define IS_SET(m,b) ((m[ (b) / 8 ] & (1U << ((b) % 8))) != 0)
+#define CONCAT(a,b) a ## b
+#define GLX(n) "GLX_" # n, 4 + sizeof( # n ) - 1, CONCAT(n,_bit)
+#define VER(a,b) a, b
+#define Y 1
+#define N 0
+#define EXT_ENABLED(bit,supported) (IS_SET(supported, bit))
+
+struct extension_info {
+ const char * const name;
+ unsigned name_len;
+
+ unsigned char bit;
+
+ /**
+ * This is the lowest version of GLX that "requires" this extension.
+ * For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and
+ * SGI_make_current_read. If the extension is not required by any known
+ * version of GLX, use 0, 0.
+ */
+ unsigned char version_major;
+ unsigned char version_minor;
+
+ /**
+ * Is driver support forced by the ABI?
+ */
+ unsigned char driver_support;
+};
+
+static const struct extension_info known_glx_extensions[] = {
+/* GLX_ARB_get_proc_address is implemented on the client. */
+ { GLX(ARB_multisample), VER(1,4), Y, },
+
+ { GLX(EXT_import_context), VER(0,0), Y, },
+ { GLX(EXT_texture_from_pixmap), VER(0,0), Y, },
+ { GLX(EXT_visual_info), VER(0,0), Y, },
+ { GLX(EXT_visual_rating), VER(0,0), Y, },
+
+ { GLX(MESA_copy_sub_buffer), VER(0,0), N, },
+ { GLX(OML_swap_method), VER(0,0), Y, },
+ { GLX(SGI_make_current_read), VER(1,3), N, },
+ { GLX(SGI_swap_control), VER(0,0), N, },
+ { GLX(SGIS_multisample), VER(0,0), Y, },
+ { GLX(SGIX_fbconfig), VER(1,3), Y, },
+ { GLX(SGIX_pbuffer), VER(1,3), N, },
+ { GLX(SGIX_visual_select_group), VER(0,0), Y, },
+ { NULL }
+};
+
+
+/**
+ * Create a GLX extension string for a set of enable bits.
+ *
+ * Creates a GLX extension string for the set of bit in \c enable_bits. This
+ * string is then stored in \c buffer if buffer is not \c NULL. This allows
+ * two-pass operation. On the first pass the caller passes \c NULL for
+ * \c buffer, and the function determines how much space is required to store
+ * the extension string. The caller allocates the buffer and calls the
+ * function again.
+ *
+ * \param enable_bits Bits representing the enabled extensions.
+ * \param buffer Buffer to store the extension string. May be \c NULL.
+ *
+ * \return
+ * The number of characters in \c buffer that were written to. If \c buffer
+ * is \c NULL, this is the size of buffer that must be allocated by the
+ * caller.
+ */
+int
+__glXGetExtensionString(const unsigned char *enable_bits, char *buffer)
+{
+ unsigned i;
+ int length = 0;
+
+
+ for (i = 0; known_glx_extensions[i].name != NULL; i++) {
+ const unsigned bit = known_glx_extensions[i].bit;
+ const size_t len = known_glx_extensions[i].name_len;
+
+ if (EXT_ENABLED(bit, enable_bits)) {
+ if (buffer != NULL) {
+ (void) memcpy(& buffer[length], known_glx_extensions[i].name,
+ len);
+
+ buffer[length + len + 0] = ' ';
+ buffer[length + len + 1] = '\0';
+ }
+
+ length += len + 1;
+ }
+ }
+
+ return length + 1;
+}
+
+
+void
+__glXEnableExtension(unsigned char *enable_bits, const char *ext)
+{
+ const size_t ext_name_len = strlen(ext);
+ unsigned i;
+
+
+ for (i = 0; known_glx_extensions[i].name != NULL; i++) {
+ if ((ext_name_len == known_glx_extensions[i].name_len)
+ && (memcmp(ext, known_glx_extensions[i].name, ext_name_len) == 0)) {
+ SET_BIT(enable_bits, known_glx_extensions[i].bit);
+ break;
+ }
+ }
+}
+
+
+void
+__glXInitExtensionEnableBits(unsigned char *enable_bits)
+{
+ unsigned i;
+
+
+ (void) memset(enable_bits, 0, __GLX_EXT_BYTES);
+
+ for (i = 0; known_glx_extensions[i].name != NULL; i++) {
+ if (known_glx_extensions[i].driver_support) {
+ SET_BIT(enable_bits, known_glx_extensions[i].bit);
+ }
+ }
+}