summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/rasterizer_dummy.h2
-rw-r--r--servers/rendering/renderer_compositor.h2
-rw-r--r--servers/rendering/renderer_rd/renderer_compositor_rd.cpp60
-rw-r--r--servers/rendering/renderer_rd/renderer_compositor_rd.h2
-rw-r--r--servers/rendering/rendering_server_default.cpp4
-rw-r--r--servers/rendering/rendering_server_default.h2
-rw-r--r--servers/rendering_server.cpp9
-rw-r--r--servers/rendering_server.h12
8 files changed, 21 insertions, 72 deletions
diff --git a/servers/rendering/rasterizer_dummy.h b/servers/rendering/rasterizer_dummy.h
index 5b12b757a3..83da8388e4 100644
--- a/servers/rendering/rasterizer_dummy.h
+++ b/servers/rendering/rasterizer_dummy.h
@@ -763,7 +763,7 @@ public:
RendererCanvasRender *get_canvas() override { return &canvas; }
RendererSceneRender *get_scene() override { return &scene; }
- void set_boot_image(const Ref<Image> &p_image, const Color &p_color, RenderingServer::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 {
diff --git a/servers/rendering/renderer_compositor.h b/servers/rendering/renderer_compositor.h
index 96a3c8af9f..f245af9a4a 100644
--- a/servers/rendering/renderer_compositor.h
+++ b/servers/rendering/renderer_compositor.h
@@ -76,7 +76,7 @@ public:
virtual RendererCanvasRender *get_canvas() = 0;
virtual RendererSceneRender *get_scene() = 0;
- virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, RenderingServer::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) = 0;
virtual void initialize() = 0;
virtual void begin_frame(double frame_step) = 0;
diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
index 009a39749c..2f8ef696cd 100644
--- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
@@ -159,7 +159,7 @@ void RendererCompositorRD::finalize() {
RD::get_singleton()->free(blit.sampler);
}
-void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color &p_color, RenderingServer::SplashStretchMode p_stretch_mode, bool p_use_filter) {
+void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
RD::get_singleton()->prepare_screen_for_drawing();
RID texture = storage->texture_allocate();
@@ -182,56 +182,22 @@ void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color
Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height());
Rect2 screenrect;
- switch (p_stretch_mode) {
- case RenderingServer::SPLASH_STRETCH_MODE_DISABLED: {
- screenrect = imgrect;
- screenrect.position += ((window_size - screenrect.size) / 2.0).floor();
- } break;
- case RenderingServer::SPLASH_STRETCH_MODE_KEEP: {
- if (window_size.width > window_size.height) {
- // Scale horizontally.
- screenrect.size.y = window_size.height;
- screenrect.size.x = imgrect.size.x * window_size.height / imgrect.size.y;
- screenrect.position.x = (window_size.width - screenrect.size.x) / 2;
- } else {
- // Scale vertically.
- screenrect.size.x = window_size.width;
- screenrect.size.y = imgrect.size.y * window_size.width / imgrect.size.x;
- screenrect.position.y = (window_size.height - screenrect.size.y) / 2;
- }
- } break;
- case RenderingServer::SPLASH_STRETCH_MODE_KEEP_WIDTH: {
- // Scale vertically.
- screenrect.size.x = window_size.width;
- screenrect.size.y = imgrect.size.y * window_size.width / imgrect.size.x;
- screenrect.position.y = (window_size.height - screenrect.size.y) / 2;
- } break;
- case RenderingServer::SPLASH_STRETCH_MODE_KEEP_HEIGHT: {
- // Scale horizontally.
+ if (p_scale) {
+ if (window_size.width > window_size.height) {
+ //scale horizontally
screenrect.size.y = window_size.height;
screenrect.size.x = imgrect.size.x * window_size.height / imgrect.size.y;
screenrect.position.x = (window_size.width - screenrect.size.x) / 2;
- } break;
- case RenderingServer::SPLASH_STRETCH_MODE_COVER: {
- double window_aspect = (double)window_size.width / window_size.height;
- double img_aspect = imgrect.size.x / imgrect.size.y;
-
- if (window_aspect > img_aspect) {
- // Scale vertically.
- screenrect.size.x = window_size.width;
- screenrect.size.y = imgrect.size.y * window_size.width / imgrect.size.x;
- screenrect.position.y = (window_size.height - screenrect.size.y) / 2;
- } else {
- // Scale horizontally.
- screenrect.size.y = window_size.height;
- screenrect.size.x = imgrect.size.x * window_size.height / imgrect.size.y;
- screenrect.position.x = (window_size.width - screenrect.size.x) / 2;
- }
- } break;
- case RenderingServer::SPLASH_STRETCH_MODE_EXPAND: {
+
+ } else {
+ //scale vertically
screenrect.size.x = window_size.width;
- screenrect.size.y = window_size.height;
- } break;
+ screenrect.size.y = imgrect.size.y * window_size.width / imgrect.size.x;
+ screenrect.position.y = (window_size.height - screenrect.size.y) / 2;
+ }
+ } else {
+ screenrect = imgrect;
+ screenrect.position += ((window_size - screenrect.size) / 2.0).floor();
}
screenrect.position /= window_size;
diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h
index 6cfd6fa11b..9a992d5819 100644
--- a/servers/rendering/renderer_rd/renderer_compositor_rd.h
+++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h
@@ -90,7 +90,7 @@ public:
RendererCanvasRender *get_canvas() { return canvas; }
RendererSceneRender *get_scene() { return scene; }
- void set_boot_image(const Ref<Image> &p_image, const Color &p_color, RenderingServer::SplashStretchMode p_stretch_mode, bool p_use_filter);
+ void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter);
void initialize();
void begin_frame(double frame_step);
diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp
index 734206c70b..d7e9d210db 100644
--- a/servers/rendering/rendering_server_default.cpp
+++ b/servers/rendering/rendering_server_default.cpp
@@ -273,9 +273,9 @@ Vector<RenderingServer::FrameProfileArea> RenderingServerDefault::get_frame_prof
/* TESTING */
-void RenderingServerDefault::set_boot_image(const Ref<Image> &p_image, const Color &p_color, RenderingServer::SplashStretchMode p_stretch_mode, bool p_use_filter) {
+void RenderingServerDefault::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
redraw_request();
- RSG::rasterizer->set_boot_image(p_image, p_color, p_stretch_mode, p_use_filter);
+ RSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter);
}
void RenderingServerDefault::set_default_clear_color(const Color &p_color) {
diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h
index dabea9175e..ee684c69ed 100644
--- a/servers/rendering/rendering_server_default.h
+++ b/servers/rendering/rendering_server_default.h
@@ -907,7 +907,7 @@ public:
virtual double get_frame_setup_time_cpu() const override;
- virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, RenderingServer::SplashStretchMode p_stretch_mode, bool p_use_filter = true) override;
+ virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) override;
virtual void set_default_clear_color(const Color &p_color) override;
virtual bool has_feature(Features p_feature) const override;
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 786cd8ad92..863aae6e4c 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -2730,7 +2730,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_test_texture"), &RenderingServer::get_test_texture);
ClassDB::bind_method(D_METHOD("get_white_texture"), &RenderingServer::get_white_texture);
- ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "stretch_mode", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true));
ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &RenderingServer::set_default_clear_color);
ClassDB::bind_method(D_METHOD("has_feature", "feature"), &RenderingServer::has_feature);
@@ -2751,13 +2751,6 @@ void RenderingServer::_bind_methods() {
BIND_ENUM_CONSTANT(RENDERING_INFO_BUFFER_MEM_USED);
BIND_ENUM_CONSTANT(RENDERING_INFO_VIDEO_MEM_USED);
- BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_DISABLED);
- BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_KEEP);
- BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_KEEP_WIDTH);
- BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_KEEP_HEIGHT);
- BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_COVER);
- BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_EXPAND);
-
BIND_ENUM_CONSTANT(FEATURE_SHADERS);
BIND_ENUM_CONSTANT(FEATURE_MULTITHREADED);
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index 21728af8c4..945fd052c6 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -1510,16 +1510,7 @@ 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);
- enum SplashStretchMode {
- SPLASH_STRETCH_MODE_DISABLED,
- SPLASH_STRETCH_MODE_KEEP,
- SPLASH_STRETCH_MODE_KEEP_WIDTH,
- SPLASH_STRETCH_MODE_KEEP_HEIGHT,
- SPLASH_STRETCH_MODE_COVER,
- SPLASH_STRETCH_MODE_EXPAND,
- };
-
- virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, RenderingServer::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) = 0;
virtual void set_default_clear_color(const Color &p_color) = 0;
enum Features {
@@ -1633,7 +1624,6 @@ VARIANT_ENUM_CAST(RenderingServer::CanvasLightShadowFilter);
VARIANT_ENUM_CAST(RenderingServer::CanvasOccluderPolygonCullMode);
VARIANT_ENUM_CAST(RenderingServer::GlobalVariableType);
VARIANT_ENUM_CAST(RenderingServer::RenderingInfo);
-VARIANT_ENUM_CAST(RenderingServer::SplashStretchMode);
VARIANT_ENUM_CAST(RenderingServer::Features);
VARIANT_ENUM_CAST(RenderingServer::CanvasTextureChannel);
VARIANT_ENUM_CAST(RenderingServer::BakeChannels);