Client.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/HashMap.h>
  8. #include <ImageDecoder/ImageDecoderClientEndpoint.h>
  9. #include <ImageDecoder/ImageDecoderServerEndpoint.h>
  10. #include <LibIPC/ConnectionToServer.h>
  11. namespace ImageDecoderClient {
  12. struct Frame {
  13. NonnullRefPtr<Gfx::Bitmap> bitmap;
  14. u32 duration { 0 };
  15. };
  16. struct DecodedImage {
  17. bool is_animated { false };
  18. Gfx::FloatPoint scale { 1, 1 };
  19. u32 loop_count { 0 };
  20. Vector<Frame> frames;
  21. };
  22. class Client final
  23. : public IPC::ConnectionToServer<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>
  24. , public ImageDecoderClientEndpoint {
  25. IPC_CLIENT_CONNECTION(Client, "/tmp/session/%sid/portal/image"sv);
  26. public:
  27. Client(NonnullOwnPtr<Core::LocalSocket>);
  28. Optional<DecodedImage> decode_image(ReadonlyBytes, Optional<Gfx::IntSize> ideal_size = {}, Optional<ByteString> mime_type = {});
  29. Function<void()> on_death;
  30. private:
  31. virtual void die() override;
  32. };
  33. }