Remove RenderingServer::map_scaling_option_to_stretch_mode and cleanup boot splash code

Removes RS as a dependency in `project_settings.cpp` (which was a bug,
`core` shouldn't include `servers`). This doesn't have a big impact on
incremental rebuild time by itself.

Also move helper `get_splash_stretched_screen_rect` to RenderingServerTypes.
This commit is contained in:
Rémi Verschelde 2026-02-19 12:06:45 +01:00
parent a3cb56dd38
commit 25bfae8ff9
No known key found for this signature in database
GPG key ID: C3336907360768E1
10 changed files with 78 additions and 78 deletions

View file

@ -44,7 +44,6 @@
#include "core/variant/typed_array.h"
#include "core/variant/variant_parser.h"
#include "core/version.h"
#include "servers/rendering/rendering_server.h"
#ifdef TOOLS_ENABLED
#include "modules/modules_enabled.gen.h" // For mono.
@ -636,7 +635,8 @@ void ProjectSettings::_convert_to_last_version(int p_from_version) {
} else if (p_from_version <= 6) {
// Check if we still have legacy boot splash (removed in 4.6), map it to new project setting, then remove legacy setting.
if (has_setting("application/boot_splash/fullsize")) {
set_setting("application/boot_splash/stretch_mode", RenderingServer::map_scaling_option_to_stretch_mode(get_setting("application/boot_splash/fullsize")));
// See RenderingServerEnums::SplashStretchMode.
set_setting("application/boot_splash/stretch_mode", get_setting("application/boot_splash/fullsize") ? 1 : 0);
set_setting("application/boot_splash/fullsize", Variant());
}
}

View file

@ -37,6 +37,7 @@
#include "core/io/image.h"
#include "core/os/os.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_types.h"
#define _EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242
#define _EXT_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
@ -465,7 +466,7 @@ void RasterizerGLES3::set_boot_image_with_stretch(const Ref<Image> &p_image, con
RID texture = texture_storage->texture_allocate();
texture_storage->texture_2d_initialize(texture, p_image);
Rect2 screenrect = RenderingServer::get_splash_stretched_screen_rect(p_image->get_size(), win_size, p_stretch_mode);
Rect2 screenrect = RenderingServerTypes::get_splash_stretched_screen_rect(p_image->get_size(), win_size, p_stretch_mode);
#ifdef WINDOWS_ENABLED
if (!screen_flipped_y)

View file

@ -77,7 +77,6 @@ public:
RendererSceneRender *get_scene() override { return &scene; }
void set_boot_image_with_stretch(const Ref<Image> &p_image, const Color &p_color, RSE::SplashStretchMode p_stretch_mode, bool p_use_filter = true) override {}
void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) override {}
void initialize() override {}
void begin_frame(double frame_step) override {

View file

@ -30,9 +30,8 @@
#include "renderer_compositor.h"
#include "core/config/project_settings.h"
#ifndef XR_DISABLED
#include "core/config/project_settings.h"
#include "servers/xr/xr_server.h"
#endif // XR_DISABLED
@ -45,11 +44,6 @@ RendererCompositor *RendererCompositor::create() {
return _create_func();
}
void RendererCompositor::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
RSE::SplashStretchMode stretch_mode = RenderingServer::map_scaling_option_to_stretch_mode(p_scale);
set_boot_image_with_stretch(p_image, p_color, stretch_mode, p_use_filter);
}
bool RendererCompositor::is_xr_enabled() const {
return xr_enabled;
}

View file

@ -68,7 +68,6 @@ public:
virtual RendererUtilities *get_utilities() = 0;
virtual void set_boot_image_with_stretch(const Ref<Image> &p_image, const Color &p_color, RSE::SplashStretchMode p_stretch_mode, bool p_use_filter = true) = 0;
virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true);
virtual void initialize() = 0;
virtual void begin_frame(double frame_step) = 0;

View file

@ -32,9 +32,9 @@
#include "core/config/project_settings.h"
#include "core/io/dir_access.h"
#include "servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h"
#include "servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h"
#include "servers/rendering/rendering_server_types.h"
void RendererCompositorRD::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const RenderingServerTypes::BlitToScreen *p_render_targets, int p_amount) {
Error err = RD::get_singleton()->screen_prepare_for_drawing(p_screen);
@ -245,7 +245,7 @@ void RendererCompositorRD::set_boot_image_with_stretch(const Ref<Image> &p_image
Size2 window_size = DisplayServer::get_singleton()->window_get_size();
Rect2 screenrect = RenderingServer::get_splash_stretched_screen_rect(p_image->get_size(), window_size, p_stretch_mode);
Rect2 screenrect = RenderingServerTypes::get_splash_stretched_screen_rect(p_image->get_size(), window_size, p_stretch_mode);
screenrect.position /= window_size;
screenrect.size /= window_size;

View file

@ -1888,63 +1888,6 @@ int RenderingServer::global_shader_uniform_type_get_shader_datatype(RSE::GlobalS
}
}
Rect2 RenderingServer::get_splash_stretched_screen_rect(const Size2 &p_image_size, const Size2 &p_window_size, RSE::SplashStretchMode p_stretch_mode) {
Size2 imgsize = p_image_size;
Rect2 screenrect;
switch (p_stretch_mode) {
case RSE::SPLASH_STRETCH_MODE_DISABLED: {
screenrect.size = imgsize;
screenrect.position = ((p_window_size - screenrect.size) / 2.0).floor();
} break;
case RSE::SPLASH_STRETCH_MODE_KEEP: {
if (p_window_size.width > p_window_size.height) {
// Scale horizontally.
screenrect.size.y = p_window_size.height;
screenrect.size.x = imgsize.width * p_window_size.height / imgsize.height;
screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;
} else {
// Scale vertically.
screenrect.size.x = p_window_size.width;
screenrect.size.y = imgsize.height * p_window_size.width / imgsize.width;
screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;
}
} break;
case RSE::SPLASH_STRETCH_MODE_KEEP_WIDTH: {
// Scale vertically.
screenrect.size.x = p_window_size.width;
screenrect.size.y = imgsize.height * p_window_size.width / imgsize.width;
screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;
} break;
case RSE::SPLASH_STRETCH_MODE_KEEP_HEIGHT: {
// Scale horizontally.
screenrect.size.y = p_window_size.height;
screenrect.size.x = imgsize.width * p_window_size.height / imgsize.height;
screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;
} break;
case RSE::SPLASH_STRETCH_MODE_COVER: {
double window_aspect = (double)p_window_size.width / p_window_size.height;
double img_aspect = imgsize.width / imgsize.height;
if (window_aspect > img_aspect) {
// Scale vertically.
screenrect.size.x = p_window_size.width;
screenrect.size.y = imgsize.height * p_window_size.width / imgsize.width;
screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;
} else {
// Scale horizontally.
screenrect.size.y = p_window_size.height;
screenrect.size.x = imgsize.width * p_window_size.height / imgsize.height;
screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;
}
} break;
case RSE::SPLASH_STRETCH_MODE_IGNORE: {
screenrect.size.x = p_window_size.width;
screenrect.size.y = p_window_size.height;
} break;
}
return screenrect;
}
RenderingDevice *RenderingServer::get_rendering_device() const {
// Return the rendering device we're using globally.
return RenderingDevice::get_singleton();
@ -3662,7 +3605,7 @@ void RenderingServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plan
#ifndef DISABLE_DEPRECATED
void RenderingServer::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
RSE::SplashStretchMode stretch_mode = map_scaling_option_to_stretch_mode(p_scale);
RSE::SplashStretchMode stretch_mode = p_scale ? RSE::SPLASH_STRETCH_MODE_KEEP : RSE::SPLASH_STRETCH_MODE_DISABLED;
set_boot_image_with_stretch(p_image, p_color, stretch_mode, p_use_filter);
}
#endif

View file

@ -1068,19 +1068,18 @@ public:
virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data);
virtual void mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes);
/* MISC */
/* BACKGROUND */
virtual void set_boot_image_with_stretch(const Ref<Image> &p_image, const Color &p_color, RSE::SplashStretchMode p_stretch_mode, bool p_use_filter = true) = 0;
static Rect2 get_splash_stretched_screen_rect(const Size2 &p_image_size, const Size2 &p_window_size, RSE::SplashStretchMode p_stretch_mode); // Helper for splash screen
#ifndef DISABLE_DEPRECATED
void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true); // Superseded, but left to preserve compat.
#endif
_ALWAYS_INLINE_ static RSE::SplashStretchMode map_scaling_option_to_stretch_mode(bool p_scale) {
return p_scale ? RSE::SplashStretchMode::SPLASH_STRETCH_MODE_KEEP : RSE::SplashStretchMode::SPLASH_STRETCH_MODE_DISABLED;
}
virtual Color get_default_clear_color() = 0;
virtual void set_default_clear_color(const Color &p_color) = 0;
/* MISC */
#ifndef DISABLE_DEPRECATED
// Never actually used, should be removed when we can break compatibility.
virtual bool has_feature(RSE::Features p_feature) const = 0;

View file

@ -887,8 +887,10 @@ enum RenderingInfo {
RENDERING_INFO_MAX,
};
/* MISC */
/* BACKGROUND */
// If this is modified, review the conversion code in `project_settings.cpp`
// which is hardcoded to avoid coupling `core` with `servers`.
enum SplashStretchMode {
SPLASH_STRETCH_MODE_DISABLED,
SPLASH_STRETCH_MODE_KEEP,
@ -898,6 +900,8 @@ enum SplashStretchMode {
SPLASH_STRETCH_MODE_IGNORE,
};
/* MISC */
#ifndef DISABLE_DEPRECATED
// Never actually used, should be removed when we can break compatibility.
enum Features {

View file

@ -35,6 +35,7 @@
#include "core/math/vector2.h"
#include "core/string/ustring.h"
#include "core/templates/rid.h"
#include "servers/rendering/rendering_server_enums.h"
#include <cstdint>
@ -72,4 +73,64 @@ struct BlitToScreen {
} lens_distortion;
};
/* BACKGROUND */
// Helper for RSE::SplashStretchMode, put here for convenience.
inline Rect2 get_splash_stretched_screen_rect(const Size2 &p_image_size, const Size2 &p_window_size, RSE::SplashStretchMode p_stretch_mode) {
Size2 imgsize = p_image_size;
Rect2 screenrect;
switch (p_stretch_mode) {
case RSE::SPLASH_STRETCH_MODE_DISABLED: {
screenrect.size = imgsize;
screenrect.position = ((p_window_size - screenrect.size) / 2.0).floor();
} break;
case RSE::SPLASH_STRETCH_MODE_KEEP: {
if (p_window_size.width > p_window_size.height) {
// Scale horizontally.
screenrect.size.y = p_window_size.height;
screenrect.size.x = imgsize.width * p_window_size.height / imgsize.height;
screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;
} else {
// Scale vertically.
screenrect.size.x = p_window_size.width;
screenrect.size.y = imgsize.height * p_window_size.width / imgsize.width;
screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;
}
} break;
case RSE::SPLASH_STRETCH_MODE_KEEP_WIDTH: {
// Scale vertically.
screenrect.size.x = p_window_size.width;
screenrect.size.y = imgsize.height * p_window_size.width / imgsize.width;
screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;
} break;
case RSE::SPLASH_STRETCH_MODE_KEEP_HEIGHT: {
// Scale horizontally.
screenrect.size.y = p_window_size.height;
screenrect.size.x = imgsize.width * p_window_size.height / imgsize.height;
screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;
} break;
case RSE::SPLASH_STRETCH_MODE_COVER: {
double window_aspect = (double)p_window_size.width / p_window_size.height;
double img_aspect = imgsize.width / imgsize.height;
if (window_aspect > img_aspect) {
// Scale vertically.
screenrect.size.x = p_window_size.width;
screenrect.size.y = imgsize.height * p_window_size.width / imgsize.width;
screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;
} else {
// Scale horizontally.
screenrect.size.y = p_window_size.height;
screenrect.size.x = imgsize.width * p_window_size.height / imgsize.height;
screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;
}
} break;
case RSE::SPLASH_STRETCH_MODE_IGNORE: {
screenrect.size.x = p_window_size.width;
screenrect.size.y = p_window_size.height;
} break;
}
return screenrect;
}
} // namespace RenderingServerTypes