ShareableBitmap.h 730 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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/RefPtr.h>
  8. #include <LibGfx/Bitmap.h>
  9. #include <LibGfx/Size.h>
  10. namespace Gfx {
  11. class ShareableBitmap {
  12. public:
  13. ShareableBitmap() = default;
  14. enum Tag { ConstructWithKnownGoodBitmap };
  15. ShareableBitmap(NonnullRefPtr<Gfx::Bitmap>, Tag);
  16. bool is_valid() const { return m_bitmap; }
  17. Bitmap const* bitmap() const { return m_bitmap; }
  18. Bitmap* bitmap() { return m_bitmap; }
  19. private:
  20. friend class Bitmap;
  21. RefPtr<Bitmap> m_bitmap;
  22. };
  23. }
  24. namespace IPC {
  25. bool encode(Encoder&, Gfx::ShareableBitmap const&);
  26. ErrorOr<void> decode(Decoder&, Gfx::ShareableBitmap&);
  27. }