glamor_window.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright © 2008 Intel Corporation
  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. #include "glamor_priv.h"
  24. /** @file glamor_window.c
  25. *
  26. * Screen Change Window Attribute implementation.
  27. */
  28. static void
  29. glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
  30. {
  31. PixmapPtr pPixmap = *ppPixmap;
  32. glamor_pixmap_private *pixmap_priv;
  33. if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel) {
  34. pixmap_priv = glamor_get_pixmap_private(pPixmap);
  35. if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
  36. glamor_fallback("pixmap %p has no fbo\n", pPixmap);
  37. goto fail;
  38. }
  39. glamor_debug_output(GLAMOR_DEBUG_UNIMPL, "To be implemented.\n");
  40. }
  41. return;
  42. fail:
  43. GLAMOR_PANIC
  44. (" We can't fall back to fbFixupWindowPixmap, as the fb24_32ReformatTile"
  45. " is broken for glamor. \n");
  46. }
  47. Bool
  48. glamor_change_window_attributes(WindowPtr pWin, unsigned long mask)
  49. {
  50. if (mask & CWBackPixmap) {
  51. if (pWin->backgroundState == BackgroundPixmap)
  52. glamor_fixup_window_pixmap(&pWin->drawable,
  53. &pWin->background.pixmap);
  54. }
  55. if (mask & CWBorderPixmap) {
  56. if (pWin->borderIsPixel == FALSE)
  57. glamor_fixup_window_pixmap(&pWin->drawable, &pWin->border.pixmap);
  58. }
  59. return TRUE;
  60. }
  61. void
  62. glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
  63. {
  64. ScreenPtr screen = win->drawable.pScreen;
  65. glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
  66. PixmapPtr old = screen->GetWindowPixmap(win);
  67. if (pPixmap != old) {
  68. glamor_pixmap_private *pixmap_priv;
  69. PicturePtr pic = NULL;
  70. pixmap_priv = glamor_get_pixmap_private(old);
  71. if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) &&
  72. pixmap_priv->base.picture->pDrawable == (DrawablePtr) win) {
  73. pic = pixmap_priv->base.picture;
  74. pixmap_priv->base.is_picture = 0;
  75. pixmap_priv->base.picture = NULL;
  76. }
  77. pixmap_priv = glamor_get_pixmap_private(pPixmap);
  78. if (pixmap_priv) {
  79. pixmap_priv->base.is_picture = ! !pic;
  80. pixmap_priv->base.picture = pic;
  81. }
  82. }
  83. screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
  84. (screen->SetWindowPixmap) (win, pPixmap);
  85. glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
  86. screen->SetWindowPixmap = glamor_set_window_pixmap;
  87. }