10#ifndef BLITTER_32BPP_BASE_HPP
11#define BLITTER_32BPP_BASE_HPP
14#include "../gfx_func.h"
15#include "../palette_func.h"
21 void *
MoveTo(
void *video,
int x,
int y)
override;
22 void SetPixel(
void *video,
int x,
int y, uint8_t colour)
override;
23 void DrawLine(
void *video,
int x,
int y,
int x2,
int y2,
int screen_width,
int screen_height, uint8_t colour,
int width,
int dash)
override;
24 void DrawRect(
void *video,
int width,
int height, uint8_t colour)
override;
25 void CopyFromBuffer(
void *video,
const void *src,
int width,
int height)
override;
26 void CopyToBuffer(
const void *video,
void *dst,
int width,
int height)
override;
27 void CopyImageToBuffer(
const void *video,
void *dst,
int width,
int height,
int dst_pitch)
override;
28 void ScrollBuffer(
void *video,
int &left,
int &top,
int &width,
int &height,
int scroll_x,
int scroll_y)
override;
29 size_t BufferSize(uint width, uint height)
override;
52 ((
int)(r - cr) * a) / 256 + cr,
53 ((
int)(g - cg) * a) / 256 + cg,
54 ((
int)(b - cb) * a) / 256 + cb);
63 if (a == 0)
return current;
64 if (a >= 255)
return Colour(r, g, b);
87 if (a == 0)
return current;
109 return Colour(r * nom / denom, g * nom / denom, b * nom / denom);
119 static inline uint8_t
MakeDark(uint8_t r, uint8_t g, uint8_t b)
122 return ((r * 13063) + (g * 25647) + (b * 4981)) / 65536;
132 uint8_t d =
MakeDark(colour.r, colour.g, colour.b);
134 return Colour(d, d, d);
151 uint grey = ((r * 19595) + (g * 38470) + (b * 7471)) / 65536;
153 return Colour(grey, grey, grey);
Base for all 32bpp blitters.
size_t BufferSize(uint width, uint height) override
Calculate how much memory there is needed for an image of this size in 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.
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override
Draw a line with a given colour.
static Colour ComposeColourPANoCheck(Colour colour, uint a, Colour current)
Compose a colour based on Pixel value, alpha value, and the current pixel value.
void CopyToBuffer(const void *video, void *dst, int width, int height) override
Copy from the screen to a buffer.
void DrawRect(void *video, int width, int height, uint8_t colour) override
Make a single horizontal line in a single colour on the video-buffer.
static Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
static Colour MakeTransparent(Colour colour, uint nom, uint denom=256)
Make a pixel looks like it is transparent.
static Colour ComposeColourPA(Colour colour, uint a, Colour current)
Compose a colour based on Pixel value, alpha value, and the current pixel value.
Blitter::PaletteAnimation UsePaletteAnimation() override
Check if the blitter uses palette animation at all.
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...
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.
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...
void CopyFromBuffer(void *video, const void *src, int width, int height) override
Copy from a buffer to the screen.
static Colour MakeGrey(Colour colour)
Make a colour grey - based.
static uint8_t MakeDark(uint8_t r, uint8_t g, uint8_t b)
Make a colour dark grey, for specialized 32bpp remapping.
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.
static Colour MakeDark(Colour colour)
Make a colour dark grey, for specialized 32bpp remapping.
uint8_t GetScreenDepth() override
Get the screen depth this blitter works for.
void SetPixel(void *video, int x, int y, uint8_t colour) override
Draw a pixel with a given colour on the video-buffer.
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.
How all blitters should look like.
PaletteAnimation
Types of palette animation.
Palette _cur_palette
Current palette.
Information about the currently used palette.
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!