Client.h 926 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/ServerConnection.h>
  11. namespace ImageDecoderClient {
  12. struct Frame {
  13. RefPtr<Gfx::Bitmap> bitmap;
  14. u32 duration { 0 };
  15. };
  16. struct DecodedImage {
  17. bool is_animated { false };
  18. u32 loop_count { 0 };
  19. Vector<Frame> frames;
  20. };
  21. class Client final
  22. : public IPC::ServerConnection<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>
  23. , public ImageDecoderClientEndpoint {
  24. C_OBJECT(Client);
  25. public:
  26. virtual void handshake() override;
  27. Optional<DecodedImage> decode_image(const ByteBuffer&);
  28. Function<void()> on_death;
  29. private:
  30. Client();
  31. virtual void die() override;
  32. virtual void dummy() override;
  33. };
  34. }