# base.hpp

Go to the documentation of this file.

    00001 /* $Id$ */
    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 #include "../zoom_type.h"
    00018
    00019 enum BlitterMode {
    00020   BM_NORMAL,
    00021   BM_COLOUR_REMAP,
    00022   BM_TRANSPARENT,
    00023 };
    00024
    00028 class Blitter {
    00029 public:
    00030   struct BlitterParams {
    00031     const void *sprite;
    00032     const byte *remap;
    00033
    00034     int skip_left, skip_top;
    00035     int width, height;
    00036     int sprite_width;
    00037     int sprite_height;
    00038     int left, top;
    00039
    00040     void *dst;
    00041     int pitch;
    00042   };
    00043
    00044   enum PaletteAnimation {
    00045     PALETTE_ANIMATION_NONE,
    00046     PALETTE_ANIMATION_VIDEO_BACKEND,
    00047     PALETTE_ANIMATION_BLITTER,
    00048   };
    00049
    00050   typedef void *AllocatorProc(size_t size);
    00051
    00056   virtual uint8 GetScreenDepth() = 0;
    00057
    00061   virtual void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) = 0;
    00062
    00072   virtual void DrawColourMappingRect(void *dst, int width, int height, int pal) = 0;
    00073
    00077   virtual Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) = 0;
    00078
    00087   virtual void *MoveTo(const void *video, int x, int y) = 0;
    00088
    00096   virtual void SetPixel(void *video, int x, int y, uint8 colour) = 0;
    00097
    00105   virtual void SetPixelIfEmpty(void *video, int x, int y, uint8 colour) = 0;
    00106
    00114   virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0;
    00115
    00127   virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour) = 0;
    00128
    00137   virtual void CopyFromBuffer(void *video, const void *src, int width, int height) = 0;
    00138
    00147   virtual void CopyToBuffer(const void *video, void *dst, int width, int height) = 0;
    00148
    00157   virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0;
    00158
    00169   virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) = 0;
    00170
    00177   virtual int BufferSize(int width, int height) = 0;
    00178
    00185   virtual void PaletteAnimate(uint start, uint count) = 0;
    00186
    00191   virtual Blitter::PaletteAnimation UsePaletteAnimation() = 0;
    00192
    00196   virtual const char *GetName() = 0;
    00197
    00201   virtual int GetBytesPerPixel() = 0;
    00202
    00203   virtual ~Blitter() { }
    00204 };
    00205
    00206 #endif /* BLITTER_BASE_HPP */