Monado OpenXR Runtime
org.freedesktop.monado.auxiliary.impl.hpp
Go to the documentation of this file.
1// Copyright 2020-2021, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Inline implementations for partially-generated wrapper for the
6 * `org.freedesktop.monado.auxiliary` Java package - do not include on its own!
7 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
8 * @ingroup aux_android
9 */
10
11#pragma once
12
13#include "wrap/android.app.h"
14#include "wrap/android.content.h"
15#include "wrap/android.view.h"
16#include <vector>
17
18
19namespace wrap {
20namespace org::freedesktop::monado::auxiliary {
21 inline MonadoView
22 MonadoView::attachToWindow(android::content::Context const &displayContext,
23 void *nativePointer,
24 wrap::android::view::WindowManager_LayoutParams const &lp)
25 {
26 return MonadoView(Meta::data().clazz().call<jni::Object>(
27 Meta::data().attachToWindow, displayContext.object(),
28 static_cast<long long>(reinterpret_cast<uintptr_t>(nativePointer)), lp.object()));
29 }
30
31 inline void
33 {
34 Meta::data().clazz().call<void>(Meta::data().removeFromWindow, view.object());
35 }
36
37 inline jni::Object
38 MonadoView::getDisplayMetrics(android::content::Context const &context)
39 {
40 return Meta::data().clazz().call<jni::Object>(Meta::data().getDisplayMetrics, context.object());
41 }
42
43 inline float
44 MonadoView::getDisplayRefreshRate(android::content::Context const &context)
45 {
46 return Meta::data().clazz().call<float>(Meta::data().getDisplayRefreshRate, context.object());
47 }
48
49 inline int32_t
50 MonadoView::getDisplayModeIdWidth(const android::content::Context &displayContext,
51 int32_t displayId,
52 int32_t displayModeId)
53 {
54 return Meta::data().clazz().call<int32_t>(Meta::data().getDisplayModeIdWidth, displayContext.object(),
55 displayId, displayModeId);
56 }
57
58 inline int32_t
59 MonadoView::getDisplayModeIdHeight(const android::content::Context &displayContext,
60 int32_t displayId,
61 int32_t displayModeId)
62 {
63 return Meta::data().clazz().call<int32_t>(Meta::data().getDisplayModeIdHeight, displayContext.object(),
64 displayId, displayModeId);
65 }
66
67 inline std::vector<float>
68 MonadoView::getSupportedRefreshRates(android::content::Context const &context)
69 {
70 jni::Object refreshRateArray =
71 Meta::data().clazz().call<jni::Object>(Meta::data().getSupportedRefreshRates, context.object());
72 jfloat *refreshRates =
73 (jfloat *)jni::env()->GetFloatArrayElements((jfloatArray)refreshRateArray.getHandle(), 0);
74 jsize length = jni::env()->GetArrayLength((jfloatArray)refreshRateArray.getHandle());
75 std::vector<float> refreshRateVector;
76 for (int i = 0; i < length; i++) {
77 refreshRateVector.push_back(refreshRates[i]);
78 }
79 return refreshRateVector;
80 }
81
82 inline void *
84 {
85 assert(!isNull());
86 return reinterpret_cast<void *>(
87 static_cast<intptr_t>(object().call<long long>(Meta::data().getNativePointer)));
88 }
89
90 inline void
92 {
93 assert(!isNull());
94 return object().call<void>(Meta::data().markAsDiscardedByNative);
95 }
96
97 inline android::view::SurfaceHolder
99 {
100 assert(!isNull());
101 return android::view::SurfaceHolder(
102 object().call<jni::Object>(Meta::data().waitGetSurfaceHolder, wait_ms));
103 }
104
107 {
108 return ActivityLifecycleListener(Meta::data().clazz().newInstance(
109 Meta::data().init, static_cast<long long>(reinterpret_cast<uintptr_t>(nativePointer))));
110 }
111
112 inline void
113 ActivityLifecycleListener::registerCallback(android::app::Activity const &activity)
114 {
115 object().call<void>(Meta::data().registerCallback, activity.object());
116 }
117
118 inline void
119 ActivityLifecycleListener::unregisterCallback(android::app::Activity const &activity)
120 {
121 object().call<void>(Meta::data().unregisterCallback, activity.object());
122 }
123} // namespace org::freedesktop::monado::auxiliary
124} // namespace wrap
Definition: org.freedesktop.monado.auxiliary.hpp:230
void registerCallback(android::app::Activity const &activity)
Wrapper for the registerCallback method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:113
static ActivityLifecycleListener construct(void *nativePointer)
Wrapper for a constructor.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:106
void unregisterCallback(android::app::Activity const &activity)
Wrapper for the unregisterCallback method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:119
Wrapper for org.freedesktop.monado.auxiliary.MonadoView objects.
Definition: org.freedesktop.monado.auxiliary.hpp:42
static void removeFromWindow(MonadoView const &view)
Wrapper for the removeFromWindow static method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:32
void markAsDiscardedByNative()
Wrapper for the markAsDiscardedByNative method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:91
static float getDisplayRefreshRate(android::content::Context const &context)
Wrapper for the getDisplayRefreshRate static method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:44
static int32_t getDisplayModeIdHeight(android::content::Context const &context, int32_t displayId, int32_t displayModeId)
Wrapper for the getDisplayModeIdHeight static method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:59
static int32_t getDisplayModeIdWidth(android::content::Context const &context, int32_t displayId, int32_t displayModeId)
Wrapper for the getDisplayModeIdWidth static method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:50
android::view::SurfaceHolder waitGetSurfaceHolder(int32_t wait_ms)
Wrapper for the waitGetSurfaceHolder method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:98
static MonadoView attachToWindow(android::content::Context const &displayContext, void *nativePointer, android::view::WindowManager_LayoutParams const &lp)
Wrapper for the attachToWindow static method.
static std::vector< float > getSupportedRefreshRates(android::content::Context const &context)
Wrapper for the getSupportedRefreshRates static method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:68
static jni::Object getDisplayMetrics(android::content::Context const &context)
Wrapper for the getDisplayMetrics static method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:38
void * getNativePointer()
Wrapper for the getNativePointer method.
Definition: org.freedesktop.monado.auxiliary.impl.hpp:83
static Meta & data(jni::jclass clazz=nullptr)
Singleton accessor.
Definition: org.freedesktop.monado.auxiliary.hpp:304
static Meta & data(jni::jclass clazz=nullptr)
Singleton accessor.
Definition: org.freedesktop.monado.auxiliary.hpp:218