From 25b73fd1c19750105ba6126d379f3cd1f0a9fd63 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 1 Mar 2020 17:40:23 +0100 Subject: WIP: Remove unused pixel functions. --- plugingui/painter.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'plugingui/painter.cc') diff --git a/plugingui/painter.cc b/plugingui/painter.cc index 89d7498..761fe9b 100644 --- a/plugingui/painter.cc +++ b/plugingui/painter.cc @@ -65,7 +65,8 @@ static void plot(PixelBufferAlpha& pixbuf, const Colour& colour, } // plot the pixel at (x, y) with brightness c (where 0 ≤ c ≤ 1) - pixbuf.addPixel(x, y, colour.red(), colour.green(), colour.blue(), colour.alpha() * c); + Colour col(colour.red(), colour.green(), colour.blue(), (std::uint8_t)(colour.alpha() * c)); + pixbuf.addPixel(x, y, col); } static inline double fpart(double x) @@ -202,21 +203,19 @@ void Painter::drawText(int x0, int y0, const Font& font, { for(int x = -1 * std::min(0, x0); x < renderWidth; ++x) { - unsigned char r, g, b, a; - assert(x >= 0); assert(y >= 0); assert(x < (int)textbuf->width); assert(y < (int)textbuf->height); - textbuf->pixel(x, y, &r, &g, &b, &a); + auto c = textbuf->pixel(x, y); assert(x + x0 >= 0); assert(y + y0 >= 0); assert(x + x0 < (int)pixbuf.width); assert(y + y0 < (int)pixbuf.height); - pixbuf.addPixel(x + x0, y + y0, r, g, b, a); + pixbuf.addPixel(x + x0, y + y0, c); } } } @@ -226,22 +225,21 @@ void Painter::drawText(int x0, int y0, const Font& font, { for(int x = -1 * std::min(0, x0); x < renderWidth; ++x) { - unsigned char r,g,b,a; - assert(x >= 0); assert(y >= 0); assert(x < (int)textbuf->width); assert(y < (int)textbuf->height); - textbuf->pixel(x, y, &r, &g, &b, &a); + auto c = textbuf->pixel(x, y); assert(x + x0 >= 0); assert(y + y0 >= 0); assert(x + x0 < (int)pixbuf.width); assert(y + y0 < (int)pixbuf.height); - pixbuf.addPixel(x + x0, y + y0, colour.red(), colour.green(), - colour.blue(), (int)(colour.alpha() * a) / 255); + Colour col(colour.red(), colour.green(), + colour.blue(), (int)(colour.alpha() * c.alpha()) / 255); + pixbuf.addPixel(x + x0, y + y0, col); } } } -- cgit v1.2.3