mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:57:35 +00:00
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.
This commit is contained in:
parent
8ebb4e8047
commit
063e66cae9
49 changed files with 1970 additions and 441 deletions
|
@ -10,61 +10,12 @@
|
|||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibWeb/CSS/ComputedValues.h>
|
||||
#include <LibWeb/Painting/PaintContext.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/Painting/BorderRadiiData.h>
|
||||
#include <LibWeb/Painting/BordersData.h>
|
||||
|
||||
namespace Web::Painting {
|
||||
|
||||
struct BorderRadiusData {
|
||||
CSSPixels horizontal_radius { 0 };
|
||||
CSSPixels vertical_radius { 0 };
|
||||
|
||||
Gfx::AntiAliasingPainter::CornerRadius as_corner(PaintContext& context) const
|
||||
{
|
||||
return Gfx::AntiAliasingPainter::CornerRadius {
|
||||
context.floored_device_pixels(horizontal_radius).value(),
|
||||
context.floored_device_pixels(vertical_radius).value()
|
||||
};
|
||||
}
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
return horizontal_radius > 0 && vertical_radius > 0;
|
||||
}
|
||||
|
||||
inline void shrink(CSSPixels horizontal, CSSPixels vertical)
|
||||
{
|
||||
if (horizontal_radius != 0)
|
||||
horizontal_radius = max(CSSPixels(0), horizontal_radius - horizontal);
|
||||
if (vertical_radius != 0)
|
||||
vertical_radius = max(CSSPixels(0), vertical_radius - vertical);
|
||||
}
|
||||
};
|
||||
|
||||
struct BorderRadiiData {
|
||||
BorderRadiusData top_left;
|
||||
BorderRadiusData top_right;
|
||||
BorderRadiusData bottom_right;
|
||||
BorderRadiusData bottom_left;
|
||||
|
||||
inline bool has_any_radius() const
|
||||
{
|
||||
return top_left || top_right || bottom_right || bottom_left;
|
||||
}
|
||||
|
||||
inline void shrink(CSSPixels top, CSSPixels right, CSSPixels bottom, CSSPixels left)
|
||||
{
|
||||
top_left.shrink(left, top);
|
||||
top_right.shrink(right, top);
|
||||
bottom_right.shrink(right, bottom);
|
||||
bottom_left.shrink(left, bottom);
|
||||
}
|
||||
|
||||
inline void inflate(CSSPixels top, CSSPixels right, CSSPixels bottom, CSSPixels left)
|
||||
{
|
||||
shrink(-top, -right, -bottom, -left);
|
||||
}
|
||||
};
|
||||
|
||||
BorderRadiiData normalized_border_radii_data(Layout::Node const&, CSSPixelRect const&, CSS::BorderRadiusData top_left_radius, CSS::BorderRadiusData top_right_radius, CSS::BorderRadiusData bottom_right_radius, CSS::BorderRadiusData bottom_left_radius);
|
||||
|
||||
enum class BorderEdge {
|
||||
|
@ -73,12 +24,6 @@ enum class BorderEdge {
|
|||
Bottom,
|
||||
Left,
|
||||
};
|
||||
struct BordersData {
|
||||
CSS::BorderData top;
|
||||
CSS::BorderData right;
|
||||
CSS::BorderData bottom;
|
||||
CSS::BorderData left;
|
||||
};
|
||||
|
||||
// Returns OptionalNone if there is no outline to paint.
|
||||
Optional<BordersData> borders_data_for_outline(Layout::Node const&, Color outline_color, CSS::OutlineStyle outline_style, CSSPixels outline_width);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue