OpenTTD
Public Member Functions | Protected Attributes
Blitter_32bppAnim Class Reference

The optimised 32 bpp blitter with palette animation. More...

#include <32bpp_anim.hpp>

Inheritance diagram for Blitter_32bppAnim:
Blitter_32bppOptimized Blitter_32bppSimple Blitter_32bppBase Blitter

Public Member Functions

void Draw (Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
 Draws a sprite to a (screen) buffer.
void DrawColourMappingRect (void *dst, int width, int height, PaletteID pal)
 Draw a colourtable to the screen.
void SetPixel (void *video, int x, int y, uint8 colour)
 Draw a pixel with a given colour on the video-buffer.
void DrawRect (void *video, int width, int height, uint8 colour)
 Make a single horizontal line in a single colour on the video-buffer.
void CopyFromBuffer (void *video, const void *src, int width, int height)
 Copy from a buffer to the screen.
void CopyToBuffer (const void *video, void *dst, int width, int height)
 Copy from the screen to a buffer.
void ScrollBuffer (void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
 Scroll the videobuffer some 'x' and 'y' value.
int BufferSize (int width, int height)
 Calculate how much memory there is needed for an image of this size in the video-buffer.
void PaletteAnimate (const Palette &palette)
 Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to the 8bpp palette indexes 'first_dirty' to 'first_dirty + count_dirty'.
Blitter::PaletteAnimation UsePaletteAnimation ()
 Check if the blitter uses palette animation at all.
const char * GetName ()
 Get the name of the blitter, the same as the Factory-instance returns.
int GetBytesPerPixel ()
 Get how many bytes are needed to store a pixel.
void PostResize ()
 Post resize event.
Colour LookupColourInPalette (uint index)
 Look up the colour in the current palette.
template<BlitterMode mode>
void Draw (const Blitter::BlitterParams *bp, ZoomLevel zoom)
 Draws a sprite to a (screen) buffer.
- Public Member Functions inherited from Blitter_32bppOptimized
SpriteEncode (const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
 Convert a sprite from the loader to our own format.

Protected Attributes

uint16 * 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.
Palette palette
 The current palette.

Additional Inherited Members

- Public Types inherited from Blitter
enum  PaletteAnimation { PALETTE_ANIMATION_NONE, PALETTE_ANIMATION_VIDEO_BACKEND, PALETTE_ANIMATION_BLITTER }
 Types of palette animation. More...
- Static Public Member Functions inherited from Blitter_32bppBase
static Colour ComposeColourRGBANoCheck (uint r, uint g, uint b, uint a, Colour current)
 Compose a colour based on RGBA values and the current pixel value.
static Colour ComposeColourRGBA (uint r, uint g, uint b, uint a, Colour current)
 Compose a colour based on RGBA values and the current pixel value.
static Colour ComposeColourPANoCheck (Colour colour, uint a, Colour current)
 Compose a colour based on Pixel value, alpha value, and the current pixel value.
static Colour ComposeColourPA (Colour colour, uint a, Colour current)
 Compose a colour based on Pixel value, alpha value, and the current pixel value.
static Colour MakeTransparent (Colour colour, uint nom, uint denom=256)
 Make a pixel looks like it is transparent.
static uint8 MakeDark (uint8 r, uint8 g, uint8 b)
 Make a colour dark grey, for specialized 32bpp remapping.
static Colour MakeGrey (Colour colour)
 Make a colour grey - based.
static Colour AdjustBrightness (Colour colour, uint8 brightness)
- Static Public Attributes inherited from Blitter_32bppBase
static const int DEFAULT_BRIGHTNESS = 128

Detailed Description

The optimised 32 bpp blitter with palette animation.

Definition at line 18 of file 32bpp_anim.hpp.

Member Function Documentation

int Blitter_32bppAnim::BufferSize ( int  width,
int  height 
)
virtual

Calculate how much memory there is needed for an image of this size in the video-buffer.

Parameters
widthThe width of the buffer-to-be.
heightThe height of the buffer-to-be.
Returns
The size needed for the buffer.

Reimplemented from Blitter_32bppBase.

Definition at line 468 of file 32bpp_anim.cpp.

void Blitter_32bppAnim::CopyFromBuffer ( void *  video,
const void *  src,
int  width,
int  height 
)
virtual

Copy from a buffer to the screen.

Parameters
videoThe destination pointer (video-buffer).
srcThe buffer from which the data will be read.
widthThe width of the buffer.
heightThe height of the buffer.
Note
You can not do anything with the content of the buffer, as the blitter can store non-pixel data in it too!

Reimplemented from Blitter_32bppBase.

Definition at line 354 of file 32bpp_anim.cpp.

References _screen_disable_anim, anim_buf, anim_buf_width, GB(), LookupColourInPalette(), and PALETTE_ANIM_START.

void Blitter_32bppAnim::CopyToBuffer ( const void *  video,
void *  dst,
int  width,
int  height 
)
virtual

Copy from the screen to a buffer.

Parameters
videoThe destination pointer (video-buffer).
dstThe buffer in which the data will be stored.
widthThe width of the buffer.
heightThe height of the buffer.
Note
You can not do anything with the content of the buffer, as the blitter can store non-pixel data in it too!

Reimplemented from Blitter_32bppBase.

Definition at line 394 of file 32bpp_anim.cpp.

References _screen_disable_anim, anim_buf, and anim_buf_width.

void Blitter_32bppAnim::Draw ( Blitter::BlitterParams bp,
BlitterMode  mode,
ZoomLevel  zoom 
)
virtual

Draws a sprite to a (screen) buffer.

Calls adequate templated function.

Parameters
bpfurther blitting parameters
modeblitter mode
zoomzoom level at which we are drawing

Reimplemented from Blitter_32bppOptimized.

Definition at line 255 of file 32bpp_anim.cpp.

References _screen_disable_anim, BM_BLACK_REMAP, BM_COLOUR_REMAP, BM_CRASH_REMAP, BM_NORMAL, and BM_TRANSPARENT.

template<BlitterMode mode>
void Blitter_32bppAnim::Draw ( const Blitter::BlitterParams bp,
ZoomLevel  zoom 
)
inline
void Blitter_32bppAnim::DrawColourMappingRect ( void *  dst,
int  width,
int  height,
PaletteID  pal 
)
virtual

Draw a colourtable to the screen.

This is: the colour of the screen is read and is looked-up in the palette to match a new colour, which then is put on the screen again.

Parameters
dstthe destination pointer (video-buffer).
widththe width of the buffer.
heightthe height of the buffer.
palthe palette to use.

Reimplemented from Blitter_32bppSimple.

Definition at line 273 of file 32bpp_anim.cpp.

References _screen_disable_anim, anim_buf, anim_buf_width, DEBUG, Blitter_32bppBase::MakeGrey(), Blitter_32bppBase::MakeTransparent(), PALETTE_NEWSPAPER, and PALETTE_TO_TRANSPARENT.

void Blitter_32bppAnim::DrawRect ( void *  video,
int  width,
int  height,
uint8  colour 
)
virtual

Make a single horizontal line in a single colour on the video-buffer.

Parameters
videoThe destination pointer (video-buffer).
widthThe length of the line.
heightThe height of the line.
colourA 8bpp mapping colour.

Reimplemented from Blitter_32bppBase.

Definition at line 325 of file 32bpp_anim.cpp.

References _screen_disable_anim, anim_buf, and LookupColourInPalette().

void Blitter_32bppAnim::PaletteAnimate ( const Palette palette)
virtual

Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to the 8bpp palette indexes 'first_dirty' to 'first_dirty + count_dirty'.

Parameters
paletteThe new palette.

Reimplemented from Blitter_32bppBase.

Definition at line 473 of file 32bpp_anim.cpp.

References _screen_disable_anim, anim_buf, anim_buf_height, anim_buf_width, Palette::first_dirty, GB(), VideoDriver::GetInstance(), LookupColourInPalette(), VideoDriver::MakeDirty(), palette, and PALETTE_ANIM_START.

void Blitter_32bppAnim::ScrollBuffer ( void *  video,
int &  left,
int &  top,
int &  width,
int &  height,
int  scroll_x,
int  scroll_y 
)
virtual

Scroll the videobuffer some 'x' and 'y' value.

Parameters
videoThe buffer to scroll into.
leftThe left value of the screen to scroll.
topThe top value of the screen to scroll.
widthThe width of the screen to scroll.
heightThe height of the screen to scroll.
scroll_xHow much to scroll in X.
scroll_yHow much to scroll in Y.

Reimplemented from Blitter_32bppBase.

Definition at line 417 of file 32bpp_anim.cpp.

References _screen_disable_anim, anim_buf, and anim_buf_width.

void Blitter_32bppAnim::SetPixel ( void *  video,
int  x,
int  y,
uint8  colour 
)
virtual

Draw a pixel with a given colour on the video-buffer.

Parameters
videoThe destination pointer (video-buffer).
xThe x position within video-buffer.
yThe y position within video-buffer.
colourA 8bpp mapping colour.

Reimplemented from Blitter_32bppBase.

Definition at line 316 of file 32bpp_anim.cpp.

References _screen_disable_anim, anim_buf, anim_buf_width, and LookupColourInPalette().

Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation ( )
virtual

Check if the blitter uses palette animation at all.

Returns
True if it uses palette animation.

Reimplemented from Blitter_32bppBase.

Definition at line 504 of file 32bpp_anim.cpp.

References Blitter::PALETTE_ANIMATION_BLITTER.


The documentation for this class was generated from the following files: