tile_manager.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* The GIMP -- an image manipulation program
  2. * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #ifndef __TILE_MANAGER_H__
  19. #define __TILE_MANAGER_H__
  20. #include "tile.h"
  21. typedef struct _TileManager TileManager;
  22. typedef void (*TileValidateProc) (TileManager *tm,
  23. Tile *tile);
  24. /* Creates a new tile manager with the specified
  25. * width for the toplevel. The toplevel sizes is
  26. * used to compute the number of levels and there
  27. * size. Each level is 1/2 the width and height of
  28. * the level above it.
  29. * The toplevel is level 0. The smallest level in the
  30. * hierarchy is "nlevels - 1". That level will be smaller
  31. * than TILE_WIDTH x TILE_HEIGHT
  32. */
  33. TileManager* tile_manager_new (int toplevel_width,
  34. int toplevel_height,
  35. int bpp);
  36. /* Destroy a tile manager and all the tiles it contains.
  37. */
  38. void tile_manager_destroy (TileManager *tm);
  39. /* Set the validate procedure for the tile manager.
  40. * The validate procedure is called when an invalid tile
  41. * is referenced. If the procedure is NULL, then the tile
  42. * is set to valid and its memory is allocated, but
  43. * not initialized.
  44. */
  45. void tile_manager_set_validate_proc (TileManager *tm,
  46. TileValidateProc proc);
  47. /* Get a specified tile from a tile manager.
  48. */
  49. Tile* tile_manager_get_tile (TileManager *tm,
  50. int xpixel,
  51. int ypixel,
  52. int wantread,
  53. int wantwrite);
  54. /* Get a specified tile from a tile manager.
  55. */
  56. Tile* tile_manager_get (TileManager *tm,
  57. int tile_num,
  58. int wantread,
  59. int wantwrite);
  60. /* Request that (if possible) the tile at x,y be swapped
  61. * in. This is only a hint to improve performance; no guarantees.
  62. * The tile may be swapped in or otherwise made more accessible
  63. * if it is convenient...
  64. */
  65. void tile_manager_get_async (TileManager *tm,
  66. int xpixel,
  67. int ypixel);
  68. void tile_manager_map_tile (TileManager *tm,
  69. int xpixel,
  70. int ypixel,
  71. Tile *srctile);
  72. void tile_manager_map (TileManager *tm,
  73. int time_num,
  74. Tile *srctile);
  75. /* Validate a tiles memory.
  76. */
  77. void tile_manager_validate (TileManager *tm,
  78. Tile *tile);
  79. void tile_invalidate (Tile **tile_ptr, TileManager *tm, int tile_num);
  80. void tile_invalidate_tile (Tile **tile_ptr, TileManager *tm,
  81. int xpixel, int ypixel);
  82. /* Given a toplevel tile, this procedure will invalidate
  83. * (set the dirty bit) for this toplevel tile.
  84. */
  85. void tile_manager_invalidate_tiles (TileManager *tm,
  86. Tile *toplevel_tile);
  87. void tile_manager_set_user_data (TileManager *tm,
  88. void *user_data);
  89. void *tile_manager_get_user_data (TileManager *tm);
  90. int tile_manager_level_width (TileManager *tm);
  91. int tile_manager_level_height (TileManager *tm);
  92. int tile_manager_level_bpp (TileManager *tm);
  93. void tile_manager_get_tile_coordinates (TileManager *tm, Tile *tile,
  94. int *x, int *y);
  95. void tile_manager_map_over_tile (TileManager *tm, Tile *tile, Tile *srctile);
  96. #endif /* __TILE_MANAGER_H__ */