summaryrefslogtreecommitdiff
path: root/plugingui/colour.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-02-29 16:12:26 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2020-03-07 19:22:34 +0100
commita65278c7bc9c0dbca8a74db09fd0aebf1c26ef28 (patch)
treef6137641afd154dca1c45480137e9b56afb1a7d6 /plugingui/colour.cc
parent450e39c5b02ace3c50d116e4cba825ff695c8665 (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/colour.cc')
-rw-r--r--plugingui/colour.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/plugingui/colour.cc b/plugingui/colour.cc
index 02d03c6..7fd649c 100644
--- a/plugingui/colour.cc
+++ b/plugingui/colour.cc
@@ -28,43 +28,50 @@
#include <cstring>
-namespace GUI {
+namespace GUI
+{
Colour::Colour()
{
- data = {{1.0f, 1.0f, 1.0f, 1.0f}};
}
Colour::Colour(float grey, float a)
+ : pixel({{(std::uint8_t)(grey * 255),
+ (std::uint8_t)(grey * 255),
+ (std::uint8_t)(grey * 255),
+ (std::uint8_t)(a * 255)}})
{
- data = {{grey, grey, grey, a}};
}
Colour::Colour(float r, float g, float b, float a)
+ : pixel({{(std::uint8_t)(r * 255),
+ (std::uint8_t)(g * 255),
+ (std::uint8_t)(b * 255),
+ (std::uint8_t)(a * 255)}})
{
- data = {{r, g, b, a}};
}
Colour::Colour(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a)
- : Colour(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f)
-{}
+ : pixel({{r, g, b, a}})
+{
+}
Colour::Colour(const Colour& other)
+ : pixel(other.pixel)
{
- data = other.data;
}
Colour& Colour::operator=(const Colour& other)
{
- data = other.data;
+ pixel = other.pixel;
return *this;
}
bool Colour::operator==(const Colour& other) const
{
- return data[0] == other.data[0] &&
- data[1] == other.data[1] &&
- data[2] == other.data[2];
+ return pixel[0] == other.pixel[0] &&
+ pixel[1] == other.pixel[1] &&
+ pixel[2] == other.pixel[2];
}
bool Colour::operator!=(const Colour& other) const