compositor_storage.h 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #pragma once
  31. #include "core/templates/rid_owner.h"
  32. #include "servers/rendering_server.h"
  33. class RendererCompositorStorage {
  34. private:
  35. static RendererCompositorStorage *singleton;
  36. int num_compositor_effects_with_motion_vectors = 0;
  37. // Compositor effect
  38. struct CompositorEffect {
  39. bool is_enabled = true;
  40. RS::CompositorEffectCallbackType callback_type;
  41. Callable callback;
  42. BitField<RS::CompositorEffectFlags> flags = {};
  43. };
  44. mutable RID_Owner<CompositorEffect, true> compositor_effects_owner;
  45. // Compositor
  46. struct Compositor {
  47. // Compositor effects
  48. Vector<RID> compositor_effects;
  49. };
  50. mutable RID_Owner<Compositor, true> compositor_owner;
  51. public:
  52. static RendererCompositorStorage *get_singleton() { return singleton; }
  53. int get_num_compositor_effects_with_motion_vectors() const { return num_compositor_effects_with_motion_vectors; }
  54. RendererCompositorStorage();
  55. virtual ~RendererCompositorStorage();
  56. // Compositor effect
  57. RID compositor_effect_allocate();
  58. void compositor_effect_initialize(RID p_rid);
  59. void compositor_effect_free(RID p_rid);
  60. bool is_compositor_effect(RID p_effect) const {
  61. return compositor_effects_owner.owns(p_effect);
  62. }
  63. void compositor_effect_set_enabled(RID p_effect, bool p_enabled);
  64. bool compositor_effect_get_enabled(RID p_effect) const;
  65. void compositor_effect_set_callback(RID p_effect, RS::CompositorEffectCallbackType p_callback_type, const Callable &p_callback);
  66. RS::CompositorEffectCallbackType compositor_effect_get_callback_type(RID p_effect) const;
  67. Callable compositor_effect_get_callback(RID p_effect) const;
  68. void compositor_effect_set_flag(RID p_effect, RS::CompositorEffectFlags p_flag, bool p_set);
  69. bool compositor_effect_get_flag(RID p_effect, RS::CompositorEffectFlags p_flag) const;
  70. // Compositor
  71. RID compositor_allocate();
  72. void compositor_initialize(RID p_rid);
  73. void compositor_free(RID p_rid);
  74. bool is_compositor(RID p_compositor) const {
  75. return compositor_owner.owns(p_compositor);
  76. }
  77. void compositor_set_compositor_effects(RID p_compositor, const Vector<RID> &p_effects);
  78. 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;
  79. };