arcore_device_provider.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/webxr/android/arcore_device_provider.h"
  5. #include "components/webxr/android/arcore_java_utils.h"
  6. #include "components/webxr/mailbox_to_surface_bridge_impl.h"
  7. #include "device/vr/android/arcore/ar_image_transport.h"
  8. #include "device/vr/android/arcore/arcore_device.h"
  9. #include "device/vr/android/arcore/arcore_impl.h"
  10. #include "device/vr/android/arcore/arcore_shim.h"
  11. namespace webxr {
  12. ArCoreDeviceProvider::ArCoreDeviceProvider(
  13. webxr::ArCompositorDelegateProvider compositor_delegate_provider)
  14. : compositor_delegate_provider_(compositor_delegate_provider) {}
  15. ArCoreDeviceProvider::~ArCoreDeviceProvider() = default;
  16. void ArCoreDeviceProvider::Initialize(device::VRDeviceProviderClient* client) {
  17. if (device::IsArCoreSupported()) {
  18. DVLOG(2) << __func__ << ": ARCore is supported, creating device";
  19. arcore_device_ = std::make_unique<device::ArCoreDevice>(
  20. std::make_unique<device::ArCoreImplFactory>(),
  21. std::make_unique<device::ArImageTransportFactory>(),
  22. std::make_unique<webxr::MailboxToSurfaceBridgeFactoryImpl>(),
  23. std::make_unique<webxr::ArCoreJavaUtils>(compositor_delegate_provider_),
  24. client->GetXrFrameSinkClientFactory());
  25. client->AddRuntime(arcore_device_->GetId(), arcore_device_->GetDeviceData(),
  26. arcore_device_->BindXRRuntime());
  27. }
  28. initialized_ = true;
  29. client->OnProviderInitialized();
  30. }
  31. bool ArCoreDeviceProvider::Initialized() {
  32. return initialized_;
  33. }
  34. } // namespace webxr