mirror of
https://github.com/godotengine/godot.git
synced 2024-11-25 05:33:11 +00:00
aaa0e2fddf
- Adds Swappy for Android for stable frame pacing - Implements pre-transformed Swapchain so that Godot's compositor is in charge of rotating the screen instead of Android's compositor (performance optimization for phones that don't have HW rotator) ============================ The work was performed by collaboration of TheForge and Google. I am merely splitting it up into smaller PRs and cleaning it up. Changes from original PR: - Removed "display/window/frame_pacing/android/target_frame_rate" option to use Engine::get_max_fps instead. - Target framerate can be changed at runtime using Engine::set_max_fps. - Swappy is enabled by default. - Added documentation. - enable_auto_swap setting is replaced with swappy_mode.
97 lines
4.1 KiB
C++
97 lines
4.1 KiB
C++
/**************************************************************************/
|
|
/* java_godot_io_wrapper.h */
|
|
/**************************************************************************/
|
|
/* This file is part of: */
|
|
/* GODOT ENGINE */
|
|
/* https://godotengine.org */
|
|
/**************************************************************************/
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
/* */
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
/* a copy of this software and associated documentation files (the */
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
/* the following conditions: */
|
|
/* */
|
|
/* The above copyright notice and this permission notice shall be */
|
|
/* included in all copies or substantial portions of the Software. */
|
|
/* */
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
/**************************************************************************/
|
|
|
|
#ifndef JAVA_GODOT_IO_WRAPPER_H
|
|
#define JAVA_GODOT_IO_WRAPPER_H
|
|
|
|
#include "string_android.h"
|
|
|
|
#include "core/math/rect2i.h"
|
|
#include "core/variant/typed_array.h"
|
|
|
|
#include <android/log.h>
|
|
#include <jni.h>
|
|
|
|
// Class that makes functions in java/src/org/godotengine/godot/GodotIO.java callable from C++
|
|
class GodotIOJavaWrapper {
|
|
private:
|
|
jobject godot_io_instance;
|
|
jclass cls;
|
|
|
|
jmethodID _open_URI = 0;
|
|
jmethodID _get_cache_dir = 0;
|
|
jmethodID _get_data_dir = 0;
|
|
jmethodID _get_display_cutouts = 0;
|
|
jmethodID _get_display_safe_area = 0;
|
|
jmethodID _get_locale = 0;
|
|
jmethodID _get_model = 0;
|
|
jmethodID _get_screen_DPI = 0;
|
|
jmethodID _get_scaled_density = 0;
|
|
jmethodID _get_screen_refresh_rate = 0;
|
|
jmethodID _get_unique_id = 0;
|
|
jmethodID _show_keyboard = 0;
|
|
jmethodID _hide_keyboard = 0;
|
|
jmethodID _has_hardware_keyboard = 0;
|
|
jmethodID _set_screen_orientation = 0;
|
|
jmethodID _get_screen_orientation = 0;
|
|
jmethodID _get_internal_current_screen_rotation = 0;
|
|
jmethodID _get_system_dir = 0;
|
|
|
|
public:
|
|
GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instance);
|
|
~GodotIOJavaWrapper();
|
|
|
|
jobject get_instance();
|
|
|
|
Error open_uri(const String &p_uri);
|
|
String get_cache_dir();
|
|
String get_user_data_dir();
|
|
String get_locale();
|
|
String get_model();
|
|
int get_screen_dpi();
|
|
float get_scaled_density();
|
|
float get_screen_refresh_rate(float fallback);
|
|
TypedArray<Rect2> get_display_cutouts();
|
|
Rect2i get_display_safe_area();
|
|
String get_unique_id();
|
|
bool has_vk();
|
|
bool has_hardware_keyboard();
|
|
void show_vk(const String &p_existing, int p_type, int p_max_input_length, int p_cursor_start, int p_cursor_end);
|
|
void hide_vk();
|
|
int get_vk_height();
|
|
void set_vk_height(int p_height);
|
|
void set_screen_orientation(int p_orient);
|
|
int get_screen_orientation();
|
|
int get_internal_current_screen_rotation();
|
|
String get_system_dir(int p_dir, bool p_shared_storage);
|
|
};
|
|
|
|
#endif // JAVA_GODOT_IO_WRAPPER_H
|