Commit Graph

246 Commits

Author SHA1 Message Date
Jonathan Gamble
793a4eeb8e Meta: Support nullable BufferSource as Optional in IDL generator
This IDL change is needed for webaudio's WaveShaperNode, where a
null BufferSource for a curve attribute results in a zero-length buffer.

WebGL also has a nullable BufferSource arg in bufferData(...). But
there, a null data/srcData value returns GL_INVALID_VALUE.
2026-03-27 00:03:39 +01:00
Tim Ledbetter
26389363ad LibGfx+LibWeb: Move Skia backend context to process level singleton
Previously, this was attached to the traversable navigable. Using a
singleton instead allows us to use the context for detached documents.
2026-03-19 13:35:16 +01:00
Undefine
3ac56aad7b LibWeb: Don't lie about supported WebGL extensions unless told to do so
We shouldn't say we support something we don't, unless we are told to
do so by the flag that exposes experimental interfaces.
2026-03-11 20:19:45 +01:00
Undefine
c2aeb9ea73 LibWeb: Move WebGL extensions requests to WebGLRenderingContextBase
Instead of making the extension objects request the OpenGL extensions
themselves, we can do it here since we already store that information
to be able to compute the list of available extensions. As bonus points
this makes it impossible to forget to request an OpenGL extension when
implementing a new WebGL one.
2026-03-11 20:19:45 +01:00
Undefine
09f592a34c LibWeb: Introduce a WebGL extension_enabled helper
Since we moved to using a hash map in the previous commits we get
a quite easy way to check if a certain extension is enabled without
having to create a seperate method for each one.
2026-03-11 20:19:45 +01:00
Undefine
d7bdc5b6c8 LibWeb: Refactor WebGL extensions to use a factory field and a hash map
Instead of manually listing out all the extensions which leads to
a bunch of if cases that are more or less the same, lets replace all
the fields with a hash map and introduces a factory field in the
already existing list of extensions. This allows us to neatly compact
the `get_extension` and makes implementing more extensions trivialy
easy.
2026-03-11 20:19:45 +01:00
Undefine
72d5fe7faf LibWeb: Ensure all extension factory functions have the same signature
This allows the next commit to have a factory function field in the
extension info struct.
2026-03-11 20:19:45 +01:00
Undefine
b4dbb0380d LibWeb: Split checking WebGL extensions away from OpenGLContext
This allows us to move the list of possible extensions to the WebGL
context class, which will need it in a later commit. It also makes
`OpenGLContext` more specialized towards only handling OpenGL itself.
2026-03-11 20:19:45 +01:00
Undefine
fa8e122dd4 LibWeb: Move enabling of WebGL compressed texture formats to extensions 2026-03-11 20:19:45 +01:00
Undefine
3101565f05 LibWeb: Unify WebGL handling code in WebGLRenderingContextBase 2026-03-11 20:19:45 +01:00
Undefine
5a029b4533 LibWeb: Make WebGL extensions creation agnostic of WebGL version 2026-03-11 20:19:45 +01:00
Zaggy1024
682662d44c LibWeb: Pass some WebGL context attribute flags to OpenGLContext
This allows us to conditionally enable depth and stencil.

The antialias option is currently unused.
2026-03-06 23:00:40 +01:00
Zaggy1024
e84dc71291 LibWeb: Bump the WebGL depth buffer bit depth to 24
This matches what Firefox, Chromium and Safari all supply wherever they
are able to. In Firefox and Chromium, they always initialize with
24-bit depth and 8-bit stencil when either is needed.
2026-03-06 23:00:40 +01:00
Zaggy1024
c83a625681 LibWeb: Add missing includes to OpenGLContext.h 2026-03-06 23:00:40 +01:00
Aliaksandr Kalenik
eae94a8a46 LibWeb: Route repaint requests through paintables, not Document
Rename Document::set_needs_display() to set_needs_repaint() and make it
private. External callers must now go through Node/Paintable which
route the request to the document internally.

Fix one existing misuse in AnimationEffect that was calling
document-level set_needs_display() instead of routing through the
target element's paintable.

This is preparation for per-paintable display list command caching:
repaint requests must go through specific paintables so their cached
command lists can be invalidated.
2026-03-04 19:35:45 +01:00
Andreas Kling
a146225331 LibWeb: Use unsafe layout/paintable accessors where appropriate
Add unsafe_layout_node(), unsafe_paintable(), and unsafe_paintable_box()
accessors that skip layout-staleness verification. These are for use in
contexts where accessing layout/paintable data is legitimate despite
layout not being up to date: tree construction, style recalculation,
painting, animation interpolation, DOM mutation, and invalidation
propagation.

Also add wrapper APIs on Node to centralize common patterns:
- set_needs_display() wraps if (unsafe_paintable()) ...set_needs_display
- set_needs_paint_only_properties_update() wraps similar
- set_needs_layout_update() wraps if (unsafe_layout_node()) ...

And add Document::layout_is_up_to_date() which checks whether layout
tree update flags are all clear.
2026-02-26 21:09:08 +01:00
Aliaksandr Kalenik
004e5f851e LibWeb: Use ExternalContentSource for canvas painting
present() now snapshots the PaintingSurface into an ImmutableBitmap
and publishes it to the ExternalContentSource, so the rendering thread
never touches the live GPU surface — eliminating the data race
described in the ExternalContentSource commit (problem 1).

Canvas elements are registered with Page and presented once per frame
from the event loop, rather than on every individual draw call in
CRC2D::did_draw(). A dirty flag on HTMLCanvasElement ensures the
snapshot is only taken when content has actually changed, and makes
the present() call in CanvasPaintable::paint() a no-op when the
surface has already been snapshotted for the current frame.
2026-02-20 18:41:33 +01:00
Shannon Booth
4d64f21fa5 LibWeb: Give IDL exposed PlatformObjects an InterfaceName
By making use of the WEB_PLATFORM_OBJECT macro we can remove
the boilerplate of needing to add this override for every
serializable platform object so that we can check whether they
are exposed or not.
2026-02-14 20:22:40 +01:00
Undefine
4f1f968d80 LibWeb: Clear set WebGL textures when they get deleted 2026-02-02 11:22:52 -07:00
Undefine
e9e959876f LibWeb: Set error when buffer passed to WebGL readPixels is null 2026-02-02 11:22:52 -07:00
Undefine
3c8aedbb8e LibWeb: Clear WebGL attached shaders in detach_shader 2026-02-02 11:22:52 -07:00
Undefine
3c4a31bca7 LibWeb: Implement the OES_element_index_uint WebGL extension 2026-02-02 11:22:52 -07:00
Undefine
c37f1160fe LibWeb: Implement WebGL getParameter(COLOR_WRITEMASK) 2026-02-02 11:22:52 -07:00
Undefine
6249753594 LibWeb: Stub out UNPACK_COLORSPACE_CONVERSION_WEBGL
This implements setting and getting the value but it does nothing
with it.
2026-02-02 11:22:52 -07:00
Undefine
0810025f0e LibWeb: Use the robust ANGLE variant of getRenderbufferParameter
We use those everywhere else as those are more secure.
2026-02-02 11:22:52 -07:00
Undefine
59e73a9de9 LibWeb: Implement WebGL2 getQuery 2026-02-02 11:22:52 -07:00
Undefine
42836ea3e4 LibWeb: Implement WebGL getTexParameter 2026-02-02 11:22:52 -07:00
Zaggy1024
e6dbcccb99 LibGfx+LibMedia: Send video frames to Skia as subsampled YUV
This saves us from having our own color conversion code, which was
taking up a fair amount of time in VideoDataProvider. With this change,
we should be able to play high resolution videos without interruptions
on machines where the CPU can keep up with decoding.

In order to make this change, ImmutableBitmap is now able to be
constructed with YUV data instead of an RBG bitmap. It holds onto a
YUVData instance that stores the buffers of image data, since Skia
itself doesn't take ownership of them.

In order to support greater than 8 bits of color depth, we normalize
the 10- or 12-bit color values into a 16-bit range.
2026-01-22 19:44:36 +01:00
Undefine
2107142cdb LibWeb: Make WebGLRenderingContextBase derive from PlatformObject
This resolves a bunch of FIXMEs and removes a bunch sketchy raw
pointers and hacks.
2026-01-10 13:22:17 +01:00
Undefine
cda2330658 LibWeb: Make a bunch of WebGL functions protected instead of public
Those do not need to accessible outside of WebGL code as they are just
helper functions.
2026-01-10 13:22:17 +01:00
Luke Wilde
63503c1ad6 LibWeb/WebGL2: Implement getUniformIndices 2025-12-08 23:59:46 +01:00
InvalidUsernameException
88c4814de6 LibGfx+LibWeb: Extract bitmap-to-buffer conversion into LibGfx
This factors the conversion logic to be independent from WebGL code,
allowing us to write unit tests for it that can run in CI (since WebGL
can't run in CI).
2025-11-28 18:32:48 +01:00
InvalidUsernameException
28ba610f32 Everywhere: Avoid large rebuilds when editing (Immutable)Bitmap headers
This reduces the number of recompiled files as follow:
- Bitmap.h: 1309 -> 101
- ImmutableBitmap.h: 1218 -> 75
2025-11-28 18:32:48 +01:00
Undefine
c01f0e537e LibWeb: Clear m_current_program when the program gets deleted 2025-11-27 19:19:54 +01:00
Undefine
b0fcb35134 LibWeb: Implement WebGL getParameter(GL_VERTEX_ARRAY_BINDING) 2025-11-27 19:19:54 +01:00
Undefine
f373ab7011 LibWeb: Bind WebGL uniform locations to their respective program
The spec mandates that each uniform location object only gets used with
the program it was created with.
2025-11-27 19:19:54 +01:00
Undefine
7d6212ae71 LibWeb: Ensure WebGL buffers don't mix between index and other data
The spec mandates that a buffer during its lifetime can only get bound
to either an index buffer or any other type.
2025-11-27 19:19:54 +01:00
Jelle Raaijmakers
82dfa69e4e LibWeb/WebGL: Implement getRenderbufferParameter() 2025-11-27 15:51:59 +01:00
Undefine
2a73f779c3 LibWeb: Small WebGL spec fix for vertexAttribPointer 2025-11-06 19:02:36 +01:00
Undefine
5caead88fc LibWeb: Allow WebGL getParameter when WEBGL_draw_buffers is enabled
When that extensions is enabled we should allow getting the parameter
value of MAX_COLOR_ATTACHMENTS_WEBGL.
2025-11-06 19:02:36 +01:00
Undefine
d4ac9fc5c6 LibWeb: Implement WebGL extension OES_standard_derivatives 2025-11-06 19:02:36 +01:00
Undefine
2bf35881f9 LibWeb: Ensure compressed* WebGL functions don't allow disabled formats 2025-11-06 19:02:36 +01:00
Undefine
044ac2dd28 LibWeb: Fix WebGL getError
getError was just calling out to glGetError and never checking our
error value that we were maintaining ourselves.
2025-11-06 19:02:36 +01:00
Undefine
e7aeb71d29 LibWeb: Move WebGL error variable to WebGLRenderingContextBase
Implementations in both WebGL1 and WebGL2 were the same and most
probably will stay the same.
2025-11-06 19:02:36 +01:00
Undefine
5b88b76b84 LibWeb: Deduplicate WebGL1 implementations from WebGL2
This makes the WebGL2 implementation file inherit from the WebGL1
implementation file. This is actually closer to what the IDL files
describe and allows us to not have to maintain two copies of the same
functions.
2025-11-05 02:19:32 +01:00
Undefine
7a1668fe22 LibWeb: Switch include in WebGLRenderingContextImpl to OpenGL ES 3
The reasoning behind this is that in the next commit some of the WebGL2
specific parameters will be moved here. This header is needed to give
us access to those defines. Note that when in WebGL1 nothing from ES3
will be used as it's locked behind WebGL2 checks (it wouldn't work
anyways as we request ES2 from ANGLE).
2025-11-05 02:19:32 +01:00
Undefine
395bc3ee27 LibWeb: Add a webgl_version getter to OpenGLContext 2025-11-05 02:19:32 +01:00
Undefine
df1aeda955 LibWeb: Deduplicate the WebGL null_terminated_string helper 2025-11-05 02:19:32 +01:00
Undefine
6c115171da LibWeb: Split off WebGL2RenderingContextImpl to Impl and Overloads
This mostly analogous to the previous commit that does the same with
the WebGL1 Impl file.
2025-11-05 02:19:32 +01:00
Undefine
c70886ab1f LibWeb: Split off WebGLRenderingContextImpl to Impl and Overloads
This is more like what the IDL files specify with two different mixins,
but the inheritance structure here is slightly different for easier
maintenance. This will also allow the WebGL2 Impl to inherit from the
WebGL1 Impl as WebGL versions don't share the functions defined in the
Overloads interfaces.
2025-11-05 02:19:32 +01:00