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

surface.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: surface.cpp,v 1.2 2001/03/28 00:40:04 grumbel 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 
00015 #include "Core/precomp.h"
00016 
00017 #include <API/Display/Display/display.h>
00018 #include <API/Display/Display/displaycard.h>
00019 #include <API/Display/Display/surface.h>
00020 #include <Display/Display/Generic/displaycard_generic.h>
00021 #include <Display/Display/Generic/surface_generic.h>
00022 #include <Display/Display/Generic/restype_surface.h>
00023 #include <Display/Display/Generic/blit_dynamic.h>
00024 #include "cardsurface_blitter.h"
00025 #include "colormap.h"
00026 #include "blit_macros.h"
00027 
00028 extern "C"
00029 {
00030         #include <Hermes/H_Conv.h>
00031         #include <Hermes/H_Pal.h>
00032 }
00033 
00034 CL_Surface *CL_Surface::load(
00035         const char *resource_id,
00036         CL_ResourceManager *manager)
00037 {
00038         return new CL_Surface(resource_id, manager);
00039 }
00040 
00041 CL_Surface *CL_Surface::create(
00042         CL_SurfaceProvider *provider,
00043         bool delete_provider)
00044 {
00045         return new CL_Surface(provider, delete_provider);
00046 }
00047 
00048 CL_Surface *CL_Surface::create_dynamic(
00049         CL_SurfaceProvider *provider,
00050         bool delete_provider)
00051 {
00052         return new CL_Surface(new CL_Surface_Generic(provider, delete_provider, true));
00053 }
00054 
00055 CL_Surface::CL_Surface() : impl (0)
00056 {
00057 }
00058 
00059 CL_Surface::CL_Surface(
00060         const char *resource_id,
00061         CL_ResourceManager *manager)
00062 {
00063         CL_WritableSurfaceResource *resource =
00064                 (CL_WritableSurfaceResource *) manager->get_resource(resource_id);
00065         
00066         impl = resource->create_surface()->impl;
00067         impl->add_reference();
00068 }
00069 
00070 CL_Surface::CL_Surface(
00071         CL_SurfaceProvider *provider,
00072         bool delete_provider,
00073         bool dynamic,
00074         CL_Resource *resource)
00075 {
00076         provider->lock();
00077         impl = new CL_Surface_Generic(provider, delete_provider, dynamic, resource);
00078         impl->add_reference();
00079         provider->unlock();
00080 }
00081 
00082 CL_Surface::CL_Surface(class CL_Surface_Generic *_impl) : impl(_impl)
00083 {
00084         if (impl) impl->add_reference();
00085 }
00086 
00087 CL_Surface::CL_Surface(const CL_Surface &surface) : impl(surface.impl)
00088 {
00089         if (impl) impl->add_reference();
00090 }
00091 
00092 CL_Surface::~CL_Surface()
00093 {
00094         if (impl && impl->release_reference() == 0) delete impl;
00095 }
00096 
00097 void CL_Surface::reload()
00098 {
00099         impl->reload();
00100 }
00101 
00102 CL_Surface::operator bool () const
00103 {
00104         return (impl != 0);
00105 }
00106 
00107 const CL_Surface& 
00108 CL_Surface::operator=(const CL_Surface& surface) 
00109 {
00110         if (impl && impl->release_reference() == 0) delete impl;
00111         impl = surface.impl;
00112         if (impl)
00113           impl->add_reference ();
00114         return *this;
00115 }
00116 
00117 CL_SurfaceProvider *CL_Surface::get_provider() const
00118 {
00119         return impl->get_provider();
00120 }
00121 
00122 void CL_Surface::put_screen(
00123         int x,
00124         int y,
00125         int spr_no,
00126         CL_DisplayCard *card)
00127 {
00128         impl->put_screen(x, y, spr_no, card);
00129 }
00130 
00131 void CL_Surface::put_screen(
00132         int x,
00133         int y,
00134         float scale_x,
00135         float scale_y,
00136         int spr_no,
00137         CL_DisplayCard *card)
00138 {
00139         impl->put_screen(x, y, scale_x, scale_y, spr_no, card);
00140 }
00141 
00142 void CL_Surface::put_screen(
00143         int x,
00144         int y,
00145         int size_x,
00146         int size_y,
00147         int spr_no,
00148         CL_DisplayCard *card)
00149 {
00150         impl->put_screen(x, y, size_x, size_y, spr_no, card);
00151 }
00152 
00153 void CL_Surface::put_target(
00154         int x,
00155         int y,
00156         int spr_no,
00157         CL_Target *target)
00158 {
00159         impl->put_target(x, y, spr_no, target);
00160 }
00161 
00162 unsigned int CL_Surface::get_width() const
00163 {
00164         return impl->get_width();
00165 }
00166 
00167 unsigned int CL_Surface::get_height() const
00168 {
00169         return impl->get_height();
00170 }
00171 
00172 unsigned int CL_Surface::get_num_frames() const
00173 {
00174         return impl->get_num_frames();
00175 }
00176 
00177 bool CL_Surface::is_video(CL_DisplayCard *card) const
00178 {
00179         return impl->is_video(card);
00180 }
00181 
00182 bool CL_Surface::is_loaded(CL_DisplayCard *card) const
00183 {
00184         return impl->is_loaded(card);
00185 }
00186 
00187 bool CL_Surface::convert_video(CL_DisplayCard *card)
00188 {
00189         return impl->convert_video(card);
00190 }
00191 
00192 bool CL_Surface::convert_system(CL_DisplayCard *card)
00193 {
00194         return impl->convert_system(card);
00195 }
00196 
00197 void CL_Surface::flush(CL_DisplayCard *card)
00198 {
00199         impl->flush(card);
00200 }

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