From f3f744d36a60431a6845d2b7e3ce17e64ee2e4f5 Mon Sep 17 00:00:00 2001 From: truelight Date: Tue, 12 Jun 2007 20:24:12 +0000 Subject: (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 --- src/blitter/8bpp_debug.cpp | 8 ++++---- src/blitter/8bpp_debug.hpp | 10 +++++----- src/blitter/8bpp_optimized.cpp | 10 +++++----- src/blitter/8bpp_optimized.hpp | 10 +++++----- src/blitter/8bpp_simple.cpp | 8 ++++---- src/blitter/8bpp_simple.hpp | 10 +++++----- src/blitter/blitter.hpp | 5 +++++ src/blitter/null.cpp | 24 ++++++++++++++++++++++++ src/blitter/null.hpp | 30 ++++++++++++++++++++++++++++++ 9 files changed, 87 insertions(+), 28 deletions(-) create mode 100644 src/blitter/null.cpp create mode 100644 src/blitter/null.hpp (limited to 'src/blitter') 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 { 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 { 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 { 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 { +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 */ -- cgit v1.2.3-54-g00ecf