ImageCodecPlugin.h 850 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, Dex♪ <dexes.ttp@gmail.com>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/RefPtr.h>
  9. #include <AK/Vector.h>
  10. #include <LibCore/Promise.h>
  11. #include <LibGfx/Forward.h>
  12. namespace Web::Platform {
  13. struct Frame {
  14. RefPtr<Gfx::Bitmap> bitmap;
  15. size_t duration { 0 };
  16. };
  17. struct DecodedImage {
  18. bool is_animated { false };
  19. u32 loop_count { 0 };
  20. Vector<Frame> frames;
  21. };
  22. class ImageCodecPlugin {
  23. public:
  24. static ImageCodecPlugin& the();
  25. static void install(ImageCodecPlugin&);
  26. virtual ~ImageCodecPlugin();
  27. virtual NonnullRefPtr<Core::Promise<DecodedImage>> decode_image(ReadonlyBytes, ESCAPING Function<ErrorOr<void>(DecodedImage&)> on_resolved, ESCAPING Function<void(Error&)> on_rejected) = 0;
  28. };
  29. }