From 786a7341a7443390e2c98ff7fe00a995f4d8cf67 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 13 Jun 2019 22:37:19 +0200 Subject: [PATCH] Add an option to disable boot splash filtering Disabling filtering is usually desired in projects using a pixel art style. This closes #19415. --- doc/classes/VisualServer.xml | 4 +++- drivers/dummy/rasterizer_dummy.h | 2 +- drivers/gles2/rasterizer_gles2.cpp | 4 ++-- drivers/gles2/rasterizer_gles2.h | 2 +- drivers/gles3/rasterizer_gles3.cpp | 4 ++-- drivers/gles3/rasterizer_gles3.h | 2 +- main/main.cpp | 3 ++- servers/visual/rasterizer.h | 2 +- servers/visual/visual_server_raster.cpp | 4 ++-- servers/visual/visual_server_raster.h | 2 +- servers/visual/visual_server_wrap_mt.h | 2 +- servers/visual_server.cpp | 2 +- servers/visual_server.h | 2 +- 13 files changed, 19 insertions(+), 16 deletions(-) diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml index 3997798ccac..cb890cbc939 100644 --- a/doc/classes/VisualServer.xml +++ b/doc/classes/VisualServer.xml @@ -3157,8 +3157,10 @@ + + - Sets a boot image. The color defines the background color and if scale is [code]true[/code] the image will be scaled to fit the screen size. + Sets a boot image. The color defines the background color. If [code]scale[/code] is [code]true[/code], the image will be scaled to fit the screen size. If [code]use_filter[/code] is [code]true[/code], the image will be scaled with linear interpolation. If [code]use_filter[/code] is [code]false[/code], the image will be scaled with nearest-neighbor interpolation. diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 253936ca346..db6a63a5e12 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -780,7 +780,7 @@ public: RasterizerCanvas *get_canvas() { return &canvas; } RasterizerScene *get_scene() { return &scene; } - void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale) {} + void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) {} void initialize() {} void begin_frame(double frame_step) {} diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index f49f52e47b3..cbd0e4a5d5c 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -338,7 +338,7 @@ void RasterizerGLES2::clear_render_target(const Color &p_color) { storage->frame.clear_request_color = p_color; } -void RasterizerGLES2::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale) { +void RasterizerGLES2::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { if (p_image.is_null() || p_image->empty()) return; @@ -360,7 +360,7 @@ void RasterizerGLES2::set_boot_image(const Ref &p_image, const Color &p_c canvas->canvas_begin(); RID texture = storage->texture_create(); - storage->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER); + storage->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_use_filter ? VS::TEXTURE_FLAG_FILTER : 0); storage->texture_set_data(texture, p_image); Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height()); diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index eeed86e2631..4d0d961ae4f 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -51,7 +51,7 @@ public: virtual RasterizerCanvas *get_canvas(); virtual RasterizerScene *get_scene(); - virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale); + virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true); virtual void initialize(); virtual void begin_frame(double frame_step); diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index bdffb1ecdc3..ea15a278d68 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -273,7 +273,7 @@ void RasterizerGLES3::clear_render_target(const Color &p_color) { storage->frame.clear_request_color = p_color; } -void RasterizerGLES3::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale) { +void RasterizerGLES3::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { if (p_image.is_null() || p_image->empty()) return; @@ -296,7 +296,7 @@ void RasterizerGLES3::set_boot_image(const Ref &p_image, const Color &p_c canvas->canvas_begin(); RID texture = storage->texture_create(); - storage->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER); + storage->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_use_filter ? VS::TEXTURE_FLAG_FILTER : 0); storage->texture_set_data(texture, p_image); Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height()); diff --git a/drivers/gles3/rasterizer_gles3.h b/drivers/gles3/rasterizer_gles3.h index ad0d004c9de..8fa208a1aa1 100644 --- a/drivers/gles3/rasterizer_gles3.h +++ b/drivers/gles3/rasterizer_gles3.h @@ -51,7 +51,7 @@ public: virtual RasterizerCanvas *get_canvas(); virtual RasterizerScene *get_scene(); - virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale); + virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true); virtual void initialize(); virtual void begin_frame(double frame_step); diff --git a/main/main.cpp b/main/main.cpp index 3f01a17ea7c..304bda0e62e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1153,6 +1153,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { if (show_logo) { //boot logo! String boot_logo_path = GLOBAL_DEF("application/boot_splash/image", String()); bool boot_logo_scale = GLOBAL_DEF("application/boot_splash/fullsize", true); + bool boot_logo_filter = GLOBAL_DEF("application/boot_splash/use_filter", true); ProjectSettings::get_singleton()->set_custom_property_info("application/boot_splash/image", PropertyInfo(Variant::STRING, "application/boot_splash/image", PROPERTY_HINT_FILE, "*.png")); Ref boot_logo; @@ -1169,7 +1170,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color); if (boot_logo.is_valid()) { OS::get_singleton()->_msec_splash = OS::get_singleton()->get_ticks_msec(); - VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale); + VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale, boot_logo_filter); } else { #ifndef NO_DEFAULT_BOOT_LOGO diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 31888261ecb..77ab1b5548f 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -1103,7 +1103,7 @@ public: virtual RasterizerCanvas *get_canvas() = 0; virtual RasterizerScene *get_scene() = 0; - virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale) = 0; + virtual void set_boot_image(const Ref &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/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 310aa161303..d45bda72b77 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -153,10 +153,10 @@ int VisualServerRaster::get_render_info(RenderInfo p_info) { /* TESTING */ -void VisualServerRaster::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale) { +void VisualServerRaster::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { redraw_request(); - VSG::rasterizer->set_boot_image(p_image, p_color, p_scale); + VSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter); } void VisualServerRaster::set_default_clear_color(const Color &p_color) { VSG::viewport->set_default_clear_color(p_color); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 921d55556d6..81010c32d32 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -685,7 +685,7 @@ public: /* TESTING */ - virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale); + virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true); virtual void set_default_clear_color(const Color &p_color); virtual bool has_feature(Features p_feature) const; diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index cd24deb60cc..d6da914c37a 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -602,7 +602,7 @@ public: return visual_server->get_render_info(p_info); } - FUNC3(set_boot_image, const Ref &, const Color &, bool) + FUNC4(set_boot_image, const Ref &, const Color &, bool, bool) FUNC1(set_default_clear_color, const Color &) FUNC0R(RID, get_test_cube) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 0fe00ad61a0..27288768eb1 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -2047,7 +2047,7 @@ void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_test_texture"), &VisualServer::get_test_texture); ClassDB::bind_method(D_METHOD("get_white_texture"), &VisualServer::get_white_texture); - ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale"), &VisualServer::set_boot_image); + ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &VisualServer::set_boot_image, DEFVAL(true)); ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &VisualServer::set_default_clear_color); ClassDB::bind_method(D_METHOD("has_feature", "feature"), &VisualServer::has_feature); diff --git a/servers/visual_server.h b/servers/visual_server.h index 01be996bfc1..8be8c1c1f13 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -1029,7 +1029,7 @@ public: virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data); virtual void mesh_add_surface_from_planes(RID p_mesh, const PoolVector &p_planes); - virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale) = 0; + virtual void set_boot_image(const Ref &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 {