2
0

renderer_compositor.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*************************************************************************/
  2. /* renderer_compositor.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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 RENDERING_SERVER_COMPOSITOR_H
  31. #define RENDERING_SERVER_COMPOSITOR_H
  32. #include "core/math/camera_matrix.h"
  33. #include "core/templates/pair.h"
  34. #include "core/templates/self_list.h"
  35. #include "servers/rendering/renderer_canvas_render.h"
  36. #include "servers/rendering/renderer_scene.h"
  37. #include "servers/rendering/renderer_storage.h"
  38. #include "servers/rendering_server.h"
  39. class RendererSceneRender;
  40. struct BlitToScreen {
  41. RID render_target;
  42. Rect2 src_rect = Rect2(0.0, 0.0, 1.0, 1.0);
  43. Rect2i dst_rect;
  44. struct {
  45. bool use_layer = false;
  46. uint32_t layer = 0;
  47. } multi_view;
  48. struct {
  49. //lens distorted parameters for VR
  50. bool apply = false;
  51. Vector2 eye_center;
  52. float k1 = 0.0;
  53. float k2 = 0.0;
  54. float upscale = 1.0;
  55. float aspect_ratio = 1.0;
  56. } lens_distortion;
  57. };
  58. class RendererCompositor {
  59. private:
  60. bool xr_enabled = false;
  61. protected:
  62. static RendererCompositor *(*_create_func)();
  63. public:
  64. static RendererCompositor *create();
  65. virtual RendererStorage *get_storage() = 0;
  66. virtual RendererCanvasRender *get_canvas() = 0;
  67. virtual RendererSceneRender *get_scene() = 0;
  68. virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0;
  69. virtual void initialize() = 0;
  70. virtual void begin_frame(double frame_step) = 0;
  71. virtual void prepare_for_blitting_render_targets() = 0;
  72. virtual void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) = 0;
  73. virtual void end_frame(bool p_swap_buffers) = 0;
  74. virtual void finalize() = 0;
  75. virtual uint64_t get_frame_number() const = 0;
  76. virtual double get_frame_delta_time() const = 0;
  77. virtual bool is_low_end() const = 0;
  78. virtual bool is_xr_enabled() const;
  79. RendererCompositor();
  80. virtual ~RendererCompositor() {}
  81. };
  82. #endif // RASTERIZER_H