~ubuntu-branches/ubuntu/precise/xorg-server/precise-updates

« back to all changes in this revision

Viewing changes to hw/dmx/glxProxy/glxcmds.c

Tags: 2:1.10.1-2
* Build xserver-xorg-core-udeb on hurd-i386.  Thanks, Samuel Thibault!
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "dmxfont.h"
39
39
#include "dmxsync.h"
40
40
 
41
 
#undef Xmalloc
42
 
#undef Xcalloc
43
 
#undef Xrealloc
44
 
#undef Xfree
45
 
 
46
41
#include "glxserver.h"
47
42
#include <GL/glxtokens.h>
48
43
#include "g_disptab.h"
106
101
    int from_screen = screen;
107
102
    int to_screen = screen;
108
103
    DMXScreenInfo *dmxScreen;
109
 
    VisualID be_vid;
110
 
    GLXFBConfigID be_fbconfigId;
 
104
    VisualID be_vid = 0;
 
105
    GLXFBConfigID be_fbconfigId = 0;
111
106
    int num_be_screens;
112
107
    Display *dpy;
113
108
    
134
129
    if (shareList == None) {
135
130
       shareglxc = NULL;
136
131
    } else {
137
 
       shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes);
 
132
       dixLookupResourceByType((pointer*) &shareglxc, shareList,
 
133
                               __glXContextRes, NullClient, DixUnknownAccess);
138
134
       if (!shareglxc) {
139
135
          client->errorValue = shareList;
140
136
          return __glXBadContext;
144
140
    /*
145
141
    ** Allocate memory for the new context
146
142
    */
147
 
    glxc = __glXCalloc(1, sizeof(__GLXcontext));
 
143
    glxc = calloc(1, sizeof(__GLXcontext));
148
144
    if (!glxc) {
149
145
        return BadAlloc;
150
146
    }
156
152
       glxc->pFBConfig = glxLookupFBConfig( fbconfigId );
157
153
       if (!glxc->pFBConfig) {
158
154
          client->errorValue = fbconfigId;
159
 
          __glXFree( glxc );
 
155
          free( glxc );
160
156
          return BadValue;
161
157
       }
162
158
       visual = glxc->pFBConfig->associatedVisualId;
177
173
       }
178
174
       if (i == pScreen->numVisuals) {
179
175
          client->errorValue = visual;
180
 
          __glXFree( glxc );
 
176
          free( glxc );
181
177
          return BadValue;
182
178
       }
183
179
 
192
188
           ** Visual not support on this screen by this OpenGL implementation.
193
189
           */
194
190
          client->errorValue = visual;
195
 
          __glXFree( glxc );
 
191
          free( glxc );
196
192
          return BadValue;
197
193
       }
198
194
 
203
199
              /*
204
200
               * visual does not have an FBConfig ???
205
201
              client->errorValue = visual;
206
 
              __glXFree( glxc );
 
202
              free( glxc );
207
203
              return BadValue;
208
204
               */
209
205
           }
223
219
     * allocate memory for back-end servers info
224
220
     */
225
221
    num_be_screens = to_screen - from_screen + 1;
226
 
    glxc->real_ids = (XID *)__glXMalloc(sizeof(XID) * num_be_screens);
 
222
    glxc->real_ids = (XID *)malloc(sizeof(XID) * num_be_screens);
227
223
    if (!glxc->real_ids) {
228
224
        return BadAlloc;
229
225
    }
230
 
    glxc->real_vids = (XID *)__glXMalloc(sizeof(XID) * num_be_screens);
 
226
    glxc->real_vids = (XID *)malloc(sizeof(XID) * num_be_screens);
231
227
    if (!glxc->real_vids) {
232
228
        return BadAlloc;
233
229
    }
252
248
 
253
249
          if (!be_vid) {
254
250
             /* visual is not supported on the back-end server */
255
 
             __glXFree( glxc->real_ids );
256
 
             __glXFree( glxc->real_vids );
257
 
             __glXFree( glxc );
 
251
             free( glxc->real_ids );
 
252
             free( glxc->real_vids );
 
253
             free( glxc );
258
254
             return BadValue;
259
255
          }
260
256
       }
346
342
    ** Register this context as a resource.
347
343
    */
348
344
    if (!AddResource(gcId, __glXContextRes, (pointer)glxc)) {
349
 
       __glXFree( glxc->real_ids );
350
 
       __glXFree( glxc->real_vids );
351
 
       __glXFree( glxc );
 
345
       free( glxc->real_ids );
 
346
       free( glxc->real_vids );
 
347
       free( glxc );
352
348
        client->errorValue = gcId;
353
349
        return BadAlloc;
354
350
    }
425
421
 
426
422
    rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixGetAttrAccess);
427
423
    if (rc != Success) {
428
 
        pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable,
429
 
                                                    __glXPixmapRes);
 
424
        dixLookupResourceByType((pointer*) &pGlxPixmap, req->drawable,
 
425
                                __glXPixmapRes, NullClient, DixUnknownAccess);
430
426
        if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
431
427
    }
432
428
 
433
429
    if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
434
 
       pGlxWindow = (__glXWindow *) LookupIDByType(req->drawable,
435
 
                                                   __glXWindowRes);
 
430
       dixLookupResourceByType((pointer*) &pGlxWindow, req->drawable,
 
431
                               __glXWindowRes, NullClient, DixUnknownAccess);
436
432
       if (pGlxWindow) pDraw = pGlxWindow->pDraw;
437
433
    }
438
434
 
455
451
 
456
452
    rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixManageAccess);
457
453
    if (rc != Success) {
458
 
        pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable,
459
 
                                                    __glXPixmapRes);
 
454
        dixLookupResourceByType((pointer*) &pGlxPixmap, req->drawable,
 
455
                                __glXPixmapRes, NullClient, DixUnknownAccess);
460
456
        if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
461
457
    }
462
458
 
463
459
    if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
464
 
       pGlxWindow = (__glXWindow *) LookupIDByType(req->drawable,
465
 
                                                   __glXWindowRes);
 
460
       dixLookupResourceByType((pointer*) &pGlxWindow, req->drawable,
 
461
                               __glXWindowRes, NullClient, DixUnknownAccess);
466
462
       if (pGlxWindow) pDraw = pGlxWindow->pDraw;
467
463
    }
468
464
 
475
471
        rc = dixLookupDrawable(&pMember, req->member, client, 0,
476
472
                               DixGetAttrAccess);
477
473
        if (rc != Success) {
478
 
            pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->member,
479
 
                                                        __glXPixmapRes);
 
474
            dixLookupResourceByType((pointer*) &pGlxPixmap, req->member,
 
475
                                    __glXPixmapRes, NullClient,
 
476
                                    DixUnknownAccess);
480
477
            if (pGlxPixmap) pMember = pGlxPixmap->pDraw;
481
478
        }
482
479
 
483
480
        if (!pMember && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
484
 
            pGlxWindow = (__glXWindow *) LookupIDByType(req->member,
485
 
                                                        __glXWindowRes);
 
481
            dixLookupResourceByType((pointer*) &pGlxWindow, req->member,
 
482
                                    __glXWindowRes, NullClient,
 
483
                                    DixUnknownAccess);
486
484
            if (pGlxWindow) pMember = pGlxWindow->pDraw;
487
485
        }
488
486
 
510
508
    int to_screen = 0;
511
509
    int s;
512
510
    
513
 
    glxc = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes);
 
511
    dixLookupResourceByType((pointer*) &glxc, gcId, __glXContextRes,
 
512
                            NullClient, DixUnknownAccess);
514
513
    if (glxc) {
515
514
        /*
516
515
        ** Just free the resource; don't actually destroy the context,
585
584
    ** Didn't find a free slot, so we'll have to grow the table.
586
585
    */
587
586
    if (!num) {
588
 
        table = (__GLXcontext **) __glXMalloc(sizeof(__GLXcontext *));
589
 
        cl->currentDrawables = (DrawablePtr *) __glXMalloc(sizeof(DrawablePtr));
590
 
        cl->be_currentCTag = (GLXContextTag *) __glXMalloc(screenInfo.numScreens *sizeof(GLXContextTag));
 
587
        table = (__GLXcontext **) malloc(sizeof(__GLXcontext *));
 
588
        cl->currentDrawables = (DrawablePtr *) malloc(sizeof(DrawablePtr));
 
589
        cl->be_currentCTag = (GLXContextTag *) malloc(screenInfo.numScreens *sizeof(GLXContextTag));
591
590
    } else {
592
 
        table = (__GLXcontext **) __glXRealloc(table,
 
591
        table = (__GLXcontext **) realloc(table,
593
592
                                           (num+1)*sizeof(__GLXcontext *));
594
 
        cl->currentDrawables = (DrawablePtr *) __glXRealloc(
 
593
        cl->currentDrawables = (DrawablePtr *) realloc(
595
594
                                                  cl->currentDrawables ,
596
595
                                                  (num+1)*sizeof(DrawablePtr));
597
 
        cl->be_currentCTag = (GLXContextTag *) __glXRealloc(cl->be_currentCTag,
 
596
        cl->be_currentCTag = (GLXContextTag *) realloc(cl->be_currentCTag,
598
597
                    (num+1)*screenInfo.numScreens*sizeof(GLXContextTag));
599
598
    }
600
599
    table[num] = glxc;
757
756
    ** Lookup new context.  It must not be current for someone else.
758
757
    */
759
758
    if (contextId != None) {
760
 
        glxc = (__GLXcontext *) LookupIDByType(contextId, __glXContextRes);
 
759
        dixLookupResourceByType((pointer*) &glxc, contextId, __glXContextRes,
 
760
                                NullClient, DixUnknownAccess);
761
761
        if (!glxc) {
762
762
            client->errorValue = contextId;
763
763
            return __glXBadContext;
807
807
        }
808
808
 
809
809
        if (!pDraw) {
810
 
            pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
811
 
                                                        __glXPixmapRes);
 
810
            dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
 
811
                                    __glXPixmapRes, NullClient,
 
812
                                    DixUnknownAccess);
812
813
            if (pGlxPixmap) {
813
814
                /*
814
815
                ** Check if pixmap and context are similar.
831
832
        }
832
833
 
833
834
        if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
834
 
           pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
 
835
           dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
 
836
                                   __glXWindowRes, NullClient,
 
837
                                   DixUnknownAccess);
835
838
            if (pGlxWindow) {
836
839
                /*
837
840
                ** Drawable is a GLXWindow.
852
855
        }
853
856
 
854
857
        if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
855
 
           pGlxPbuffer = (__glXPbuffer *)LookupIDByType(drawId, __glXPbufferRes);
 
858
           dixLookupResourceByType((pointer*) &pGlxPbuffer, drawId,
 
859
                                   __glXPbufferRes, NullClient,
 
860
                                   DixUnknownAccess);
856
861
           if (pGlxPbuffer) {
857
862
                if (pGlxPbuffer->pScreen != glxc->pScreen ||
858
863
                    pGlxPbuffer->pFBConfig != glxc->pFBConfig) {
913
918
        }
914
919
 
915
920
        if (!pReadDraw) {
916
 
            pReadGlxPixmap = (__GLXpixmap *) LookupIDByType(readId,
917
 
                                                        __glXPixmapRes);
 
921
            dixLookupResourceByType((pointer*) &pReadGlxPixmap, readId,
 
922
                                    __glXPixmapRes, NullClient,
 
923
                                    DixUnknownAccess);
918
924
            if (pReadGlxPixmap) {
919
925
                /*
920
926
                ** Check if pixmap and context are similar.
934
940
        }
935
941
 
936
942
        if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
937
 
           pGlxReadWindow = (__glXWindow *)
938
 
                                LookupIDByType(readId, __glXWindowRes);
 
943
           dixLookupResourceByType((pointer*) &pGlxReadWindow, readId,
 
944
                                   __glXWindowRes, NullClient,
 
945
                                   DixUnknownAccess);
939
946
            if (pGlxReadWindow) {
940
947
                /*
941
948
                ** Drawable is a GLXWindow.
955
962
        }
956
963
 
957
964
        if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
958
 
           pGlxReadPbuffer = (__glXPbuffer *)LookupIDByType(readId, __glXPbufferRes);
 
965
           dixLookupResourceByType((pointer*) &pGlxReadPbuffer, readId,
 
966
                                   __glXPbufferRes, NullClient,
 
967
                                   DixUnknownAccess);
959
968
           if (pGlxReadPbuffer) {
960
969
                if (pGlxReadPbuffer->pScreen != glxc->pScreen ||
961
970
                    pGlxReadPbuffer->pFBConfig != glxc->pFBConfig) {
1095
1104
       to_screen = screenInfo.numScreens - 1;
1096
1105
 
1097
1106
       if (pDraw && new_reply.writeType != GLX_PBUFFER_TYPE) {
1098
 
          pXinDraw = (PanoramiXRes *)
1099
 
             SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
 
1107
          dixLookupResourceByClass((pointer*) &pXinDraw,
 
1108
                                   pDraw->id, XRC_DRAWABLE,
 
1109
                                   client, DixReadAccess);
1100
1110
       }
1101
1111
 
1102
1112
       if (pReadDraw && pReadDraw != pDraw && 
1103
1113
             new_reply.readType != GLX_PBUFFER_TYPE) {
1104
 
          pXinReadDraw = (PanoramiXRes *)
1105
 
             SecurityLookupIDByClass(client, pReadDraw->id, XRC_DRAWABLE, DixReadAccess);
 
1114
          dixLookupResourceByClass((pointer*) &pXinReadDraw,
 
1115
                                   pReadDraw->id, XRC_DRAWABLE,
 
1116
                                   client, DixReadAccess);
1106
1117
       }
1107
1118
       else {
1108
1119
          pXinReadDraw = pXinDraw;
1308
1319
    /*
1309
1320
    ** Find the GL context.
1310
1321
    */
1311
 
    glxc = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes);
 
1322
    dixLookupResourceByType((pointer*) &glxc, req->context, __glXContextRes,
 
1323
                            NullClient, DixUnknownAccess);
1312
1324
    if (!glxc) {
1313
1325
        client->errorValue = req->context;
1314
1326
        return __glXBadContext;
1454
1466
    /*
1455
1467
    ** Check that each context exists.
1456
1468
    */
1457
 
    src = (__GLXcontext *) LookupIDByType(source, __glXContextRes);
 
1469
    dixLookupResourceByType((pointer*) &src, source, __glXContextRes,
 
1470
                            NullClient, DixUnknownAccess);
1458
1471
    if (!src) {
1459
1472
        client->errorValue = source;
1460
1473
        return __glXBadContext;
1461
1474
    }
1462
 
    dst = (__GLXcontext *) LookupIDByType(dest, __glXContextRes);
 
1475
    dixLookupResourceByType((pointer*) &dst, dest, __glXContextRes,
 
1476
                            NullClient, DixUnknownAccess);
1463
1477
    if (!dst) {
1464
1478
        client->errorValue = dest;
1465
1479
        return __glXBadContext;
1646
1660
        return BadMatch;
1647
1661
    }
1648
1662
 
1649
 
    if (fbconfigId == NULL && visual == NULL) {
 
1663
    if (fbconfigId == 0 && visual == 0) {
1650
1664
          return BadValue;
1651
1665
    }
1652
1666
 
1719
1733
    else {
1720
1734
       pVisual = NULL;
1721
1735
       pGlxVisual = NULL;
 
1736
       pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum];
1722
1737
    }
1723
1738
 
1724
 
    pGlxPixmap = (__GLXpixmap *) __glXMalloc(sizeof(__GLXpixmap));
 
1739
    pGlxPixmap = (__GLXpixmap *) malloc(sizeof(__GLXpixmap));
1725
1740
    if (!pGlxPixmap) {
1726
1741
        return BadAlloc;
1727
1742
    }
1728
 
    pGlxPixmap->be_xids = (XID *) __glXMalloc(sizeof(XID) * screenInfo.numScreens);
 
1743
    pGlxPixmap->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens);
1729
1744
    if (!pGlxPixmap->be_xids) {
1730
 
        __glXFree( pGlxPixmap );
 
1745
        free( pGlxPixmap );
1731
1746
        return BadAlloc;
1732
1747
    }
1733
1748
 
1753
1768
       from_screen = 0;
1754
1769
       to_screen = screenInfo.numScreens - 1;
1755
1770
 
1756
 
       pXinDraw = (PanoramiXRes *)
1757
 
          SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
 
1771
       dixLookupResourceByClass((pointer*) &pXinDraw,
 
1772
                                pDraw->id, XRC_DRAWABLE,
 
1773
                                client, DixReadAccess);
1758
1774
    }
1759
1775
#endif
1760
1776
 
1832
1848
       }
1833
1849
       else {
1834
1850
          client->errorValue = ( visual ? visual : fbconfigId );
1835
 
          __glXFree( pGlxPixmap );
 
1851
          free( pGlxPixmap );
1836
1852
          return BadValue;
1837
1853
       }
1838
1854
 
1840
1856
    }
1841
1857
 
1842
1858
    if (!(AddResource(glxpixmapId, __glXPixmapRes, pGlxPixmap))) {
1843
 
        __glXFree( pGlxPixmap );
 
1859
        free( pGlxPixmap );
1844
1860
        return BadAlloc;
1845
1861
    }
1846
1862
 
1875
1891
    /*
1876
1892
    ** Check if it's a valid GLX pixmap.
1877
1893
    */
1878
 
    pGlxPixmap = (__GLXpixmap *)LookupIDByType(glxpixmap, __glXPixmapRes);
 
1894
    dixLookupResourceByType((pointer*) &pGlxPixmap, glxpixmap,
 
1895
                            __glXPixmapRes, NullClient, DixUnknownAccess);
1879
1896
    if (!pGlxPixmap) {
1880
1897
        client->errorValue = glxpixmap;
1881
1898
        return __glXBadPixmap;
1958
1975
    } 
1959
1976
 
1960
1977
    if (!pDraw) {
1961
 
        pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
1962
 
                                                    __glXPixmapRes);
 
1978
        dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
 
1979
                                __glXPixmapRes, NullClient, DixUnknownAccess);
1963
1980
        if (pGlxPixmap) {
1964
1981
            /*
1965
1982
            ** Drawable is a GLX pixmap.
1970
1987
    }
1971
1988
 
1972
1989
    if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
1973
 
       pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
 
1990
       dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
 
1991
                               __glXWindowRes, NullClient, DixUnknownAccess);
1974
1992
       if (pGlxWindow) {
1975
1993
          /*
1976
1994
           ** Drawable is a GLXWindow.
1999
2017
    if (!noPanoramiXExtension) {
2000
2018
       from_screen = 0;
2001
2019
       to_screen = screenInfo.numScreens - 1;
2002
 
       pXinDraw = (PanoramiXRes *)
2003
 
        SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
 
2020
       dixLookupResourceByClass((pointer*) &pXinDraw,
 
2021
                                pDraw->id, XRC_DRAWABLE,
 
2022
                                client, DixReadAccess);
2004
2023
    }
2005
2024
#endif
2006
2025
 
2105
2124
    } 
2106
2125
 
2107
2126
    if (!pDraw) {
2108
 
        pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
2109
 
                                                    __glXPixmapRes);
 
2127
        dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
 
2128
                                __glXPixmapRes, NullClient, DixUnknownAccess);
2110
2129
        if (pGlxPixmap) {
2111
2130
            /*
2112
2131
            ** Drawable is a GLX pixmap.
2116
2135
    }
2117
2136
 
2118
2137
    if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
2119
 
       pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
 
2138
       dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
 
2139
                               __glXWindowRes, NullClient, DixUnknownAccess);
2120
2140
       if (pGlxWindow) {
2121
2141
          /*
2122
2142
           ** Drawable is a GLXWindow.
2570
2590
   
2571
2591
    cl->GLClientmajorVersion = req->major;
2572
2592
    cl->GLClientminorVersion = req->minor;
2573
 
    if (cl->GLClientextensions) __glXFree(cl->GLClientextensions);
 
2593
    free(cl->GLClientextensions);
2574
2594
    buf = (const char *)(req+1);
2575
2595
    cl->GLClientextensions = strdup(buf);
2576
2596
 
2625
2645
    ** Font can actually be either the ID of a font or the ID of a GC
2626
2646
    ** containing a font.
2627
2647
    */
2628
 
    pFont = (FontPtr)LookupIDByType(req->font, RT_FONT);
 
2648
    dixLookupResourceByType((pointer*) &pFont, req->font, RT_FONT,
 
2649
                            NullClient, DixUnknownAccess);
2629
2650
    if (!pFont) {
2630
 
        GC *pGC = (GC *)LookupIDByType(req->font, RT_GC);
 
2651
        GC *pGC;
 
2652
        dixLookupResourceByType((pointer*) &pGC, req->font,
 
2653
                                RT_GC, NullClient,
 
2654
                                DixUnknownAccess);
2631
2655
        if (!pGC) {
2632
2656
            client->errorValue = req->font;
2633
2657
            return BadFont;
2878
2902
    VisualPtr pVisual;
2879
2903
    VisualID visId;
2880
2904
    int i, rc;
 
2905
    pointer val;
2881
2906
 
2882
2907
    /*
2883
2908
    ** Check if windowId is valid 
2943
2968
    /*
2944
2969
    ** Check if there is already a fbconfig associated with this window
2945
2970
    */
2946
 
    if ( LookupIDByType(glxwindowId, __glXWindowRes) ) {
 
2971
    if (Success == dixLookupResourceByType(&val,
 
2972
                                           glxwindowId, __glXWindowRes,
 
2973
                                           NullClient, DixUnknownAccess)) {
2947
2974
        client->errorValue = glxwindowId;
2948
2975
        return BadAlloc;
2949
2976
    }
2975
3002
    ClientPtr client = cl->client;
2976
3003
    xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
2977
3004
    XID glxwindow = req->glxwindow;
 
3005
    pointer val;
2978
3006
 
2979
3007
    /*
2980
3008
    ** Check if it's a valid GLX window.
2981
3009
    */
2982
 
    if (!LookupIDByType(glxwindow, __glXWindowRes)) {
 
3010
    if (Success != dixLookupResourceByType(&val,
 
3011
                                           glxwindow, __glXWindowRes,
 
3012
                                           NullClient, DixUnknownAccess)) {
2983
3013
        client->errorValue = glxwindow;
2984
3014
        return __glXBadDrawable;
2985
3015
    }
3003
3033
    int nReplyBytes;
3004
3034
 
3005
3035
    req = (xGLXQueryContextReq *)pc;
3006
 
    ctx = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes);
 
3036
    dixLookupResourceByType((pointer*) &ctx, req->context, __glXContextRes,
 
3037
                            NullClient, DixUnknownAccess);
3007
3038
    if (!ctx) {
3008
3039
        client->errorValue = req->context;
3009
3040
        return __glXBadContext;
3048
3079
    int nReplyBytes;
3049
3080
 
3050
3081
    req = (xGLXQueryContextInfoEXTReq *)pc;
3051
 
    ctx = (__GLXcontext *) SecurityLookupIDByType(client, req->context, __glXContextRes, DixReadAccess);
 
3082
    dixLookupResourceByType((pointer*) &ctx,
 
3083
                            req->context, __glXContextRes,
 
3084
                            client,  DixReadAccess);
 
3085
 
3052
3086
    if (!ctx) {
3053
3087
        client->errorValue = req->context;
3054
3088
        return __glXBadContext;
3213
3247
    /*
3214
3248
    ** Check if it's a valid Pbuffer
3215
3249
    */
3216
 
    pGlxPbuffer = (__glXPbuffer *)LookupIDByType(pbuffer, __glXPbufferRes);
 
3250
    dixLookupResourceByType((pointer*) &pGlxPbuffer, pbuffer,
 
3251
                            __glXPbufferRes, NullClient, DixUnknownAccess);
3217
3252
    if (!pGlxPbuffer) {
3218
3253
        client->errorValue = pbuffer;
3219
3254
        return __glXBadPbuffer;
3261
3296
   int screen, rc;
3262
3297
   DMXScreenInfo *dmxScreen;
3263
3298
   CARD32 *attribs = NULL;
3264
 
   int attribs_size;
 
3299
   int attribs_size = 0;
3265
3300
#ifdef PANORAMIX
3266
3301
    PanoramiXRes *pXinDraw = NULL;
3267
3302
#endif
3268
3303
 
3269
3304
   if (drawId != None) {
3270
3305
      rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixGetAttrAccess);
3271
 
      if (rc == Success) {
3272
 
         if (pDraw->type == DRAWABLE_WINDOW) {
3273
 
                WindowPtr pWin = (WindowPtr)pDraw;
3274
 
                be_drawable = 0;
3275
 
                screen = pWin->drawable.pScreen->myNum;
3276
 
 
3277
 
         }
3278
 
         else {
3279
 
            /*
3280
 
             ** Drawable is not a Window , GLXWindow or a GLXPixmap.
3281
 
             */
3282
 
            client->errorValue = drawId;
3283
 
            return __glXBadDrawable;
3284
 
         }
 
3306
      if (rc == Success && pDraw->type == DRAWABLE_WINDOW) {
 
3307
         WindowPtr pWin = (WindowPtr)pDraw;
 
3308
         be_drawable = 0;
 
3309
         screen = pWin->drawable.pScreen->myNum;
 
3310
      } else {
 
3311
         /*
 
3312
          ** Drawable is not a Window , GLXWindow or a GLXPixmap.
 
3313
          */
 
3314
         client->errorValue = drawId;
 
3315
         return __glXBadDrawable;
3285
3316
      }
3286
3317
 
3287
3318
      if (!pDraw) {
3288
 
         __GLXpixmap *pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
3289
 
                                                        __glXPixmapRes);
 
3319
         __GLXpixmap *pGlxPixmap;
 
3320
         dixLookupResourceByType((pointer*) &pGlxPixmap,
 
3321
                                 drawId, __glXPixmapRes,
 
3322
                                 NullClient, DixUnknownAccess);
3290
3323
         if (pGlxPixmap) {
3291
3324
                pDraw = pGlxPixmap->pDraw;
3292
3325
                screen = pGlxPixmap->pScreen->myNum;
3295
3328
      }
3296
3329
 
3297
3330
      if (!pDraw) {
3298
 
         __glXWindow *pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
 
3331
         __glXWindow *pGlxWindow;
 
3332
         dixLookupResourceByType((pointer*) &pGlxWindow,
 
3333
                                 drawId, __glXWindowRes,
 
3334
                                 NullClient, DixUnknownAccess);
3299
3335
         if (pGlxWindow) {
3300
3336
            pDraw = pGlxWindow->pDraw;
3301
3337
            screen = pGlxWindow->pScreen->myNum;
3304
3340
      }
3305
3341
 
3306
3342
      if (!pDraw) {
3307
 
         __glXPbuffer *pGlxPbuffer = (__glXPbuffer *)LookupIDByType(drawId, __glXPbufferRes);
 
3343
         __glXPbuffer *pGlxPbuffer;
 
3344
         dixLookupResourceByType((pointer*) &pGlxPbuffer,
 
3345
                                 drawId, __glXPbufferRes,
 
3346
                                 NullClient, DixUnknownAccess);
3308
3347
         if (pGlxPbuffer) {
3309
3348
            pDraw = (DrawablePtr)pGlxPbuffer;
3310
3349
            screen = pGlxPbuffer->pScreen->myNum;
3311
3350
            be_drawable = pGlxPbuffer->be_xids[screen];
3312
3351
         }
3313
3352
      }
3314
 
 
3315
 
 
3316
 
      if (!pDraw) {
3317
 
         /*
3318
 
          ** Drawable is not a Window , GLXWindow or a GLXPixmap.
3319
 
          */
3320
 
         client->errorValue = drawId;
3321
 
         return __glXBadDrawable;
3322
 
      }
3323
3353
    }
3324
3354
 
 
3355
    if (!pDraw) {
 
3356
        /*
 
3357
         ** Drawable is not a Window , GLXWindow or a GLXPixmap.
 
3358
         */
 
3359
        client->errorValue = drawId;
 
3360
        return __glXBadDrawable;
 
3361
   }
3325
3362
 
3326
3363
   /* if the drawable is a window or GLXWindow - 
3327
3364
    * we need to find the base id on the back-end server
3331
3368
 
3332
3369
#ifdef PANORAMIX
3333
3370
       if (!noPanoramiXExtension) {
3334
 
          pXinDraw = (PanoramiXRes *)
3335
 
             SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
3336
 
          if (!pXinDraw) {
 
3371
          if (Success != dixLookupResourceByClass((pointer*) &pXinDraw,
 
3372
                                                  pDraw->id, XRC_DRAWABLE,
 
3373
                                                  client, DixReadAccess)) {
3337
3374
             client->errorValue = drawId;
3338
3375
             return __glXBadDrawable;
3339
3376
          }
3424
3461
 
3425
3462
   if (drawId != None) {
3426
3463
      rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixSetAttrAccess);
3427
 
      if (rc == Success) {
3428
 
         if (pDraw->type == DRAWABLE_WINDOW) {
3429
 
                WindowPtr pWin = (WindowPtr)pDraw;
3430
 
                be_drawable = 0;
3431
 
                screen = pWin->drawable.pScreen->myNum;
3432
 
 
3433
 
         }
3434
 
         else {
3435
 
            /*
3436
 
             ** Drawable is not a Window , GLXWindow or a GLXPixmap.
3437
 
             */
3438
 
            client->errorValue = drawId;
3439
 
            return __glXBadDrawable;
3440
 
         }
 
3464
      if (rc == Success && pDraw->type == DRAWABLE_WINDOW) {
 
3465
          be_drawable = 0;
 
3466
          screen = pDraw->pScreen->myNum;
 
3467
      } else {
 
3468
         /*
 
3469
          ** Drawable is not a Window , GLXWindow or a GLXPixmap.
 
3470
          */
 
3471
         client->errorValue = drawId;
 
3472
         return __glXBadDrawable;
3441
3473
      }
3442
3474
 
3443
3475
      if (!pDraw) {
3444
 
         __GLXpixmap *pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
3445
 
                                                        __glXPixmapRes);
 
3476
         __GLXpixmap *pGlxPixmap;
 
3477
         dixLookupResourceByType((pointer*) &pGlxPixmap,
 
3478
                                 drawId, __glXPixmapRes,
 
3479
                                 NullClient, DixUnknownAccess);
3446
3480
         if (pGlxPixmap) {
3447
3481
                pDraw = pGlxPixmap->pDraw;
3448
3482
                screen = pGlxPixmap->pScreen->myNum;
3451
3485
      }
3452
3486
 
3453
3487
      if (!pDraw) {
3454
 
         __glXWindow *pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
 
3488
         __glXWindow *pGlxWindow;
 
3489
         dixLookupResourceByType((pointer*) &pGlxWindow,
 
3490
                                 drawId, __glXWindowRes,
 
3491
                                 NullClient, DixUnknownAccess);
3455
3492
         if (pGlxWindow) {
3456
3493
            pDraw = pGlxWindow->pDraw;
3457
3494
            screen = pGlxWindow->pScreen->myNum;
3460
3497
      }
3461
3498
 
3462
3499
      if (!pDraw) {
3463
 
         __glXPbuffer *pGlxPbuffer = (__glXPbuffer *)LookupIDByType(drawId, __glXPbufferRes);
 
3500
         __glXPbuffer *pGlxPbuffer;
 
3501
         dixLookupResourceByType((pointer*) &pGlxPbuffer,
 
3502
                                 drawId, __glXPbufferRes,
 
3503
                                 NullClient, DixUnknownAccess);
3464
3504
         if (pGlxPbuffer) {
3465
3505
            pDraw = (DrawablePtr)pGlxPbuffer;
3466
3506
            screen = pGlxPbuffer->pScreen->myNum;
3467
3507
            be_drawable = pGlxPbuffer->be_xids[screen];
3468
3508
         }
3469
3509
      }
3470
 
 
3471
 
 
3472
 
      if (!pDraw) {
 
3510
   }
 
3511
 
 
3512
   if (!pDraw) {
3473
3513
         /*
3474
3514
          ** Drawable is not a Window , GLXWindow or a GLXPixmap.
3475
3515
          */
3476
3516
         client->errorValue = drawId;
3477
3517
         return __glXBadDrawable;
3478
 
      }
3479
 
    }
3480
 
 
 
3518
   }
3481
3519
 
3482
3520
   /* if the drawable is a window or GLXWindow - 
3483
3521
    * we need to find the base id on the back-end server
3487
3525
 
3488
3526
#ifdef PANORAMIX
3489
3527
       if (!noPanoramiXExtension) {
3490
 
          PanoramiXRes *pXinDraw = (PanoramiXRes *)
3491
 
             SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
3492
 
          if (!pXinDraw) {
 
3528
          PanoramiXRes *pXinDraw;
 
3529
          if (Success != dixLookupResourceByClass((pointer*) &pXinDraw,
 
3530
                                                  pDraw->id, XRC_DRAWABLE,
 
3531
                                                  client, DixReadAccess)) {
3493
3532
             client->errorValue = drawId;
3494
3533
             return __glXBadDrawable;
3495
3534
          }