From aa190c9f92902b284cc745cb61b9b784eb1328e3 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Tue, 16 Feb 2021 08:50:54 +0200 Subject: [PATCH] Uncached LRGB->RGB conversion The new LRGB->RGB conversion is in speed comparable to array lookup, so instead of precomputing the palette and then looking up values, just recompute the conversion for each pixel. --- src/library/framebuffer-pixfmt-lrgb.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/library/framebuffer-pixfmt-lrgb.cpp b/src/library/framebuffer-pixfmt-lrgb.cpp index a44f9395..9fbb6d9a 100644 --- a/src/library/framebuffer-pixfmt-lrgb.cpp +++ b/src/library/framebuffer-pixfmt-lrgb.cpp @@ -46,7 +46,7 @@ void _pixfmt_lrgb::decode(uint32_t* target, const uint8_t* src, size_t width, { const uint32_t* _src = reinterpret_cast(src); for(size_t i = 0; i < width; i++) - target[i] = auxp.pcache[_src[i] & 0x7FFFF]; + target[i] = convert_lowcolor(_src[i], auxp.rshift, auxp.gshift, auxp.bshift); } void _pixfmt_lrgb::decode(uint64_t* target, const uint8_t* src, size_t width, @@ -54,16 +54,12 @@ void _pixfmt_lrgb::decode(uint64_t* target, const uint8_t* src, size_t width, { const uint32_t* _src = reinterpret_cast(src); for(size_t i = 0; i < width; i++) - target[i] = auxp.pcache[_src[i] & 0x7FFFF]; + target[i] = convert_hicolor(_src[i], auxp.rshift, auxp.gshift, auxp.bshift); } void _pixfmt_lrgb::set_palette(auxpalette& auxp, uint8_t rshift, uint8_t gshift, uint8_t bshift) { - auxp.pcache.resize(0x80000); - for(size_t i = 0; i < 0x80000; i++) { - auxp.pcache[i] = convert_lowcolor(i, rshift, gshift, bshift); - } auxp.rshift = rshift; auxp.gshift = gshift; auxp.bshift = bshift; @@ -72,10 +68,6 @@ void _pixfmt_lrgb::set_palette(auxpalette& auxp, uint8_t rshift, uint8_t void _pixfmt_lrgb::set_palette(auxpalette& auxp, uint8_t rshift, uint8_t gshift, uint8_t bshift) { - auxp.pcache.resize(0x80000); - for(size_t i = 0; i < 0x80000; i++) { - auxp.pcache[i] = convert_hicolor(i, rshift, gshift, bshift); - } auxp.rshift = rshift; auxp.gshift = gshift; auxp.bshift = bshift;