ShareableBitmap.h 783 B

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