summaryrefslogtreecommitdiffstats
path: root/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/rendering/renderer_rd/renderer_compositor_rd.cpp')
-rw-r--r--servers/rendering/renderer_rd/renderer_compositor_rd.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
index 84ea6a5da2..ba47508700 100644
--- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
@@ -66,6 +66,16 @@ void RendererCompositorRD::blit_render_targets_to_screen(DisplayServer::WindowID
RD::get_singleton()->draw_list_bind_index_array(draw_list, blit.array);
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, render_target_descriptors[rd_texture], 0);
+ // We need to invert the phone rotation.
+ const int screen_rotation_degrees = -RD::get_singleton()->screen_get_pre_rotation_degrees(p_screen);
+ float screen_rotation = Math::deg_to_rad((float)screen_rotation_degrees);
+
+ blit.push_constant.rotation_cos = Math::cos(screen_rotation);
+ blit.push_constant.rotation_sin = Math::sin(screen_rotation);
+ // Swap width and height when the orientation is not the native one.
+ if (screen_rotation_degrees % 180 != 0) {
+ SWAP(screen_size.width, screen_size.height);
+ }
blit.push_constant.src_rect[0] = p_render_targets[i].src_rect.position.x;
blit.push_constant.src_rect[1] = p_render_targets[i].src_rect.position.y;
blit.push_constant.src_rect[2] = p_render_targets[i].src_rect.size.width;
@@ -228,6 +238,10 @@ void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color
RD::get_singleton()->draw_list_bind_index_array(draw_list, blit.array);
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, uset, 0);
+ const int screen_rotation_degrees = -RD::get_singleton()->screen_get_pre_rotation_degrees(DisplayServer::MAIN_WINDOW_ID);
+ float screen_rotation = Math::deg_to_rad((float)screen_rotation_degrees);
+ blit.push_constant.rotation_cos = Math::cos(screen_rotation);
+ blit.push_constant.rotation_sin = Math::sin(screen_rotation);
blit.push_constant.src_rect[0] = 0.0;
blit.push_constant.src_rect[1] = 0.0;
blit.push_constant.src_rect[2] = 1.0;