mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
LibAccelGfx+LibWeb: Discard painting of commands outside of viewport
This commit is contained in:
parent
c68a9b2cfe
commit
17fb82d49b
Notes:
sideshowbarker
2024-07-17 05:21:12 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/17fb82d49b Pull-request: https://github.com/SerenityOS/serenity/pull/22060
3 changed files with 9 additions and 3 deletions
|
@ -550,11 +550,13 @@ void Painter::restore()
|
|||
|
||||
void Painter::set_clip_rect(Gfx::IntRect rect)
|
||||
{
|
||||
state().clip_rect = transform().map(rect);
|
||||
GL::enable_scissor_test(transform().map(rect));
|
||||
}
|
||||
|
||||
void Painter::clear_clip_rect()
|
||||
{
|
||||
state().clip_rect = { { 0, 0 }, m_target_canvas->size() };
|
||||
GL::disable_scissor_test();
|
||||
}
|
||||
|
||||
|
@ -569,6 +571,7 @@ void Painter::set_target_canvas(NonnullRefPtr<Canvas> canvas)
|
|||
m_target_canvas = canvas;
|
||||
canvas->bind();
|
||||
GL::set_viewport({ 0, 0, canvas->size().width(), canvas->size().height() });
|
||||
state().clip_rect = { { 0, 0 }, m_target_canvas->size() };
|
||||
}
|
||||
|
||||
void Painter::flush(Gfx::Bitmap& bitmap)
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
void set_transform(Gfx::AffineTransform const& transform) { state().transform = transform; }
|
||||
void translate(Gfx::FloatPoint translation) { state().transform.translate(translation); }
|
||||
|
||||
Gfx::IntRect const& clip_rect() const { return state().clip_rect; }
|
||||
|
||||
void fill_rect(Gfx::FloatRect, Gfx::Color);
|
||||
void fill_rect(Gfx::IntRect, Gfx::Color);
|
||||
|
||||
|
@ -88,6 +90,7 @@ private:
|
|||
|
||||
struct State {
|
||||
Gfx::AffineTransform transform;
|
||||
Gfx::IntRect clip_rect;
|
||||
};
|
||||
|
||||
[[nodiscard]] State& state() { return m_state_stack.last(); }
|
||||
|
|
|
@ -306,10 +306,10 @@ CommandResult PaintingCommandExecutorGPU::paint_borders(DevicePixelRect const& b
|
|||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
bool PaintingCommandExecutorGPU::would_be_fully_clipped_by_painter(Gfx::IntRect) const
|
||||
bool PaintingCommandExecutorGPU::would_be_fully_clipped_by_painter(Gfx::IntRect rect) const
|
||||
{
|
||||
// FIXME
|
||||
return false;
|
||||
auto translation = painter().transform().translation().to_type<int>();
|
||||
return !painter().clip_rect().intersects(rect.translated(translation));
|
||||
}
|
||||
|
||||
void PaintingCommandExecutorGPU::prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const& unique_glyphs)
|
||||
|
|
Loading…
Reference in a new issue