From 41dc73adc46e040f6de5353fa9ace22da7199766 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 9 May 2021 10:11:30 +0200 Subject: [PATCH] Demos: Fix a bunch of incorrect use of GUI::PaintEvent::rect() A bunch of programs were using the paint event rect as the rect to draw into. Since the event rect could be any invalidated part of the widget, we need to be passing the full Widget::rect(). --- Userland/Demos/Cube/Cube.cpp | 4 +--- Userland/Demos/Fire/Fire.cpp | 4 +--- Userland/Demos/GLTeapot/main.cpp | 4 +--- Userland/Demos/LibGfxDemo/main.cpp | 3 ++- Userland/Demos/Screensaver/Screensaver.cpp | 3 ++- Userland/Demos/Starfield/Starfield.cpp | 4 +--- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Userland/Demos/Cube/Cube.cpp b/Userland/Demos/Cube/Cube.cpp index 55704d2d2f5..cc64e3e81f3 100644 --- a/Userland/Demos/Cube/Cube.cpp +++ b/Userland/Demos/Cube/Cube.cpp @@ -78,9 +78,7 @@ void Cube::paint_event(GUI::PaintEvent& event) { GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); - - /* Blit it! */ - painter.draw_scaled_bitmap(event.rect(), *m_bitmap, m_bitmap->rect()); + painter.draw_scaled_bitmap(rect(), *m_bitmap, m_bitmap->rect()); } void Cube::timer_event(Core::TimerEvent&) diff --git a/Userland/Demos/Fire/Fire.cpp b/Userland/Demos/Fire/Fire.cpp index 1755bd1af1f..1f6499142da 100644 --- a/Userland/Demos/Fire/Fire.cpp +++ b/Userland/Demos/Fire/Fire.cpp @@ -118,9 +118,7 @@ void Fire::paint_event(GUI::PaintEvent& event) GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); - - /* Blit it! */ - painter.draw_scaled_bitmap(event.rect(), *bitmap, bitmap->rect()); + painter.draw_scaled_bitmap(rect(), *bitmap, bitmap->rect()); timeAvg += timer.elapsed(); cycles++; diff --git a/Userland/Demos/GLTeapot/main.cpp b/Userland/Demos/GLTeapot/main.cpp index 0107db298f8..dead9e6d6ad 100644 --- a/Userland/Demos/GLTeapot/main.cpp +++ b/Userland/Demos/GLTeapot/main.cpp @@ -62,9 +62,7 @@ void GLContextWidget::paint_event(GUI::PaintEvent& event) { GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); - - /* Blit it! */ - painter.draw_scaled_bitmap(event.rect(), *m_bitmap, m_bitmap->rect()); + painter.draw_scaled_bitmap(rect(), *m_bitmap, m_bitmap->rect()); } void GLContextWidget::timer_event(Core::TimerEvent&) diff --git a/Userland/Demos/LibGfxDemo/main.cpp b/Userland/Demos/LibGfxDemo/main.cpp index 0077855beaf..34acadd7f4c 100644 --- a/Userland/Demos/LibGfxDemo/main.cpp +++ b/Userland/Demos/LibGfxDemo/main.cpp @@ -47,7 +47,8 @@ Canvas::~Canvas() void Canvas::paint_event(GUI::PaintEvent& event) { GUI::Painter painter(*this); - painter.draw_scaled_bitmap(event.rect(), *m_bitmap, m_bitmap->rect()); + painter.add_clip_rect(event.rect()); + painter.draw_scaled_bitmap(rect(), *m_bitmap, m_bitmap->rect()); } void Canvas::draw() diff --git a/Userland/Demos/Screensaver/Screensaver.cpp b/Userland/Demos/Screensaver/Screensaver.cpp index b218a4fc767..959a432eea2 100644 --- a/Userland/Demos/Screensaver/Screensaver.cpp +++ b/Userland/Demos/Screensaver/Screensaver.cpp @@ -69,7 +69,8 @@ void Screensaver::keydown_event(GUI::KeyEvent&) void Screensaver::paint_event(GUI::PaintEvent& event) { GUI::Painter painter(*this); - painter.draw_scaled_bitmap(event.rect(), *m_bitmap, m_bitmap->rect()); + painter.add_clip_rect(event.rect()); + painter.draw_scaled_bitmap(rect(), *m_bitmap, m_bitmap->rect()); } void Screensaver::timer_event(Core::TimerEvent&) diff --git a/Userland/Demos/Starfield/Starfield.cpp b/Userland/Demos/Starfield/Starfield.cpp index 6d632dda2ea..63792196b1a 100644 --- a/Userland/Demos/Starfield/Starfield.cpp +++ b/Userland/Demos/Starfield/Starfield.cpp @@ -90,11 +90,9 @@ void Starfield::keydown_event(GUI::KeyEvent&) void Starfield::paint_event(GUI::PaintEvent& event) { - GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); - - painter.draw_scaled_bitmap(event.rect(), *m_bitmap, m_bitmap->rect()); + painter.draw_scaled_bitmap(rect(), *m_bitmap, m_bitmap->rect()); } void Starfield::timer_event(Core::TimerEvent&)