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 *src = sprite_src->
data + offset;
33 for (
int y = 0; y < bp->
skip_top; y++) {
37 if (trans == 0 && pixels == 0)
break;
42 const uint8 *src_next = src;
44 for (
int y = 0; y < bp->
height; y++) {
45 uint8 *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 = min<uint>(pixels, (uint)width);
89 const uint8 *remap = bp->
remap;
94 }
while (--pixels != 0);
104 const uint8 *remap = bp->
remap;
109 }
while (--pixels != 0);
115 dst += pixels; src += pixels;
139 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
151 memset(temp_dst, 0,
sizeof(*temp_dst));
152 byte *dst = temp_dst->
data;
155 for (
ZoomLevel i = zoom_min; i <= zoom_max; i++) {
157 uint offset = dst - temp_dst->
data;
158 temp_dst->
offset[i] = offset;
161 int scaled_height = sprite[i].
height;
162 int scaled_width = sprite[i].
width;
164 for (
int y = 0; y < scaled_height; y++) {
167 uint last_colour = 0;
168 byte *count_dst =
nullptr;
173 for (
int x = 0; x < scaled_width; x++) {
174 uint colour = src++->
m;
176 if (last_colour == 0 || colour == 0 || pixels == 255) {
177 if (count_dst !=
nullptr) {
184 if (colour == 0 && trans != 255) {
197 last_colour = colour;
207 if (count_dst !=
nullptr) *count_dst = pixels;
215 uint size = dst - (byte *)temp_dst;
218 assert(size < memory);
221 Sprite *dest_sprite = (
Sprite *)allocator(
sizeof(*dest_sprite) + size);
227 memcpy(dest_sprite->
data, temp_dst, size);
int left
The left offset in the 'dst' in pixels to start drawing.
int height
The height in pixels that needs to be drawn to dst.
Perform transparency colour remapping.
int skip_top
How much pixels of the source to skip on the top (based on zoom of dst)
Data structure describing a sprite.
byte data[]
Data, all zoomlevels.
int width
The width in pixels that needs to be drawn to dst.
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst)
uint32 offset[ZOOM_LVL_COUNT]
Offsets (from .data) to streams for different zoom levels.
Definition of a common pixel in OpenTTD's realm.
SpriteType type
The sprite type.
int16 y_offs
Number of pixels to shift the sprite downwards.
Parameters related to blitting.
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override
Draw an image to the screen, given an amount of params defined above.
ClientSettings _settings_client
The current settings for this game.
int pitch
The pitch of the destination buffer.
T * Allocate(size_t count)
Get buffer of at least count times T.
int16 x_offs
The x-offset of where the sprite will be drawn.
SpriteLoader::CommonPixel * data
The sprite itself.
Perform a crash remapping.
ZoomLevel zoom_max
maximum zoom out level
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
Structure for passing information from the sprite loader to the blitter.
Perform remapping to a completely blackened sprite.
uint16 height
Height of the sprite.
static void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
uint16 width
Width of the sprite.
uint16 width
Width of the sprite.
int top
The top offset in the 'dst' in pixels to start drawing.
GUISettings gui
settings related to the GUI
const byte * remap
XXX – Temporary storage for remap array.
Sprite * Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override
Convert a sprite from the loader to our own format.
const void * sprite
Pointer to the sprite how ever the encoder stored it.
Perform a colour remapping.
static FBlitter_8bppOptimized iFBlitter_8bppOptimized
Instantiation of the 8bpp optimised blitter factory.
Data stored about a (single) sprite.
uint16 height
Height of the sprite.
Factory for the 8bpp blitter optimised for speed.
int16 x_offs
Number of pixels to shift the sprite to the right.
void * dst
Destination buffer.
int16 y_offs
The y-offset of where the sprite will be drawn.
BlitterMode
The modes of blitting we can do.
ZoomLevel
All zoom levels we know.
ZoomLevel zoom_min
minimum zoom out level
An optimized 8 bpp blitter.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().