mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibWeb: Delegate painting surface allocation to canvas's active context
This change prepares for the addition of WebGL support, where painting surface allocation process will differ from that of context2d.
This commit is contained in:
parent
e683700fe6
commit
f719b05ab9
Notes:
github-actions[bot]
2024-12-03 22:37:53 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: f719b05ab9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2688
Reviewed-by: https://github.com/ADKaster ✅
8 changed files with 116 additions and 67 deletions
|
@ -5,15 +5,12 @@
|
|||
*/
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibWeb/WebGL/OpenGLContext.h>
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
||||
OwnPtr<OpenGLContext> OpenGLContext::create(Gfx::PaintingSurface& bitmap)
|
||||
OwnPtr<OpenGLContext> OpenGLContext::create()
|
||||
{
|
||||
(void)bitmap;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::WebGL {
|
|||
|
||||
class OpenGLContext {
|
||||
public:
|
||||
static OwnPtr<OpenGLContext> create(Gfx::PaintingSurface&);
|
||||
static OwnPtr<OpenGLContext> create();
|
||||
|
||||
virtual void present() = 0;
|
||||
void clear_buffer_to_default_values();
|
||||
|
|
|
@ -39,14 +39,7 @@ JS::ThrowCompletionOr<GC::Ptr<WebGLRenderingContext>> WebGLRenderingContext::cre
|
|||
// We should be coming here from getContext being called on a wrapped <canvas> element.
|
||||
auto context_attributes = TRY(convert_value_to_context_attributes_dictionary(canvas_element.vm(), options));
|
||||
|
||||
bool created_surface = canvas_element.allocate_painting_surface(/* minimum_width= */ 1, /* minimum_height= */ 1);
|
||||
if (!created_surface) {
|
||||
fire_webgl_context_creation_error(canvas_element);
|
||||
return GC::Ptr<WebGLRenderingContext> { nullptr };
|
||||
}
|
||||
|
||||
VERIFY(canvas_element.surface());
|
||||
auto context = OpenGLContext::create(*canvas_element.surface());
|
||||
auto context = OpenGLContext::create();
|
||||
|
||||
if (!context) {
|
||||
fire_webgl_context_creation_error(canvas_element);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue