Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
#include "../zoom_func.h"
|
||||
#include "../settings_type.h"
|
||||
#include "../core/math_func.hpp"
|
||||
#include "../core/mem_func.hpp"
|
||||
#include "8bpp_optimized.hpp"
|
||||
|
||||
#include "../safeguards.h"
|
||||
@@ -97,7 +96,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
|
||||
}
|
||||
|
||||
case BlitterMode::BlackRemap:
|
||||
MemSetT(dst, 0, pixels);
|
||||
std::fill_n(dst, pixels, 0);
|
||||
dst += pixels;
|
||||
break;
|
||||
|
||||
@@ -113,7 +112,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
|
||||
}
|
||||
|
||||
default:
|
||||
MemCpyT(dst, src, pixels);
|
||||
std::copy_n(src, pixels, dst);
|
||||
dst += pixels; src += pixels;
|
||||
break;
|
||||
}
|
||||
@@ -121,7 +120,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
|
||||
}
|
||||
}
|
||||
|
||||
Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
Sprite *Blitter_8bppOptimized::Encode(SpriteType sprite_type, const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
{
|
||||
/* Make memory for all zoom-levels */
|
||||
uint memory = sizeof(SpriteData);
|
||||
@@ -129,13 +128,13 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
ZoomLevel zoom_min;
|
||||
ZoomLevel zoom_max;
|
||||
|
||||
if (sprite[ZOOM_LVL_MIN].type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_MIN;
|
||||
zoom_max = ZOOM_LVL_MIN;
|
||||
if (sprite_type == SpriteType::Font) {
|
||||
zoom_min = ZoomLevel::Min;
|
||||
zoom_max = ZoomLevel::Min;
|
||||
} else {
|
||||
zoom_min = _settings_client.gui.zoom_min;
|
||||
zoom_max = _settings_client.gui.zoom_max;
|
||||
if (zoom_max == zoom_min) zoom_max = ZOOM_LVL_MAX;
|
||||
if (zoom_max == zoom_min) zoom_max = ZoomLevel::Max;
|
||||
}
|
||||
|
||||
for (ZoomLevel i = zoom_min; i <= zoom_max; i++) {
|
||||
@@ -154,13 +153,14 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
|
||||
/* Make the sprites per zoom-level */
|
||||
for (ZoomLevel i = zoom_min; i <= zoom_max; i++) {
|
||||
const SpriteLoader::Sprite &src_orig = sprite[i];
|
||||
/* Store the index table */
|
||||
uint offset = dst - temp_dst->data;
|
||||
temp_dst->offset[i] = offset;
|
||||
|
||||
/* cache values, because compiler can't cache it */
|
||||
int scaled_height = sprite[i].height;
|
||||
int scaled_width = sprite[i].width;
|
||||
int scaled_height = src_orig.height;
|
||||
int scaled_width = src_orig.width;
|
||||
|
||||
for (int y = 0; y < scaled_height; y++) {
|
||||
uint trans = 0;
|
||||
@@ -169,7 +169,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
uint8_t *count_dst = nullptr;
|
||||
|
||||
/* Store the scaled image */
|
||||
const SpriteLoader::CommonPixel *src = &sprite[i].data[y * sprite[i].width];
|
||||
const SpriteLoader::CommonPixel *src = &src_orig.data[y * src_orig.width];
|
||||
|
||||
for (int x = 0; x < scaled_width; x++) {
|
||||
uint colour = src++->m;
|
||||
@@ -221,11 +221,12 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
/* Allocate the exact amount of memory we need */
|
||||
Sprite *dest_sprite = allocator.Allocate<Sprite>(sizeof(*dest_sprite) + size);
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
memcpy(dest_sprite->data, temp_dst, size);
|
||||
const auto &root_sprite = sprite.Root();
|
||||
dest_sprite->height = root_sprite.height;
|
||||
dest_sprite->width = root_sprite.width;
|
||||
dest_sprite->x_offs = root_sprite.x_offs;
|
||||
dest_sprite->y_offs = root_sprite.y_offs;
|
||||
std::copy_n(reinterpret_cast<std::byte *>(temp_dst), size, dest_sprite->data);
|
||||
|
||||
return dest_sprite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user