mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:47:44 +00:00
LibWeb: Don't encode painting limitations in RecordingPainter API
The current set of stacking context commands do not encode the information needed to correctly paint the stacking context, instead, they're based on the limitations of the current CPU renderer. Stacking contexts should be able to be transformed by an arbitrary 3D transformation matrix, not just scaled from a source to a destination rect. The `_with_mask()` stacking context also should not be separate from the regular stacking context. ```c++ push_stacking_context( bool semitransparent_or_has_non_identity_transform, float opacity, Gfx::FloatRect const& source_rect, Gfx::FloatRect const& transformed_destination_rect, Gfx::IntPoint const& painter_location); pop_stacking_context( bool semitransparent_or_has_non_identity_transform, Gfx::Painter::ScalingMode scaling_mode); push_stacking_context_with_mask( Gfx::IntRect const& paint_rect); pop_stacking_context_with_mask( Gfx::IntRect const& paint_rect, RefPtr<Gfx::Bitmap> const& mask_bitmap, Gfx::Bitmap::MaskKind mask_kind, float opacity); ``` This patch replaces this APIs with just: ```c++ push_stacking_context( float opacity, bool is_fixed_position, Gfx::IntRect const& source_paintable_rect, Gfx::IntPoint post_transform_translation, CSS::ImageRendering image_rendering, StackingContextTransform transform, Optional<StackingContextMask> mask); pop_stacking_context() ``` And moves the implementation details into the executor, this should allow future backends to implement stacking contexts without these limitations.
This commit is contained in:
parent
848b0d9c81
commit
4e04f81626
7 changed files with 189 additions and 253 deletions
|
@ -27,6 +27,7 @@
|
|||
#include <LibGfx/TextElision.h>
|
||||
#include <LibGfx/TextLayout.h>
|
||||
#include <LibGfx/TextWrapping.h>
|
||||
#include <LibWeb/CSS/Enums.h>
|
||||
#include <LibWeb/Painting/BorderRadiiData.h>
|
||||
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
||||
#include <LibWeb/Painting/GradientData.h>
|
||||
|
@ -86,31 +87,30 @@ struct SetFont {
|
|||
NonnullRefPtr<Gfx::Font> font;
|
||||
};
|
||||
|
||||
struct PushStackingContext {
|
||||
bool semitransparent_or_has_non_identity_transform;
|
||||
bool has_fixed_position;
|
||||
float opacity;
|
||||
Gfx::FloatRect source_rect;
|
||||
Gfx::FloatRect transformed_destination_rect;
|
||||
Gfx::IntPoint painter_location;
|
||||
struct StackingContextTransform {
|
||||
Gfx::FloatPoint origin;
|
||||
Gfx::FloatMatrix4x4 matrix;
|
||||
};
|
||||
|
||||
struct PopStackingContext {
|
||||
bool semitransparent_or_has_non_identity_transform;
|
||||
Gfx::Painter::ScalingMode scaling_mode;
|
||||
};
|
||||
|
||||
struct PushStackingContextWithMask {
|
||||
Gfx::IntRect paint_rect;
|
||||
};
|
||||
|
||||
struct PopStackingContextWithMask {
|
||||
Gfx::IntRect paint_rect;
|
||||
RefPtr<Gfx::Bitmap> mask_bitmap;
|
||||
struct StackingContextMask {
|
||||
NonnullRefPtr<Gfx::Bitmap> mask_bitmap;
|
||||
Gfx::Bitmap::MaskKind mask_kind;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
struct PushStackingContext {
|
||||
float opacity;
|
||||
bool is_fixed_position;
|
||||
// The bounding box of the source paintable (pre-transform).
|
||||
Gfx::IntRect source_paintable_rect;
|
||||
// A translation to be applied after the stacking context has been transformed.
|
||||
Gfx::IntPoint post_transform_translation;
|
||||
CSS::ImageRendering image_rendering;
|
||||
StackingContextTransform transform;
|
||||
Optional<StackingContextMask> mask = {};
|
||||
};
|
||||
|
||||
struct PopStackingContext { };
|
||||
|
||||
struct PaintLinearGradient {
|
||||
Gfx::IntRect gradient_rect;
|
||||
LinearGradientData linear_gradient_data;
|
||||
|
@ -312,8 +312,6 @@ using PaintingCommand = Variant<
|
|||
SetFont,
|
||||
PushStackingContext,
|
||||
PopStackingContext,
|
||||
PushStackingContextWithMask,
|
||||
PopStackingContextWithMask,
|
||||
PaintLinearGradient,
|
||||
PaintRadialGradient,
|
||||
PaintConicGradient,
|
||||
|
@ -348,10 +346,8 @@ public:
|
|||
virtual CommandResult set_clip_rect(Gfx::IntRect const& rect) = 0;
|
||||
virtual CommandResult clear_clip_rect() = 0;
|
||||
virtual CommandResult set_font(Gfx::Font const& font) = 0;
|
||||
virtual CommandResult push_stacking_context(bool semitransparent_or_has_non_identity_transform, float opacity, Gfx::FloatRect const& source_rect, Gfx::FloatRect const& transformed_destination_rect, Gfx::IntPoint const& painter_location) = 0;
|
||||
virtual CommandResult pop_stacking_context(bool semitransparent_or_has_non_identity_transform, Gfx::Painter::ScalingMode scaling_mode) = 0;
|
||||
virtual CommandResult push_stacking_context_with_mask(Gfx::IntRect const& paint_rect) = 0;
|
||||
virtual CommandResult pop_stacking_context_with_mask(Gfx::IntRect const& paint_rect, RefPtr<Gfx::Bitmap> const& mask_bitmap, Gfx::Bitmap::MaskKind mask_kind, float opacity) = 0;
|
||||
virtual CommandResult push_stacking_context(float opacity, bool is_fixed_position, Gfx::IntRect const& source_paintable_rect, Gfx::IntPoint post_transform_translation, CSS::ImageRendering image_rendering, StackingContextTransform transform, Optional<StackingContextMask> mask) = 0;
|
||||
virtual CommandResult pop_stacking_context() = 0;
|
||||
virtual CommandResult paint_linear_gradient(Gfx::IntRect const&, LinearGradientData const&) = 0;
|
||||
virtual CommandResult paint_radial_gradient(Gfx::IntRect const& rect, RadialGradientData const&, Gfx::IntPoint const& center, Gfx::IntSize const& size) = 0;
|
||||
virtual CommandResult paint_conic_gradient(Gfx::IntRect const& rect, ConicGradientData const&, Gfx::IntPoint const& position) = 0;
|
||||
|
@ -452,23 +448,15 @@ public:
|
|||
void restore();
|
||||
|
||||
struct PushStackingContextParams {
|
||||
bool semitransparent_or_has_non_identity_transform;
|
||||
bool has_fixed_position;
|
||||
float opacity;
|
||||
Gfx::FloatRect source_rect;
|
||||
Gfx::FloatRect transformed_destination_rect;
|
||||
Gfx::IntPoint painter_location;
|
||||
bool is_fixed_position;
|
||||
Gfx::IntRect source_paintable_rect;
|
||||
CSS::ImageRendering image_rendering;
|
||||
StackingContextTransform transform;
|
||||
Optional<StackingContextMask> mask = {};
|
||||
};
|
||||
void push_stacking_context(PushStackingContextParams params);
|
||||
|
||||
struct PopStackingContextParams {
|
||||
bool semitransparent_or_has_non_identity_transform;
|
||||
Gfx::Painter::ScalingMode scaling_mode;
|
||||
};
|
||||
void pop_stacking_context(PopStackingContextParams params);
|
||||
|
||||
void push_stacking_context_with_mask(Gfx::IntRect paint_rect);
|
||||
void pop_stacking_context_with_mask(RefPtr<Gfx::Bitmap> mask_bitmap, Gfx::Bitmap::MaskKind mask_kind, Gfx::IntRect paint_rect, float opacity);
|
||||
void pop_stacking_context();
|
||||
|
||||
void sample_under_corners(NonnullRefPtr<BorderRadiusCornerClipper> corner_clipper);
|
||||
void blit_corner_clipping(NonnullRefPtr<BorderRadiusCornerClipper> corner_clipper);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue