surfacemanager.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 __SURFACEMANAGER_H__
  24. #define __SURFACEMANAGER_H__
  25. #include <directfb.h>
  26. #include <core/coretypes.h>
  27. typedef struct _SurfaceManager SurfaceManager;
  28. typedef struct _Chunk Chunk;
  29. /*
  30. * initially there is one big free chunk,
  31. * chunks are splitted into a free and an occupied chunk if memory is allocated,
  32. * two chunks are merged to one free chunk if memory is deallocated
  33. */
  34. struct _Chunk {
  35. int magic;
  36. int offset; /* offset in memory,
  37. is greater or equal to the heap offset */
  38. int length; /* length of this chunk in bytes */
  39. int pitch;
  40. CoreSurfaceBuffer *buffer; /* pointer to surface buffer occupying
  41. this chunk, or NULL if chunk is free */
  42. CoreSurfaceAllocation *allocation;
  43. int tolerations; /* number of times this chunk was scanned
  44. occupied, resetted in assure_video */
  45. Chunk *prev;
  46. Chunk *next;
  47. };
  48. struct _SurfaceManager {
  49. int magic;
  50. FusionSHMPoolShared *shmpool;
  51. Chunk *chunks;
  52. int offset;
  53. int length; /* length of the heap in bytes */
  54. int avail; /* amount of available memory in bytes */
  55. int min_toleration;
  56. bool suspended;
  57. };
  58. DFBResult dfb_surfacemanager_create ( CoreDFB *core,
  59. unsigned int length,
  60. SurfaceManager **ret_manager );
  61. void dfb_surfacemanager_destroy( SurfaceManager *manager );
  62. /*
  63. * adjust the offset within the framebuffer for surface storage,
  64. * needs to be called after a resolution switch
  65. */
  66. DFBResult dfb_surfacemanager_adjust_heap_offset( SurfaceManager *manager,
  67. int offset );
  68. /*
  69. * finds and allocates one for the surface or fails,
  70. * after success the video health is CSH_RESTORE.
  71. * NOTE: this does not notify the listeners
  72. */
  73. DFBResult dfb_surfacemanager_allocate( CoreDFB *core,
  74. SurfaceManager *manager,
  75. CoreSurfaceBuffer *buffer,
  76. CoreSurfaceAllocation *allocation,
  77. Chunk **ret_chunk );
  78. DFBResult dfb_surfacemanager_displace( CoreDFB *core,
  79. SurfaceManager *manager,
  80. CoreSurfaceBuffer *buffer );
  81. /*
  82. * sets the video health to CSH_INVALID frees the chunk and
  83. * notifies the listeners
  84. */
  85. DFBResult dfb_surfacemanager_deallocate( SurfaceManager *manager,
  86. Chunk *chunk );
  87. #endif