# base.hpp

Go to the documentation of this file.

    00001 /* $Id: base.hpp 18809 2010-01-15 16:41:15Z 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
    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, int 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 SetPixelIfEmpty(void *video, int x, int y, uint8 colour) = 0;
    00105
    00113   virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0;
    00114
    00126   virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour) = 0;
    00127
    00136   virtual void CopyFromBuffer(void *video, const void *src, int width, int height) = 0;
    00137
    00146   virtual void CopyToBuffer(const void *video, void *dst, int width, int height) = 0;
    00147
    00156   virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0;
    00157
    00168   virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) = 0;
    00169
    00176   virtual int BufferSize(int width, int height) = 0;
    00177
    00184   virtual void PaletteAnimate(uint start, uint count) = 0;
    00185
    00190   virtual Blitter::PaletteAnimation UsePaletteAnimation() = 0;
    00191
    00195   virtual const char *GetName() = 0;
    00196
    00200   virtual int GetBytesPerPixel() = 0;
    00201
    00205   virtual void PostResize() { };
    00206
    00207   virtual ~Blitter() { }
    00208 };
    00209
    00210 #endif /* BLITTER_BASE_HPP */