Go to the documentation of this file.
10 #ifndef BLITTER_32BPP_BASE_HPP
11 #define BLITTER_32BPP_BASE_HPP
14 #include "../core/bitmath_func.hpp"
15 #include "../core/math_func.hpp"
16 #include "../gfx_func.h"
22 void *
MoveTo(
void *video,
int x,
int y)
override;
23 void SetPixel(
void *video,
int x,
int y, uint8 colour)
override;
24 void DrawLine(
void *video,
int x,
int y,
int x2,
int y2,
int screen_width,
int screen_height, uint8 colour,
int width,
int dash)
override;
25 void DrawRect(
void *video,
int width,
int height, uint8 colour)
override;
26 void CopyFromBuffer(
void *video,
const void *src,
int width,
int height)
override;
27 void CopyToBuffer(
const void *video,
void *dst,
int width,
int height)
override;
28 void CopyImageToBuffer(
const void *video,
void *dst,
int width,
int height,
int dst_pitch)
override;
29 void ScrollBuffer(
void *video,
int &left,
int &top,
int &width,
int &height,
int scroll_x,
int scroll_y)
override;
30 int BufferSize(
int width,
int height)
override;
54 ((
int)(r - cr) * a) / 256 + cr,
55 ((
int)(g - cg) * a) / 256 + cg,
56 ((
int)(b - cb) * a) / 256 + cb);
65 if (a == 0)
return current;
66 if (a >= 255)
return Colour(r, g, b);
89 if (a == 0)
return current;
111 return Colour(r * nom / denom, g * nom / denom, b * nom / denom);
121 static inline uint8
MakeDark(uint8 r, uint8 g, uint8 b)
124 return ((r * 13063) + (g * 25647) + (b * 4981)) / 65536;
134 uint8 d =
MakeDark(colour.r, colour.g, colour.b);
153 uint grey = ((r * 19595) + (g * 38470) + (b * 7471)) / 65536;
155 return Colour(grey, grey, grey);
158 static const int DEFAULT_BRIGHTNESS = 128;
160 static Colour ReallyAdjustBrightness(
Colour colour, uint8 brightness);
162 static inline Colour AdjustBrightness(
Colour colour, uint8 brightness)
165 if (brightness == DEFAULT_BRIGHTNESS)
return colour;
167 return ReallyAdjustBrightness(colour, brightness);
170 static inline uint8 GetColourBrightness(
Colour colour)
172 uint8 rgb_max = std::max(colour.r, std::max(colour.g, colour.b));
175 if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
void * MoveTo(void *video, int x, int y) override
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
How all blitters should look like.
void PaletteAnimate(const Palette &palette) override
Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to...
Base for all 32bpp blitters.
static Colour ComposeColourPANoCheck(Colour colour, uint a, Colour current)
Compose a colour based on Pixel value, alpha value, and the current pixel value.
void SetPixel(void *video, int x, int y, uint8 colour) override
Draw a pixel with a given colour on the video-buffer.
static Colour MakeDark(Colour colour)
Make a colour dark grey, for specialized 32bpp remapping.
void CopyToBuffer(const void *video, void *dst, int width, int height) override
Copy from the screen to a buffer.
static Colour MakeGrey(Colour colour)
Make a colour grey - based.
void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override
Scroll the videobuffer some 'x' and 'y' value.
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!
void CopyFromBuffer(void *video, const void *src, int width, int height) override
Copy from a buffer to the screen.
uint8 GetScreenDepth() override
Get the screen depth this blitter works for.
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 LookupColourInPalette(uint index)
Look up the colour in the current palette.
static uint8 MakeDark(uint8 r, uint8 g, uint8 b)
Make a colour dark grey, for specialized 32bpp remapping.
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
PaletteAnimation
Types of palette animation.
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.
uint8 a
colour channels in LE order
int GetBytesPerPixel() override
Get how many bytes are needed to store a pixel.
void DrawRect(void *video, int width, int height, uint8 colour) override
Make a single horizontal line in a single colour on the video-buffer.
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 MakeTransparent(Colour colour, uint nom, uint denom=256)
Make a pixel looks like it is transparent.
Palette _cur_palette
Current palette.
Blitter::PaletteAnimation UsePaletteAnimation() override
Check if the blitter uses palette animation at all.
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override
Draw a line with a given colour.
int BufferSize(int width, int height) override
Calculate how much memory there is needed for an image of this size in the video-buffer.
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override
Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp.
Information about the currently used palette.