/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include "ArSessionArKit.h" #include "Data/Concurent/MutexProtectedObject.hpp" #include "Scene/Texture.hpp" #include "Vulkan/Metal/MetalTextureCache.h" #include #import #import @class ArKitDelegate; namespace OpenVulkano::AR::ArKit { class ArSessionArKitInternal final : public ArSessionArKit, public std::enable_shared_from_this { public: ArSessionArKitInternal(const ArSessionConfig& config); ~ArSessionArKitInternal() override; void Configure(const ArSessionConfig& config) override; void Restart() override; void Start() override; void Stop() override; void Pause() override; [[nodiscard]] std::shared_ptr GetFrame() override; void RequestHighResolutionFrame() override; size_t GetFrameId() { return m_frameId++; } // AR Kit delegate events void OnArNewFrame(ARSession* session, ARFrame* frame); void OnArSessionInterruptedChanged(ARSession* session, bool interrupted); void OnArSessionFailed(ARSession* session, NSError* error); void OnArCameraTrackingChange(ARSession* session, ARCamera* camera); void OnArAnchorsUpdate(NSArray<__kindof ARAnchor*>* anchors); bool ArShouldAttemptRelocalization(); void SetRenderer(IRenderer* renderer) override; void LockExposureTime(bool locked) override; void LockWhiteBalance(bool locked) override; void SetFlashlightOn(bool on) override; protected: Scene::Texture * MakeTexture(ArFrame *frame) override; void ReturnTexture(Scene::Texture *texture) override; private: ArKitDelegate* m_arKitDelegate; ARConfiguration* m_arConfig; ARSession* m_arSession; Vulkan::MetalTextureCache m_textureCache; /*#if (__cplusplus >= 202002L) std::atomic> m_frame; #else*/ SpintexProtectedObject> m_frame; //#endif std::atomic_size_t m_frameId = 0; bool m_lockedConfiguration = false; bool m_lockedExposure = false; bool m_lockedWhitebalance = false; }; }