mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +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
641a23c5c1
commit
9dac622ee9
7 changed files with 17 additions and 0 deletions
|
@ -100,6 +100,7 @@ struct DrawRepeatedImmutableBitmap {
|
|||
};
|
||||
|
||||
struct Save { };
|
||||
struct SaveLayer { };
|
||||
struct Restore { };
|
||||
|
||||
struct Translate {
|
||||
|
@ -453,6 +454,7 @@ using Command = Variant<
|
|||
DrawScaledImmutableBitmap,
|
||||
DrawRepeatedImmutableBitmap,
|
||||
Save,
|
||||
SaveLayer,
|
||||
Restore,
|
||||
Translate,
|
||||
AddClipRect,
|
||||
|
|
|
@ -98,6 +98,7 @@ void DisplayListPlayer::execute(DisplayList& display_list)
|
|||
else HANDLE_COMMAND(DrawRepeatedImmutableBitmap, draw_repeated_immutable_bitmap)
|
||||
else HANDLE_COMMAND(AddClipRect, add_clip_rect)
|
||||
else HANDLE_COMMAND(Save, save)
|
||||
else HANDLE_COMMAND(SaveLayer, save_layer)
|
||||
else HANDLE_COMMAND(Restore, restore)
|
||||
else HANDLE_COMMAND(Translate, translate)
|
||||
else HANDLE_COMMAND(PushStackingContext, push_stacking_context)
|
||||
|
|
|
@ -40,6 +40,7 @@ private:
|
|||
virtual void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) = 0;
|
||||
virtual void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) = 0;
|
||||
virtual void save(Save const&) = 0;
|
||||
virtual void save_layer(SaveLayer const&) = 0;
|
||||
virtual void restore(Restore const&) = 0;
|
||||
virtual void translate(Translate const&) = 0;
|
||||
virtual void add_clip_rect(AddClipRect const&) = 0;
|
||||
|
|
|
@ -177,6 +177,12 @@ void DisplayListPlayerSkia::save(Save const&)
|
|||
canvas.save();
|
||||
}
|
||||
|
||||
void DisplayListPlayerSkia::save_layer(SaveLayer const&)
|
||||
{
|
||||
auto& canvas = surface().canvas();
|
||||
canvas.saveLayer(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void DisplayListPlayerSkia::restore(Restore const&)
|
||||
{
|
||||
auto& canvas = surface().canvas();
|
||||
|
|
|
@ -28,6 +28,7 @@ private:
|
|||
void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) override;
|
||||
void add_clip_rect(AddClipRect const&) override;
|
||||
void save(Save const&) override;
|
||||
void save_layer(SaveLayer const&) override;
|
||||
void restore(Restore const&) override;
|
||||
void translate(Translate const&) override;
|
||||
void push_stacking_context(PushStackingContext const&) override;
|
||||
|
|
|
@ -280,6 +280,11 @@ void DisplayListRecorder::save()
|
|||
append(Save {});
|
||||
}
|
||||
|
||||
void DisplayListRecorder::save_layer()
|
||||
{
|
||||
append(SaveLayer {});
|
||||
}
|
||||
|
||||
void DisplayListRecorder::restore()
|
||||
{
|
||||
append(Restore {});
|
||||
|
|
|
@ -114,6 +114,7 @@ public:
|
|||
void pop_scroll_frame_id();
|
||||
|
||||
void save();
|
||||
void save_layer();
|
||||
void restore();
|
||||
|
||||
struct PushStackingContextParams {
|
||||
|
|
Loading…
Add table
Reference in a new issue