From d9d7188ad7b22e8991a9ef685840ac0e88566b39 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 7 Mar 2020 14:22:56 +0100 Subject: Use vector for PixelBuffer memory allocation. Use optimized render routines in some more painter algorithms. Fix capitalization of Canvas::getPixelBuffer method. --- test/paintertest.cc | 2 +- test/uitests/benchmarktest.cc | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/paintertest.cc b/test/paintertest.cc index c6e8615..518a5ac 100644 --- a/test/paintertest.cc +++ b/test/paintertest.cc @@ -39,7 +39,7 @@ public: : pixbuf(width, height) {} - GUI::PixelBufferAlpha& GetPixelBuffer() override + GUI::PixelBufferAlpha& getPixelBuffer() override { return pixbuf; } diff --git a/test/uitests/benchmarktest.cc b/test/uitests/benchmarktest.cc index 33defc6..aaf3946 100644 --- a/test/uitests/benchmarktest.cc +++ b/test/uitests/benchmarktest.cc @@ -37,11 +37,16 @@ class TimedCanvas : public GUI::Canvas { public: - GUI::PixelBufferAlpha& GetPixelBuffer() override + GUI::PixelBufferAlpha& getPixelBuffer() override { return pixbuf; } + void resize(std::size_t width, std::size_t height) + { + pixbuf.realloc(width, height); + } + private: GUI::PixelBufferAlpha pixbuf{800, 600}; }; @@ -83,6 +88,33 @@ int main() GUI::Image image_edge_alpha(":benchmarktest_resources/image_edge_alpha.png"); GUI::Image image_inner_alpha(":benchmarktest_resources/image_inner_alpha.png"); + { + TimedCanvas canvas; + TimedScope timed("Pixelbuffer resize", 100000); + painter.setColour(GUI::Colour(1.f, 1.f, 1.f, 1.f)); + for(int i = 0; i < 100000; ++i) + { + canvas.resize(i % 1000 + 100, i % 1000 + 100); + } + } + + { + TimedScope timed("Filled rect, no alpha", 100000); + for(int i = 0; i < 100000; ++i) + { + painter.drawRectangle(0, 0, 800, 600); + } + } + + { + TimedScope timed("Filled rect, with alpha", 100000); + painter.setColour(GUI::Colour(1.f, 1.f, 1.f, 0.5f)); + for(int i = 0; i < 100000; ++i) + { + painter.drawRectangle(0, 0, 800, 600); + } + } + { TimedScope timed("No scale, no alpha", 100000); for(int i = 0; i < 100000; ++i) -- cgit v1.2.3