diff options
Diffstat (limited to 'src/libXNVCtrlAttributes')
-rw-r--r-- | src/libXNVCtrlAttributes/Makefile.inc | 42 | ||||
-rw-r--r-- | src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c | 109 | ||||
-rw-r--r-- | src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h | 4 | ||||
-rw-r--r-- | src/libXNVCtrlAttributes/src.mk | 14 |
4 files changed, 78 insertions, 91 deletions
diff --git a/src/libXNVCtrlAttributes/Makefile.inc b/src/libXNVCtrlAttributes/Makefile.inc deleted file mode 100644 index 7c2a87c..0000000 --- a/src/libXNVCtrlAttributes/Makefile.inc +++ /dev/null @@ -1,42 +0,0 @@ -# -# nvidia-settings: A tool for configuring the NVIDIA X driver on Unix -# and Linux systems. -# -# Copyright (C) 2004 NVIDIA Corporation. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of Version 2 of the GNU General Public -# License as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See Version 2 -# of the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the: -# -# Free Software Foundation, Inc. -# 59 Temple Place - Suite 330 -# Boston, MA 02111-1307, USA -# - -# -# libXNVCtrlAttributes files -# - -SRC += \ - NvCtrlAttributes.c \ - NvCtrlAttributesNvControl.c \ - NvCtrlAttributesVidMode.c \ - NvCtrlAttributesXv.c \ - NvCtrlAttributesGlx.c \ - NvCtrlAttributesXrandr.c - -EXTRA_DIST += \ - Makefile.inc \ - NvCtrlAttributes.h \ - NvCtrlAttributesPrivate.h - -dist_list:: - @ echo $(SRC) $(EXTRA_DIST) diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c b/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c index 470ab44..0f38ba7 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c @@ -629,8 +629,8 @@ NvCtrlGlxGetVoidAttribute (NvCtrlAttributePrivateHandle *h, * OpenGL/GLX function. * * - * But first, the following macros are used to setup a rendering context - * such that valid information may be retrieved. (Having a context is + * But first, the following helper function may be used to set up a rendering + * context such that valid information may be retrieved. (Having a context is * required for getting OpenGL and 'Direct rendering' information.) * * NOTE: A seperate display connection is used to avoid the dependence on @@ -640,35 +640,14 @@ NvCtrlGlxGetVoidAttribute (NvCtrlAttributePrivateHandle *h, * ****/ -/* Macros to set up/tear down a rendering context */ - -#define GET_CONTEXT() \ - root = RootWindow(h->dpy, h->target_id); \ - visinfo = __libGL->glXChooseVisual(h->dpy, h->target_id, \ - &(attribListSgl[0])); \ - win_attr.background_pixel = 0; \ - win_attr.border_pixel = 0; \ - win_attr.colormap = XCreateColormap(h->dpy, root, \ - visinfo->visual, AllocNone); \ - win_attr.event_mask = 0; \ - mask = CWBackPixel | CWBorderPixel | CWColormap | \ - CWEventMask; \ - win = XCreateWindow(h->dpy, root, 0, 0, width, height, \ - 0, visinfo->depth, InputOutput, \ - visinfo->visual, mask, &win_attr); \ - ctx = __libGL->glXCreateContext(h->dpy, visinfo, NULL, True ); \ - if ( ctx ) { __libGL->glXMakeCurrent(h->dpy, win, ctx); } - -#define CLEAN_CONTEXT() \ - if ( visinfo ) { XFree(visinfo); } \ - if ( ctx ) { __libGL->glXDestroyContext(h->dpy, ctx); } \ - if ( win ) { XDestroyWindow(h->dpy, win); } - - -ReturnStatus -NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h, - unsigned int display_mask, - int attr, char **ptr) +/* + * Helper function for NvCtrlGlxGetStringAttribute for queries that require a + * current context. If getDirect is true, then check if we can create a direct + * GLX context and return "Yes" or "No". Otherwise, create a context and query + * the GLX implementation for the string specified in prop. + */ +static const char *getString(NvCtrlAttributePrivateHandle *h, + Bool getDirect, GLenum prop) { const char *str = NULL; @@ -687,7 +666,53 @@ NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None }; - + root = RootWindow(h->dpy, h->target_id); + visinfo = __libGL->glXChooseVisual(h->dpy, h->target_id, + &(attribListSgl[0])); + if (!visinfo) { + return NULL; + } + win_attr.background_pixel = 0; + win_attr.border_pixel = 0; + win_attr.colormap = XCreateColormap(h->dpy, root, + visinfo->visual, AllocNone); + win_attr.event_mask = 0; + mask = CWBackPixel | CWBorderPixel | CWColormap | + CWEventMask; + win = XCreateWindow(h->dpy, root, 0, 0, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &win_attr); + ctx = __libGL->glXCreateContext(h->dpy, visinfo, NULL, True ); + if ( ctx ) { + __libGL->glXMakeCurrent(h->dpy, win, ctx); + } + + if (getDirect) { + str = ((*(__libGL->glXIsDirect))(h->dpy, ctx)) ? "Yes" : "No"; + } else { + str = (const char *) (* (__libGL->glGetString))(prop); + } + + if (visinfo) { + XFree(visinfo); + } + if (ctx) { + __libGL->glXDestroyContext(h->dpy, ctx); + } + if (win) { + XDestroyWindow(h->dpy, win); + } + + return str; +} + +ReturnStatus +NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h, + unsigned int display_mask, + int attr, char **ptr) +{ + const char *str = NULL; + /* Validate */ if ( !h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN ) { return NvCtrlBadHandle; @@ -704,9 +729,7 @@ NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h, switch (attr) { case NV_CTRL_STRING_GLX_DIRECT_RENDERING: - GET_CONTEXT(); - str = ( (* (__libGL->glXIsDirect))(h->dpy, ctx) ) ? "Yes" : "No"; - CLEAN_CONTEXT(); + str = getString(h, True, 0); break; case NV_CTRL_STRING_GLX_GLX_EXTENSIONS: str = (* (__libGL->glXQueryExtensionsString))(h->dpy, h->target_id); @@ -733,24 +756,16 @@ NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h, str = (* (__libGL->glXGetClientString))(h->dpy, GLX_EXTENSIONS); break; case NV_CTRL_STRING_GLX_OPENGL_VENDOR: - GET_CONTEXT(); - str = (const char *) (* (__libGL->glGetString))(GL_VENDOR); - CLEAN_CONTEXT(); + str = getString(h, False, GL_VENDOR); break; case NV_CTRL_STRING_GLX_OPENGL_RENDERER: - GET_CONTEXT(); - str = (const char *) (* (__libGL->glGetString))(GL_RENDERER); - CLEAN_CONTEXT(); + str = getString(h, False, GL_RENDERER); break; case NV_CTRL_STRING_GLX_OPENGL_VERSION: - GET_CONTEXT(); - str = (const char *) (* (__libGL->glGetString))(GL_VERSION); - CLEAN_CONTEXT(); + str = getString(h, False, GL_VERSION); break; case NV_CTRL_STRING_GLX_OPENGL_EXTENSIONS: - GET_CONTEXT(); - str = (const char *) (* (__libGL->glGetString))(GL_EXTENSIONS); - CLEAN_CONTEXT(); + str = getString(h, False, GL_EXTENSIONS); break; default: diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h index f82089e..ea4a38d 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h @@ -136,8 +136,8 @@ struct __NvCtrlXvBlitterAttributes { }; struct __NvCtrlXvAttributes { - int major_version; - int minor_version; + unsigned int major_version; + unsigned int minor_version; NvCtrlXvOverlayAttributes *overlay; /* XVideo info (overlay) */ NvCtrlXvTextureAttributes *texture; /* XVideo info (texture) */ NvCtrlXvBlitterAttributes *blitter; /* XVideo info (blitter) */ diff --git a/src/libXNVCtrlAttributes/src.mk b/src/libXNVCtrlAttributes/src.mk new file mode 100644 index 0000000..e8f9609 --- /dev/null +++ b/src/libXNVCtrlAttributes/src.mk @@ -0,0 +1,14 @@ +# +# files in the src/libXNVCtrlAttributes directory of nvidia-settings +# + +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributes.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesNvControl.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesVidMode.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesXv.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesGlx.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesXrandr.c + +LIB_XNVCTRL_ATTRIBUTES_EXTRA_DIST += NvCtrlAttributes.h +LIB_XNVCTRL_ATTRIBUTES_EXTRA_DIST += NvCtrlAttributesPrivate.h +LIB_XNVCTRL_ATTRIBUTES_EXTRA_DIST += src.mk |