00001 /* 00002 Copyright (c) 2002 Xavier Trochu 00003 00004 This software is provided 'as-is', without any express or implied warranty. In no event 00005 will the authors be held liable for any damages arising from the use of this software. 00006 00007 Permission is granted to anyone to use this software for any purpose, including commercial 00008 applications, and to alter it and redistribute it freely, subject to the following 00009 restrictions: 00010 00011 1. The origin of this software must not be misrepresented; you must not claim that you 00012 wrote the original software. If you use this software in a product, an acknowledgment 00013 in the product documentation would be appreciated but is not required. 00014 00015 2. Altered source versions must be plainly marked as such, and must not be misrepresented 00016 as being the original software. 00017 00018 3. This notice may not be removed or altered from any source distribution. 00019 */ 00020 #ifndef __BRENDERER_H_ 00021 #define __BRENDERER_H_ 00022 00023 #ifdef HAVE_CONFIG_H 00024 #include "config.h" 00025 #endif 00026 00027 #include "renderer.h" 00028 #include "palette.h" 00029 #include "rect.h" 00030 00036 class base_renderer : public renderer { 00037 private: 00038 palette _pal; 00039 char * _data; 00040 int _frame; 00041 int _nbframes; 00042 int _width; 00043 int _height; 00044 std::string _fname; 00045 protected: 00046 virtual void save(int frame = -1) = 0; 00047 00048 protected: 00049 const std::string & get_filename() const throw() { return _fname; }; 00050 int get_nbframes() const throw() { return _nbframes; }; 00051 int get_width() const throw() { return _width; }; 00052 int get_height() const throw() { return _height; }; 00053 const palette & pal() const throw() { return _pal; }; 00054 const char * data() const throw() { return _data; }; 00055 void clean() throw(); 00056 void set_frame(int f) throw() { _frame = f; }; 00057 public: 00058 int get_frame() const throw() { return _frame; }; 00059 base_renderer() throw(); 00060 virtual ~base_renderer() throw(); 00061 00062 virtual bool init_frame(const point & size) throw(std::exception); 00063 virtual char * lock_frame(int frame) throw(std::exception); 00064 virtual bool unlock_frame() throw(); 00065 virtual bool flip_frame() throw(); 00066 virtual bool set_palette(const palette & pal) throw(); 00067 virtual bool start_decode(const std::string & fname, int version, int nbframes) throw() { _fname = fname; _nbframes = nbframes; return true; } 00068 virtual sound_renderer * get_sound_renderer() throw(std::exception) { return 0; }; 00069 }; 00070 00076 class null_renderer : public base_renderer { 00077 protected: 00078 void save(int frame = -1) {}; 00079 public: 00080 null_renderer() throw() {}; 00081 virtual ~null_renderer() throw() {}; 00082 bool wait(int ms) throw() { return true; }; 00083 }; 00084 00085 #endif