/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace ImageDecoderClient { struct Frame { NonnullRefPtr bitmap; u32 duration { 0 }; }; struct DecodedImage { bool is_animated { false }; Gfx::FloatPoint scale { 1, 1 }; u32 loop_count { 0 }; Vector frames; }; class Client final : public IPC::ConnectionToServer , public ImageDecoderClientEndpoint { IPC_CLIENT_CONNECTION(Client, "/tmp/session/%sid/portal/image"sv); public: Client(IPC::Transport); NonnullRefPtr> decode_image(ReadonlyBytes, Function(DecodedImage&)> on_resolved, Function on_rejected, Optional ideal_size = {}, Optional mime_type = {}); Function on_death; private: virtual void die() override; virtual void did_decode_image(i64 image_id, bool is_animated, u32 loop_count, Gfx::BitmapSequence const& bitmap_sequence, Vector const& durations, Gfx::FloatPoint scale) override; virtual void did_fail_to_decode_image(i64 image_id, String const& error_message) override; HashMap>> m_pending_decoded_images; }; }