OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../zoom_func.h"
12 #include "../settings_type.h"
13 #include "../core/math_func.hpp"
14 #include "../core/mem_func.hpp"
17 #include "../safeguards.h"
26 uint offset = sprite_src->
offset[zoom];
29 const uint8_t *src = sprite_src->
data + offset;
30 uint8_t *dst_line = (uint8_t *)bp->
dst + bp->
top * bp->
pitch + bp->
left;
33 for (
int y = 0; y < bp->
skip_top; y++) {
37 if (trans == 0 && pixels == 0)
break;
42 const uint8_t *src_next = src;
44 for (
int y = 0; y < bp->
height; y++) {
45 uint8_t *dst = dst_line;
46 dst_line += bp->
pitch;
49 int width = bp->
width;
55 src_next = src + pixels;
56 if (trans == 0 && pixels == 0)
break;
57 if (width <= 0)
continue;
60 if (skip_left < trans) {
67 if (skip_left < pixels) {
77 if (skip_left != 0)
continue;
82 if (width <= 0 || pixels == 0)
continue;
83 pixels = std::min<uint>(pixels, width);
89 const uint8_t *remap = bp->
remap;
94 }
while (--pixels != 0);
105 const uint8_t *remap = bp->
remap;
110 }
while (--pixels != 0);
116 dst += pixels; src += pixels;
140 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
141 memory += sprite[i].width * sprite[i].height;
152 memset(temp_dst, 0,
sizeof(*temp_dst));
153 uint8_t *dst = temp_dst->
data;
156 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
158 uint offset = dst - temp_dst->
data;
159 temp_dst->
offset[i] = offset;
162 int scaled_height = sprite[i].height;
163 int scaled_width = sprite[i].width;
165 for (
int y = 0; y < scaled_height; y++) {
168 uint last_colour = 0;
169 uint8_t *count_dst =
nullptr;
174 for (
int x = 0; x < scaled_width; x++) {
175 uint colour = src++->
m;
177 if (last_colour == 0 || colour == 0 || pixels == 255) {
178 if (count_dst !=
nullptr) {
185 if (colour == 0 && trans != 255) {
198 last_colour = colour;
208 if (count_dst !=
nullptr) *count_dst = pixels;
216 uint size = dst - (uint8_t *)temp_dst;
219 assert(size < memory);
228 memcpy(dest_sprite->
data, temp_dst, size);
uint16_t height
Height of the sprite.
Data stored about a (single) sprite.
int16_t x_offs
Number of pixels to shift the sprite to the right.
int top
The top offset in the 'dst' in pixels to start drawing.
@ BM_TRANSPARENT
Perform transparency darkening remapping.
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst)
BlitterMode
The modes of blitting we can do.
int width
The width in pixels that needs to be drawn to dst.
const uint8_t * remap
XXX – Temporary storage for remap array.
void * dst
Destination buffer.
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override
Draw an image to the screen, given an amount of params defined above.
int pitch
The pitch of the destination buffer.
ClientSettings _settings_client
The current settings for this game.
T * Allocate(size_t count)
Get buffer of at least count times T.
ZoomLevel zoom_max
maximum zoom out level
Interface for something that can allocate memory for a sprite.
std::array< Sprite, ZOOM_LVL_END > SpriteCollection
Type defining a collection of sprites, one for each zoom level.
@ ZOOM_LVL_MIN
Minimum zoom level.
void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
const void * sprite
Pointer to the sprite how ever the encoder stored it.
static FBlitter_8bppOptimized iFBlitter_8bppOptimized
Instantiation of the 8bpp optimised blitter factory.
@ BM_COLOUR_REMAP
Perform a colour remapping.
Definition of a common pixel in OpenTTD's realm.
uint16_t width
Width of the sprite.
Factory for the 8bpp blitter optimised for speed.
@ BM_CRASH_REMAP
Perform a crash remapping.
@ BM_BLACK_REMAP
Perform remapping to a completely blackened sprite.
T * Allocate(size_t size)
Allocate memory for a sprite.
Sprite * Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override
Convert a sprite from the loader to our own format.
ZoomLevel zoom_min
minimum zoom out level
@ ZOOM_LVL_MAX
Maximum zoom level.
int16_t y_offs
Number of pixels to shift the sprite downwards.
int left
The left offset in the 'dst' in pixels to start drawing.
uint32_t offset[ZOOM_LVL_END]
Offsets (from .data) to streams for different zoom levels.
Parameters related to blitting.
@ Font
A sprite used for fonts.
int height
The height in pixels that needs to be drawn to dst.
uint8_t data[]
Sprite data.
void MemSetT(T *ptr, uint8_t value, size_t num=1)
Type-safe version of memset().
int skip_top
How much pixels of the source to skip on the top (based on zoom of dst)
Data structure describing a sprite.
@ BM_TRANSPARENT_REMAP
Perform transparency colour remapping.
GUISettings gui
settings related to the GUI
ZoomLevel
All zoom levels we know.
uint8_t data[]
Data, all zoomlevels.