mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:17:35 +00:00
LibAccelGfx+WebContent: Use the same Painter across page repaints
In the upcoming changes, Painter will be used to store the state of OpenGL context. For example, if Painter is aware of the shader that have already been loaded, it will be possible to reuse them across repaints. Also, it would be possible to manage state of loaded textures and add/remove them depending on which ones are present in the next sequence of painting commands.
This commit is contained in:
parent
e73a1803ac
commit
1e85bf221d
7 changed files with 54 additions and 27 deletions
|
@ -27,6 +27,13 @@
|
|||
|
||||
namespace WebContent {
|
||||
|
||||
static bool s_use_gpu_painter = false;
|
||||
|
||||
void PageHost::set_use_gpu_painter()
|
||||
{
|
||||
s_use_gpu_painter = true;
|
||||
}
|
||||
|
||||
PageHost::PageHost(ConnectionFromClient& client)
|
||||
: m_client(client)
|
||||
, m_page(make<Web::Page>(*this))
|
||||
|
@ -36,17 +43,16 @@ PageHost::PageHost(ConnectionFromClient& client)
|
|||
m_client.async_did_invalidate_content_rect({ m_invalidation_rect.x().value(), m_invalidation_rect.y().value(), m_invalidation_rect.width().value(), m_invalidation_rect.height().value() });
|
||||
m_invalidation_rect = {};
|
||||
});
|
||||
|
||||
if (s_use_gpu_painter) {
|
||||
#ifdef HAS_ACCELERATED_GRAPHICS
|
||||
m_accelerated_painter = AccelGfx::Painter::create();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
PageHost::~PageHost() = default;
|
||||
|
||||
static bool s_use_gpu_painter = false;
|
||||
|
||||
void PageHost::set_use_gpu_painter()
|
||||
{
|
||||
s_use_gpu_painter = true;
|
||||
}
|
||||
|
||||
void PageHost::set_has_focus(bool has_focus)
|
||||
{
|
||||
m_has_focus = has_focus;
|
||||
|
@ -158,8 +164,11 @@ void PageHost::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& targ
|
|||
|
||||
if (s_use_gpu_painter) {
|
||||
#ifdef HAS_ACCELERATED_GRAPHICS
|
||||
Web::Painting::PaintingCommandExecutorGPU painting_command_executor(target);
|
||||
auto canvas = AccelGfx::Canvas::create(AccelGfx::Context::the(), target);
|
||||
m_accelerated_painter->set_canvas(canvas);
|
||||
Web::Painting::PaintingCommandExecutorGPU painting_command_executor(*m_accelerated_painter);
|
||||
recording_painter.execute(painting_command_executor);
|
||||
m_accelerated_painter->flush();
|
||||
#endif
|
||||
} else {
|
||||
Web::Painting::PaintingCommandExecutorCPU painting_command_executor(target);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue