Skip to content

Commit 2d9d4ba

Browse files
committed
Undo clang formatting
1 parent 89190b2 commit 2d9d4ba

File tree

2 files changed

+63
-53
lines changed

2 files changed

+63
-53
lines changed

filament/backend/include/backend/platforms/PlatformEGLAndroid.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class ExternalStreamManagerAndroid;
4040
*/
4141
class PlatformEGLAndroid : public PlatformEGL {
4242
public:
43+
4344
PlatformEGLAndroid() noexcept;
4445
~PlatformEGLAndroid() noexcept override;
4546

@@ -77,7 +78,9 @@ class PlatformEGLAndroid : public PlatformEGL {
7778

7879
void terminate() noexcept override;
7980

80-
void beginFrame(int64_t monotonic_clock_ns, int64_t refreshIntervalNs,
81+
void beginFrame(
82+
int64_t monotonic_clock_ns,
83+
int64_t refreshIntervalNs,
8184
uint32_t frameId) noexcept override;
8285

8386
void preCommit() noexcept override;
@@ -111,7 +114,8 @@ class PlatformEGLAndroid : public PlatformEGL {
111114
ExternalTexture* texture) noexcept;
112115

113116
protected:
114-
bool makeCurrent(ContextType type, SwapChain* drawSwapChain,
117+
bool makeCurrent(ContextType type,
118+
SwapChain* drawSwapChain,
115119
SwapChain* readSwapChain) noexcept override;
116120

117121
private:
@@ -133,6 +137,6 @@ class PlatformEGLAndroid : public PlatformEGL {
133137
bool mAssertNativeWindowIsValid = false;
134138
};
135139

136-
}// namespace filament::backend
140+
} // namespace filament::backend
137141

138-
#endif// TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_EGL_ANDROID_H
142+
#endif // TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_EGL_ANDROID_H

filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp

+55-49
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@
2222
#include <private/backend/BackendUtilsAndroid.h>
2323
#include <private/backend/VirtualMachineEnv.h>
2424

25-
#include "ExternalStreamManagerAndroid.h"
2625
#include "opengl/GLUtils.h"
26+
#include "ExternalStreamManagerAndroid.h"
2727

2828
#include <android/api-level.h>
29-
#include <android/hardware_buffer.h>
3029
#include <android/native_window.h>
30+
#include <android/hardware_buffer.h>
3131

3232
#include <utils/android/PerformanceHintManager.h>
3333

34-
#include <utils/Log.h>
34+
#include <utils/compiler.h>
35+
#include <utils/ostream.h>
3536
#include <utils/Panic.h>
37+
#include <utils/Log.h>
3638
#include <utils/compiler.h>
3739
#include <utils/ostream.h>
3840

@@ -57,8 +59,8 @@
5759
// We require filament to be built with an API 19 toolchain, before that, OpenGLES 3.0 didn't exist
5860
// Actually, OpenGL ES 3.0 was added to API 18, but API 19 is the better target and
5961
// the minimum for Jetpack at the time of this comment.
60-
#if __ANDROID_API__ < 21
61-
#error "__ANDROID_API__ must be at least 21"
62+
#if __ANDROID_API__ < 19
63+
#error "__ANDROID_API__ must be at least 19"
6264
#endif
6365

6466
using namespace utils;
@@ -77,44 +79,43 @@ extern PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
7779

7880
UTILS_PRIVATE PFNEGLGETNATIVECLIENTBUFFERANDROIDPROC eglGetNativeClientBufferANDROID = {};
7981
UTILS_PRIVATE PFNEGLPRESENTATIONTIMEANDROIDPROC eglPresentationTimeANDROID = {};
80-
UTILS_PRIVATE PFNEGLGETCOMPOSITORTIMINGSUPPORTEDANDROIDPROC
81-
eglGetCompositorTimingSupportedANDROID = {};
82+
UTILS_PRIVATE PFNEGLGETCOMPOSITORTIMINGSUPPORTEDANDROIDPROC eglGetCompositorTimingSupportedANDROID = {};
8283
UTILS_PRIVATE PFNEGLGETCOMPOSITORTIMINGANDROIDPROC eglGetCompositorTimingANDROID = {};
8384
UTILS_PRIVATE PFNEGLGETNEXTFRAMEIDANDROIDPROC eglGetNextFrameIdANDROID = {};
8485
UTILS_PRIVATE PFNEGLGETFRAMETIMESTAMPSUPPORTEDANDROIDPROC eglGetFrameTimestampSupportedANDROID = {};
8586
UTILS_PRIVATE PFNEGLGETFRAMETIMESTAMPSANDROIDPROC eglGetFrameTimestampsANDROID = {};
86-
}// namespace glext
87+
}
8788
using namespace glext;
8889

8990
// ---------------------------------------------------------------------------------------------
9091

91-
PlatformEGLAndroid::InitializeJvmForPerformanceManagerIfNeeded::
92-
InitializeJvmForPerformanceManagerIfNeeded() {
92+
PlatformEGLAndroid::InitializeJvmForPerformanceManagerIfNeeded::InitializeJvmForPerformanceManagerIfNeeded() {
9393
// PerformanceHintManager() needs the calling thread to be a Java thread; so we need
9494
// to attach this thread to the JVM before we initialize PerformanceHintManager.
9595
// This should be done in PerformanceHintManager(), but libutils doesn't have access to
9696
// VirtualMachineEnv.
9797
if (PerformanceHintManager::isSupported()) {
98-
(void) VirtualMachineEnv::get().getEnvironment();
98+
(void)VirtualMachineEnv::get().getEnvironment();
9999
}
100100
}
101101

102102
// ---------------------------------------------------------------------------------------------
103103

104104
PlatformEGLAndroid::PlatformEGLAndroid() noexcept
105-
: PlatformEGL(),
106-
mExternalStreamManager(ExternalStreamManagerAndroid::create()),
107-
mInitializeJvmForPerformanceManagerIfNeeded(),
108-
mPerformanceHintManager() {
105+
: PlatformEGL(),
106+
mExternalStreamManager(ExternalStreamManagerAndroid::create()),
107+
mInitializeJvmForPerformanceManagerIfNeeded(),
108+
mPerformanceHintManager() {
109109
mOSVersion = android_get_device_api_level();
110110
if (mOSVersion < 0) {
111111
mOSVersion = __ANDROID_API_FUTURE__;
112112
}
113113

114114
mNativeWindowLib = dlopen("libnativewindow.so", RTLD_LOCAL | RTLD_NOW);
115115
if (mNativeWindowLib) {
116-
ANativeWindow_getBuffersDefaultDataSpace = (int32_t (*)(ANativeWindow*)) dlsym(
117-
mNativeWindowLib, "ANativeWindow_getBuffersDefaultDataSpace");
116+
ANativeWindow_getBuffersDefaultDataSpace =
117+
(int32_t(*)(ANativeWindow*))dlsym(mNativeWindowLib,
118+
"ANativeWindow_getBuffersDefaultDataSpace");
118119
}
119120
}
120121

@@ -132,7 +133,8 @@ void PlatformEGLAndroid::terminate() noexcept {
132133
static constexpr const std::string_view kNativeWindowInvalidMsg =
133134
"ANativeWindow is invalid. It probably has been destroyed. EGL surface = ";
134135

135-
bool PlatformEGLAndroid::makeCurrent(ContextType type, SwapChain* drawSwapChain,
136+
bool PlatformEGLAndroid::makeCurrent(ContextType type,
137+
SwapChain* drawSwapChain,
136138
SwapChain* readSwapChain) noexcept {
137139

138140
// fast & safe path
@@ -157,12 +159,12 @@ bool PlatformEGLAndroid::makeCurrent(ContextType type, SwapChain* drawSwapChain,
157159
// is valid query enum value
158160
enum { IS_VALID = 17 };
159161
uint64_t pad[18];
160-
int (*query)(ANativeWindow const*, int, int*);
162+
int (* query)(ANativeWindow const*, int, int*);
161163
} const* pWindow = reinterpret_cast<NativeWindow const*>(dsc->nativeWindow);
162164
int isValid = 0;
163-
if (UTILS_LIKELY(pWindow->query)) {// just in case it's nullptr
165+
if (UTILS_LIKELY(pWindow->query)) { // just in case it's nullptr
164166
int const err = pWindow->query(dsc->nativeWindow, NativeWindow::IS_VALID, &isValid);
165-
if (UTILS_LIKELY(err >= 0)) {// in case the IS_VALID enum is not recognized
167+
if (UTILS_LIKELY(err >= 0)) { // in case the IS_VALID enum is not recognized
166168
// query call succeeded
167169
FILAMENT_CHECK_POSTCONDITION(isValid) << kNativeWindowInvalidMsg << dsc->sur;
168170
}
@@ -171,7 +173,9 @@ bool PlatformEGLAndroid::makeCurrent(ContextType type, SwapChain* drawSwapChain,
171173
return PlatformEGL::makeCurrent(type, drawSwapChain, readSwapChain);
172174
}
173175

174-
void PlatformEGLAndroid::beginFrame(int64_t monotonic_clock_ns, int64_t refreshIntervalNs,
176+
void PlatformEGLAndroid::beginFrame(
177+
int64_t monotonic_clock_ns,
178+
int64_t refreshIntervalNs,
175179
uint32_t frameId) noexcept {
176180
if (mPerformanceHintSession.isValid()) {
177181
if (refreshIntervalNs <= 0) {
@@ -198,8 +202,8 @@ Driver* PlatformEGLAndroid::createDriver(void* sharedContext,
198202

199203
// the refresh rate default value doesn't matter, we change it later
200204
int32_t const tid = gettid();
201-
mPerformanceHintSession =
202-
PerformanceHintManager::Session{ mPerformanceHintManager, &tid, 1, 16'666'667 };
205+
mPerformanceHintSession = PerformanceHintManager::Session{
206+
mPerformanceHintManager, &tid, 1, 16'666'667 };
203207

204208
Driver* driver = PlatformEGL::createDriver(sharedContext, driverConfig);
205209
auto extensions = GLUtils::split(eglQueryString(mEGLDisplay, EGL_EXTENSIONS));
@@ -208,22 +212,20 @@ Driver* PlatformEGLAndroid::createDriver(void* sharedContext,
208212
"eglGetNativeClientBufferANDROID");
209213

210214
if (extensions.has("EGL_ANDROID_presentation_time")) {
211-
eglPresentationTimeANDROID =
212-
(PFNEGLPRESENTATIONTIMEANDROIDPROC) eglGetProcAddress("eglPresentationTimeANDROID");
215+
eglPresentationTimeANDROID = (PFNEGLPRESENTATIONTIMEANDROIDPROC)eglGetProcAddress(
216+
"eglPresentationTimeANDROID");
213217
}
214218

215219
if (extensions.has("EGL_ANDROID_get_frame_timestamps")) {
216-
eglGetCompositorTimingSupportedANDROID =
217-
(PFNEGLGETCOMPOSITORTIMINGSUPPORTEDANDROIDPROC) eglGetProcAddress(
218-
"eglGetCompositorTimingSupportedANDROID");
219-
eglGetCompositorTimingANDROID = (PFNEGLGETCOMPOSITORTIMINGANDROIDPROC) eglGetProcAddress(
220+
eglGetCompositorTimingSupportedANDROID = (PFNEGLGETCOMPOSITORTIMINGSUPPORTEDANDROIDPROC)eglGetProcAddress(
221+
"eglGetCompositorTimingSupportedANDROID");
222+
eglGetCompositorTimingANDROID = (PFNEGLGETCOMPOSITORTIMINGANDROIDPROC)eglGetProcAddress(
220223
"eglGetCompositorTimingANDROID");
221-
eglGetNextFrameIdANDROID =
222-
(PFNEGLGETNEXTFRAMEIDANDROIDPROC) eglGetProcAddress("eglGetNextFrameIdANDROID");
223-
eglGetFrameTimestampSupportedANDROID =
224-
(PFNEGLGETFRAMETIMESTAMPSUPPORTEDANDROIDPROC) eglGetProcAddress(
225-
"eglGetFrameTimestampSupportedANDROID");
226-
eglGetFrameTimestampsANDROID = (PFNEGLGETFRAMETIMESTAMPSANDROIDPROC) eglGetProcAddress(
224+
eglGetNextFrameIdANDROID = (PFNEGLGETNEXTFRAMEIDANDROIDPROC)eglGetProcAddress(
225+
"eglGetNextFrameIdANDROID");
226+
eglGetFrameTimestampSupportedANDROID = (PFNEGLGETFRAMETIMESTAMPSUPPORTEDANDROIDPROC)eglGetProcAddress(
227+
"eglGetFrameTimestampSupportedANDROID");
228+
eglGetFrameTimestampsANDROID = (PFNEGLGETFRAMETIMESTAMPSANDROIDPROC)eglGetProcAddress(
227229
"eglGetFrameTimestampsANDROID");
228230
}
229231

@@ -327,7 +329,9 @@ void PlatformEGLAndroid::setPresentationTime(int64_t presentationTimeInNanosecon
327329
EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW);
328330
if (currentDrawSurface != EGL_NO_SURFACE) {
329331
if (eglPresentationTimeANDROID) {
330-
eglPresentationTimeANDROID(mEGLDisplay, currentDrawSurface,
332+
eglPresentationTimeANDROID(
333+
mEGLDisplay,
334+
currentDrawSurface,
331335
presentationTimeInNanosecond);
332336
}
333337
}
@@ -345,7 +349,9 @@ void PlatformEGLAndroid::attach(Stream* stream, intptr_t tname) noexcept {
345349
mExternalStreamManager.attach(stream, tname);
346350
}
347351

348-
void PlatformEGLAndroid::detach(Stream* stream) noexcept { mExternalStreamManager.detach(stream); }
352+
void PlatformEGLAndroid::detach(Stream* stream) noexcept {
353+
mExternalStreamManager.detach(stream);
354+
}
349355

350356
void PlatformEGLAndroid::updateTexImage(Stream* stream, int64_t* timestamp) noexcept {
351357
mExternalStreamManager.updateTexImage(stream, timestamp);
@@ -355,11 +361,13 @@ math::mat3f PlatformEGLAndroid::getTransformMatrix(Stream* stream) noexcept {
355361
return mExternalStreamManager.getTransformMatrix(stream);
356362
}
357363

358-
int PlatformEGLAndroid::getOSVersion() const noexcept { return mOSVersion; }
364+
int PlatformEGLAndroid::getOSVersion() const noexcept {
365+
return mOSVersion;
366+
}
359367

360368
AcquiredImage PlatformEGLAndroid::transformAcquiredImage(AcquiredImage source) noexcept {
361369
// Convert the AHardwareBuffer to EGLImage.
362-
AHardwareBuffer const* const pHardwareBuffer = (const AHardwareBuffer*) source.image;
370+
AHardwareBuffer const* const pHardwareBuffer = (const AHardwareBuffer*)source.image;
363371

364372
EGLClientBuffer clientBuffer = eglGetNativeClientBufferANDROID(pHardwareBuffer);
365373
if (!clientBuffer) {
@@ -379,8 +387,8 @@ AcquiredImage PlatformEGLAndroid::transformAcquiredImage(AcquiredImage source) n
379387
}
380388
}
381389

382-
EGLImageKHR eglImage = eglCreateImageKHR(mEGLDisplay, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
383-
clientBuffer, attributes.data());
390+
EGLImageKHR eglImage = eglCreateImageKHR(mEGLDisplay,
391+
EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, clientBuffer, attributes.data());
384392
if (eglImage == EGL_NO_IMAGE_KHR) {
385393
slog.e << "eglCreateImageKHR returned no image." << io::endl;
386394
return {};
@@ -389,25 +397,23 @@ AcquiredImage PlatformEGLAndroid::transformAcquiredImage(AcquiredImage source) n
389397
// Destroy the EGLImage before invoking the user's callback.
390398
struct Closure {
391399
Closure(AcquiredImage const& acquiredImage, EGLDisplay display)
392-
: acquiredImage(acquiredImage),
393-
display(display) {}
400+
: acquiredImage(acquiredImage), display(display) {}
394401
AcquiredImage acquiredImage;
395402
EGLDisplay display;
396403
};
397-
Closure* closure = new (std::nothrow) Closure(source, mEGLDisplay);
404+
Closure* closure = new(std::nothrow) Closure(source, mEGLDisplay);
398405
auto patchedCallback = [](void* image, void* userdata) {
399-
Closure* closure = (Closure*) userdata;
406+
Closure* closure = (Closure*)userdata;
400407
if (eglDestroyImageKHR(closure->display, (EGLImageKHR) image) == EGL_FALSE) {
401408
slog.e << "eglDestroyImageKHR failed." << io::endl;
402409
}
403-
closure->acquiredImage.callback(closure->acquiredImage.image,
404-
closure->acquiredImage.userData);
410+
closure->acquiredImage.callback(closure->acquiredImage.image, closure->acquiredImage.userData);
405411
delete closure;
406412
};
407413

408414
return { eglImage, patchedCallback, closure, source.handler };
409415
}
410416

411-
}// namespace filament::backend
417+
} // namespace filament::backend
412418

413419
// ---------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)