mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb/Painting: Add SaveLayer
command
This adds a command for saving the current layer of the canvas. This is useful for painting content onto a blank background in isolation and later compositing it onto the canvas.
This commit is contained in:
parent
3e56e9e65d
commit
1898643ba4
Notes:
github-actions[bot]
2025-03-28 09:42:13 +00:00
Author: https://github.com/skyz1
Commit: 1898643ba4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3940
Reviewed-by: https://github.com/AtkinsSJ ✅
7 changed files with 17 additions and 0 deletions
|
@ -100,6 +100,7 @@ struct DrawRepeatedImmutableBitmap {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Save { };
|
struct Save { };
|
||||||
|
struct SaveLayer { };
|
||||||
struct Restore { };
|
struct Restore { };
|
||||||
|
|
||||||
struct Translate {
|
struct Translate {
|
||||||
|
@ -453,6 +454,7 @@ using Command = Variant<
|
||||||
DrawScaledImmutableBitmap,
|
DrawScaledImmutableBitmap,
|
||||||
DrawRepeatedImmutableBitmap,
|
DrawRepeatedImmutableBitmap,
|
||||||
Save,
|
Save,
|
||||||
|
SaveLayer,
|
||||||
Restore,
|
Restore,
|
||||||
Translate,
|
Translate,
|
||||||
AddClipRect,
|
AddClipRect,
|
||||||
|
|
|
@ -97,6 +97,7 @@ void DisplayListPlayer::execute(DisplayList& display_list)
|
||||||
else HANDLE_COMMAND(DrawRepeatedImmutableBitmap, draw_repeated_immutable_bitmap)
|
else HANDLE_COMMAND(DrawRepeatedImmutableBitmap, draw_repeated_immutable_bitmap)
|
||||||
else HANDLE_COMMAND(AddClipRect, add_clip_rect)
|
else HANDLE_COMMAND(AddClipRect, add_clip_rect)
|
||||||
else HANDLE_COMMAND(Save, save)
|
else HANDLE_COMMAND(Save, save)
|
||||||
|
else HANDLE_COMMAND(SaveLayer, save_layer)
|
||||||
else HANDLE_COMMAND(Restore, restore)
|
else HANDLE_COMMAND(Restore, restore)
|
||||||
else HANDLE_COMMAND(Translate, translate)
|
else HANDLE_COMMAND(Translate, translate)
|
||||||
else HANDLE_COMMAND(PushStackingContext, push_stacking_context)
|
else HANDLE_COMMAND(PushStackingContext, push_stacking_context)
|
||||||
|
|
|
@ -40,6 +40,7 @@ private:
|
||||||
virtual void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) = 0;
|
virtual void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) = 0;
|
||||||
virtual void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) = 0;
|
virtual void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) = 0;
|
||||||
virtual void save(Save const&) = 0;
|
virtual void save(Save const&) = 0;
|
||||||
|
virtual void save_layer(SaveLayer const&) = 0;
|
||||||
virtual void restore(Restore const&) = 0;
|
virtual void restore(Restore const&) = 0;
|
||||||
virtual void translate(Translate const&) = 0;
|
virtual void translate(Translate const&) = 0;
|
||||||
virtual void add_clip_rect(AddClipRect const&) = 0;
|
virtual void add_clip_rect(AddClipRect const&) = 0;
|
||||||
|
|
|
@ -177,6 +177,12 @@ void DisplayListPlayerSkia::save(Save const&)
|
||||||
canvas.save();
|
canvas.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisplayListPlayerSkia::save_layer(SaveLayer const&)
|
||||||
|
{
|
||||||
|
auto& canvas = surface().canvas();
|
||||||
|
canvas.saveLayer(nullptr, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void DisplayListPlayerSkia::restore(Restore const&)
|
void DisplayListPlayerSkia::restore(Restore const&)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
|
|
|
@ -28,6 +28,7 @@ private:
|
||||||
void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) override;
|
void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) override;
|
||||||
void add_clip_rect(AddClipRect const&) override;
|
void add_clip_rect(AddClipRect const&) override;
|
||||||
void save(Save const&) override;
|
void save(Save const&) override;
|
||||||
|
void save_layer(SaveLayer const&) override;
|
||||||
void restore(Restore const&) override;
|
void restore(Restore const&) override;
|
||||||
void translate(Translate const&) override;
|
void translate(Translate const&) override;
|
||||||
void push_stacking_context(PushStackingContext const&) override;
|
void push_stacking_context(PushStackingContext const&) override;
|
||||||
|
|
|
@ -280,6 +280,11 @@ void DisplayListRecorder::save()
|
||||||
append(Save {});
|
append(Save {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisplayListRecorder::save_layer()
|
||||||
|
{
|
||||||
|
append(SaveLayer {});
|
||||||
|
}
|
||||||
|
|
||||||
void DisplayListRecorder::restore()
|
void DisplayListRecorder::restore()
|
||||||
{
|
{
|
||||||
append(Restore {});
|
append(Restore {});
|
||||||
|
|
|
@ -114,6 +114,7 @@ public:
|
||||||
void pop_scroll_frame_id();
|
void pop_scroll_frame_id();
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
void save_layer();
|
||||||
void restore();
|
void restore();
|
||||||
|
|
||||||
struct PushStackingContextParams {
|
struct PushStackingContextParams {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue