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);
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.
@ BM_BLACK_REMAP
Perform remapping to a completely blackened sprite.
@ BM_COLOUR_REMAP
Perform a colour remapping.
@ BM_TRANSPARENT_REMAP
Perform transparency colour remapping.
@ BM_TRANSPARENT
Perform transparency darkening remapping.
@ BM_CRASH_REMAP
Perform a crash remapping.
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override
Draw an image to the screen, given an amount of params defined above.
Sprite * Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override
Convert a sprite from the loader to our own format.
Factory for the 8bpp blitter optimised for speed.
T * Allocate(size_t count)
Get buffer of at least count times T.
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.
void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
void MemSetT(T *ptr, uint8_t value, size_t num=1)
Type-safe version of memset().
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.
uint32_t offset[ZOOM_LVL_END]
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.
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.
ZoomLevel
All zoom levels we know.
@ ZOOM_LVL_MAX
Maximum zoom level.
@ ZOOM_LVL_MIN
Minimum zoom level.