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:
parent
424a3f5ac3
commit
39045bfde8
5 changed files with 56 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue