IOSurface.h 973 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <AK/Noncopyable.h>
  9. #include <AK/OwnPtr.h>
  10. #include <LibCore/MachPort.h>
  11. namespace Core {
  12. class IOSurfaceHandle {
  13. AK_MAKE_NONCOPYABLE(IOSurfaceHandle);
  14. public:
  15. IOSurfaceHandle(IOSurfaceHandle&& other);
  16. IOSurfaceHandle& operator=(IOSurfaceHandle&& other);
  17. static IOSurfaceHandle create(int width, int height);
  18. static IOSurfaceHandle from_mach_port(MachPort const& port);
  19. MachPort create_mach_port() const;
  20. size_t width() const;
  21. size_t height() const;
  22. size_t bytes_per_element() const;
  23. size_t bytes_per_row() const;
  24. void* data() const;
  25. void* core_foundation_pointer() const;
  26. ~IOSurfaceHandle();
  27. private:
  28. struct IOSurfaceRefWrapper;
  29. IOSurfaceHandle(OwnPtr<IOSurfaceRefWrapper>&&);
  30. OwnPtr<IOSurfaceRefWrapper> m_ref_wrapper;
  31. };
  32. }