From a65278c7bc9c0dbca8a74db09fd0aebf1c26ef28 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 29 Feb 2020 16:12:26 +0100 Subject: Read images as uint8_t instead of float. Convert Colour and all colour related operations to use uint8_t instade of float and finally optimize rendering to render lines instead of single pixels. --- plugingui/pixelbuffer.h | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'plugingui/pixelbuffer.h') diff --git a/plugingui/pixelbuffer.h b/plugingui/pixelbuffer.h index 71869a0..499940d 100644 --- a/plugingui/pixelbuffer.h +++ b/plugingui/pixelbuffer.h @@ -41,13 +41,12 @@ public: void realloc(std::size_t width, std::size_t height); - void setPixel(std::size_t x, std::size_t y, - unsigned char red, - unsigned char green, - unsigned char blue, - unsigned char alpha); + void setPixel(std::size_t x, std::size_t y, const Colour& c); - unsigned char* buf{nullptr}; + void writeLine(std::size_t x, std::size_t y, + const std::uint8_t* line, std::size_t len); + + std::uint8_t* buf{nullptr}; std::size_t width{0}; std::size_t height{0}; }; @@ -61,28 +60,35 @@ public: void realloc(std::size_t width, std::size_t height); - void setPixel(std::size_t x, std::size_t y, - unsigned char red, - unsigned char green, - unsigned char blue, - unsigned char alpha); + void clear(); + + void setPixel(std::size_t x, std::size_t y, const Colour& c); + + void writeLine(std::size_t x, std::size_t y, + const std::uint8_t* line, std::size_t len); + void blendLine(std::size_t x, std::size_t y, + const std::uint8_t* line, std::size_t len); void addPixel(std::size_t x, std::size_t y, - unsigned char red, - unsigned char green, - unsigned char blue, - unsigned char alpha); + std::uint8_t red, + std::uint8_t green, + std::uint8_t blue, + std::uint8_t alpha); void addPixel(std::size_t x, std::size_t y, const Colour& c); void pixel(std::size_t x, std::size_t y, - unsigned char* red, - unsigned char* green, - unsigned char* blue, - unsigned char* alpha) const; + std::uint8_t* red, + std::uint8_t* green, + std::uint8_t* blue, + std::uint8_t* alpha) const; + + const Colour& pixel(std::size_t x, std::size_t y) const; + + const std::uint8_t* getLine(std::size_t x, std::size_t y) const; bool managed{false}; - unsigned char* buf{nullptr}; + std::uint8_t* buf{nullptr}; std::size_t width{0}; std::size_t height{0}; int x{0}; -- cgit v1.2.3