mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 06:47:34 +00:00
LibWeb: Record painting commands in coordinates of stacking context
By storing painting command coordinates relative to the nearest stacking context we can get rid of the Translate command. Additionally, this allows us to easily check if the bounding rectangles of the commands cover or intersect within a stacking context. This should be useful if we decide to optimize by avoiding the execution of commands that will be overpainted by the results of subsequent commands.
This commit is contained in:
parent
311cc7d9b9
commit
4318bcf447
6 changed files with 76 additions and 68 deletions
|
@ -83,12 +83,6 @@ struct DrawScaledBitmap {
|
|||
[[nodiscard]] CommandResult execute(CommandExecutionState&) const;
|
||||
};
|
||||
|
||||
struct Translate {
|
||||
Gfx::IntPoint translation_delta;
|
||||
|
||||
[[nodiscard]] CommandResult execute(CommandExecutionState&) const;
|
||||
};
|
||||
|
||||
struct SaveState {
|
||||
[[nodiscard]] CommandResult execute(CommandExecutionState&) const;
|
||||
};
|
||||
|
@ -367,7 +361,6 @@ using PaintingCommand = Variant<
|
|||
DrawText,
|
||||
FillRect,
|
||||
DrawScaledBitmap,
|
||||
Translate,
|
||||
SaveState,
|
||||
RestoreState,
|
||||
AddClipRect,
|
||||
|
@ -510,6 +503,17 @@ public:
|
|||
|
||||
void execute(Gfx::Bitmap&);
|
||||
|
||||
RecordingPainter()
|
||||
{
|
||||
m_state_stack.append(State());
|
||||
}
|
||||
|
||||
struct State {
|
||||
Gfx::AffineTransform translation;
|
||||
};
|
||||
State& state() { return m_state_stack.last(); }
|
||||
State const& state() const { return m_state_stack.last(); }
|
||||
|
||||
private:
|
||||
void push_command(PaintingCommand command)
|
||||
{
|
||||
|
@ -517,6 +521,7 @@ private:
|
|||
}
|
||||
|
||||
Vector<PaintingCommand> m_painting_commands;
|
||||
Vector<State> m_state_stack;
|
||||
};
|
||||
|
||||
class RecordingPainterStateSaver {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue