/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #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; Gfx::ColorSpace color_space; }; class Client final : public IPC::ConnectionToServer , public ImageDecoderClientEndpoint { C_OBJECT_ABSTRACT(Client); public: using InitTransport = Messages::ImageDecoderServer::InitTransport; 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 bitmap_sequence, Vector durations, Gfx::FloatPoint scale, Gfx::ColorSpace color_space) override; virtual void did_fail_to_decode_image(i64 image_id, String error_message) override; HashMap>> m_pending_decoded_images; }; }