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

LibAccelGfx+LibWeb: Add support for stacking context opacity

For each stacking context with an opacity less than 1, we create a
separate framebuffer. We then blit the texture attached to this
framebuffer with the specified opacity.

To avoid the performance overhead of reading pixels from the texture
into Gfx::Bitmap, a new method that allows for direct blitting from
the texture is introduced, named blit_scaled_texture().
This commit is contained in:
Aliaksandr Kalenik 2023-11-23 15:28:51 +01:00 committed by Andreas Kling
parent cb90daadc7
commit 5f7ac559a7
8 changed files with 133 additions and 74 deletions

View file

@ -51,13 +51,23 @@ public:
virtual bool needs_prepare_glyphs_texture() const override { return true; }
void prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const&) override;
PaintingCommandExecutorGPU(AccelGfx::Painter& painter);
PaintingCommandExecutorGPU(Gfx::Bitmap& bitmap);
~PaintingCommandExecutorGPU() override;
private:
AccelGfx::Painter& painter() { return m_painter; }
Gfx::Bitmap& m_target_bitmap;
AccelGfx::Painter& m_painter;
struct StackingContext {
RefPtr<AccelGfx::Canvas> canvas;
OwnPtr<AccelGfx::Painter> painter;
float opacity;
Gfx::IntRect destination;
};
[[nodiscard]] AccelGfx::Painter const& painter() const { return *stacking_contexts.last().painter; }
[[nodiscard]] AccelGfx::Painter& painter() { return *stacking_contexts.last().painter; }
Vector<StackingContext> stacking_contexts;
};
}