summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/register_driver_types.cpp3
-rw-r--r--platform/javascript/display_server_javascript.cpp2
-rw-r--r--servers/display_server.cpp16
-rw-r--r--servers/display_server_headless.h (renamed from drivers/dummy/display_server_headless.h)33
-rw-r--r--servers/rendering/rasterizer_dummy.h (renamed from drivers/dummy/rasterizer_dummy.h)0
5 files changed, 28 insertions, 26 deletions
diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp
index b7342694c8..18262c74c4 100644
--- a/drivers/register_driver_types.cpp
+++ b/drivers/register_driver_types.cpp
@@ -30,7 +30,6 @@
#include "register_driver_types.h"
-#include "drivers/dummy/display_server_headless.h"
#include "drivers/png/image_loader_png.h"
#include "drivers/png/resource_saver_png.h"
@@ -38,8 +37,6 @@ static ImageLoaderPNG *image_loader_png;
static Ref<ResourceSaverPNG> resource_saver_png;
void register_core_driver_types() {
- DisplayServerHeadless::register_headless_driver();
-
image_loader_png = memnew(ImageLoaderPNG);
ImageLoader::add_image_format_loader(image_loader_png);
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index dae0b5f7e7..cce1f8dca7 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -30,8 +30,8 @@
#include "platform/javascript/display_server_javascript.h"
-#include "drivers/dummy/rasterizer_dummy.h"
#include "platform/javascript/os_javascript.h"
+#include "servers/rendering/rasterizer_dummy.h"
#include <emscripten.h>
#include <png.h>
diff --git a/servers/display_server.cpp b/servers/display_server.cpp
index 7bd1075006..c7d444c993 100644
--- a/servers/display_server.cpp
+++ b/servers/display_server.cpp
@@ -32,14 +32,18 @@
#include "core/input/input.h"
#include "scene/resources/texture.h"
+#include "servers/display_server_headless.h"
DisplayServer *DisplayServer::singleton = nullptr;
DisplayServer::SwitchVSyncCallbackInThread DisplayServer::switch_vsync_function = nullptr;
bool DisplayServer::hidpi_allowed = false;
-DisplayServer::DisplayServerCreate DisplayServer::server_create_functions[DisplayServer::MAX_SERVERS];
-int DisplayServer::server_create_count = 0;
+DisplayServer::DisplayServerCreate DisplayServer::server_create_functions[DisplayServer::MAX_SERVERS] = {
+ { "headless", &DisplayServerHeadless::create_func, &DisplayServerHeadless::get_rendering_drivers_func }
+};
+
+int DisplayServer::server_create_count = 1;
void DisplayServer::global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag) {
WARN_PRINT("Global menus not supported by this display server.");
@@ -560,9 +564,11 @@ void DisplayServer::_bind_methods() {
void DisplayServer::register_create_function(const char *p_name, CreateFunction p_function, GetRenderingDriversFunction p_get_drivers) {
ERR_FAIL_COND(server_create_count == MAX_SERVERS);
- server_create_functions[server_create_count].name = p_name;
- server_create_functions[server_create_count].create_function = p_function;
- server_create_functions[server_create_count].get_rendering_drivers_function = p_get_drivers;
+ // Headless display server is always last
+ server_create_functions[server_create_count] = server_create_functions[server_create_count - 1];
+ server_create_functions[server_create_count - 1].name = p_name;
+ server_create_functions[server_create_count - 1].create_function = p_function;
+ server_create_functions[server_create_count - 1].get_rendering_drivers_function = p_get_drivers;
server_create_count++;
}
diff --git a/drivers/dummy/display_server_headless.h b/servers/display_server_headless.h
index ee19abda29..8b386c8d9c 100644
--- a/drivers/dummy/display_server_headless.h
+++ b/servers/display_server_headless.h
@@ -33,9 +33,24 @@
#include "servers/display_server.h"
-#include "drivers/dummy/rasterizer_dummy.h"
+#include "servers/rendering/rasterizer_dummy.h"
class DisplayServerHeadless : public DisplayServer {
+private:
+ friend class DisplayServer;
+
+ static Vector<String> get_rendering_drivers_func() {
+ Vector<String> drivers;
+ drivers.push_back("dummy");
+ return drivers;
+ }
+
+ static DisplayServer *create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
+ r_error = OK;
+ RasterizerDummy::make_current();
+ return memnew(DisplayServerHeadless());
+ }
+
public:
bool has_feature(Feature p_feature) const override { return false; }
String get_name() const override { return "headless"; }
@@ -105,22 +120,6 @@ public:
void set_icon(const Ref<Image> &p_icon) override {}
- static void register_headless_driver() {
- register_create_function("headless", create_func, get_rendering_drivers_func);
- }
-
- static Vector<String> get_rendering_drivers_func() {
- Vector<String> drivers;
- drivers.push_back("dummy");
- return drivers;
- }
-
- static DisplayServer *create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
- r_error = OK;
- RasterizerDummy::make_current();
- return memnew(DisplayServerHeadless());
- }
-
DisplayServerHeadless() {}
~DisplayServerHeadless() {}
};
diff --git a/drivers/dummy/rasterizer_dummy.h b/servers/rendering/rasterizer_dummy.h
index bfc7e7684f..bfc7e7684f 100644
--- a/drivers/dummy/rasterizer_dummy.h
+++ b/servers/rendering/rasterizer_dummy.h