1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

LibWeb: Make private RecordingPainter::state()

Removes usage of `RecordingPainter::state()` and makes it private.

No behavior change intended.
This commit is contained in:
Aliaksandr Kalenik 2023-12-16 14:06:47 +01:00 committed by Alexander Kalenik
parent 55c483b763
commit f361b8c000
5 changed files with 10 additions and 10 deletions

View file

@ -117,7 +117,7 @@ ScopedCornerRadiusClip::ScopedCornerRadiusClip(PaintContext& context, DevicePixe
.bottom_right = border_radii.bottom_right.as_corner(context), .bottom_right = border_radii.bottom_right.as_corner(context),
.bottom_left = border_radii.bottom_left.as_corner(context) .bottom_left = border_radii.bottom_left.as_corner(context)
}; };
m_context.recording_painter().sample_under_corners(m_id, corner_radii, context.recording_painter().state().translation.map(border_rect.to_type<int>()), corner_clip); m_context.recording_painter().sample_under_corners(m_id, corner_radii, border_rect.to_type<int>(), corner_clip);
} }
ScopedCornerRadiusClip::~ScopedCornerRadiusClip() ScopedCornerRadiusClip::~ScopedCornerRadiusClip()

View file

@ -485,7 +485,7 @@ void PaintableBox::apply_clip_overflow_rect(PaintContext& context, PaintPhase ph
if (border_radii_data.has_any_radius()) { if (border_radii_data.has_any_radius()) {
VERIFY(!m_corner_clipper_id.has_value()); VERIFY(!m_corner_clipper_id.has_value());
m_corner_clipper_id = context.allocate_corner_clipper_id(); m_corner_clipper_id = context.allocate_corner_clipper_id();
context.recording_painter().sample_under_corners(*m_corner_clipper_id, corner_radii, context.recording_painter().state().translation.map(context.rounded_device_rect(*clip_rect).to_type<int>()), CornerClip::Outside); context.recording_painter().sample_under_corners(*m_corner_clipper_id, corner_radii, context.rounded_device_rect(*clip_rect).to_type<int>(), CornerClip::Outside);
} }
} }
} }
@ -503,7 +503,7 @@ void PaintableBox::clear_clip_overflow_rect(PaintContext& context, PaintPhase ph
if (m_corner_clipper_id.has_value()) { if (m_corner_clipper_id.has_value()) {
VERIFY(m_corner_clipper_id.has_value()); VERIFY(m_corner_clipper_id.has_value());
auto clip_rect = this->calculate_overflow_clipped_rect(); auto clip_rect = this->calculate_overflow_clipped_rect();
context.recording_painter().blit_corner_clipping(*m_corner_clipper_id, context.recording_painter().state().translation.map(context.rounded_device_rect(*clip_rect).to_type<int>())); context.recording_painter().blit_corner_clipping(*m_corner_clipper_id, context.rounded_device_rect(*clip_rect).to_type<int>());
m_corner_clipper_id = {}; m_corner_clipper_id = {};
} }
} }
@ -677,7 +677,6 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const
Optional<u32> corner_clip_id; Optional<u32> corner_clip_id;
auto clip_box = context.rounded_device_rect(absolute_padding_box_rect()); auto clip_box = context.rounded_device_rect(absolute_padding_box_rect());
auto border_radius_clip_rect = context.recording_painter().state().translation.map(clip_box.to_type<int>());
if (should_clip_overflow) { if (should_clip_overflow) {
context.recording_painter().save(); context.recording_painter().save();
@ -695,7 +694,7 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const
}; };
if (border_radii.has_any_radius()) { if (border_radii.has_any_radius()) {
corner_clip_id = context.allocate_corner_clipper_id(); corner_clip_id = context.allocate_corner_clipper_id();
context.recording_painter().sample_under_corners(*corner_clip_id, corner_radii, border_radius_clip_rect, CornerClip::Outside); context.recording_painter().sample_under_corners(*corner_clip_id, corner_radii, clip_box.to_type<int>(), CornerClip::Outside);
} }
} }
@ -746,7 +745,7 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const
if (should_clip_overflow) { if (should_clip_overflow) {
context.recording_painter().restore(); context.recording_painter().restore();
if (corner_clip_id.has_value()) { if (corner_clip_id.has_value()) {
context.recording_painter().blit_corner_clipping(*corner_clip_id, border_radius_clip_rect); context.recording_painter().blit_corner_clipping(*corner_clip_id, clip_box.to_type<int>());
corner_clip_id = {}; corner_clip_id = {};
} }
} }

View file

@ -29,13 +29,13 @@ void RecordingPainter::sample_under_corners(u32 id, CornerRadii corner_radii, Gf
push_command(SampleUnderCorners { push_command(SampleUnderCorners {
id, id,
corner_radii, corner_radii,
border_rect, border_rect = state().translation.map(border_rect),
corner_clip }); corner_clip });
} }
void RecordingPainter::blit_corner_clipping(u32 id, Gfx::IntRect border_rect) void RecordingPainter::blit_corner_clipping(u32 id, Gfx::IntRect border_rect)
{ {
push_command(BlitCornerClipping { id, border_rect }); push_command(BlitCornerClipping { id, border_rect = state().translation.map(border_rect) });
} }
void RecordingPainter::fill_rect(Gfx::IntRect const& rect, Color color) void RecordingPainter::fill_rect(Gfx::IntRect const& rect, Color color)
@ -323,6 +323,7 @@ void RecordingPainter::apply_backdrop_filter(Gfx::IntRect const& backdrop_region
void RecordingPainter::paint_outer_box_shadow_params(PaintOuterBoxShadowParams params) void RecordingPainter::paint_outer_box_shadow_params(PaintOuterBoxShadowParams params)
{ {
params.device_content_rect = state().translation.map(params.device_content_rect.to_type<int>()).to_type<DevicePixels>();
push_command(PaintOuterBoxShadow { push_command(PaintOuterBoxShadow {
.outer_box_shadow_params = params, .outer_box_shadow_params = params,
}); });

View file

@ -498,6 +498,7 @@ public:
m_state_stack.append(State()); m_state_stack.append(State());
} }
private:
struct State { struct State {
Gfx::AffineTransform translation; Gfx::AffineTransform translation;
Optional<Gfx::IntRect> clip_rect; Optional<Gfx::IntRect> clip_rect;
@ -505,7 +506,6 @@ public:
State& state() { return m_state_stack.last(); } State& state() { return m_state_stack.last(); }
State const& state() const { return m_state_stack.last(); } State const& state() const { return m_state_stack.last(); }
private:
void push_command(PaintingCommand command) void push_command(PaintingCommand command)
{ {
m_painting_commands.append(command); m_painting_commands.append(command);

View file

@ -564,7 +564,7 @@ void paint_box_shadow(PaintContext& context,
.offset_y = offset_y, .offset_y = offset_y,
.blur_radius = blur_radius, .blur_radius = blur_radius,
.spread_distance = spread_distance, .spread_distance = spread_distance,
.device_content_rect = context.recording_painter().state().translation.map(device_content_rect.to_type<int>()).to_type<DevicePixels>(), .device_content_rect = device_content_rect,
}; };
if (box_shadow_data.placement == ShadowPlacement::Inner) { if (box_shadow_data.placement == ShadowPlacement::Inner) {