fballpriv.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. *
  3. * Copyright © 1998 Keith Packard
  4. *
  5. * Permission to use, copy, modify, distribute, and sell this software and its
  6. * documentation for any purpose is hereby granted without fee, provided that
  7. * the above copyright notice appear in all copies and that both that
  8. * copyright notice and this permission notice appear in supporting
  9. * documentation, and that the name of Keith Packard not be used in
  10. * advertising or publicity pertaining to distribution of the software without
  11. * specific, written prior permission. Keith Packard makes no
  12. * representations about the suitability of this software for any purpose. It
  13. * is provided "as is" without express or implied warranty.
  14. *
  15. * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  16. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  17. * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  18. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  19. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  20. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21. * PERFORMANCE OF THIS SOFTWARE.
  22. */
  23. #ifdef HAVE_DIX_CONFIG_H
  24. #include <dix-config.h>
  25. #endif
  26. #include "fb.h"
  27. int fbScreenPrivateIndex;
  28. int
  29. fbGetScreenPrivateIndex(void)
  30. {
  31. return fbScreenPrivateIndex;
  32. }
  33. int fbGCPrivateIndex;
  34. int
  35. fbGetGCPrivateIndex(void)
  36. {
  37. return fbGCPrivateIndex;
  38. }
  39. int fbWinPrivateIndex;
  40. int
  41. fbGetWinPrivateIndex(void)
  42. {
  43. return fbWinPrivateIndex;
  44. }
  45. int fbGeneration;
  46. Bool
  47. fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
  48. {
  49. if (fbGeneration != serverGeneration) {
  50. fbGCPrivateIndex = miAllocateGCPrivateIndex();
  51. fbWinPrivateIndex = AllocateWindowPrivateIndex();
  52. fbScreenPrivateIndex = AllocateScreenPrivateIndex();
  53. if (fbScreenPrivateIndex == -1)
  54. return FALSE;
  55. fbGeneration = serverGeneration;
  56. }
  57. if (pGCIndex)
  58. *pGCIndex = fbGCPrivateIndex;
  59. if (!AllocateGCPrivate(pScreen, fbGCPrivateIndex, sizeof(FbGCPrivRec)))
  60. return FALSE;
  61. if (!AllocateWindowPrivate(pScreen, fbWinPrivateIndex, 0))
  62. return FALSE;
  63. {
  64. FbScreenPrivPtr pScreenPriv;
  65. pScreenPriv = malloc(sizeof(FbScreenPrivRec));
  66. if (!pScreenPriv)
  67. return FALSE;
  68. pScreen->devPrivates[fbScreenPrivateIndex].ptr = (pointer) pScreenPriv;
  69. }
  70. return TRUE;
  71. }