# base.hpp

Go to the documentation of this file.

    00001 /* $Id: base.hpp 26541 2014-04-29 18:18:52Z frosch $ */
    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   BM_CRASH_REMAP,
    00024 };
    00025
    00029 class Blitter {
    00030 public:
    00032   struct BlitterParams {
    00033     const void *sprite;
    00034     const byte *remap;
    00035
    00036     int skip_left;
    00037     int skip_top;
    00038     int width;
    00039     int height;
    00040     int sprite_width;
    00041     int sprite_height;
    00042     int left;
    00043     int top;
    00044
    00045     void *dst;
    00046     int pitch;
    00047   };
    00048
    00050   enum PaletteAnimation {
    00051     PALETTE_ANIMATION_NONE,
    00052     PALETTE_ANIMATION_VIDEO_BACKEND,
    00053     PALETTE_ANIMATION_BLITTER,
    00054   };
    00055
    00060   virtual uint8 GetScreenDepth() = 0;
    00061
    00065   virtual void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) = 0;
    00066
    00076   virtual void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) = 0;
    00077
    00081   virtual Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) = 0;
    00082
    00091   virtual void *MoveTo(void *video, int x, int y) = 0;
    00092
    00100   virtual void SetPixel(void *video, int x, int y, uint8 colour) = 0;
    00101
    00109   virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0;
    00110
    00124   virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash = 0);
    00125
    00134   virtual void CopyFromBuffer(void *video, const void *src, int width, int height) = 0;
    00135
    00144   virtual void CopyToBuffer(const void *video, void *dst, int width, int height) = 0;
    00145
    00154   virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0;
    00155
    00166   virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) = 0;
    00167
    00174   virtual int BufferSize(int width, int height) = 0;
    00175
    00181   virtual void PaletteAnimate(const Palette &palette) = 0;
    00182
    00187   virtual Blitter::PaletteAnimation UsePaletteAnimation() = 0;
    00188
    00192   virtual const char *GetName() = 0;
    00193
    00197   virtual int GetBytesPerPixel() = 0;
    00198
    00202   virtual void PostResize() { };
    00203
    00204   virtual ~Blitter() { }
    00205 };
    00206
    00207 #endif /* BLITTER_BASE_HPP */