base.hpp

Go to the documentation of this file.
00001 /* $Id: base.hpp 23448 2011-12-08 19:37:33Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #ifndef BLITTER_BASE_HPP
00013 #define BLITTER_BASE_HPP
00014 
00015 #include "../spritecache.h"
00016 #include "../spriteloader/spriteloader.hpp"
00017 
00019 enum BlitterMode {
00020   BM_NORMAL,       
00021   BM_COLOUR_REMAP, 
00022   BM_TRANSPARENT,  
00023 };
00024 
00028 class Blitter {
00029 public:
00031   struct BlitterParams {
00032     const void *sprite; 
00033     const byte *remap;  
00034 
00035     int skip_left;      
00036     int skip_top;       
00037     int width;          
00038     int height;         
00039     int sprite_width;   
00040     int sprite_height;  
00041     int left;           
00042     int top;            
00043 
00044     void *dst;          
00045     int pitch;          
00046   };
00047 
00049   enum PaletteAnimation {
00050     PALETTE_ANIMATION_NONE,           
00051     PALETTE_ANIMATION_VIDEO_BACKEND,  
00052     PALETTE_ANIMATION_BLITTER,        
00053   };
00054 
00059   virtual uint8 GetScreenDepth() = 0;
00060 
00064   virtual void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) = 0;
00065 
00075   virtual void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) = 0;
00076 
00080   virtual Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator) = 0;
00081 
00090   virtual void *MoveTo(void *video, int x, int y) = 0;
00091 
00099   virtual void SetPixel(void *video, int x, int y, uint8 colour) = 0;
00100 
00108   virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0;
00109 
00122   virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width);
00123 
00132   virtual void CopyFromBuffer(void *video, const void *src, int width, int height) = 0;
00133 
00142   virtual void CopyToBuffer(const void *video, void *dst, int width, int height) = 0;
00143 
00152   virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0;
00153 
00164   virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) = 0;
00165 
00172   virtual int BufferSize(int width, int height) = 0;
00173 
00179   virtual void PaletteAnimate(const Palette &palette) = 0;
00180 
00185   virtual Blitter::PaletteAnimation UsePaletteAnimation() = 0;
00186 
00190   virtual const char *GetName() = 0;
00191 
00195   virtual int GetBytesPerPixel() = 0;
00196 
00200   virtual void PostResize() { };
00201 
00202   virtual ~Blitter() { }
00203 };
00204 
00205 #endif /* BLITTER_BASE_HPP */