# base.hpp

Go to the documentation of this file.

    00001 /* $Id: base.hpp 18907 2010-01-23 22:37:14Z alberth $ */
    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
    00018 enum BlitterMode {
    00019   BM_NORMAL,
    00020   BM_COLOUR_REMAP,
    00021   BM_TRANSPARENT,
    00022 };
    00023
    00027 class Blitter {
    00028 public:
    00029   struct BlitterParams {
    00030     const void *sprite;
    00031     const byte *remap;
    00032
    00033     int skip_left, skip_top;
    00034     int width, height;
    00035     int sprite_width;
    00036     int sprite_height;
    00037     int left, top;
    00038
    00039     void *dst;
    00040     int pitch;
    00041   };
    00042
    00043   enum PaletteAnimation {
    00044     PALETTE_ANIMATION_NONE,
    00045     PALETTE_ANIMATION_VIDEO_BACKEND,
    00046     PALETTE_ANIMATION_BLITTER,
    00047   };
    00048
    00049   typedef void *AllocatorProc(size_t size);
    00050
    00055   virtual uint8 GetScreenDepth() = 0;
    00056
    00060   virtual void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) = 0;
    00061
    00071   virtual void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) = 0;
    00072
    00076   virtual Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) = 0;
    00077
    00086   virtual void *MoveTo(const void *video, int x, int y) = 0;
    00087
    00095   virtual void SetPixel(void *video, int x, int y, uint8 colour) = 0;
    00096
    00104   virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0;
    00105
    00117   virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour) = 0;
    00118
    00127   virtual void CopyFromBuffer(void *video, const void *src, int width, int height) = 0;
    00128
    00137   virtual void CopyToBuffer(const void *video, void *dst, int width, int height) = 0;
    00138
    00147   virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0;
    00148
    00159   virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) = 0;
    00160
    00167   virtual int BufferSize(int width, int height) = 0;
    00168
    00175   virtual void PaletteAnimate(uint start, uint count) = 0;
    00176
    00181   virtual Blitter::PaletteAnimation UsePaletteAnimation() = 0;
    00182
    00186   virtual const char *GetName() = 0;
    00187
    00191   virtual int GetBytesPerPixel() = 0;
    00192
    00196   virtual void PostResize() { };
    00197
    00198   virtual ~Blitter() { }
    00199 };
    00200
    00201 #endif /* BLITTER_BASE_HPP */