1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:18:13 +00:00

LibWeb: Add basic support for requestAnimationFrame()

We now support rAF, driven by GUI::DisplayLink callbacks. It's a bit
strange how we keep registering new callbacks over and over.
That's something we can definitely optimize.

This allows you to update animations/whatever without doing it more
often than the browser can display.
This commit is contained in:
Andreas Kling 2020-03-22 21:15:49 +01:00
parent 424a3f5ac3
commit 39045bfde8
5 changed files with 56 additions and 2 deletions

View file

@ -30,7 +30,19 @@ void CanvasRenderingContext2D::fill_rect(int x, int y, int width, int height)
if (!painter)
return;
painter->fill_rect({ x, y, width, height }, m_fill_style);
Gfx::Rect rect(x, y, width, height);
painter->fill_rect(rect, m_fill_style);
did_draw(rect);
}
void CanvasRenderingContext2D::did_draw(const Gfx::Rect&)
{
// FIXME: Make use of the rect to reduce the invalidated area when possible.
if (!m_element)
return;
if (!m_element->layout_node())
return;
m_element->layout_node()->set_needs_display();
}
OwnPtr<Gfx::Painter> CanvasRenderingContext2D::painter()