Commit graph

23 commits

Author SHA1 Message Date
Aliaksandr Kalenik
1b3223dd9e LibWeb: Rename painter() to recording_painter() in PaintContext
Using recording_painter() as a name is less misleading, indicating
the painter in stacking context traversal doesn't perform actual
painting commands.
2023-11-27 21:53:38 +01:00
Aliaksandr Kalenik
d9990c6ea9 LibWeb: Remove opacity parameter for DrawScaledBitmap painting command
Every usage of this command specifies opacity equal to 1.
2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
063e66cae9 LibWeb: Introduce RecordingPainter to serialize painting commands
This modification introduces a new layer to the painting process. The
stacking context traversal no longer immediately calls the
Gfx::Painter methods. Instead, it writes serialized painting commands
into newly introduced RecordingPainter. Created list of commands is
executed later to produce resulting bitmap.

Producing painting command list will make it easier to add new
optimizations:
- It's simpler to check if the painting result is not visible in the
  viewport at the command level rather than during stacking context
  traversal.
- Run painting in a separate thread. The painting thread can process
  serialized painting commands, while the main thread can work on the
  next paintable tree and safely invalidate the previous one.
- As we consider GPU-accelerated painting support, it would be easier
  to back each painting command rather than constructing an alternative
  for the entire Gfx::Painter API.
2023-10-18 10:58:42 +02:00
Timothy Flynn
44911173f5 LibWeb: Make VideoPaintable's clip rect temporary
Otherwise, in a simple page such as:

    <video src=...>
    <audio src=...>

The video's clip rect would "leak" to the AudioPaintable, preventing the
audio controls from rendering at all.
2023-08-01 11:14:26 -04:00
Timothy Flynn
ee48d7514f LibWeb: Extract media element timeline painting to a base class
This moves the painting of the media timeout out of VideoPaintable into
a base MediaPaintable. This is to allow re-using the same timeline logic
and controls for audio elements.
2023-06-13 06:14:01 +02:00
MacDue
656f72adc0 LibWeb: Use fill_path() to paint <video> play buttons
With this, the play button is nicely antialiased.
2023-06-10 07:08:14 +02:00
Andreas Kling
655d9d1462 LibWeb: Make CSSPixels and Length use 64-bit (double) floating point
This fixes a plethora of rounding problems on many websites.
In the future, we may want to replace this with fixed-point arithmetic
(bug #18566) for performance (and consistency with other engines),
but in the meantime this makes the web look a bit better. :^)

There's a lot more things that could be converted to doubles, which
would reduce the amount of casting necessary in this patch.
We can do that incrementally, however.
2023-05-24 14:40:35 +02:00
Jelle Raaijmakers
7652dbd983 LibWeb: Use box sampling instead of bilinear scaling when downscaling
As a heuristic, either the width or height of the scaled image should
decrease for box sampling to be used. Otherwise, we use bilinear
scaling.
2023-05-19 18:36:36 +02:00
Andreas Kling
77db621be5 Revert "LibWeb: Use box sampling instead of bilinear scaling when downscaling"
This reverts commit b79fd3d1a9.
2023-05-19 13:33:52 +02:00
Jelle Raaijmakers
b79fd3d1a9 LibWeb: Use box sampling instead of bilinear scaling when downscaling
As a heuristic, either the width or height of the scaled image should
decrease for box sampling to be used. Otherwise, we use bilinear
scaling.
2023-05-19 06:16:14 +02:00
Timothy Flynn
5f473bcb5f LibWeb: Propagate non-primary mouse button clicks on video elements
Otherwise, returning "no" here will disallow the browser process from
showing a context menu, as the event handler will bail early.
2023-05-16 12:48:39 +02:00
Timothy Flynn
ab1244a160 LibWeb: Paint video timestamps using CSS/device pixel-aware scaled fonts
The timestamp text was very tiny on a HiDPI display.
2023-04-23 16:22:45 +02:00
Timothy Flynn
83bb24991b LibWeb: Implement HTMLVideoElement representation closer to the spec
The representation is used to indicate whether the layout node should
paint a video frame, the video's poster, or a "transparent black" box.
2023-04-21 07:54:36 +02:00
Timothy Flynn
dd188aafb9 LibWeb: Track decoded video frame positions along with the frame image
This will be needed by the layout node, which may change what is painted
when the position of the frame image is not the same as the element's
current time.
2023-04-21 07:54:36 +02:00
Timothy Flynn
6131e621d6 LibWeb: Render HTMLVideoElement controls when scripting is disabled
The spec recommends exposing the user agent interface when scripting is
disabled on the media element.
2023-04-18 16:30:02 +02:00
Timothy Flynn
c403f8e92c LibWeb: Update the media playback time for clicks on the media timeline
When clicking on the media timeline, compute the percentage along the
timeline's width the user clicked, and set the playback time to the same
percentage of the video's duration.
2023-04-17 01:16:04 +02:00
Timothy Flynn
ad3c63684c LibWeb: Restrict toggling video playback to certain areas in a video
When the control bar is shown, do not toggle playback when clicking on
the control bar, unless the click target is the playback button. This
will let us implement clicking on the timeline to seek.

Note that this requires caching some layout rects on the video element.
We need to remember where the corresponding layout boxes are, and we
can't cache them on the layout box, as that may be destroyed any time.
2023-04-17 01:16:04 +02:00
Timothy Flynn
fe66490399 LibWeb: Paint a media timeline on HTMLVideoElement layout nodes 2023-04-11 19:27:55 +02:00
Timothy Flynn
d5412f4e78 LibWeb: Move VideoPaintable's cached mouse position to HTMLVideoElement
The layout node, and therefore the painting box, is frequently destroyed
and recreated. This causes us to forget the cached mouse position we use
to highlight media controls. Move this cached position to the DOM node
instead, which survives relayout.
2023-04-11 19:27:55 +02:00
Timothy Flynn
cdf4c410bf LibWeb: Tweak the color used for hovered media controls
The link color is what closely resembled the color I was going for on
the machine I originally developed the controls on. But turns out this
is a very dark blue on most Serenity themes. Instead, hard-code the
original intended color, which is a lighter blue.
2023-04-11 19:27:55 +02:00
Timothy Flynn
d0e18b8a17 LibWeb: Convert video control dimensions from CSSPixels to DevicePixels
Rather than storing static DevicePixels dimensions, treat the desired
pixel sizes as CSSPixels and convert them to DevicePixels.

This was originally developed on a mac with a device-to-CSS-pixel ratio
of 2. Running it on another machine with a ratio of 1 made the controls
appear huge.
2023-04-10 10:15:48 -04:00
Timothy Flynn
4555e3b8d2 LibWeb: Begin painting video controls on HTMLVideoElement layout nodes
If the video element has a 'controls' attribute, we now paint some basic
video controls over the video element. If no frame has been decoded yet,
we paint a play button on the center of the element.

If a frame has been decoded, we paint that frame and paint a control bar
on the bottom of the frame. This control bar currently only contains a
play/pause button, depending on the video's playback state. We will only
paint the control bar if the video is paused or hovered.
2023-04-08 22:04:14 +02:00
Timothy Flynn
f156d3d5e5 LibWeb: Create a basic layout node for HTMLVideoElement 2023-04-07 16:02:22 +02:00