mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibWeb: Pass PaintingSurface into DisplayListPlayer::execute()
Deleteing set_surface() makes DisplayListPlayer API a bit more intuitive because now caller doesn't have to think whether it's necessary to restore previous surface after execution, instead DisplayListPlayer takes care of it by maintaining a stack of surfaces.
This commit is contained in:
parent
c5c3859205
commit
0094480fd6
7 changed files with 18 additions and 19 deletions
|
@ -94,8 +94,7 @@ Optional<Gfx::ImageCursor> CursorStyleValue::make_image_cursor(Layout::NodeWithS
|
|||
case DisplayListPlayerType::SkiaCPU: {
|
||||
auto painting_surface = Gfx::PaintingSurface::wrap_bitmap(bitmap);
|
||||
Painting::DisplayListPlayerSkia display_list_player;
|
||||
display_list_player.set_surface(painting_surface);
|
||||
display_list_player.execute(*display_list);
|
||||
display_list_player.execute(*display_list, painting_surface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ void RenderingThread::rendering_thread_loop()
|
|||
break;
|
||||
}
|
||||
|
||||
m_skia_player->set_surface(task->painting_surface);
|
||||
m_skia_player->execute(*task->display_list);
|
||||
m_skia_player->execute(*task->display_list, task->painting_surface);
|
||||
m_main_thread_event_loop.deferred_invoke([callback = move(task->callback)] {
|
||||
callback();
|
||||
});
|
||||
|
|
|
@ -35,13 +35,20 @@ static bool command_is_clip_or_mask(Command const& command)
|
|||
});
|
||||
}
|
||||
|
||||
void DisplayListPlayer::execute(DisplayList& display_list)
|
||||
void DisplayListPlayer::execute(DisplayList& display_list, RefPtr<Gfx::PaintingSurface> surface)
|
||||
{
|
||||
if (surface)
|
||||
m_surfaces.append(*surface);
|
||||
ScopeGuard guard = [&surfaces = m_surfaces, pop_surface_from_stack = !!surface] {
|
||||
if (pop_surface_from_stack)
|
||||
(void)surfaces.take_last();
|
||||
};
|
||||
|
||||
auto const& commands = display_list.commands();
|
||||
auto const& scroll_state = display_list.scroll_state();
|
||||
auto device_pixels_per_css_pixel = display_list.device_pixels_per_css_pixel();
|
||||
|
||||
VERIFY(m_surface);
|
||||
VERIFY(!m_surfaces.is_empty());
|
||||
|
||||
for (size_t command_index = 0; command_index < commands.size(); command_index++) {
|
||||
auto scroll_frame_id = commands[command_index].scroll_frame_id;
|
||||
|
|
|
@ -26,11 +26,10 @@ class DisplayListPlayer {
|
|||
public:
|
||||
virtual ~DisplayListPlayer() = default;
|
||||
|
||||
void execute(DisplayList&);
|
||||
void set_surface(NonnullRefPtr<Gfx::PaintingSurface> surface) { m_surface = surface; }
|
||||
void execute(DisplayList&, RefPtr<Gfx::PaintingSurface>);
|
||||
|
||||
protected:
|
||||
Gfx::PaintingSurface& surface() const { return *m_surface; }
|
||||
Gfx::PaintingSurface& surface() const { return m_surfaces.last(); }
|
||||
|
||||
private:
|
||||
virtual void flush() = 0;
|
||||
|
@ -74,7 +73,7 @@ private:
|
|||
virtual void apply_mask_bitmap(ApplyMaskBitmap const&) = 0;
|
||||
virtual bool would_be_fully_clipped_by_painter(Gfx::IntRect) const = 0;
|
||||
|
||||
RefPtr<Gfx::PaintingSurface> m_surface;
|
||||
Vector<NonnullRefPtr<Gfx::PaintingSurface>, 1> m_surfaces;
|
||||
};
|
||||
|
||||
class DisplayList : public AtomicRefCounted<DisplayList> {
|
||||
|
|
|
@ -972,10 +972,7 @@ void DisplayListPlayerSkia::add_mask(AddMask const& command)
|
|||
|
||||
auto mask_surface = Gfx::PaintingSurface::create_with_size(m_context, rect.size(), Gfx::BitmapFormat::BGRA8888, Gfx::AlphaType::Premultiplied);
|
||||
|
||||
NonnullRefPtr old_surface = surface();
|
||||
set_surface(mask_surface);
|
||||
execute(*command.display_list);
|
||||
set_surface(old_surface);
|
||||
execute(*command.display_list, mask_surface);
|
||||
|
||||
SkMatrix mask_matrix;
|
||||
mask_matrix.setTranslate(rect.x(), rect.y());
|
||||
|
@ -988,7 +985,7 @@ void DisplayListPlayerSkia::paint_nested_display_list(PaintNestedDisplayList con
|
|||
{
|
||||
auto& canvas = surface().canvas();
|
||||
canvas.translate(command.rect.x(), command.rect.y());
|
||||
execute(*command.display_list);
|
||||
execute(*command.display_list, {});
|
||||
}
|
||||
|
||||
void DisplayListPlayerSkia::paint_scrollbar(PaintScrollBar const& command)
|
||||
|
|
|
@ -100,8 +100,7 @@ RefPtr<Gfx::ImmutableBitmap> SVGMaskable::calculate_mask_of_svg(PaintContext& co
|
|||
StackingContext::paint_svg(paint_context, paintable, PaintPhase::Foreground);
|
||||
auto painting_surface = Gfx::PaintingSurface::wrap_bitmap(*mask_bitmap);
|
||||
DisplayListPlayerSkia display_list_player;
|
||||
display_list_player.set_surface(painting_surface);
|
||||
display_list_player.execute(display_list);
|
||||
display_list_player.execute(display_list, painting_surface);
|
||||
return mask_bitmap;
|
||||
};
|
||||
RefPtr<Gfx::Bitmap> mask_bitmap = {};
|
||||
|
|
|
@ -106,8 +106,7 @@ RefPtr<Gfx::Bitmap> SVGDecodedImageData::render(Gfx::IntSize size) const
|
|||
case DisplayListPlayerType::SkiaCPU: {
|
||||
auto painting_surface = Gfx::PaintingSurface::wrap_bitmap(*bitmap);
|
||||
Painting::DisplayListPlayerSkia display_list_player;
|
||||
display_list_player.set_surface(painting_surface);
|
||||
display_list_player.execute(*display_list);
|
||||
display_list_player.execute(*display_list, painting_surface);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue