From 9a109128f84a3e10008844be676f0076f126e9df Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 18 Apr 2020 13:46:55 +0200 Subject: [PATCH] Cube: Two small tweaks I noticed these when playing with the demo locally: - Use RGB32 instead of RGBA32 for the bitmap buffer. This avoids some flickering that would sometimes occur. - Clip the gradient fill to the widget rect rather than the painter clip rect. In practice, the painter was always clipped to the widget rect here, but it seems logical to say "fill widget with gradient." --- Demos/Cube/Cube.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Demos/Cube/Cube.cpp b/Demos/Cube/Cube.cpp index 8222eebcf9..91afcaba7b 100644 --- a/Demos/Cube/Cube.cpp +++ b/Demos/Cube/Cube.cpp @@ -62,7 +62,7 @@ private: Cube::Cube() { - m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGBA32, { WIDTH, HEIGHT }); + m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, { WIDTH, HEIGHT }); m_accumulated_time = 0; m_cycles = 0; @@ -142,7 +142,7 @@ void Cube::timer_event(Core::TimerEvent&) } GUI::Painter painter(*m_bitmap); - painter.fill_rect_with_gradient(Gfx::Orientation::Vertical, painter.clip_rect(), Gfx::Color::White, Gfx::Color::Blue); + painter.fill_rect_with_gradient(Gfx::Orientation::Vertical, m_bitmap->rect(), Gfx::Color::White, Gfx::Color::Blue); auto to_point = [](const FloatVector3& v) { return Gfx::Point(v.x(), v.y());