Ver código fonte

Move remaining dummy drivers to servers.

Fabio Alessandrelli 4 anos atrás
pai
commit
8cdef21d6c

+ 0 - 3
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);
 

+ 1 - 1
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>

+ 11 - 5
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++;
 }
 

+ 16 - 17
drivers/dummy/display_server_headless.h → 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() {}
 };

+ 0 - 0
drivers/dummy/rasterizer_dummy.h → servers/rendering/rasterizer_dummy.h