Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

surface_manager.h

Go to the documentation of this file.
00001 /*
00002         $Id: surface_manager.h,v 1.1 2001/03/06 15:09:12 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 
00014         File purpose:
00015                 Surface management functionality
00016 
00017 
00018 */
00019 
00021 
00022 #ifndef header_surface_manager
00023 #define header_surface_manager
00024 /*
00025 class CL_SurfaceManager_Priority
00026 {
00027 public:
00028         virtual int get_priority()=0;
00029         virtual void reset_priority()=0;
00030         virtual CL_Surface *get_surface()=0;
00031 };
00032 
00033 class CL_SurfaceManager_Card
00034 {
00035 protected:
00036         list<CL_SurfaceManager_Priority*> priority_list;
00037         CL_DisplayCard *card;
00038 
00039         static int compare_surfaces(const void *s1, const void *s2);
00040 
00041 public:
00042         CL_SurfaceManager_Card(CL_DisplayCard *_card);
00043         virtual ~CL_SurfaceManager_Card() { ; }
00044 
00045         // add surface to priority list
00046         virtual void add_surface(CL_SurfaceManager_Priority *surf_prio);
00047 
00048         // remove surface from list
00049         virtual void remove_surface(CL_SurfaceManager_Priority *surf_prio);
00050 
00051         // move surfaces with highest priorities into video memory
00052         virtual void optimize_video();
00053 };
00054 
00055 class CL_FilterSurface : public CL_Surface, public CL_SurfaceManager_Priority
00056 {
00057 protected:
00058         CL_Surface *subsurface;
00059 
00060 public:
00061         CL_FilterSurface(CL_Surface *_subsurface) { subsurface = _subsurface; }
00062         virtual ~CL_FilterSurface() { ; }
00063 
00064         virtual void reload() { subsurface->reload(); }
00065         virtual CL_SurfaceProvider *get_provider() const { return subsurface->get_provider(); }
00066 
00067         // Display functions
00068         virtual void put_screen(int x, int y, int spr_no=0, CL_DisplayCard *card=NULL)
00069         { subsurface->put_screen(x, y, spr_no, card); }
00070 
00071         virtual void put_screen(int x, int y, float scale_x, float scale_y, int spr_no=0, CL_DisplayCard *card=NULL)
00072         { subsurface->put_screen(x, y, scale_x, scale_y, spr_no, card); }
00073 
00074         virtual void put_screen(int x, int y, int size_x, int size_y, int spr_no=0, CL_DisplayCard *card=NULL)
00075         { subsurface->put_screen(x, y, size_x, size_y, spr_no, card); }
00076 
00077         // is_video() returns true if in videomemory
00078         // on the specified card (null = current dispcard)
00079         virtual bool is_video(CL_DisplayCard *card = NULL) const
00080         { return subsurface->is_video(card); }
00081 
00082         virtual bool is_loaded(CL_DisplayCard *card= NULL) const
00083         { return subsurface->is_loaded(card); }
00084 
00085         // returns true if successfully loaded into videomemory, or already there
00086         virtual bool convert_video(CL_DisplayCard *card = NULL)
00087         { return subsurface->convert_video(card); }
00088 
00089         // never fails! (or serious heap usage!)
00090         virtual bool convert_system(CL_DisplayCard *card = NULL)
00091         { return subsurface->convert_system(card); }
00092 
00093         // completely flushes surface (removes from video/system-memory)
00094         virtual void flush(CL_DisplayCard *card = NULL)
00095         { subsurface->flush(card); }
00096 
00097         virtual CL_Surface *get_surface() { return this; }
00098 
00099         virtual int get_width() const { return subsurface->get_width(); }
00100         virtual int get_height() const { return subsurface->get_height(); }
00101         virtual int get_no_sprs() const { return subsurface->get_no_sprs(); }
00102 };
00103 
00104 class CL_PeakSurface : public CL_FilterSurface
00105 {
00106 public:
00107         int blt_count;
00108         int default_prio;
00109 
00110         CL_PeakSurface(CL_Surface *surf, int _default_prio) : CL_FilterSurface(surf)
00111         { blt_count = 0; default_prio = _default_prio; }
00112 
00113         virtual void put_screen(int x, int y, int spr_no=0, CL_DisplayCard *card=NULL)
00114         {
00115                 blt_count++;
00116                 CL_FilterSurface::put_screen(x, y, spr_no, card);
00117         }
00118 
00119         virtual void put_screen(int x, int y, float scale_x, float scale_y, int spr_no=0, CL_DisplayCard *card=NULL)
00120         {
00121                 blt_count++;
00122                 CL_FilterSurface::put_screen(x, y, scale_x, scale_y, spr_no, card);
00123         }
00124 
00125         virtual void put_screen(int x, int y, int size_x, int size_y, int spr_no=0, CL_DisplayCard *card=NULL)
00126         {
00127                 blt_count++;
00128                 CL_FilterSurface::put_screen(x, y, size_x, size_y, spr_no, card);
00129         }
00130 
00131         virtual void reset_priority()
00132         {
00133                 blt_count = 0;
00134         }
00135         virtual int get_priority()
00136         {
00137                 return blt_count*get_provider()->get_width()*get_provider()->get_height() + default_prio;
00138         }
00139 };
00140 
00141 class CL_PeakPriority : public CL_SurfacePriority
00142 {
00143 protected:
00144         CL_SurfaceManager_Card *manager;
00145 
00146 public:
00147         CL_PeakPriority(CL_SurfaceManager_Card *_manager)
00148         {
00149                 manager = _manager;
00150         }
00151 
00152         virtual ~CL_PeakPriority() { ; }
00153 
00154         virtual CL_Surface *manage_surface(CL_Surface *surf)
00155         {
00156                 CL_PeakSurface *peaksurf = new CL_PeakSurface(surf, 0); // monitor the blits
00157                 manager->add_surface(peaksurf);
00158                 return peaksurf;
00159         }
00160 };
00161 */
00162 #endif

Generated at Wed Apr 4 19:54:04 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001