Truly independent web browser
Compositor: Make the polygon of a plane clip directly in Skia
Aliaksandr Kalenik3b30ef890ce3
diff --git a/Services/Compositor/DisplayListPlayer.cpp b/Services/Compositor/DisplayListPlayer.cppindex db6d55c7e40..31151443cc7 100644--- a/Services/Compositor/DisplayListPlayer.cpp+++ b/Services/Compositor/DisplayListPlayer.cpp@@ -83,13 +83,7 @@ struct DisplayListPlayer::ReplayCallbacks {.push_mask = [](void* context, ReplayMask const* mask, ReplayLayer const* backdrop) { static_cast<DisplayListPlayer*>(context)->push_mask(*mask, backdrop); },.pop_mask = [](void* context, ReplayMask const* mask, EffectNodeIndex effect) { static_cast<DisplayListPlayer*>(context)->pop_mask(*mask, effect); },.pop = [](void* context) { static_cast<DisplayListPlayer*>(context)->pop(); },- .push_device_space_plane_clip = [](void* context, Gfx::FloatVector3 const* vertices, size_t vertex_count) {- Gfx::Path path;- path.move_to({ vertices[0].x(), vertices[0].y() });- for (size_t i = 1; i < vertex_count; ++i)- path.line_to({ vertices[i].x(), vertices[i].y() });- path.close();- static_cast<DisplayListPlayer*>(context)->push_device_space_plane_clip(path); },+ .push_device_space_plane_clip = [](void* context, Gfx::FloatVector3 const* vertices, size_t vertex_count) { static_cast<DisplayListPlayer*>(context)->push_device_space_plane_clip({ vertices, vertex_count }); },.push_transform = [](void* context, Gfx::AffineTransform const* transform) { static_cast<DisplayListPlayer*>(context)->push_transform(*transform); },.push_clip_path_bytes = [](void* context, u8 const* path_bytes, size_t path_bytes_size, Gfx::WindingRule winding_rule) { static_cast<DisplayListPlayer*>(context)->push_clip_path_bytes({ path_bytes, path_bytes_size }, winding_rule); },.play_command = [](void* context, DisplayListCommandType command_type, u8 const* command, u8 const* payload, size_t payload_size) { static_cast<DisplayListPlayer*>(context)->play_command_bytes(command_type, command, { payload, payload_size }); },diff --git a/Services/Compositor/DisplayListPlayer.h b/Services/Compositor/DisplayListPlayer.hindex d9c078f5b24..4685b7433f7 100644--- a/Services/Compositor/DisplayListPlayer.h+++ b/Services/Compositor/DisplayListPlayer.h@@ -78,7 +78,7 @@ private:virtual void push_mask(Compositing::ReplayMask const&, Compositing::ReplayLayer const* backdrop) = 0;virtual void pop_mask(Compositing::ReplayMask const&, Compositing::EffectNodeIndex) = 0;virtual void pop() = 0;- virtual void push_device_space_plane_clip(Gfx::Path const&) = 0;+ virtual void push_device_space_plane_clip(ReadonlySpan<Gfx::FloatVector3> polygon_vertices) = 0;Compositing::DisplayList const* m_active_display_list { nullptr };Compositing::AccumulatedVisualContextTree const* m_active_visual_context_tree { nullptr };diff --git a/Services/Compositor/DisplayListPlayerSkia.cpp b/Services/Compositor/DisplayListPlayerSkia.cppindex 110d317527a..704598bf3c0 100644--- a/Services/Compositor/DisplayListPlayerSkia.cpp+++ b/Services/Compositor/DisplayListPlayerSkia.cpp@@ -1686,12 +1686,17 @@ void DisplayListPlayerSkia::pop()surface().canvas().restore();}-void DisplayListPlayerSkia::push_device_space_plane_clip(Gfx::Path const& path)+void DisplayListPlayerSkia::push_device_space_plane_clip(ReadonlySpan<Gfx::FloatVector3> polygon_vertices){+ Vector<SkPoint, 8> polygon_points;+ polygon_points.ensure_capacity(polygon_vertices.size());+ for (auto const& vertex : polygon_vertices)+ polygon_points.unchecked_append(Gfx::to_skia_point(vertex));+auto& canvas = surface().canvas();canvas.save();canvas.setMatrix(SkM44());- clip_path(Gfx::to_skia_path(path), Gfx::WindingRule::Nonzero, false);+ clip_path(SkPath::Polygon({ polygon_points.data(), polygon_points.size() }, true), Gfx::WindingRule::Nonzero, false);}void DisplayListPlayerSkia::set_matrix(Gfx::FloatMatrix4x4 const& matrix)diff --git a/Services/Compositor/DisplayListPlayerSkia.h b/Services/Compositor/DisplayListPlayerSkia.hindex 77f90f06e3b..580d6704954 100644--- a/Services/Compositor/DisplayListPlayerSkia.h+++ b/Services/Compositor/DisplayListPlayerSkia.h@@ -75,7 +75,7 @@ private:void push_mask(Compositing::ReplayMask const&, Compositing::ReplayLayer const* backdrop) override;void pop_mask(Compositing::ReplayMask const&, Compositing::EffectNodeIndex) override;void pop() override;- void push_device_space_plane_clip(Gfx::Path const&) override;+ void push_device_space_plane_clip(ReadonlySpan<Gfx::FloatVector3> polygon_vertices) override;void clip_path(SkPath, Gfx::WindingRule, bool anti_aliased);