ICONCACH.H 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /***********************************************************************************************
  15. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  16. ***********************************************************************************************
  17. * *
  18. * Project Name : Drawbuff - Westwood win95 library *
  19. * *
  20. * File Name : Iconcach.H *
  21. * *
  22. * Programmer : Steve Tall *
  23. * *
  24. * Start Date : November 8th, 1995 *
  25. * *
  26. * Last Update : November 16th, 1995 [ST] *
  27. * *
  28. *---------------------------------------------------------------------------------------------*
  29. * Overview: This file cantains definition of the IconCacheClass and associated non member *
  30. * function prototypes. *
  31. * *
  32. * Functions: *
  33. * IconCacheClass::Get_Is_Cached -- member to allow access to private IsCached flag *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef ICONCACH_H
  36. #define ICONCACH_H
  37. #include <tile.h>
  38. #define ICON_WIDTH 24 // Icons must be this width to be cached
  39. #define ICON_HEIGHT 24 // Icons must be this height to be cached
  40. #define MAX_CACHED_ICONS 500 // Maximum number of icons that can be cached
  41. #define MAX_ICON_SETS 100 // Maximum number of icon sets that can be registered
  42. #define MAX_LOOKUP_ENTRIES 3000 // Size of icon index table
  43. /*
  44. ** IconCacheClass for tracking individual icons cached into video memory
  45. **
  46. ** Use Register_Icon_Set to identify a set of icons as cachable. Once registered, the icons
  47. ** will be cached automatically when drawn.
  48. ** Use Invalidate_Cached_Icons at the end of icon drawing to release the video memory used by the
  49. ** caching system.
  50. ** Restore_Cached_Icons may be used to reload the icons into video memory after a focus loss.
  51. **
  52. */
  53. class IconCacheClass {
  54. public:
  55. IconCacheClass (void); // class constructor
  56. ~IconCacheClass (void); // class destructor
  57. void Restore(void); // restore the surface
  58. BOOL Cache_It (void * icon_ptr); // Cache the icon to video memory
  59. void Uncache_It (void); // Restore the video memory and flag the icon as uncached
  60. void Draw_It (LPDIRECTDRAWSURFACE dest_surface , int x_pixel, int y_pixel, int window_left , int window_top , int window_width , int window_height);
  61. inline BOOL Get_Is_Cached(void); // Return the IsCached member
  62. int TimesDrawn; // counter of times cached icon has been drawn
  63. int TimesFailed; // counter of times cached icon has failed to draw
  64. private:
  65. LPDIRECTDRAWSURFACE CacheSurface; // Ptr to direct draw surface where icon resides
  66. BOOL IsCached; // Flag to say whether an icon is cached
  67. BOOL SurfaceLost; // Flag to indicate that our icons surface has been lost
  68. int DrawFrequency; // Number of times icon has been drawn
  69. void *IconSource; // Ptr to original icon data in system memory
  70. };
  71. /*
  72. ** Structure to keep track of registered icon sets
  73. **
  74. */
  75. typedef struct tIconSetType{
  76. IControl_Type *IconSetPtr; // Ptr to icon set data
  77. int IconListOffset; // Offset into icon index table for this icon set
  78. }IconSetType;
  79. extern IconCacheClass CachedIcons[MAX_CACHED_ICONS];
  80. extern void Invalidate_Cached_Icons (void);
  81. extern void Restore_Cached_Icons (void);
  82. extern void Register_Icon_Set (void *icon_data , BOOL pre_cache);
  83. //
  84. // Prototypes for assembly language procedures in STMPCACH.ASM
  85. //
  86. extern "C" void Clear_Icon_Pointers (void);
  87. extern "C" void Cache_Copy_Icon (void const *icon_ptr ,void * , int);
  88. extern "C" int Is_Icon_Cached (void const *icon_data , int icon);
  89. extern "C" int Get_Icon_Index (void *icon_ptr);
  90. extern "C" int Get_Free_Index (void);
  91. extern "C" BOOL Cache_New_Icon (int icon_index, void *icon_ptr);
  92. extern "C" int Get_Free_Cache_Slot(void);
  93. extern int CachedIconsDrawn;
  94. extern int UnCachedIconsDrawn;
  95. /***********************************************************************************************
  96. * ICC::Get_Is_Cached -- member to allow access to the private IsCached flag *
  97. * *
  98. * *
  99. * *
  100. * INPUT: Nothing *
  101. * *
  102. * OUTPUT: IsCached *
  103. * *
  104. * WARNINGS: None *
  105. * *
  106. * HISTORY: *
  107. * 11/13/95 9:42AM ST : Created *
  108. *=============================================================================================*/
  109. inline BOOL IconCacheClass::Get_Is_Cached (void)
  110. {
  111. return (IsCached);
  112. }
  113. #endif //ICONCACH_H