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

blitters.h

Go to the documentation of this file.
00001 /*
00002         $Id: blitters.h,v 1.1 2001/03/06 15:09:17 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         TODO:
00015         
00016          - Add blitters for primitive types: lines, triangles and polygons.
00017 */
00018 
00019 #ifndef header_blitters
00020 #define header_blitters
00021 
00022 class CL_Target;
00023 #include <stdlib.h>
00024 #include "API/Display/Display/cliprect.h"
00025 /*
00026 #include "API/Display/Display/surfaceprovider.h"
00027 #include "API/Display/Display/target.h"
00028 #include "pixeldata.h"
00029 */
00030 class CL_RefCountable
00031 {
00032 public:
00033         void add_ref() { ref++; }
00034         int release_ref() { ref--; return ref; }
00035 
00036         virtual ~CL_RefCountable() { return; }
00037 protected:
00038         CL_RefCountable() { ref = 0; }
00039 private:
00040         int ref;
00041 };
00042 
00043 class CL_Blit_NoClip : virtual public CL_RefCountable
00044 {
00045 public:
00046         virtual ~CL_Blit_NoClip() { return; }
00047 
00048         virtual void blt_noclip(
00049                 CL_Target *target,
00050                 int x,
00051                 int y,
00052                 int spr_no)=0;
00053 };
00054 
00055 class CL_Blit_Clip : virtual public CL_RefCountable
00056 {
00057 public:
00058         virtual ~CL_Blit_Clip() { return; }
00059 
00060         virtual void blt_clip(
00061                 CL_Target *target,
00062                 int x,
00063                 int y,
00064                 int spr_no,
00065                 const CL_ClipRect &clip)=0;
00066 };
00067 
00068 class CL_Blit_Scale_NoClip : virtual public CL_RefCountable
00069 {
00070 public:
00071         virtual ~CL_Blit_Scale_NoClip() { return; }
00072 
00073         virtual void blt_scale_noclip(
00074                 CL_Target *target,
00075                 int x,
00076                 int y,
00077                 int dest_width,
00078                 int dest_height,
00079                 int spr_no)=0;
00080 };
00081 
00082 class CL_Blit_Scale_Clip : virtual public CL_RefCountable
00083 {
00084 public:
00085         virtual ~CL_Blit_Scale_Clip() { return; }
00086 
00087         virtual void blt_scale_clip(
00088                 CL_Target *target,
00089                 int x,
00090                 int y,
00091                 int dest_width,
00092                 int dest_height,
00093                 int spr_no,
00094                 const CL_ClipRect &clip)=0;
00095 };
00096 
00097 class CL_Blitters
00098 {
00099 public:
00100         CL_Blitters()
00101         {
00102                 noclip = NULL;
00103                 clip = NULL;
00104                 scale_noclip = NULL;
00105                 scale_clip = NULL;
00106         }
00107         
00108         void delete_all()
00109         {
00110                 delete_noclip();
00111                 delete_clip();
00112                 delete_scale_noclip();
00113                 delete_scale_clip();
00114         }
00115         
00116         void set_noclip(CL_Blit_NoClip *ptr)
00117         {
00118                 delete_noclip();
00119                 noclip = ptr;
00120                 ptr->add_ref();
00121         }
00122         
00123         void set_clip(CL_Blit_Clip *ptr)
00124         {
00125                 delete_clip();
00126                 clip = ptr;
00127                 ptr->add_ref();
00128         }
00129         
00130         void set_scale_noclip(CL_Blit_Scale_NoClip *ptr)
00131         {
00132                 delete_scale_noclip();
00133                 scale_noclip = ptr;
00134                 ptr->add_ref();
00135         }
00136         
00137         void set_scale_clip(CL_Blit_Scale_Clip *ptr)
00138         {
00139                 delete_scale_clip();
00140                 scale_clip = ptr;
00141                 ptr->add_ref();
00142         }
00143         
00144         void delete_noclip() { remove(noclip); noclip = NULL; }
00145         void delete_clip() { remove(clip); clip = NULL; }
00146         void delete_scale_noclip() { remove(scale_noclip); scale_noclip = NULL; }
00147         void delete_scale_clip() { remove(scale_clip); scale_clip = NULL; }
00148         
00149         bool test_noclip() { return (noclip == NULL) ? false : true; }
00150         bool test_clip() { return (clip == NULL) ? false : true; }
00151         bool test_scale_noclip() { return (scale_noclip == NULL) ? false : true; }
00152         bool test_scale_clip() { return (scale_clip == NULL) ? false : true; }
00153         
00154         bool test_complete()
00155         {
00156                 return
00157                         test_noclip() &&
00158                         test_clip() &&
00159                         test_scale_noclip() &&
00160                         test_scale_clip();
00161         }
00162         
00163         CL_Blit_NoClip *get_noclip() { return noclip; }
00164         CL_Blit_Clip *get_clip() { return clip; }
00165         CL_Blit_Scale_NoClip *get_scale_noclip() { return scale_noclip; }
00166         CL_Blit_Scale_Clip *get_scale_clip() { return scale_clip; }
00167 
00168 private:
00169         CL_Blit_NoClip *noclip;
00170         CL_Blit_Clip *clip;
00171         CL_Blit_Scale_NoClip *scale_noclip;
00172         CL_Blit_Scale_Clip *scale_clip;
00173 
00174         void remove(CL_RefCountable *ptr)
00175         {
00176                 if (ptr != NULL && ptr->release_ref() == 0) delete ptr;
00177         }
00178 };
00179 
00180 #endif

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