From 9db68c5d7688ffc8afb17ddee6db279928ef757d Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 19 Jan 2023 15:08:52 +0100 Subject: [PATCH] Only draw visible pixels --- source/utils/DrawUtils.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/utils/DrawUtils.cpp b/source/utils/DrawUtils.cpp index 77e717a..607fb36 100644 --- a/source/utils/DrawUtils.cpp +++ b/source/utils/DrawUtils.cpp @@ -121,6 +121,9 @@ void DrawUtils::clear(Color col) { } void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + if (a == 0) { + return; + } float opacity = a / 255.0f; // put pixel in the drc buffer @@ -302,6 +305,9 @@ void DrawUtils::setFontColor(Color col) { } static void draw_freetype_bitmap(SFT_Image *bmp, int32_t x, int32_t y) { + if (font_col.a == 0) { + return; + } int32_t i, j, p, q; int32_t x_max = x + bmp->width; @@ -314,6 +320,9 @@ static void draw_freetype_bitmap(SFT_Image *bmp, int32_t x, int32_t y) { if (i < 0 || j < 0 || i >= SCREEN_WIDTH || j >= SCREEN_HEIGHT) { continue; } + if (src[q * bmp->width + p] == 0) { + continue; + } float opacity = src[q * bmp->width + p] / 255.0f; DrawUtils::drawPixel(i, j, font_col.r, font_col.g, font_col.b, font_col.a * opacity);