Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2012 Francisco Jerez
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the
  8.  * "Software"), to deal in the Software without restriction, including
  9.  * without limitation the rights to use, copy, modify, merge, publish,
  10.  * distribute, sub license, and/or sell copies of the Software, and to
  11.  * permit persons to whom the Software is furnished to do so, subject to
  12.  * the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21.  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  22.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  *
  26.  **************************************************************************/
  27.  
  28. #include "pipe_loader_priv.h"
  29.  
  30. #include "util/u_memory.h"
  31. #include "util/u_dl.h"
  32. #include "target-helpers/inline_sw_helper.h"
  33. #include "sw/kos_sw_winsys.h"
  34.  
  35. struct pipe_loader_sw_device {
  36.    struct pipe_loader_device base;
  37.    struct util_dl_library *lib;
  38.    struct sw_winsys *ws;
  39. };
  40.  
  41. #define pipe_loader_sw_device(dev) ((struct pipe_loader_sw_device *)dev)
  42.  
  43. static struct pipe_loader_ops pipe_loader_sw_ops;
  44.  
  45. static struct sw_winsys *(*backends[])() = {
  46. #ifdef HAVE_WINSYS_XLIB
  47.    x11_sw_create,
  48. #endif
  49.    kos_create_sw_winsys
  50. };
  51.  
  52. int
  53. pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev)
  54. {
  55.    int i;
  56.  
  57.    for (i = 0; i < Elements(backends); i++) {
  58.       if (i < ndev) {
  59.          struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
  60.  
  61.          sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
  62.          sdev->base.driver_name = "swrast";
  63.          sdev->base.ops = &pipe_loader_sw_ops;
  64.          sdev->ws = backends[i]();
  65.          devs[i] = &sdev->base;
  66.       }
  67.    }
  68.  
  69.    return i;
  70. }
  71.  
  72. static void
  73. pipe_loader_sw_release(struct pipe_loader_device **dev)
  74. {
  75.    struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
  76.  
  77. //   if (sdev->lib)
  78. //      util_dl_close(sdev->lib);
  79.  
  80.    FREE(sdev);
  81.    *dev = NULL;
  82. }
  83.  
  84. static struct pipe_screen *
  85. pipe_loader_sw_create_screen(struct pipe_loader_device *dev,
  86.                              const char *library_paths)
  87. {
  88.     struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(dev);
  89.     struct pipe_screen *(*init)(struct sw_winsys *);
  90.  
  91.     printf("%s\n",__FUNCTION__);
  92.    
  93.     if (!sdev->lib)
  94.         sdev->lib = pipe_loader_find_module(dev, library_paths);
  95.     if (!sdev->lib)
  96.         return NULL;
  97.  
  98.    init = (void *)get_proc_address(sdev->lib, "swrast_create_screen");
  99.    
  100.    printf("swrast_create_screen %p\n", init);
  101.    
  102.    if (!init)
  103.       return NULL;
  104.  
  105.    return init(sdev->ws);
  106. }
  107.  
  108. static struct pipe_loader_ops pipe_loader_sw_ops = {
  109.    .create_screen = pipe_loader_sw_create_screen,
  110.    .release = pipe_loader_sw_release
  111. };
  112.