Skip to content

Commit

Permalink
LibWeb: Remove RecordingPainter::paint_frame()
Browse files Browse the repository at this point in the history
PaintFrame is not primitive painting command, we inherited from OS, that
is hard to replicate in GPU-painter or alternative CPU-painter API. We
should remove it as a part of refactoring towards simplifying recording
painter commands set.

Fixes: SerenityOS#23796
  • Loading branch information
Grillo-0 authored and kalenikaliaksandr committed Apr 14, 2024
1 parent 3b89a18 commit 3645b67
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 37 deletions.
3 changes: 3 additions & 0 deletions Tests/LibWeb/Ref/alt-frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!DOCTYPE html>
<link rel="match" href="reference/alt-frame.html" />
<img alt='Hello!!'>
9 changes: 9 additions & 0 deletions Tests/LibWeb/Ref/reference/alt-frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<style>
* {
margin: 0;
}
body {
background-color: white;
}
</style>
<img src="./images/alt-frame.png">
Binary file added Tests/LibWeb/Ref/reference/images/alt-frame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 0 additions & 11 deletions Userland/Libraries/LibWeb/Painting/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,6 @@ struct DrawSignedDistanceField {
}
};

struct PaintFrame {
Gfx::IntRect rect;
Palette palette;
Gfx::FrameStyle style;

[[nodiscard]] Gfx::IntRect bounding_rect() const { return rect; }

void translate_by(Gfx::IntPoint const& offset) { rect.translate_by(offset); }
};

struct ApplyBackdropFilter {
Gfx::IntRect backdrop_region;
BorderRadiiData border_radii_data;
Expand Down Expand Up @@ -428,7 +418,6 @@ using Command = Variant<
FillEllipse,
DrawLine,
DrawSignedDistanceField,
PaintFrame,
ApplyBackdropFilter,
DrawRect,
DrawTriangleWave,
Expand Down
6 changes: 0 additions & 6 deletions Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,6 @@ CommandResult CommandExecutorCPU::draw_signed_distance_field(Gfx::IntRect const&
return CommandResult::Continue;
}

CommandResult CommandExecutorCPU::paint_frame(Gfx::IntRect const& rect, Palette const& palette, Gfx::FrameStyle style)
{
Gfx::StylePainter::paint_frame(painter(), rect, palette, style);
return CommandResult::Continue;
}

CommandResult CommandExecutorCPU::apply_backdrop_filter(Gfx::IntRect const& backdrop_region, Web::CSS::ResolvedBackdropFilter const& backdrop_filter)
{
auto& painter = this->painter();
Expand Down
1 change: 0 additions & 1 deletion Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class CommandExecutorCPU : public CommandExecutor {
CommandResult fill_ellipse(Gfx::IntRect const& rect, Color const& color, Gfx::AntiAliasingPainter::BlendMode blend_mode) override;
CommandResult draw_line(Color const&, Gfx::IntPoint const& from, Gfx::IntPoint const& to, int thickness, Gfx::Painter::LineStyle style, Color const& alternate_color) override;
CommandResult draw_signed_distance_field(Gfx::IntRect const& rect, Color const&, Gfx::GrayscaleBitmap const& sdf, float smoothing) override;
CommandResult paint_frame(Gfx::IntRect const& rect, Palette const&, Gfx::FrameStyle) override;
CommandResult apply_backdrop_filter(Gfx::IntRect const& backdrop_region, Web::CSS::ResolvedBackdropFilter const& backdrop_filter) override;
CommandResult draw_rect(Gfx::IntRect const& rect, Color const&, bool rough) override;
CommandResult paint_radial_gradient(Gfx::IntRect const& rect, Web::Painting::RadialGradientData const& radial_gradient_data, Gfx::IntPoint const& center, Gfx::IntSize const& size, Vector<Gfx::Path> const& clip_paths = {}) override;
Expand Down
6 changes: 0 additions & 6 deletions Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,6 @@ CommandResult CommandExecutorGPU::draw_signed_distance_field(Gfx::IntRect const&
return CommandResult::Continue;
}

CommandResult CommandExecutorGPU::paint_frame(Gfx::IntRect const&, Palette const&, Gfx::FrameStyle)
{
// FIXME
return CommandResult::Continue;
}

CommandResult CommandExecutorGPU::apply_backdrop_filter(Gfx::IntRect const&, Web::CSS::ResolvedBackdropFilter const&)
{
// FIXME
Expand Down
1 change: 0 additions & 1 deletion Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class CommandExecutorGPU : public CommandExecutor {
CommandResult fill_ellipse(Gfx::IntRect const& rect, Color const& color, Gfx::AntiAliasingPainter::BlendMode blend_mode) override;
CommandResult draw_line(Color const&, Gfx::IntPoint const& from, Gfx::IntPoint const& to, int thickness, Gfx::Painter::LineStyle style, Color const& alternate_color) override;
CommandResult draw_signed_distance_field(Gfx::IntRect const& rect, Color const&, Gfx::GrayscaleBitmap const& sdf, float smoothing) override;
CommandResult paint_frame(Gfx::IntRect const& rect, Palette const&, Gfx::FrameStyle) override;
CommandResult apply_backdrop_filter(Gfx::IntRect const& backdrop_region, Web::CSS::ResolvedBackdropFilter const& backdrop_filter) override;
CommandResult draw_rect(Gfx::IntRect const& rect, Color const&, bool rough) override;
CommandResult paint_radial_gradient(Gfx::IntRect const& rect, Web::Painting::RadialGradientData const& radial_gradient_data, Gfx::IntPoint const& center, Gfx::IntSize const& size, Vector<Gfx::Path> const& clip_paths = {}) override;
Expand Down
3 changes: 0 additions & 3 deletions Userland/Libraries/LibWeb/Painting/CommandList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ void CommandList::execute(CommandExecutor& executor)
return executor.draw_signed_distance_field(command.rect, command.color, command.sdf,
command.smoothing);
},
[&](PaintFrame const& command) {
return executor.paint_frame(command.rect, command.palette, command.style);
},
[&](ApplyBackdropFilter const& command) {
return executor.apply_backdrop_filter(command.backdrop_region, command.backdrop_filter);
},
Expand Down
1 change: 0 additions & 1 deletion Userland/Libraries/LibWeb/Painting/CommandList.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class CommandExecutor {
virtual CommandResult fill_ellipse(Gfx::IntRect const&, Color const&, Gfx::AntiAliasingPainter::BlendMode blend_mode) = 0;
virtual CommandResult draw_line(Color const& color, Gfx::IntPoint const& from, Gfx::IntPoint const& to, int thickness, Gfx::Painter::LineStyle, Color const& alternate_color) = 0;
virtual CommandResult draw_signed_distance_field(Gfx::IntRect const& rect, Color const&, Gfx::GrayscaleBitmap const&, float smoothing) = 0;
virtual CommandResult paint_frame(Gfx::IntRect const& rect, Palette const&, Gfx::FrameStyle) = 0;
virtual CommandResult apply_backdrop_filter(Gfx::IntRect const& backdrop_region, Web::CSS::ResolvedBackdropFilter const& backdrop_filter) = 0;
virtual CommandResult draw_rect(Gfx::IntRect const& rect, Color const&, bool rough) = 0;
virtual CommandResult draw_triangle_wave(Gfx::IntPoint const& p1, Gfx::IntPoint const& p2, Color const& color, int amplitude, int thickness) = 0;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const
auto image_rect = context.rounded_device_rect(absolute_rect());
if (m_renders_as_alt_text) {
auto enclosing_rect = context.enclosing_device_rect(absolute_rect()).to_type<int>();
context.recording_painter().paint_frame(enclosing_rect, context.palette(), Gfx::FrameStyle::SunkenContainer);
context.recording_painter().draw_rect(enclosing_rect, Gfx::Color::Black, 1);
context.recording_painter().draw_text(enclosing_rect, m_alt_text, Platform::FontPlugin::the().default_font(), Gfx::TextAlignment::Center, computed_values().color(), Gfx::TextElision::Right);
} else if (auto bitmap = m_image_provider.current_image_bitmap(image_rect.size().to_type<int>())) {
ScopedCornerRadiusClip corner_clip { context, image_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
Expand Down
5 changes: 0 additions & 5 deletions Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,6 @@ void RecordingPainter::pop_stacking_context()
append(PopStackingContext {});
}

void RecordingPainter::paint_frame(Gfx::IntRect rect, Palette palette, Gfx::FrameStyle style)
{
append(PaintFrame { state().translation.map(rect), palette, style });
}

void RecordingPainter::apply_backdrop_filter(Gfx::IntRect const& backdrop_region, BorderRadiiData const& border_radii_data, CSS::ResolvedBackdropFilter const& backdrop_filter)
{
append(ApplyBackdropFilter {
Expand Down
2 changes: 0 additions & 2 deletions Userland/Libraries/LibWeb/Painting/RecordingPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ class RecordingPainter {
void sample_under_corners(u32 id, CornerRadii corner_radii, Gfx::IntRect border_rect, CornerClip corner_clip);
void blit_corner_clipping(u32 id, Gfx::IntRect border_rect);

void paint_frame(Gfx::IntRect rect, Palette palette, Gfx::FrameStyle style);

void apply_backdrop_filter(Gfx::IntRect const& backdrop_region, BorderRadiiData const& border_radii_data, CSS::ResolvedBackdropFilter const& backdrop_filter);

void paint_outer_box_shadow_params(PaintOuterBoxShadowParams params);
Expand Down

0 comments on commit 3645b67

Please sign in to comment.