idirectfbsurface.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
  3. (c) Copyright 2000-2004 Convergence (integrated media) GmbH
  4. All rights reserved.
  5. Written by Denis Oliver Kropp <dok@directfb.org>,
  6. Andreas Hundt <andi@fischlustig.de>,
  7. Sven Neumann <neo@directfb.org>,
  8. Ville Syrjälä <syrjala@sci.fi> and
  9. Claudio Ciccani <klan@users.sf.net>.
  10. This library is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU Lesser General Public
  12. License as published by the Free Software Foundation; either
  13. version 2 of the License, or (at your option) any later version.
  14. This library is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. Lesser General Public License for more details.
  18. You should have received a copy of the GNU Lesser General Public
  19. License along with this library; if not, write to the
  20. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. Boston, MA 02111-1307, USA.
  22. */
  23. #ifndef __IDIRECTFBSURFACE_H__
  24. #define __IDIRECTFBSURFACE_H__
  25. #include <directfb.h>
  26. #include <direct/types.h>
  27. #include <fusion/reactor.h>
  28. #include <core/state.h>
  29. #include <core/CoreGraphicsStateClient.h>
  30. /*
  31. * private data struct of IDirectFBSurface
  32. */
  33. typedef struct {
  34. DirectLink link;
  35. int ref; /* reference counter */
  36. DFBSurfaceCapabilities caps; /* capabilities */
  37. struct {
  38. /* 'wanted' is passed to GetSubSurface(), it doesn't matter if it's
  39. too large or has negative starting coordinates as long as it
  40. intersects with the 'granted' rectangle of the parent.
  41. 'wanted' should be seen as the origin for operations on that
  42. surface. Non sub surfaces have a 'wanted' rectangle
  43. of '{ 0, 0, width, height }'. 'wanted' is calculated just once
  44. during surface creation. */
  45. DFBRectangle wanted;
  46. /* 'granted' is the intersection of the 'wanted' rectangle and the
  47. 'granted' one of the parent. If they do not intersect DFB_INVAREA
  48. is returned. For non sub surfaces it's the same as the 'wanted'
  49. rectangle, because it's the rectangle describing the whole
  50. surface. 'granted' is calculated just once during surface
  51. creation */
  52. DFBRectangle granted;
  53. /* 'current' is the intersection of the 'granted' rectangle and the
  54. surface extents. SetClip() and many other functions are limited
  55. by this.
  56. This way sub surface area information is preserved during surface
  57. resizing, e.g. when resizing a window. Calling SetClip() with NULL
  58. causes the clipping region to exactly cover the 'current'
  59. rectangle, also the flag 'clip_set' is cleared causing the
  60. clipping region to be set to the new 'current' after resizing. If
  61. SetClip() is called with a clipping region specified, an
  62. intersection is done with the 'wanted' rectangle that is then
  63. stored in 'clip_wanted' and 'clip_set' is set. However, if there
  64. is no intersection 'DFB_INVARG' is returned, otherwise another
  65. intersection is made with the 'current' rectangle and gets applied
  66. to the surface's state.
  67. Each resize, after the 'current' rectangle is updated, the
  68. clipping region is set to NULL or 'clip_wanted' depending on
  69. 'clip_set'. This way even clipping regions are restored or
  70. extended automatically. It's now possible to create a fullscreen
  71. primary and call SetVideoMode() with different resolutions or
  72. pixelformats several times without the need for updating the
  73. primary surface by recreating it */
  74. DFBRectangle current; /* currently available area */
  75. DFBInsets insets; /* actually set by the window manager */
  76. } area;
  77. bool limit_set; /* greanted rectangle set?
  78. (GetSubSurface called with rect != NULL) */
  79. bool clip_set; /* fixed clip set? (SetClip called
  80. with clip != NULL) */
  81. DFBRegion clip_wanted; /* last region passed to SetClip
  82. intersected by wanted area,
  83. only valid if clip_set != 0 */
  84. CoreSurface *surface; /* buffer to show */
  85. bool locked; /* which buffer is locked? */
  86. CoreSurfaceBufferLock lock;
  87. IDirectFBFont *font; /* font to use */
  88. CardState state; /* render state to use */
  89. DFBTextEncodingID encoding; /* text encoding */
  90. struct {
  91. u8 r; /* red component */
  92. u8 g; /* green component */
  93. u8 b; /* blue component */
  94. u32 value; /* r/g/b in surface's format */
  95. } src_key; /* src key for blitting from
  96. this surface */
  97. struct {
  98. u8 r; /* red component */
  99. u8 g; /* green component */
  100. u8 b; /* blue component */
  101. u32 value; /* r/g/b in surface's format */
  102. } dst_key; /* dst key for blitting to
  103. this surface */
  104. Reaction reaction;
  105. CoreDFB *core;
  106. IDirectFBSurface *parent;
  107. DirectLink *children_data;
  108. pthread_mutex_t children_lock;
  109. CoreGraphicsStateClient state_client;
  110. } IDirectFBSurface_data;
  111. /*
  112. * initializes interface struct and private data
  113. */
  114. DFBResult IDirectFBSurface_Construct( IDirectFBSurface *thiz,
  115. IDirectFBSurface *parent,
  116. DFBRectangle *req_rect,
  117. DFBRectangle *clip_rect,
  118. DFBInsets *insets,
  119. CoreSurface *surface,
  120. DFBSurfaceCapabilities caps,
  121. CoreDFB *core );
  122. /*
  123. * destroys surface(s) and frees private data
  124. */
  125. void IDirectFBSurface_Destruct( IDirectFBSurface *thiz );
  126. /*
  127. * internal
  128. */
  129. void IDirectFBSurface_StopAll( IDirectFBSurface_data *data );
  130. #endif