ShareableBitmap.h 738 B

123456789101112131415161718192021222324252627282930313233343536373839
  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() { }
  14. explicit ShareableBitmap(const Gfx::Bitmap&);
  15. enum Tag { ConstructWithKnownGoodBitmap };
  16. ShareableBitmap(NonnullRefPtr<Gfx::Bitmap>, Tag);
  17. bool is_valid() const { return m_bitmap; }
  18. const Bitmap* bitmap() const { return m_bitmap; }
  19. Bitmap* bitmap() { return m_bitmap; }
  20. private:
  21. RefPtr<Bitmap> m_bitmap;
  22. };
  23. }
  24. namespace IPC {
  25. bool encode(Encoder&, const Gfx::ShareableBitmap&);
  26. bool decode(Decoder&, Gfx::ShareableBitmap&);
  27. }