compositor_storage.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**************************************************************************/
  2. /* compositor_storage.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef COMPOSITOR_STORAGE_H
  31. #define COMPOSITOR_STORAGE_H
  32. #include "core/templates/rid_owner.h"
  33. #include "servers/rendering_server.h"
  34. class RendererCompositorStorage {
  35. private:
  36. static RendererCompositorStorage *singleton;
  37. int num_compositor_effects_with_motion_vectors = 0;
  38. // Compositor effect
  39. struct CompositorEffect {
  40. bool is_enabled = true;
  41. RS::CompositorEffectCallbackType callback_type;
  42. Callable callback;
  43. BitField<RS::CompositorEffectFlags> flags;
  44. };
  45. mutable RID_Owner<CompositorEffect, true> compositor_effects_owner;
  46. // Compositor
  47. struct Compositor {
  48. // Compositor effects
  49. Vector<RID> compositor_effects;
  50. };
  51. mutable RID_Owner<Compositor, true> compositor_owner;
  52. public:
  53. static RendererCompositorStorage *get_singleton() { return singleton; }
  54. int get_num_compositor_effects_with_motion_vectors() const { return num_compositor_effects_with_motion_vectors; }
  55. RendererCompositorStorage();
  56. virtual ~RendererCompositorStorage();
  57. // Compositor effect
  58. RID compositor_effect_allocate();
  59. void compositor_effect_initialize(RID p_rid);
  60. void compositor_effect_free(RID p_rid);
  61. bool is_compositor_effect(RID p_effect) const {
  62. return compositor_effects_owner.owns(p_effect);
  63. }
  64. void compositor_effect_set_enabled(RID p_effect, bool p_enabled);
  65. bool compositor_effect_get_enabled(RID p_effect) const;
  66. void compositor_effect_set_callback(RID p_effect, RS::CompositorEffectCallbackType p_callback_type, const Callable &p_callback);
  67. RS::CompositorEffectCallbackType compositor_effect_get_callback_type(RID p_effect) const;
  68. Callable compositor_effect_get_callback(RID p_effect) const;
  69. void compositor_effect_set_flag(RID p_effect, RS::CompositorEffectFlags p_flag, bool p_set);
  70. bool compositor_effect_get_flag(RID p_effect, RS::CompositorEffectFlags p_flag) const;
  71. // Compositor
  72. RID compositor_allocate();
  73. void compositor_initialize(RID p_rid);
  74. void compositor_free(RID p_rid);
  75. bool is_compositor(RID p_compositor) const {
  76. return compositor_owner.owns(p_compositor);
  77. }
  78. void compositor_set_compositor_effects(RID p_compositor, const Vector<RID> &p_effects);
  79. Vector<RID> compositor_get_compositor_effects(RID p_compositor, RS::CompositorEffectCallbackType p_callback_type = RS::COMPOSITOR_EFFECT_CALLBACK_TYPE_ANY, bool p_enabled_only = true) const;
  80. };
  81. #endif // COMPOSITOR_STORAGE_H