* Use `context` instead of `activity` as possible.
* Remove unused JniNativeGlue.h include.
* Remove unused import.
* Update JniHelper.h/.cpp, JniHelper::sActivity -> JniHelper::sContext.
* Fix log output name in CocosHelper.java
* Rename the second parameter JniHelper::init from `activity` to `context`.
* Update todo in JniHelper::getActivity()
* fix:android activity jni global reference leak
* improve:only release jniObjectActivity,keep classloader
add nullptr check for classloader to avoid new global reference many times
The operation of swapping (presenting) buffers is done in gfx::Device::present. To swap multi-systemwindows, multiple gfx swapchains need be created, and relevant gfx backend will iterate each swapchain and present them. Therefore, `swap buffers` operation doesn't need to be in SystemWindow or SystemWindowManager.
```c++
void GLES3Device::present() {
CC_PROFILE(GLES3DevicePresent);
auto *queue = static_cast<GLES3Queue *>(_queue);
_numDrawCalls = queue->_numDrawCalls;
_numInstances = queue->_numInstances;
_numTriangles = queue->_numTriangles;
bool isGFXDeviceNeedsPresent = _xr ? _xr->isGFXDeviceNeedsPresent(_api) : true;
for (auto *swapchain : _swapchains) { // We iterate each swapchain and do the present thing here.
if (isGFXDeviceNeedsPresent) _gpuContext->present(swapchain);
}
if (_xr) _xr->postGFXDevicePresent(_api);
// Clear queue stats
queue->_numDrawCalls = 0;
queue->_numInstances = 0;
queue->_numTriangles = 0;
}
```
Besides, `SDL_GL_SwapWindow` invocation is doing nothing on Windows & Linux platforms, it will generate an SDL an error that `The specified window isn't an OpenGL window` because GL context is not created by SDL_GL_CreateContext. We create contexts in our gfx code.
https://github.com/libsdl-org/SDL/blob/main/src/video/SDL_video.c#L4192
```c++
#define NOT_AN_OPENGL_WINDOW "The specified window isn't an OpenGL window"
int
SDL_GL_SwapWindowWithResult(SDL_Window * window)
{
CHECK_WINDOW_MAGIC(window, -1);
if (!(window->flags & SDL_WINDOW_OPENGL)) {
return SDL_SetError(NOT_AN_OPENGL_WINDOW);
}
if (SDL_GL_GetCurrentWindow() != window) {
return SDL_SetError("The specified window has not been made current");
}
return _this->GL_SwapWindow(_this, window);
}
void
SDL_GL_SwapWindow(SDL_Window * window)
{
SDL_GL_SwapWindowWithResult(window);
}
```
Also, SDL_GL_SwapWindow could not take any effect if running on gfx Vulkan backend.
```c++
void SDLHelper::swapWindow(SDL_Window *window) {
SDL_GL_SwapWindow(window);
}
```
* Change Android mainloop, add global config and template projects for XR.
* Change gfx/gles device's process flow for XR, working with other PRs, waiting.
* Change gfx/Vulkan device's process flow for XR, working with other PRs, waiting.
* Change render process for XR.
* Develop XR input and events.
* Develop 3D feature of UI widgets and raycast effect for XR.
Co-authored-by: fqamic <fqamic@vip.qq.com>
* Move Any.h/Optional.h/Variant.h to base/std and rename them to lowercase.
* fixed#11195: Rename cc::optional, cc::any, cc::variant to ccstd::optional, ccstd::any, ccstd::variant
* Format code.