LibWeb: Make sure painter's context is active before executing commands
In the upcoming changes, the AccelGfx context will be used for WebGL, so we can no longer assume that the WebContent process has a single global context.
This commit is contained in:
parent
aac439edb1
commit
c6289fad49
Notes:
sideshowbarker
2024-07-17 02:56:25 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/c6289fad49 Pull-request: https://github.com/SerenityOS/serenity/pull/22872 Issue: https://github.com/SerenityOS/serenity/issues/22670 Reviewed-by: https://github.com/awesomekling
4 changed files with 13 additions and 0 deletions
|
@ -14,6 +14,7 @@ PaintingCommandExecutorGPU::PaintingCommandExecutorGPU(AccelGfx::Context& contex
|
|||
: m_target_bitmap(bitmap)
|
||||
, m_context(context)
|
||||
{
|
||||
m_context.activate();
|
||||
auto canvas = AccelGfx::Canvas::create(bitmap.size());
|
||||
auto painter = AccelGfx::Painter::create(m_context, canvas);
|
||||
m_stacking_contexts.append({ .canvas = canvas,
|
||||
|
@ -25,6 +26,7 @@ PaintingCommandExecutorGPU::PaintingCommandExecutorGPU(AccelGfx::Context& contex
|
|||
|
||||
PaintingCommandExecutorGPU::~PaintingCommandExecutorGPU()
|
||||
{
|
||||
m_context.activate();
|
||||
VERIFY(m_stacking_contexts.size() == 1);
|
||||
painter().flush(m_target_bitmap);
|
||||
}
|
||||
|
@ -418,6 +420,11 @@ void PaintingCommandExecutorGPU::prepare_glyph_texture(HashMap<Gfx::Font const*,
|
|||
AccelGfx::GlyphAtlas::the().update(unique_glyphs);
|
||||
}
|
||||
|
||||
void PaintingCommandExecutorGPU::prepare_to_execute()
|
||||
{
|
||||
m_context.activate();
|
||||
}
|
||||
|
||||
void PaintingCommandExecutorGPU::update_immutable_bitmap_texture_cache(HashMap<u32, Gfx::ImmutableBitmap const*>& immutable_bitmaps)
|
||||
{
|
||||
painter().update_immutable_bitmap_texture_cache(immutable_bitmaps);
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
virtual bool needs_prepare_glyphs_texture() const override { return true; }
|
||||
void prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const&) override;
|
||||
|
||||
virtual void prepare_to_execute() override;
|
||||
|
||||
bool needs_update_immutable_bitmap_texture_cache() const override { return true; }
|
||||
void update_immutable_bitmap_texture_cache(HashMap<u32, Gfx::ImmutableBitmap const*>&) override;
|
||||
|
||||
|
|
|
@ -448,6 +448,8 @@ void RecordingPainter::apply_scroll_offsets(Vector<Gfx::IntPoint> const& offsets
|
|||
|
||||
void RecordingPainter::execute(PaintingCommandExecutor& executor)
|
||||
{
|
||||
executor.prepare_to_execute();
|
||||
|
||||
if (executor.needs_prepare_glyphs_texture()) {
|
||||
HashMap<Gfx::Font const*, HashTable<u32>> unique_glyphs;
|
||||
for (auto& command_with_scroll_id : m_painting_commands) {
|
||||
|
|
|
@ -486,6 +486,8 @@ public:
|
|||
virtual bool needs_prepare_glyphs_texture() const { return false; }
|
||||
virtual void prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const& unique_glyphs) = 0;
|
||||
|
||||
virtual void prepare_to_execute() { }
|
||||
|
||||
virtual bool needs_update_immutable_bitmap_texture_cache() const = 0;
|
||||
virtual void update_immutable_bitmap_texture_cache(HashMap<u32, Gfx::ImmutableBitmap const*>&) = 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue