Repository: godotengine/godot
File: platform/android/display_server_android.cpp (C++)

Code before:

void DisplayServerAndroid::notify_surface_changed(int p_width, int p_height) {
	if (rect_changed_callback.is_valid()) {
		rect_changed_callback.call(Rect2i(0, 0, p_width, p_height));
	}
}

void DisplayServerAndroid::notify_application_paused() {
#if defined(RD_ENABLED)
	if (rendering_device) {
		rendering_device->update_pipeline_cache();
	}
#endif // defined(RD_ENABLED)
}

DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, int64_t p_parent_window, Error &r_error) {
	rendering_driver = p_rendering_driver;

	keep_screen_on = GLOBAL_GET("display/window/energy_saving/keep_screen_on");

	native_menu = memnew(NativeMenu);

#ifdef VULKAN_ENABLED
	if (rendering_driver == "vulkan") {
		if (rendering_context_global == nullptr) {
			ERR_PRINT(vformat("Can't initialize display server with Vulkan driver because no Vulkan context is available."));
			r_error = ERR_UNAVAILABLE;
			return;
		}

		ANativeWindow *native_window = OS_Android::get_singleton()->get_native_window();
		ERR_FAIL_NULL(native_window);

		RenderingContextDriverVulkanAndroid::WindowPlatformData wpd;
		wpd.window = native_window;

		if (rendering_context_global->window_create(MAIN_WINDOW_ID, &wpd) != OK) {
			ERR_PRINT(vformat("Failed to create %s window.", rendering_driver));
			r_error = ERR_UNAVAILABLE;
			return;
		}

		Size2i display_size = OS_Android::get_singleton()->get_display_size();
		rendering_context_global->window_set_size(MAIN_WINDOW_ID, display_size.width, display_size.height);
		rendering_context_global->window_set_vsync_mode(MAIN_WINDOW_ID, p_vsync_mode);

		rendering_device = memnew(RenderingDevice);
		if (rendering_device->initialize(rendering_context_global, MAIN_WINDOW_ID) != OK) {
			rendering_device = nullptr;
			r_error = ERR_UNAVAILABLE;
			return;

Review comment (suggestion):
```suggestion
			ERR_PRINT("Can't initialize display server with Vulkan driver because no Vulkan context is available.");
```

Code after:

		if (rendering_device) {
			rendering_device->screen_create(MAIN_WINDOW_ID);
		}
	}
#endif
}

void DisplayServerAndroid::notify_surface_changed(int p_width, int p_height) {
	if (rect_changed_callback.is_valid()) {
		rect_changed_callback.call(Rect2i(0, 0, p_width, p_height));
	}
}

void DisplayServerAndroid::notify_application_paused() {
#if defined(RD_ENABLED)
	if (rendering_device) {
		rendering_device->update_pipeline_cache();
	}
#endif // defined(RD_ENABLED)
}

DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, int64_t p_parent_window, Error &r_error) {
	rendering_driver = p_rendering_driver;

	keep_screen_on = GLOBAL_GET("display/window/energy_saving/keep_screen_on");

	native_menu = memnew(NativeMenu);

#ifdef VULKAN_ENABLED
	if (rendering_driver == "vulkan") {
		if (rendering_context_global == nullptr) {
			ERR_PRINT("Can't initialize display server with Vulkan driver because no Vulkan context is available.");
			r_error = ERR_UNAVAILABLE;
			return;
		}

		ANativeWindow *native_window = OS_Android::get_singleton()->get_native_window();
		ERR_FAIL_NULL(native_window);

		RenderingContextDriverVulkanAndroid::WindowPlatformData wpd;
		wpd.window = native_window;

		if (rendering_context_global->window_create(MAIN_WINDOW_ID, &wpd) != OK) {
			ERR_PRINT(vformat("Failed to create %s window.", rendering_driver));
			r_error = ERR_UNAVAILABLE;
			return;
		}

		Size2i display_size = OS_Android::get_singleton()->get_display_size();
		rendering_context_global->window_set_size(MAIN_WINDOW_ID, display_size.width, display_size.height);