WebGLObject.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
  3. * Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
  4. * Copyright (c) 2024, Luke Wilde <luke@ladybird.org>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include <LibWeb/Bindings/PlatformObject.h>
  10. #include <LibWeb/WebGL/Types.h>
  11. #include <LibWeb/WebGL/WebGLRenderingContextBase.h>
  12. namespace Web::WebGL {
  13. class WebGLObject : public Bindings::PlatformObject {
  14. WEB_PLATFORM_OBJECT(WebGLObject, Bindings::PlatformObject);
  15. public:
  16. virtual ~WebGLObject();
  17. String label() const { return m_label; }
  18. void set_label(String const& label) { m_label = label; }
  19. GLuint handle() const { return m_handle; }
  20. protected:
  21. explicit WebGLObject(JS::Realm&, WebGLRenderingContextBase&, GLuint handle);
  22. void initialize(JS::Realm&) override;
  23. void visit_edges(Visitor&) override;
  24. bool invalidated() const { return m_invalidated; }
  25. private:
  26. // FIXME: It should be GC::Ptr instead of raw pointer, but we need to make WebGLRenderingContextBase inherit from PlatformObject first.
  27. WebGLRenderingContextBase* m_context;
  28. GLuint m_handle { 0 };
  29. bool m_invalidated { false };
  30. String m_label;
  31. };
  32. }