13#include "../zoom_func.h"
14#include "../settings_type.h"
18#include "../safeguards.h"
21static FBlitter_32bppSSE2 iFBlitter_32bppSSE2;
39 memset(&sd, 0,
sizeof(sd));
40 uint all_sprites_size = 0;
41 for (
ZoomLevel z = zoom_min; z <= zoom_max; z++) {
43 sd.infos[z].sprite_width = src_sprite->
width;
44 sd.infos[z].sprite_offset = all_sprites_size;
45 sd.infos[z].sprite_line_size =
sizeof(
Colour) * src_sprite->
width +
sizeof(uint32_t) * META_LENGTH;
47 const uint rgba_size = sd.infos[z].sprite_line_size * src_sprite->
height;
48 sd.infos[z].mv_offset = all_sprites_size + rgba_size;
50 const uint mv_size =
sizeof(MapValue) * src_sprite->
width * src_sprite->
height;
51 all_sprites_size += rgba_size + mv_size;
59 memcpy(dst_sprite->
data, &sd,
sizeof(SpriteData));
62 bool has_remap =
false;
63 bool has_anim =
false;
64 bool has_translucency =
false;
65 for (
ZoomLevel z = zoom_min; z <= zoom_max; z++) {
68 Colour *dst_rgba_line = (
Colour *) &dst_sprite->
data[
sizeof(SpriteData) + sd.infos[z].sprite_offset];
69 MapValue *dst_mv = (MapValue *) &dst_sprite->
data[
sizeof(SpriteData) + sd.infos[z].mv_offset];
70 for (uint y = src_sprite->height; y != 0; y--) {
71 Colour *dst_rgba = dst_rgba_line + META_LENGTH;
72 for (uint x = src_sprite->width; x != 0; x--) {
75 if (src->a != 0 && src->a != 255) has_translucency =
true;
83 const uint8_t rgb_max = std::max({src->r, src->g, src->b});
84 dst_mv->v = (rgb_max == 0) ? Blitter_32bppBase::DEFAULT_BRIGHTNESS : rgb_max;
88 dst_rgba->r = colour.r;
89 dst_rgba->g = colour.g;
90 dst_rgba->
b = colour.
b;
95 dst_mv->v = Blitter_32bppBase::DEFAULT_BRIGHTNESS;
99 *(uint16_t*) dst_mv = 0;
107 dst_rgba = dst_rgba_line + META_LENGTH;
108 uint32_t nb_pix_transp = 0;
109 for (uint x = src_sprite->width; x != 0; x--) {
110 if (dst_rgba->a == 0) nb_pix_transp++;
114 (*dst_rgba_line).
data = nb_pix_transp;
116 Colour *nb_right = dst_rgba_line + 1;
117 dst_rgba_line = (
Colour*) ((uint8_t*) dst_rgba_line + sd.infos[z].sprite_line_size);
120 dst_rgba = dst_rgba_line - 1;
122 for (uint x = src_sprite->width; x != 0; x--) {
123 if (dst_rgba->a == 0) nb_pix_transp++;
127 (*nb_right).
data = nb_pix_transp;
133 if (has_translucency) sd.flags |= SF_TRANSLUCENT;
134 if (!has_remap) sd.flags |= SF_NO_REMAP;
135 if (!has_anim) sd.flags |= SF_NO_ANIM;
136 memcpy(dst_sprite->
data, &sd,
sizeof(SpriteData));
Functions related to SSE 32 bpp blitter.
static Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
Interface for something that can allocate memory for a sprite.
T * Allocate(size_t size)
Allocate memory for a sprite.
std::array< Sprite, ZOOM_LVL_END > SpriteCollection
Type defining a collection of sprites, one for each zoom level.
@ Font
A sprite used for fonts.
static constexpr uint8_t PALETTE_ANIM_START
Index in the _palettes array from which all animations are taking places (table/palettes....
ClientSettings _settings_client
The current settings for this game.
GUISettings gui
settings related to the GUI
ZoomLevel zoom_min
minimum zoom out level
ZoomLevel zoom_max
maximum zoom out level
Definition of a common pixel in OpenTTD's realm.
Structure for passing information from the sprite loader to the blitter.
uint16_t width
Width of the sprite.
SpriteLoader::CommonPixel * data
The sprite itself.
uint16_t height
Height of the sprite.
Data structure describing a sprite.
uint16_t width
Width of the sprite.
uint16_t height
Height of the sprite.
int16_t y_offs
Number of pixels to shift the sprite downwards.
uint8_t data[]
Sprite data.
int16_t x_offs
Number of pixels to shift the sprite to the right.
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
uint32_t data
Conversion of the channel information to a 32 bit number.
uint8_t b
colour channels in BE order
ZoomLevel
All zoom levels we know.
@ ZOOM_LVL_MAX
Maximum zoom level.
@ ZOOM_LVL_MIN
Minimum zoom level.