diff options
Diffstat (limited to 'src/blitter')
-rw-r--r-- | src/blitter/32bpp_anim.cpp | 1 | ||||
-rw-r--r-- | src/blitter/32bpp_anim.hpp | 8 | ||||
-rw-r--r-- | src/blitter/32bpp_base.hpp | 4 | ||||
-rw-r--r-- | src/blitter/32bpp_optimized.cpp | 1 | ||||
-rw-r--r-- | src/blitter/32bpp_optimized.hpp | 7 | ||||
-rw-r--r-- | src/blitter/32bpp_simple.cpp | 1 | ||||
-rw-r--r-- | src/blitter/32bpp_simple.hpp | 2 | ||||
-rw-r--r-- | src/blitter/8bpp_base.hpp | 3 | ||||
-rw-r--r-- | src/blitter/8bpp_debug.cpp | 1 | ||||
-rw-r--r-- | src/blitter/8bpp_debug.hpp | 2 | ||||
-rw-r--r-- | src/blitter/8bpp_optimized.cpp | 1 | ||||
-rw-r--r-- | src/blitter/8bpp_optimized.hpp | 7 | ||||
-rw-r--r-- | src/blitter/8bpp_simple.cpp | 1 | ||||
-rw-r--r-- | src/blitter/8bpp_simple.hpp | 2 | ||||
-rw-r--r-- | src/blitter/base.cpp | 12 | ||||
-rw-r--r-- | src/blitter/base.hpp | 48 | ||||
-rw-r--r-- | src/blitter/factory.hpp | 19 | ||||
-rw-r--r-- | src/blitter/null.cpp | 1 | ||||
-rw-r--r-- | src/blitter/null.hpp | 4 |
19 files changed, 82 insertions, 43 deletions
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp index a7f9a2e75..6549ca842 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -16,6 +16,7 @@ #include "../table/sprites.h" +/** Instantiation of the 32bpp with animation blitter factory. */ static FBlitter_32bppAnim iFBlitter_32bppAnim; template <BlitterMode mode> diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp index 02765698b..39a55c514 100644 --- a/src/blitter/32bpp_anim.hpp +++ b/src/blitter/32bpp_anim.hpp @@ -14,11 +14,12 @@ #include "32bpp_optimized.hpp" +/** The optimised 32 bpp blitter with palette animation. */ class Blitter_32bppAnim : public Blitter_32bppOptimized { private: - uint8 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation - int anim_buf_width; - int anim_buf_height; + uint8 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation + int anim_buf_width; ///< The width of the animation buffer. + int anim_buf_height; ///< The height of the animation buffer. public: Blitter_32bppAnim() : @@ -45,6 +46,7 @@ public: template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); }; +/** Factory for the 32bpp blitter with animation. */ class FBlitter_32bppAnim: public BlitterFactory<FBlitter_32bppAnim> { public: /* virtual */ const char *GetName() { return "32bpp-anim"; } diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp index 8312b00a5..1c9d331b6 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -16,12 +16,10 @@ #include "../core/bitmath_func.hpp" #include "../gfx_func.h" +/** Base for all 32bpp blitters. */ class Blitter_32bppBase : public Blitter { public: /* virtual */ uint8 GetScreenDepth() { return 32; } -// /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); -// /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal); -// /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator); /* virtual */ void *MoveTo(const void *video, int x, int y); /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour); /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour); diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp index b9c1f037b..91e04c02a 100644 --- a/src/blitter/32bpp_optimized.cpp +++ b/src/blitter/32bpp_optimized.cpp @@ -14,6 +14,7 @@ #include "../core/math_func.hpp" #include "32bpp_optimized.hpp" +/** Instantiation of the optimized 32bpp blitter factory. */ static FBlitter_32bppOptimized iFBlitter_32bppOptimized; /** diff --git a/src/blitter/32bpp_optimized.hpp b/src/blitter/32bpp_optimized.hpp index 07c5b5201..c8cfd91cf 100644 --- a/src/blitter/32bpp_optimized.hpp +++ b/src/blitter/32bpp_optimized.hpp @@ -14,11 +14,13 @@ #include "32bpp_simple.hpp" +/** The optimised 32 bpp blitter (without palette animation). */ class Blitter_32bppOptimized : public Blitter_32bppSimple { public: + /** Data stored about a (single) sprite. */ struct SpriteData { - uint32 offset[ZOOM_LVL_COUNT][2]; - byte data[]; + uint32 offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information. + byte data[]; ///< Data, all zoomlevels. }; /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -29,6 +31,7 @@ public: template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); }; +/** Factory for the optimised 32 bpp blitter (without palette animation). */ class FBlitter_32bppOptimized: public BlitterFactory<FBlitter_32bppOptimized> { public: /* virtual */ const char *GetName() { return "32bpp-optimized"; } diff --git a/src/blitter/32bpp_simple.cpp b/src/blitter/32bpp_simple.cpp index 57d0ca078..43b31dd3c 100644 --- a/src/blitter/32bpp_simple.cpp +++ b/src/blitter/32bpp_simple.cpp @@ -15,6 +15,7 @@ #include "../table/sprites.h" +/** Instantiation of the simple 32bpp blitter factory. */ static FBlitter_32bppSimple iFBlitter_32bppSimple; void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) diff --git a/src/blitter/32bpp_simple.hpp b/src/blitter/32bpp_simple.hpp index 233c1723d..501cf4c26 100644 --- a/src/blitter/32bpp_simple.hpp +++ b/src/blitter/32bpp_simple.hpp @@ -15,6 +15,7 @@ #include "32bpp_base.hpp" #include "factory.hpp" +/** The most trivial 32 bpp blitter (without palette animation). */ class Blitter_32bppSimple : public Blitter_32bppBase { public: /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -24,6 +25,7 @@ public: /* virtual */ const char *GetName() { return "32bpp-simple"; } }; +/** Factory for the simple 32 bpp blitter. */ class FBlitter_32bppSimple: public BlitterFactory<FBlitter_32bppSimple> { public: /* virtual */ const char *GetName() { return "32bpp-simple"; } diff --git a/src/blitter/8bpp_base.hpp b/src/blitter/8bpp_base.hpp index c1e484679..03f194763 100644 --- a/src/blitter/8bpp_base.hpp +++ b/src/blitter/8bpp_base.hpp @@ -14,12 +14,11 @@ #include "base.hpp" +/** Base for all 8bpp blitters. */ class Blitter_8bppBase : public Blitter { public: /* virtual */ uint8 GetScreenDepth() { return 8; } -// /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal); -// /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator); /* virtual */ void *MoveTo(const void *video, int x, int y); /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour); /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour); diff --git a/src/blitter/8bpp_debug.cpp b/src/blitter/8bpp_debug.cpp index e57517c99..a79eccbd9 100644 --- a/src/blitter/8bpp_debug.cpp +++ b/src/blitter/8bpp_debug.cpp @@ -14,6 +14,7 @@ #include "../core/random_func.hpp" #include "8bpp_debug.hpp" +/** Instantiation of the 8bpp debug blitter factory. */ static FBlitter_8bppDebug iFBlitter_8bppDebug; void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) diff --git a/src/blitter/8bpp_debug.hpp b/src/blitter/8bpp_debug.hpp index 3e1ad61f5..b020d3b00 100644 --- a/src/blitter/8bpp_debug.hpp +++ b/src/blitter/8bpp_debug.hpp @@ -15,6 +15,7 @@ #include "8bpp_base.hpp" #include "factory.hpp" +/** 8bpp debug blitter; colours each sprite differently. */ class Blitter_8bppDebug : public Blitter_8bppBase { public: /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -23,6 +24,7 @@ public: /* virtual */ const char *GetName() { return "8bpp-debug"; } }; +/** Factory for the 8bpp debug blitter. */ class FBlitter_8bppDebug: public BlitterFactory<FBlitter_8bppDebug> { public: /* virtual */ const char *GetName() { return "8bpp-debug"; } diff --git a/src/blitter/8bpp_optimized.cpp b/src/blitter/8bpp_optimized.cpp index 45ac4a9c4..ed3d24a77 100644 --- a/src/blitter/8bpp_optimized.cpp +++ b/src/blitter/8bpp_optimized.cpp @@ -14,6 +14,7 @@ #include "../core/math_func.hpp" #include "8bpp_optimized.hpp" +/** Instantiation of the 8bpp optimised blitter factory. */ static FBlitter_8bppOptimized iFBlitter_8bppOptimized; void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) diff --git a/src/blitter/8bpp_optimized.hpp b/src/blitter/8bpp_optimized.hpp index 5445e8055..d6c5c8956 100644 --- a/src/blitter/8bpp_optimized.hpp +++ b/src/blitter/8bpp_optimized.hpp @@ -15,11 +15,13 @@ #include "8bpp_base.hpp" #include "factory.hpp" +/** 8bpp blitter optimised for speed. */ class Blitter_8bppOptimized : public Blitter_8bppBase { public: + /** Data stored about a (single) sprite. */ struct SpriteData { - uint32 offset[ZOOM_LVL_COUNT]; ///< offsets (from .data) to streams for different zoom levels - byte data[]; ///< data, all zoomlevels + uint32 offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels. + byte data[]; ///< Data, all zoomlevels. }; /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -28,6 +30,7 @@ public: /* virtual */ const char *GetName() { return "8bpp-optimized"; } }; +/** Factory for the 8bpp blitter optimised for speed. */ class FBlitter_8bppOptimized: public BlitterFactory<FBlitter_8bppOptimized> { public: /* virtual */ const char *GetName() { return "8bpp-optimized"; } diff --git a/src/blitter/8bpp_simple.cpp b/src/blitter/8bpp_simple.cpp index 1b373cc0e..f8a808186 100644 --- a/src/blitter/8bpp_simple.cpp +++ b/src/blitter/8bpp_simple.cpp @@ -13,6 +13,7 @@ #include "../zoom_func.h" #include "8bpp_simple.hpp" +/** Instantiation of the simple 8bpp blitter factory. */ static FBlitter_8bppSimple iFBlitter_8bppSimple; void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) diff --git a/src/blitter/8bpp_simple.hpp b/src/blitter/8bpp_simple.hpp index 47485e16f..b0af35e90 100644 --- a/src/blitter/8bpp_simple.hpp +++ b/src/blitter/8bpp_simple.hpp @@ -15,6 +15,7 @@ #include "8bpp_base.hpp" #include "factory.hpp" +/** Most trivial 8bpp blitter. */ class Blitter_8bppSimple : public Blitter_8bppBase { public: /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -23,6 +24,7 @@ public: /* virtual */ const char *GetName() { return "8bpp-simple"; } }; +/** Factory for the most trivial 8bpp blitter. */ class FBlitter_8bppSimple: public BlitterFactory<FBlitter_8bppSimple> { public: /* virtual */ const char *GetName() { return "8bpp-simple"; } diff --git a/src/blitter/base.cpp b/src/blitter/base.cpp index d8e33cede..1e6afdad5 100644 --- a/src/blitter/base.cpp +++ b/src/blitter/base.cpp @@ -13,18 +13,6 @@ #include "base.hpp" #include "../core/math_func.hpp" -/** - * Draw a line with a given colour. - * @param video The destination pointer (video-buffer). - * @param x The x coordinate from where the line starts. - * @param y The y coordinate from where the line starts. - * @param x2 The x coordinate to where the line goes. - * @param y2 The y coordinate to where the lines goes. - * @param screen_width The width of the screen you are drawing in (to avoid buffer-overflows). - * @param screen_height The height of the screen you are drawing in (to avoid buffer-overflows). - * @param colour A 8bpp mapping colour. - * @param width Line width. - */ void Blitter::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width) { int dy; diff --git a/src/blitter/base.hpp b/src/blitter/base.hpp index cb76f856e..21d42d64c 100644 --- a/src/blitter/base.hpp +++ b/src/blitter/base.hpp @@ -15,10 +15,11 @@ #include "../spritecache.h" #include "../spriteloader/spriteloader.hpp" +/** The modes of blitting we can do. */ enum BlitterMode { - BM_NORMAL, - BM_COLOUR_REMAP, - BM_TRANSPARENT, + BM_NORMAL, ///< Perform the simple blitting. + BM_COLOUR_REMAP, ///< Perform a colour remapping. + BM_TRANSPARENT, ///< Perform transparency colour remapping. }; /** @@ -26,20 +27,25 @@ enum BlitterMode { */ class Blitter { public: + /** Parameters related to blitting. */ struct BlitterParams { - const void *sprite; ///< Pointer to the sprite how ever the encoder stored it - const byte *remap; ///< XXX -- Temporary storage for remap array - - int skip_left, skip_top; ///< How much pixels of the source to skip on the left and top (based on zoom of dst) - int width, height; ///< The width and height in pixels that needs to be drawn to dst - int sprite_width; ///< Real width of the sprite - int sprite_height; ///< Real height of the sprite - int left, top; ///< The offset in the 'dst' in pixels to start drawing - - void *dst; ///< Destination buffer - int pitch; ///< The pitch of the destination buffer + const void *sprite; ///< Pointer to the sprite how ever the encoder stored it + const byte *remap; ///< XXX -- Temporary storage for remap array + + int skip_left; ///< How much pixels of the source to skip on the left (based on zoom of dst) + int skip_top; ///< How much pixels of the source to skip on the top (based on zoom of dst) + int width; ///< The width in pixels that needs to be drawn to dst + int height; ///< The height in pixels that needs to be drawn to dst + int sprite_width; ///< Real width of the sprite + int sprite_height; ///< Real height of the sprite + int left; ///< The left offset in the 'dst' in pixels to start drawing + int top; ///< The top offset in the 'dst' in pixels to start drawing + + void *dst; ///< Destination buffer + int pitch; ///< The pitch of the destination buffer }; + /** Types of palette animation. */ enum PaletteAnimation { PALETTE_ANIMATION_NONE, ///< No palette animation PALETTE_ANIMATION_VIDEO_BACKEND, ///< Palette animation should be done by video backend (8bpp only!) @@ -101,7 +107,19 @@ public: */ virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0; - void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width); + /** + * Draw a line with a given colour. + * @param video The destination pointer (video-buffer). + * @param x The x coordinate from where the line starts. + * @param y The y coordinate from where the line starts. + * @param x2 The x coordinate to where the line goes. + * @param y2 The y coordinate to where the lines goes. + * @param screen_width The width of the screen you are drawing in (to avoid buffer-overflows). + * @param screen_height The height of the screen you are drawing in (to avoid buffer-overflows). + * @param colour A 8bpp mapping colour. + * @param width Line width. + */ + virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width); /** * Copy from a buffer to the screen. diff --git a/src/blitter/factory.hpp b/src/blitter/factory.hpp index cdacdac2f..7d25823a6 100644 --- a/src/blitter/factory.hpp +++ b/src/blitter/factory.hpp @@ -27,16 +27,24 @@ bool QZ_CanDisplay8bpp(); */ class BlitterFactoryBase { private: - const char *name; + const char *name; ///< The name of the blitter factory. - typedef std::map<const char *, BlitterFactoryBase *, StringCompare> Blitters; + typedef std::map<const char *, BlitterFactoryBase *, StringCompare> Blitters; ///< Map of blitter factories. + /** + * Get the map with currently known blitters. + * @return The known blitters. + */ static Blitters &GetBlitters() { static Blitters &s_blitters = *new Blitters(); return s_blitters; } + /** + * Get the currently active blitter. + * @return The currently active blitter. + */ static Blitter **GetActiveBlitter() { static Blitter *s_blitter = NULL; @@ -121,7 +129,12 @@ public: return *GetActiveBlitter(); } - + /** + * Fill a buffer with information about the blitters. + * @param p The buffer to fill. + * @param last The last element of the buffer. + * @return p The location till where we filled the buffer. + */ static char *GetBlittersInfo(char *p, const char *last) { p += seprintf(p, last, "List of blitters:\n"); diff --git a/src/blitter/null.cpp b/src/blitter/null.cpp index 4b70e52fb..470b88354 100644 --- a/src/blitter/null.cpp +++ b/src/blitter/null.cpp @@ -12,6 +12,7 @@ #include "../stdafx.h" #include "null.hpp" +/** Instantiation of the null blitter factory. */ static FBlitter_Null iFBlitter_Null; Sprite *Blitter_Null::Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator) diff --git a/src/blitter/null.hpp b/src/blitter/null.hpp index d3a3a317a..e9e157d72 100644 --- a/src/blitter/null.hpp +++ b/src/blitter/null.hpp @@ -14,6 +14,7 @@ #include "factory.hpp" +/** Blitter that does nothing. */ class Blitter_Null : public Blitter { public: /* virtual */ uint8 GetScreenDepth() { return 0; } @@ -23,7 +24,7 @@ public: /* virtual */ void *MoveTo(const void *video, int x, int y) { return NULL; }; /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour) {}; /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour) {}; - /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour) {}; + /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width) {}; /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height) {}; /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height) {}; /* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) {}; @@ -36,6 +37,7 @@ public: /* virtual */ int GetBytesPerPixel() { return 0; } }; +/** Factory for the blitter that doesn nothing. */ class FBlitter_Null: public BlitterFactory<FBlitter_Null> { public: /* virtual */ const char *GetName() { return "null"; } |