LibWeb/WebGL: Enforce minimum size when resizing existing context

Previously the enforcement was only done on creation. Not enforcing it
on change would cause a crash if the canvas width/height was set to
zero or less.
This commit is contained in:
Luke Wilde 2024-12-24 18:22:44 +00:00 committed by Alexander Kalenik
parent 8e453d5069
commit 216d5b33be
Notes: github-actions[bot] 2025-01-08 14:59:35 +00:00
2 changed files with 8 additions and 2 deletions

View file

@ -129,7 +129,10 @@ Optional<WebGLContextAttributes> WebGL2RenderingContext::get_context_attributes(
void WebGL2RenderingContext::set_size(Gfx::IntSize const& size)
{
context().set_size(size);
Gfx::IntSize final_size;
final_size.set_width(max(size.width(), 1));
final_size.set_height(max(size.height(), 1));
context().set_size(final_size);
}
void WebGL2RenderingContext::reset_to_default_state()

View file

@ -146,7 +146,10 @@ Optional<WebGLContextAttributes> WebGLRenderingContext::get_context_attributes()
void WebGLRenderingContext::set_size(Gfx::IntSize const& size)
{
context().set_size(size);
Gfx::IntSize final_size;
final_size.set_width(max(size.width(), 1));
final_size.set_height(max(size.height(), 1));
context().set_size(final_size);
}
void WebGLRenderingContext::reset_to_default_state()