xserver

xserver with xephyr scale patch
git clone https://git.neptards.moe/u3shit/xserver.git
Log | Files | Refs | README | LICENSE

vndservervendor.c (3411B)


      1 /*
      2  * Copyright (c) 2016, NVIDIA CORPORATION.
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and/or associated documentation files (the
      6  * "Materials"), to deal in the Materials without restriction, including
      7  * without limitation the rights to use, copy, modify, merge, publish,
      8  * distribute, sublicense, and/or sell copies of the Materials, and to
      9  * permit persons to whom the Materials are furnished to do so, subject to
     10  * the following conditions:
     11  *
     12  * The above copyright notice and this permission notice shall be included
     13  * unaltered in all copies or substantial portions of the Materials.
     14  * Any additions, deletions, or changes to the original source files
     15  * must be clearly indicated in accompanying documentation.
     16  *
     17  * If only executable code is distributed, then the accompanying
     18  * documentation must state that "this software is based in part on the
     19  * work of the Khronos Group."
     20  *
     21  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     24  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
     25  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     26  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     27  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
     28  */
     29 
     30 #include "vndservervendor.h"
     31 
     32 struct xorg_list GlxVendorList = { &GlxVendorList, &GlxVendorList };
     33 
     34 GlxServerVendor *GlxCreateVendor(const GlxServerImports *imports)
     35 {
     36     GlxServerVendor *vendor = NULL;
     37 
     38     if (imports == NULL) {
     39         ErrorF("GLX: Vendor library did not provide an imports table\n");
     40         return NULL;
     41     }
     42 
     43     if (imports->extensionCloseDown == NULL
     44             || imports->handleRequest == NULL
     45             || imports->getDispatchAddress == NULL
     46             || imports->makeCurrent == NULL) {
     47         ErrorF("GLX: Vendor library is missing required callback functions.\n");
     48         return NULL;
     49     }
     50 
     51     vendor = (GlxServerVendor *) calloc(1, sizeof(GlxServerVendor));
     52     if (vendor == NULL) {
     53         ErrorF("GLX: Can't allocate vendor library.\n");
     54         return NULL;
     55     }
     56     memcpy(&vendor->glxvc, imports, sizeof(GlxServerImports));
     57 
     58     xorg_list_append(&vendor->entry, &GlxVendorList);
     59     return vendor;
     60 }
     61 
     62 void GlxDestroyVendor(GlxServerVendor *vendor)
     63 {
     64     if (vendor != NULL) {
     65         xorg_list_del(&vendor->entry);
     66         free(vendor);
     67     }
     68 }
     69 
     70 void GlxVendorExtensionReset(const ExtensionEntry *extEntry)
     71 {
     72     GlxServerVendor *vendor, *tempVendor;
     73 
     74     // TODO: Do we allow the driver to destroy a vendor library handle from
     75     // here?
     76     xorg_list_for_each_entry_safe(vendor, tempVendor, &GlxVendorList, entry) {
     77         if (vendor->glxvc.extensionCloseDown != NULL) {
     78             vendor->glxvc.extensionCloseDown(extEntry);
     79         }
     80     }
     81 
     82     // If the server is exiting instead of starting a new generation, then
     83     // free the remaining GlxServerVendor structs.
     84     //
     85     // XXX this used to be conditional on xf86ServerIsExiting, but it's
     86     // cleaner to just always create the vendor struct on every generation,
     87     // if nothing else so all ddxes get the same behavior.
     88     xorg_list_for_each_entry_safe(vendor, tempVendor, &GlxVendorList, entry) {
     89         GlxDestroyVendor(vendor);
     90     }
     91 }