diff options
author | truelight <truelight@openttd.org> | 2007-06-12 20:24:12 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2007-06-12 20:24:12 +0000 |
commit | f3f744d36a60431a6845d2b7e3ce17e64ee2e4f5 (patch) | |
tree | bed173ca279e1556489d31b0b8aa873a6d1cf110 /src/blitter | |
parent | 381b11c9796d6b40653f8b4c319c33f9920f047a (diff) | |
download | openttd-f3f744d36a60431a6845d2b7e3ce17e64ee2e4f5.tar.xz |
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
-Add: added NULL blitter and renderer, which are always used for -vnull
-Add: dedicated driver doesn't blit nor render by default. Can be overruled by user. (-D -b 8bpp-optimized)
-Remove: removed CTRL+D from win32, which is incompatible with above
-Add: extended screenshot support for PNG and BMP
-Codechange: remove all hardcoded 8bpp references and replace them with more dynamic ones
-Codechange: minor stuff in blitters
Diffstat (limited to 'src/blitter')
-rw-r--r-- | src/blitter/8bpp_debug.cpp | 8 | ||||
-rw-r--r-- | src/blitter/8bpp_debug.hpp | 10 | ||||
-rw-r--r-- | src/blitter/8bpp_optimized.cpp | 10 | ||||
-rw-r--r-- | src/blitter/8bpp_optimized.hpp | 10 | ||||
-rw-r--r-- | src/blitter/8bpp_simple.cpp | 8 | ||||
-rw-r--r-- | src/blitter/8bpp_simple.hpp | 10 | ||||
-rw-r--r-- | src/blitter/blitter.hpp | 5 | ||||
-rw-r--r-- | src/blitter/null.cpp | 24 | ||||
-rw-r--r-- | src/blitter/null.hpp | 30 |
9 files changed, 87 insertions, 28 deletions
diff --git a/src/blitter/8bpp_debug.cpp b/src/blitter/8bpp_debug.cpp index 3f4c0b046..3a9b52d2a 100644 --- a/src/blitter/8bpp_debug.cpp +++ b/src/blitter/8bpp_debug.cpp @@ -12,12 +12,12 @@ static FBlitter_8bppDebug iFBlitter_8bppDebug; void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) { - const byte *src, *src_line; - Pixel8 *dst, *dst_line; + const uint8 *src, *src_line; + uint8 *dst, *dst_line; /* Find where to start reading in the source sprite */ - src_line = (const byte *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); - dst_line = (Pixel8 *)bp->dst + bp->top * bp->pitch + bp->left; + src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); + dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; for (int y = 0; y < bp->height; y++) { dst = dst_line; diff --git a/src/blitter/8bpp_debug.hpp b/src/blitter/8bpp_debug.hpp index 443fb20c4..7b8484f70 100644 --- a/src/blitter/8bpp_debug.hpp +++ b/src/blitter/8bpp_debug.hpp @@ -7,15 +7,15 @@ #include "blitter.hpp" -typedef Pixel Pixel8; - class Blitter_8bppDebug : public Blitter { public: - uint8 GetScreenDepth() { return 8; } + /* virtual */ uint8 GetScreenDepth() { return 8; } + + /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); + /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); - Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); + /* virtual */ const char *GetRenderer() { return "8bpp"; } }; class FBlitter_8bppDebug: public BlitterFactory<FBlitter_8bppDebug> { diff --git a/src/blitter/8bpp_optimized.cpp b/src/blitter/8bpp_optimized.cpp index 7a105544c..9af922e30 100644 --- a/src/blitter/8bpp_optimized.cpp +++ b/src/blitter/8bpp_optimized.cpp @@ -12,16 +12,16 @@ static FBlitter_8bppOptimized iFBlitter_8bppOptimized; void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) { - const byte *src, *src_next; - Pixel8 *dst, *dst_line; + const uint8 *src, *src_next; + uint8 *dst, *dst_line; uint offset = 0; /* Find the offset of this zoom-level */ - offset = ((const byte *)bp->sprite)[(int)zoom * 2] | ((const byte *)bp->sprite)[(int)zoom * 2 + 1] << 8; + offset = ((const uint8 *)bp->sprite)[(int)zoom * 2] | ((const byte *)bp->sprite)[(int)zoom * 2 + 1] << 8; /* Find where to start reading in the source sprite */ - src = (const byte *)bp->sprite + offset; - dst_line = (Pixel8 *)bp->dst + bp->top * bp->pitch + bp->left; + src = (const uint8 *)bp->sprite + offset; + dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; /* Skip over the top lines in the source image */ for (int y = 0; y < bp->skip_top; y++) { diff --git a/src/blitter/8bpp_optimized.hpp b/src/blitter/8bpp_optimized.hpp index b7f8b694f..540e9d1c6 100644 --- a/src/blitter/8bpp_optimized.hpp +++ b/src/blitter/8bpp_optimized.hpp @@ -7,15 +7,15 @@ #include "blitter.hpp" -typedef Pixel Pixel8; - class Blitter_8bppOptimized : public Blitter { public: - uint8 GetScreenDepth() { return 8; } + /* virtual */ uint8 GetScreenDepth() { return 8; } + + /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); + /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); - Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); + /* virtual */ const char *GetRenderer() { return "8bpp"; } }; class FBlitter_8bppOptimized: public BlitterFactory<FBlitter_8bppOptimized> { diff --git a/src/blitter/8bpp_simple.cpp b/src/blitter/8bpp_simple.cpp index 170afa460..010066f8a 100644 --- a/src/blitter/8bpp_simple.cpp +++ b/src/blitter/8bpp_simple.cpp @@ -11,12 +11,12 @@ static FBlitter_8bppSimple iFBlitter_8bppSimple; void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) { - const byte *src, *src_line; - Pixel8 *dst, *dst_line; + const uint8 *src, *src_line; + uint8 *dst, *dst_line; /* Find where to start reading in the source sprite */ - src_line = (const byte *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); - dst_line = (Pixel8 *)bp->dst + bp->top * bp->pitch + bp->left; + src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); + dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; for (int y = 0; y < bp->height; y++) { dst = dst_line; diff --git a/src/blitter/8bpp_simple.hpp b/src/blitter/8bpp_simple.hpp index f47245729..1188e509d 100644 --- a/src/blitter/8bpp_simple.hpp +++ b/src/blitter/8bpp_simple.hpp @@ -7,15 +7,15 @@ #include "blitter.hpp" -typedef Pixel Pixel8; - class Blitter_8bppSimple : public Blitter { public: - uint8 GetScreenDepth() { return 8; } + /* virtual */ uint8 GetScreenDepth() { return 8; } + + /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); + /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); - Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); + /* virtual */ const char *GetRenderer() { return "8bpp"; } }; class FBlitter_8bppSimple: public BlitterFactory<FBlitter_8bppSimple> { diff --git a/src/blitter/blitter.hpp b/src/blitter/blitter.hpp index 1114dbf58..b2e0edfe3 100644 --- a/src/blitter/blitter.hpp +++ b/src/blitter/blitter.hpp @@ -53,6 +53,11 @@ public: */ virtual Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) = 0; + /** + * Get the renderer this class depends on. + */ + virtual const char *GetRenderer() = 0; + virtual ~Blitter() { } }; diff --git a/src/blitter/null.cpp b/src/blitter/null.cpp new file mode 100644 index 000000000..1aad792a1 --- /dev/null +++ b/src/blitter/null.cpp @@ -0,0 +1,24 @@ +#include "../stdafx.h" +#include "../zoom.hpp" +#include "../gfx.h" +#include "../functions.h" +#include "null.hpp" + +static FBlitter_Null iFBlitter_Null; + +void Blitter_Null::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) +{ +} + +Sprite *Blitter_Null::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) +{ + Sprite *dest_sprite; + dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite)); + + dest_sprite->height = sprite->height; + dest_sprite->width = sprite->width; + dest_sprite->x_offs = sprite->x_offs; + dest_sprite->y_offs = sprite->y_offs; + + return dest_sprite; +} diff --git a/src/blitter/null.hpp b/src/blitter/null.hpp new file mode 100644 index 000000000..5278bd474 --- /dev/null +++ b/src/blitter/null.hpp @@ -0,0 +1,30 @@ +/* $Id$ */ + +/** @file null.hpp */ + +#ifndef BLITTER_NULL_HPP +#define BLITTER_NULL_HPP + +#include "blitter.hpp" + +class Blitter_Null : public Blitter { +public: + /* virtual */ uint8 GetScreenDepth() { return 0; } + + /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); + + /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); + + /* virtual */ const char *GetRenderer() { return "null"; } +}; + +class FBlitter_Null: public BlitterFactory<FBlitter_Null> { +public: + /* virtual */ const char *GetName() { return "null"; } + + /* virtual */ const char *GetDescription() { return "Null Blitter (does nothing)"; } + + /* virtual */ Blitter *CreateInstance() { return new Blitter_Null(); } +}; + +#endif /* BLITTER_NULL_HPP */ |