diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-02-29 16:12:26 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-03-07 19:22:34 +0100 |
commit | a65278c7bc9c0dbca8a74db09fd0aebf1c26ef28 (patch) | |
tree | f6137641afd154dca1c45480137e9b56afb1a7d6 /plugingui/pixelbuffer.h | |
parent | 450e39c5b02ace3c50d116e4cba825ff695c8665 (diff) |
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.
Diffstat (limited to 'plugingui/pixelbuffer.h')
-rw-r--r-- | plugingui/pixelbuffer.h | 46 |
1 files changed, 26 insertions, 20 deletions
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}; |