/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace ImageDecoder { class ConnectionFromClient final : public IPC::ConnectionFromClient { C_OBJECT(ConnectionFromClient); public: ~ConnectionFromClient() override = default; virtual void die() override; struct DecodeResult { bool is_animated = false; u32 loop_count = 0; Gfx::FloatPoint scale { 1, 1 }; Gfx::BitmapSequence bitmaps; Vector durations; }; private: using Job = Threading::BackgroundAction; explicit ConnectionFromClient(IPC::Transport); virtual Messages::ImageDecoderServer::DecodeImageResponse decode_image(Core::AnonymousBuffer const&, Optional const& ideal_size, Optional const& mime_type) override; virtual void cancel_decoding(i64 image_id) override; virtual Messages::ImageDecoderServer::ConnectNewClientsResponse connect_new_clients(size_t count) override; ErrorOr connect_new_client(); NonnullRefPtr make_decode_image_job(i64 image_id, Core::AnonymousBuffer, Optional ideal_size, Optional mime_type); i64 m_next_image_id { 0 }; HashMap> m_pending_jobs; }; }