| 1 |
/**************************************************************************/ |
| 2 |
/* display_server_visionos.mm */ |
| 3 |
/**************************************************************************/ |
| 4 |
/* This file is part of: */ |
| 5 |
/* GODOT ENGINE */ |
| 6 |
/* https://godotengine.org */ |
| 7 |
/**************************************************************************/ |
| 8 |
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 |
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 |
/* */ |
| 11 |
/* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 |
/* a copy of this software and associated documentation files (the */ |
| 13 |
/* "Software"), to deal in the Software without restriction, including */ |
| 14 |
/* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 |
/* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 |
/* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 |
/* the following conditions: */ |
| 18 |
/* */ |
| 19 |
/* The above copyright notice and this permission notice shall be */ |
| 20 |
/* included in all copies or substantial portions of the Software. */ |
| 21 |
/* */ |
| 22 |
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 |
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 |
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 |
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 |
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 |
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 |
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 |
/**************************************************************************/ |
| 30 |
|
| 31 |
#import "display_server_visionos.h" |
| 32 |
|
| 33 |
DisplayServerVisionOS *DisplayServerVisionOS::get_singleton() { |
| 34 |
return (DisplayServerVisionOS *)DisplayServerAppleEmbedded::get_singleton(); |
| 35 |
} |
| 36 |
|
| 37 |
DisplayServerVisionOS::DisplayServerVisionOS(const String &p_rendering_driver, 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) : |
| 38 |
DisplayServerAppleEmbedded(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_position, p_resolution, p_screen, p_context, p_parent_window, r_error) { |
| 39 |
} |
| 40 |
|
| 41 |
DisplayServerVisionOS::~DisplayServerVisionOS() { |
| 42 |
} |
| 43 |
|
| 44 |
DisplayServer *DisplayServerVisionOS::create_func(const String &p_rendering_driver, 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) { |
| 45 |
return memnew(DisplayServerVisionOS(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_position, p_resolution, p_screen, p_context, p_parent_window, r_error)); |
| 46 |
} |
| 47 |
|
| 48 |
void DisplayServerVisionOS::register_visionos_driver() { |
| 49 |
register_create_function("visionOS", create_func, get_rendering_drivers_func); |
| 50 |
} |
| 51 |
|
| 52 |
String DisplayServerVisionOS::get_name() const { |
| 53 |
return "visionOS"; |
| 54 |
} |
| 55 |
|
| 56 |
int DisplayServerVisionOS::screen_get_dpi(int p_screen) const { |
| 57 |
p_screen = _get_screen_index(p_screen); |
| 58 |
int screen_count = get_screen_count(); |
| 59 |
ERR_FAIL_INDEX_V(p_screen, screen_count, 72); |
| 60 |
|
| 61 |
// TODO(Apple): Compute this properly from SwiftUI Metric APIs |
| 62 |
return 72; |
| 63 |
} |
| 64 |
|
| 65 |
float DisplayServerVisionOS::screen_get_refresh_rate(int p_screen) const { |
| 66 |
p_screen = _get_screen_index(p_screen); |
| 67 |
int screen_count = get_screen_count(); |
| 68 |
ERR_FAIL_INDEX_V(p_screen, screen_count, SCREEN_REFRESH_RATE_FALLBACK); |
| 69 |
|
| 70 |
return 90; |
| 71 |
} |
| 72 |
|
| 73 |
float DisplayServerVisionOS::screen_get_scale(int p_screen) const { |
| 74 |
p_screen = _get_screen_index(p_screen); |
| 75 |
int screen_count = get_screen_count(); |
| 76 |
ERR_FAIL_INDEX_V(p_screen, screen_count, 1.0f); |
| 77 |
|
| 78 |
return 1; |
| 79 |
} |