Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standup Skeleton Code for Cardboard Runtime
Creates features and infrastructure and initial include to begin building the Cardboard runtime for WebXR. Currently the runtime will simply reject all session requests, but it links in and initializes the sdk as a proof of concept that all build files should be mostly structured right. Stands up the following skeletons/infrastructure: * Feature Flag and About Flags entry * Creates CardboardDevice/Provider and adds it (and does not add the GVR Device) based on the Cardboard Feature Flag * Adds build files for //third_party/cardboard * Adds VR Buildflag for Cardboard * Creates basic directory and build file structure for cardboard * Incorporates cardboard build into Chrome build. Bug: 989117 Change-Id: I3e0e4349cb1a031404c38b0a6175681575c23e4b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4160186 Commit-Queue: Alexander Cooper <alcooper@chromium.org> Reviewed-by: Alex Gough <ajgo@chromium.org> Reviewed-by: Piotr Bialecki <bialpio@chromium.org> Cr-Commit-Position: refs/heads/main@{#1096488}
- Loading branch information
1 parent
7e7dc6d
commit bdd9a76
Showing
33 changed files
with
769 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
include_rules = [ | ||
"+device/base", | ||
"+device/vr/orientation", | ||
"+device/vr/android/cardboard", | ||
"+device/vr/test", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2023 The Chromium Authors | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("//build/config/android/rules.gni") | ||
import("//device/vr/buildflags/buildflags.gni") | ||
|
||
assert(enable_cardboard) | ||
|
||
component("vr_cardboard") { | ||
defines = [ "IS_VR_CARDBOARD_IMPL" ] | ||
sources = [ | ||
"cardboard_device.cc", | ||
"cardboard_device.h", | ||
"cardboard_device_provider.cc", | ||
"cardboard_device_provider.h", | ||
"cardboard_sdk.h", | ||
"cardboard_sdk_impl.cc", | ||
"cardboard_sdk_impl.h", | ||
] | ||
|
||
public_deps = [ | ||
"//device/vr:vr_base", | ||
"//device/vr/public/cpp", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//device/vr/android:vr_android", | ||
"//gpu/command_buffer/service:gles2", | ||
"//third_party/cardboard", | ||
"//ui/android", | ||
"//ui/gfx", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_rules = [ | ||
"+third_party/cardboard/src/sdk/include" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "device/vr/android/cardboard/cardboard_device.h" | ||
|
||
#include <utility> | ||
#include <vector> | ||
|
||
#include "base/no_destructor.h" | ||
#include "base/notreached.h" | ||
|
||
namespace device { | ||
|
||
namespace { | ||
|
||
const std::vector<mojom::XRSessionFeature>& GetSupportedFeatures() { | ||
static base::NoDestructor<std::vector<mojom::XRSessionFeature>> | ||
kSupportedFeatures{{ | ||
mojom::XRSessionFeature::REF_SPACE_VIEWER, | ||
mojom::XRSessionFeature::REF_SPACE_LOCAL, | ||
mojom::XRSessionFeature::REF_SPACE_LOCAL_FLOOR, | ||
}}; | ||
|
||
return *kSupportedFeatures; | ||
} | ||
|
||
} // namespace | ||
|
||
CardboardDevice::CardboardDevice(std::unique_ptr<CardboardSdk> cardboard_sdk) | ||
: VRDeviceBase(mojom::XRDeviceId::CARDBOARD_DEVICE_ID), | ||
cardboard_sdk_(std::move(cardboard_sdk)) { | ||
SetSupportedFeatures(GetSupportedFeatures()); | ||
} | ||
|
||
CardboardDevice::~CardboardDevice() = default; | ||
|
||
void CardboardDevice::RequestSession( | ||
mojom::XRRuntimeSessionOptionsPtr options, | ||
mojom::XRRuntime::RequestSessionCallback callback) { | ||
// TODO(https://crbug.com/989117): Implement | ||
std::move(callback).Run(nullptr); | ||
} | ||
|
||
void CardboardDevice::ShutdownSession( | ||
mojom::XRRuntime::ShutdownSessionCallback on_completed) { | ||
NOTREACHED(); | ||
} | ||
|
||
} // namespace device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef DEVICE_VR_ANDROID_CARDBOARD_CARDBOARD_DEVICE_H_ | ||
#define DEVICE_VR_ANDROID_CARDBOARD_CARDBOARD_DEVICE_H_ | ||
|
||
#include <memory> | ||
|
||
#include "base/component_export.h" | ||
#include "base/memory/weak_ptr.h" | ||
#include "device/vr/android/cardboard/cardboard_sdk.h" | ||
#include "device/vr/vr_device_base.h" | ||
|
||
namespace device { | ||
|
||
class COMPONENT_EXPORT(VR_CARDBOARD) CardboardDevice : public VRDeviceBase { | ||
public: | ||
explicit CardboardDevice(std::unique_ptr<CardboardSdk> cardboard_sdk); | ||
|
||
CardboardDevice(const CardboardDevice&) = delete; | ||
CardboardDevice& operator=(const CardboardDevice&) = delete; | ||
|
||
~CardboardDevice() override; | ||
|
||
// VRDeviceBase | ||
void RequestSession( | ||
mojom::XRRuntimeSessionOptionsPtr options, | ||
mojom::XRRuntime::RequestSessionCallback callback) override; | ||
void ShutdownSession(mojom::XRRuntime::ShutdownSessionCallback) override; | ||
|
||
private: | ||
std::unique_ptr<CardboardSdk> cardboard_sdk_; | ||
|
||
base::WeakPtrFactory<CardboardDevice> weak_ptr_factory_{this}; | ||
}; | ||
|
||
} // namespace device | ||
|
||
#endif // DEVICE_VR_ANDROID_CARDBOARD_CARDBOARD_DEVICE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "device/vr/android/cardboard/cardboard_device_provider.h" | ||
|
||
#include "device/vr/android/cardboard/cardboard_device.h" | ||
#include "device/vr/android/cardboard/cardboard_sdk_impl.h" | ||
|
||
namespace device { | ||
|
||
CardboardDeviceProvider::CardboardDeviceProvider() = default; | ||
|
||
CardboardDeviceProvider::~CardboardDeviceProvider() = default; | ||
|
||
void CardboardDeviceProvider::Initialize(VRDeviceProviderClient* client) { | ||
DVLOG(2) << __func__ << ": Cardboard is supported, creating device"; | ||
|
||
cardboard_device_ = | ||
std::make_unique<CardboardDevice>(std::make_unique<CardboardSdkImpl>()); | ||
|
||
client->AddRuntime(cardboard_device_->GetId(), | ||
cardboard_device_->GetDeviceData(), | ||
cardboard_device_->BindXRRuntime()); | ||
initialized_ = true; | ||
client->OnProviderInitialized(); | ||
} | ||
|
||
bool CardboardDeviceProvider::Initialized() { | ||
return initialized_; | ||
} | ||
|
||
} // namespace device |
Oops, something went wrong.