feat:xr interface support xr eye render js callback (#14665)

This commit is contained in:
oahc09
2023-03-27 16:07:23 +08:00
committed by GitHub
parent f1c573cea9
commit 8abee5fe1c
4 changed files with 17 additions and 0 deletions
@@ -787,6 +787,7 @@ bool XRInterface::platformLoopStart() {
bool XRInterface::beginRenderFrame() {
#if CC_USE_XR
if (IS_ENABLE_XR_LOG) CC_LOG_INFO("[XR] beginRenderFrame.%d", _committedFrame);
_isEnabledEyeRenderJsCallback = xr::XrEntry::getInstance()->getXRConfig(xr::XRConfigKey::EYE_RENDER_JS_CALLBACK).getBool();
if (gfx::DeviceAgent::getInstance()) {
static uint64_t frameId = 0;
frameId++;
@@ -832,6 +833,11 @@ bool XRInterface::isRenderAllowable() {
bool XRInterface::beginRenderEyeFrame(uint32_t eye) {
#if CC_USE_XR
if (IS_ENABLE_XR_LOG) CC_LOG_INFO("[XR] beginRenderEyeFrame %d", eye);
if (_isEnabledEyeRenderJsCallback) {
se::ValueArray args;
args.emplace_back(se::Value(eye));
EventDispatcher::doDispatchJsEvent("onXREyeRenderBegin", args);
}
if (gfx::DeviceAgent::getInstance()) {
ENQUEUE_MESSAGE_1(gfx::DeviceAgent::getInstance()->getMessageQueue(),
BeginRenderEyeFrame, eye, eye,
@@ -851,6 +857,11 @@ bool XRInterface::beginRenderEyeFrame(uint32_t eye) {
bool XRInterface::endRenderEyeFrame(uint32_t eye) {
#if CC_USE_XR
if (IS_ENABLE_XR_LOG) CC_LOG_INFO("[XR] endRenderEyeFrame %d", eye);
if (_isEnabledEyeRenderJsCallback) {
se::ValueArray args;
args.emplace_back(se::Value(eye));
EventDispatcher::doDispatchJsEvent("onXREyeRenderEnd", args);
}
if (gfx::DeviceAgent::getInstance()) {
ENQUEUE_MESSAGE_1(gfx::DeviceAgent::getInstance()->getMessageQueue(),
EndRenderEyeFrame, eye, eye,