11#include "../zoom_func.h"
12#include "../settings_type.h"
15#include "../safeguards.h"
24 uint offset = sprite_src->
offset[zoom];
27 const uint8_t *src = sprite_src->
data + offset;
28 uint8_t *dst_line = (uint8_t *)bp->
dst + bp->
top * bp->
pitch + bp->
left;
31 for (
int y = 0; y < bp->
skip_top; y++) {
35 if (trans == 0 && pixels == 0)
break;
40 const uint8_t *src_next = src;
42 for (
int y = 0; y < bp->
height; y++) {
43 uint8_t *dst = dst_line;
44 dst_line += bp->
pitch;
47 int width = bp->
width;
53 src_next = src + pixels;
54 if (trans == 0 && pixels == 0)
break;
55 if (width <= 0)
continue;
58 if (skip_left < trans) {
65 if (skip_left < pixels) {
75 if (skip_left != 0)
continue;
80 if (width <= 0 || pixels == 0)
continue;
81 pixels = std::min<uint>(pixels, width);
87 const uint8_t *remap = bp->
remap;
92 }
while (--pixels != 0);
97 std::fill_n(dst, pixels, 0);
103 const uint8_t *remap = bp->
remap;
108 }
while (--pixels != 0);
113 std::copy_n(src, pixels, dst);
114 dst += pixels; src += pixels;
138 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
139 memory += sprite[i].width * sprite[i].height;
150 uint8_t *dst = temp_dst->
data;
153 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
156 uint offset = dst - temp_dst->
data;
157 temp_dst->
offset[i] = offset;
160 int scaled_height = src_orig.
height;
161 int scaled_width = src_orig.
width;
163 for (
int y = 0; y < scaled_height; y++) {
166 uint last_colour = 0;
167 uint8_t *count_dst =
nullptr;
172 for (
int x = 0; x < scaled_width; x++) {
173 uint colour = src++->
m;
175 if (last_colour == 0 || colour == 0 || pixels == 255) {
176 if (count_dst !=
nullptr) {
183 if (colour == 0 && trans != 255) {
196 last_colour = colour;
206 if (count_dst !=
nullptr) *count_dst = pixels;
214 uint size = dst - (uint8_t *)temp_dst;
217 assert(size < memory);
222 const auto &root_sprite = sprite.Root();
227 std::copy_n(
reinterpret_cast<std::byte *
>(temp_dst), size, dest_sprite->
data);
static FBlitter_8bppOptimized iFBlitter_8bppOptimized
Instantiation of the 8bpp optimised blitter factory.
An optimized 8 bpp blitter.
BlitterMode
The modes of blitting we can do.
@ Transparent
Perform transparency darkening remapping.
@ CrashRemap
Perform a crash remapping.
@ BlackRemap
Perform remapping to a completely blackened sprite.
@ TransparentRemap
Perform transparency colour remapping.
@ ColourRemap
Perform a colour remapping.
Sprite * Encode(SpriteType sprite_type, const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override
Convert a sprite from the loader to our own format.
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override
Draw an image to the screen, given an amount of params defined above.
Factory for the 8bpp blitter optimised for speed.
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
T * ZeroAllocate(size_t count)
Get buffer of at least count times T of default initialised elements.
Interface for something that can allocate memory for a sprite.
T * Allocate(size_t size)
Allocate memory for a sprite.
SpriteType
Types of sprites that might be loaded.
@ Font
A sprite used for fonts.
ClientSettings _settings_client
The current settings for this game.
Parameters related to blitting.
int skip_top
How much pixels of the source to skip on the top (based on zoom of dst)
void * dst
Destination buffer.
int left
The left offset in the 'dst' in pixels to start drawing.
int pitch
The pitch of the destination buffer.
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst)
int height
The height in pixels that needs to be drawn to dst.
const uint8_t * remap
XXX – Temporary storage for remap array.
int width
The width in pixels that needs to be drawn to dst.
const void * sprite
Pointer to the sprite how ever the encoder stored it.
int top
The top offset in the 'dst' in pixels to start drawing.
Data stored about a (single) sprite.
SpriteCollMap< uint32_t > offset
Offsets (from .data) to streams for different zoom levels.
uint8_t data[]
Data, all zoomlevels.
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.
std::byte data[]
Sprite data.
int16_t x_offs
Number of pixels to shift the sprite to the right.
ZoomLevel
All zoom levels we know.