diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-03-03 19:16:04 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-03-07 19:23:12 +0100 |
commit | df71bccf9c4731af9bcca79eee8d95651646bd82 (patch) | |
tree | 1c9485bed0fdd64410282156537553b8fde3bb86 /plugingui/painter.cc | |
parent | 560574d2e565510edd39dd9daf1d957a85f2220c (diff) |
Further optimize pixel blending. And re-introduce lineBlending in Painter::drawImage.
Diffstat (limited to 'plugingui/painter.cc')
-rw-r--r-- | plugingui/painter.cc | 14 |
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)); } } } |