mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
Prior to this change, SVGs were following the CSS painting order, which means SVG boxes could have established stacking context and be sorted by z-index. There is a section in the spec that defines what kind of SVG boxes should create a stacking context https://www.w3.org/TR/SVG2/render.html#EstablishingStackingContex Although this spec is marked as a draft and rendering order described in this spec does not match what other engines do. This spec issue comment has a good summary of what other engines actually do regarding painting order https://github.com/w3c/svgwg/issues/264#issuecomment-246432360 "as long as you're relying solely on the default z-index (which SVG1 does, by definition), nothing ever changes order when you apply opacity/filter/etc". This change aligns our implementation with other engines by forbidding SVGs to create a formatting context and painting them in order they are defined in tree tree.
95 lines
3.4 KiB
C++
95 lines
3.4 KiB
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGfx/Bitmap.h>
|
|
#include <LibWeb/Painting/DisplayListRecorder.h>
|
|
|
|
#ifdef AK_OS_MACOS
|
|
# include <LibCore/IOSurface.h>
|
|
# include <LibCore/MetalContext.h>
|
|
#endif
|
|
|
|
#ifdef USE_VULKAN
|
|
# include <LibCore/VulkanContext.h>
|
|
#endif
|
|
|
|
namespace Web::Painting {
|
|
|
|
class SkiaBackendContext {
|
|
AK_MAKE_NONCOPYABLE(SkiaBackendContext);
|
|
AK_MAKE_NONMOVABLE(SkiaBackendContext);
|
|
|
|
public:
|
|
SkiaBackendContext() {};
|
|
virtual ~SkiaBackendContext() {};
|
|
|
|
virtual void flush_and_submit() {};
|
|
};
|
|
|
|
class DisplayListPlayerSkia : public DisplayListPlayer {
|
|
public:
|
|
DisplayListPlayerSkia(Gfx::Bitmap&);
|
|
|
|
#ifdef USE_VULKAN
|
|
static OwnPtr<SkiaBackendContext> create_vulkan_context(Core::VulkanContext&);
|
|
DisplayListPlayerSkia(SkiaBackendContext&, Gfx::Bitmap&);
|
|
#endif
|
|
|
|
#ifdef AK_OS_MACOS
|
|
static OwnPtr<SkiaBackendContext> create_metal_context(Core::MetalContext const&);
|
|
DisplayListPlayerSkia(SkiaBackendContext&, Core::MetalTexture&);
|
|
#endif
|
|
|
|
virtual ~DisplayListPlayerSkia() override;
|
|
|
|
private:
|
|
void draw_glyph_run(DrawGlyphRun const&) override;
|
|
void fill_rect(FillRect const&) override;
|
|
void draw_scaled_bitmap(DrawScaledBitmap const&) override;
|
|
void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) override;
|
|
void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) override;
|
|
void add_clip_rect(AddClipRect const&) override;
|
|
void save(Save const&) override;
|
|
void restore(Restore const&) override;
|
|
void push_stacking_context(PushStackingContext const&) override;
|
|
void pop_stacking_context(PopStackingContext const&) override;
|
|
void paint_linear_gradient(PaintLinearGradient const&) override;
|
|
void paint_outer_box_shadow(PaintOuterBoxShadow const&) override;
|
|
void paint_inner_box_shadow(PaintInnerBoxShadow const&) override;
|
|
void paint_text_shadow(PaintTextShadow const&) override;
|
|
void fill_rect_with_rounded_corners(FillRectWithRoundedCorners const&) override;
|
|
void fill_path_using_color(FillPathUsingColor const&) override;
|
|
void fill_path_using_paint_style(FillPathUsingPaintStyle const&) override;
|
|
void stroke_path_using_color(StrokePathUsingColor const&) override;
|
|
void stroke_path_using_paint_style(StrokePathUsingPaintStyle const&) override;
|
|
void draw_ellipse(DrawEllipse const&) override;
|
|
void fill_ellipse(FillEllipse const&) override;
|
|
void draw_line(DrawLine const&) override;
|
|
void apply_backdrop_filter(ApplyBackdropFilter const&) override;
|
|
void draw_rect(DrawRect const&) override;
|
|
void paint_radial_gradient(PaintRadialGradient const&) override;
|
|
void paint_conic_gradient(PaintConicGradient const&) override;
|
|
void draw_triangle_wave(DrawTriangleWave const&) override;
|
|
void add_rounded_rect_clip(AddRoundedRectClip const&) override;
|
|
void add_mask(AddMask const&) override;
|
|
void paint_scrollbar(PaintScrollBar const&) override;
|
|
void paint_nested_display_list(PaintNestedDisplayList const&) override;
|
|
void apply_opacity(ApplyOpacity const&) override;
|
|
void apply_transform(ApplyTransform const&) override;
|
|
void apply_mask_bitmap(ApplyMaskBitmap const&) override;
|
|
|
|
bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override;
|
|
|
|
class SkiaSurface;
|
|
SkiaSurface& surface() const;
|
|
|
|
OwnPtr<SkiaSurface> m_surface;
|
|
Function<void()> m_flush_context;
|
|
};
|
|
|
|
}
|