~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/glx/glx_query.c

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * (C) Copyright IBM Corporation 2004
3
 
 * All Rights Reserved.
4
 
 *
5
 
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 
 * copy of this software and associated documentation files (the "Software"),
7
 
 * to deal in the Software without restriction, including without limitation
8
 
 * on the rights to use, copy, modify, merge, publish, distribute, sub
9
 
 * license, and/or sell copies of the Software, and to permit persons to whom
10
 
 * the Software is furnished to do so, subject to the following conditions:
11
 
 *
12
 
 * The above copyright notice and this permission notice (including the next
13
 
 * paragraph) shall be included in all copies or substantial portions of the
14
 
 * Software.
15
 
 *
16
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
19
 
 * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 
 * DEALINGS IN THE SOFTWARE.
23
 
 */
24
 
 
25
 
/**
26
 
 * \file glx_query.c
27
 
 * Generic utility functions to query internal data from the server.
28
 
 *
29
 
 * \author Ian Romanick <idr@us.ibm.com>
30
 
 */
31
 
 
32
 
#include "glxclient.h"
33
 
 
34
 
# include <X11/Xlib-xcb.h>
35
 
# include <xcb/xcb.h>
36
 
# include <xcb/glx.h>
37
 
 
38
 
 
39
 
/**
40
 
 * Exchange a protocol request for glXQueryServerString.
41
 
 */
42
 
char *
43
 
__glXQueryServerString(Display * dpy, CARD32 screen, CARD32 name)
44
 
{
45
 
   xcb_connection_t *c = XGetXCBConnection(dpy);
46
 
   xcb_glx_query_server_string_reply_t *reply =
47
 
      xcb_glx_query_server_string_reply(c,
48
 
                                        xcb_glx_query_server_string(c,
49
 
                                                                    screen,
50
 
                                                                    name),
51
 
                                        NULL);
52
 
 
53
 
   if (!reply)
54
 
      return NULL;
55
 
 
56
 
   /* The spec doesn't mention this, but the Xorg server replies with
57
 
    * a string already terminated with '\0'. */
58
 
   uint32_t len = xcb_glx_query_server_string_string_length(reply);
59
 
   char *buf = malloc(len);
60
 
   memcpy(buf, xcb_glx_query_server_string_string(reply), len);
61
 
   free(reply);
62
 
 
63
 
   return buf;
64
 
}
65
 
 
66
 
/**
67
 
 * Exchange a protocol request for glGetString.
68
 
 */
69
 
char *
70
 
__glXGetString(Display * dpy, CARD32 contextTag, CARD32 name)
71
 
{
72
 
   xcb_connection_t *c = XGetXCBConnection(dpy);
73
 
   xcb_glx_get_string_reply_t *reply = xcb_glx_get_string_reply(c,
74
 
                                                                xcb_glx_get_string
75
 
                                                                (c,
76
 
                                                                 contextTag,
77
 
                                                                 name),
78
 
                                                                NULL);
79
 
 
80
 
   if (!reply)
81
 
      return NULL;
82
 
 
83
 
   /* The spec doesn't mention this, but the Xorg server replies with
84
 
    * a string already terminated with '\0'. */
85
 
   uint32_t len = xcb_glx_get_string_string_length(reply);
86
 
   char *buf = malloc(len);
87
 
   memcpy(buf, xcb_glx_get_string_string(reply), len);
88
 
   free(reply);
89
 
 
90
 
   return buf;
91
 
}
92