summaryrefslogtreecommitdiff
path: root/plugingui/painter.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-03-03 19:16:04 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2020-03-03 19:16:04 +0100
commitc5dde69620d247e4e8238cace43f75a8299d0233 (patch)
tree9754b9db5c79d960961b4446b824291f11cb0448 /plugingui/painter.cc
parent25b73fd1c19750105ba6126d379f3cd1f0a9fd63 (diff)
WIP: Further optimize pixel blending. And re-introduce lineBlending in Painter::drawImage.int_ui
Diffstat (limited to 'plugingui/painter.cc')
-rw-r--r--plugingui/painter.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/plugingui/painter.cc b/plugingui/painter.cc
index 761fe9b..7f8acba 100644
--- a/plugingui/painter.cc
+++ b/plugingui/painter.cc
@@ -65,7 +65,11 @@ static void plot(PixelBufferAlpha& pixbuf, const Colour& colour,
}
// plot the pixel at (x, y) with brightness c (where 0 ≤ c ≤ 1)
- Colour col(colour.red(), colour.green(), colour.blue(), (std::uint8_t)(colour.alpha() * c));
+ Colour col(colour);
+ if(c != 1)
+ {
+ col.data()[3] *= c;
+ }
pixbuf.addPixel(x, y, col);
}
@@ -369,7 +373,7 @@ void Painter::drawImage(int x0, int y0, const Drawable& image)
if(image.hasAlpha())
{
- if(true || !image.line(0))
+ if(!image.line(0))
{
for(std::size_t y = -1 * std::min(0, y0); y < (std::size_t)fh; ++y)
{
@@ -398,7 +402,8 @@ void Painter::drawImage(int x0, int y0, const Drawable& image)
std::size_t x = -1 * std::min(0, x0);
for(std::size_t y = -1 * std::min(0, y0); y < (std::size_t)fh; ++y)
{
- pixbuf.blendLine(x + x0, y + y0, image.line(y), image.width());
+ pixbuf.blendLine(x + x0, y + y0, image.line(y),
+ std::min((int)image.width(), fw - (int)x));
}
}
}
@@ -407,7 +412,8 @@ void Painter::drawImage(int x0, int y0, const Drawable& image)
std::size_t x = -1 * std::min(0, x0);
for(std::size_t y = -1 * std::min(0, y0); y < (std::size_t)fh; ++y)
{
- pixbuf.writeLine(x + x0, y + y0, image.line(y), image.width());
+ pixbuf.writeLine(x + x0, y + y0, image.line(y),
+ std::min((int)image.width(), fw - (int)x));
}
}
}