mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 18:55:07 +00:00

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.
40 lines
970 B
C++
40 lines
970 B
C++
#pragma once
|
|
|
|
#include <AK/RefCounted.h>
|
|
#include <LibGfx/Color.h>
|
|
#include <LibGfx/Forward.h>
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
|
|
|
namespace Web {
|
|
|
|
class CanvasRenderingContext2D
|
|
: public RefCounted<CanvasRenderingContext2D>
|
|
, public Bindings::Wrappable {
|
|
|
|
AK_MAKE_NONCOPYABLE(CanvasRenderingContext2D);
|
|
AK_MAKE_NONMOVABLE(CanvasRenderingContext2D);
|
|
|
|
public:
|
|
using WrapperType = Bindings::CanvasRenderingContext2DWrapper;
|
|
|
|
static NonnullRefPtr<CanvasRenderingContext2D> create(HTMLCanvasElement& element) { return adopt(*new CanvasRenderingContext2D(element)); }
|
|
~CanvasRenderingContext2D();
|
|
|
|
void set_fill_style(String);
|
|
String fill_style() const;
|
|
|
|
void fill_rect(int x, int y, int width, int height);
|
|
|
|
private:
|
|
explicit CanvasRenderingContext2D(HTMLCanvasElement&);
|
|
|
|
void did_draw(const Gfx::Rect&);
|
|
|
|
OwnPtr<Gfx::Painter> painter();
|
|
|
|
WeakPtr<HTMLCanvasElement> m_element;
|
|
|
|
Gfx::Color m_fill_style;
|
|
};
|
|
|
|
}
|