1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

LibAccelGfx+LibWeb: Implement SetClipRect and ClearClipRect commands

This commit is contained in:
Aliaksandr Kalenik 2023-11-13 18:34:55 +01:00 committed by Andreas Kling
parent 9e4d697d23
commit 01d938c77b
5 changed files with 32 additions and 3 deletions

View file

@ -255,4 +255,17 @@ void delete_framebuffer(Framebuffer const& framebuffer)
verify_no_error(); verify_no_error();
} }
void enable_scissor_test(Gfx::IntRect rect)
{
glEnable(GL_SCISSOR_TEST);
glScissor(rect.left(), rect.top(), rect.width(), rect.height());
verify_no_error();
}
void disable_scissor_test()
{
glDisable(GL_SCISSOR_TEST);
verify_no_error();
}
} }

View file

@ -98,4 +98,7 @@ Framebuffer create_framebuffer(Gfx::IntSize);
void bind_framebuffer(Framebuffer const& framebuffer); void bind_framebuffer(Framebuffer const& framebuffer);
void delete_framebuffer(Framebuffer const& framebuffer); void delete_framebuffer(Framebuffer const& framebuffer);
void enable_scissor_test(Gfx::IntRect);
void disable_scissor_test();
} }

View file

@ -417,6 +417,16 @@ void Painter::restore()
m_state_stack.take_last(); m_state_stack.take_last();
} }
void Painter::set_clip_rect(Gfx::IntRect rect)
{
GL::enable_scissor_test(rect);
}
void Painter::clear_clip_rect()
{
GL::disable_scissor_test();
}
void Painter::set_target_bitmap(Gfx::Bitmap& bitmap) void Painter::set_target_bitmap(Gfx::Bitmap& bitmap)
{ {
if (m_target_framebuffer.has_value()) { if (m_target_framebuffer.has_value()) {

View file

@ -67,6 +67,9 @@ public:
void draw_glyph_run(Vector<Gfx::DrawGlyphOrEmoji> const& glyph_run, Color const& color); void draw_glyph_run(Vector<Gfx::DrawGlyphOrEmoji> const& glyph_run, Color const& color);
void set_clip_rect(Gfx::IntRect);
void clear_clip_rect();
void set_target_bitmap(Gfx::Bitmap&); void set_target_bitmap(Gfx::Bitmap&);
void flush(); void flush();

View file

@ -57,15 +57,15 @@ CommandResult PaintingCommandExecutorGPU::draw_scaled_bitmap(Gfx::IntRect const&
return CommandResult::Continue; return CommandResult::Continue;
} }
CommandResult PaintingCommandExecutorGPU::set_clip_rect(Gfx::IntRect const&) CommandResult PaintingCommandExecutorGPU::set_clip_rect(Gfx::IntRect const& rect)
{ {
// FIXME painter().set_clip_rect(rect);
return CommandResult::Continue; return CommandResult::Continue;
} }
CommandResult PaintingCommandExecutorGPU::clear_clip_rect() CommandResult PaintingCommandExecutorGPU::clear_clip_rect()
{ {
// FIXME painter().clear_clip_rect();
return CommandResult::Continue; return CommandResult::Continue;
} }