Commit fa29f6dd authored by Suman Kancherla's avatar Suman Kancherla Committed by Commit Bot

[ui/vr] Display different inheadset notifications

Shows a toast with instructions to exit VR session right after
session starts.

Also, displays inheadset notifications for previously granted
permissions when entering immersive presentation, and also when
they become in-use.

Bug: 913502, 732449, 934056, 937383
Change-Id: I5d17732da62d07cc7d037160e1914b9fa58f1917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1527863
Commit-Queue: Suman Kancherla <sumankancherla@chromium.org>
Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646117}
parent fa41a73c
......@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_VR_MODEL_CAPTURING_STATE_MODEL_H_
#define CHROME_BROWSER_VR_MODEL_CAPTURING_STATE_MODEL_H_
#include <string>
#include "chrome/browser/vr/vr_base_export.h"
namespace vr {
......@@ -15,6 +17,24 @@ struct VR_BASE_EXPORT CapturingStateModel {
bool screen_capture_enabled = false;
bool location_access_enabled = false;
bool bluetooth_connected = false;
bool operator==(const CapturingStateModel& rhs) const {
return audio_capture_enabled == rhs.audio_capture_enabled &&
video_capture_enabled == rhs.video_capture_enabled &&
screen_capture_enabled == rhs.screen_capture_enabled &&
location_access_enabled == rhs.location_access_enabled &&
bluetooth_connected == rhs.bluetooth_connected;
}
bool operator!=(const CapturingStateModel& rhs) const {
return !(*this == rhs);
}
bool IsAnyCapturingEnabled() const {
return audio_capture_enabled || video_capture_enabled ||
screen_capture_enabled || location_access_enabled ||
bluetooth_connected;
}
};
typedef bool CapturingStateModel::*CapturingStateModelMemberPtr;
......
......@@ -7,18 +7,21 @@
#include <memory>
#include "base/task/post_task.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
#include "chrome/browser/permissions/permission_manager.h"
#include "chrome/browser/permissions/permission_result.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/vr/metrics/session_metrics_helper.h"
#include "chrome/browser/vr/service/browser_xr_runtime.h"
#include "chrome/browser/vr/service/xr_runtime_manager.h"
#include "chrome/browser/vr/vr_tab_helper.h"
#include "chrome/browser/vr/win/vr_browser_renderer_thread_win.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/service_manager_connection.h"
#include "services/device/public/mojom/constants.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/base/l10n/l10n_util.h"
namespace vr {
......@@ -26,11 +29,18 @@ namespace vr {
namespace {
static constexpr base::TimeDelta kPermissionPromptTimeout =
base::TimeDelta::FromSeconds(5);
static constexpr base::TimeDelta kPollCapturingStateInterval =
base::TimeDelta::FromSecondsD(0.2);
const CapturingStateModel g_default_capturing_state;
} // namespace
VRUiHostImpl::VRUiHostImpl(device::mojom::XRDeviceId device_id,
device::mojom::XRCompositorHostPtr compositor)
: compositor_(std::move(compositor)), weak_ptr_factory_(this) {
: compositor_(std::move(compositor)),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_ptr_factory_(this) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DVLOG(1) << __func__;
......@@ -39,6 +49,10 @@ VRUiHostImpl::VRUiHostImpl(device::mojom::XRDeviceId device_id,
if (runtime) {
runtime->AddObserver(this);
}
auto* connector =
content::ServiceManagerConnection::GetForProcess()->GetConnector();
connector->BindInterface(device::mojom::kServiceName, &geolocation_config_);
}
VRUiHostImpl::~VRUiHostImpl() {
......@@ -109,8 +123,11 @@ void VRUiHostImpl::SetWebXRWebContents(content::WebContents* contents) {
web_contents_ = contents;
if (contents) {
StartUiRendering();
InitCapturingStates();
ui_rendering_thread_->SetWebXrPresenting(true);
PollCapturingState();
PermissionRequestManager::CreateForWebContents(contents);
permission_request_manager_ =
PermissionRequestManager::FromWebContents(contents);
......@@ -129,6 +146,8 @@ void VRUiHostImpl::SetWebXRWebContents(content::WebContents* contents) {
DVLOG(1) << __func__ << ": No PermissionRequestManager";
}
} else {
poll_capturing_state_task_.Cancel();
if (ui_rendering_thread_)
ui_rendering_thread_->SetWebXrPresenting(false);
StopUiRendering();
......@@ -159,6 +178,7 @@ void VRUiHostImpl::StartUiRendering() {
void VRUiHostImpl::StopUiRendering() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DVLOG(1) << __func__;
ui_rendering_thread_ = nullptr;
}
......@@ -185,30 +205,130 @@ void VRUiHostImpl::OnBubbleAdded() {
SetLocationInfoOnUi();
if (indicators_visible_) {
indicators_visible_ = false;
ui_rendering_thread_->SetIndicatorsVisible(false);
}
ui_rendering_thread_->SetVisibleExternalPromptNotification(
ExternalPromptNotificationType::kPromptGenericPermission);
is_prompt_showing_in_headset_ = true;
current_prompt_sequence_num_++;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&VRUiHostImpl::RemoveHeadsetNotificationPrompt,
weak_ptr_factory_.GetWeakPtr(),
current_prompt_sequence_num_),
is_external_prompt_showing_in_headset_ = true;
external_prompt_timeout_task_.Reset(
base::BindRepeating(&VRUiHostImpl::RemoveHeadsetNotificationPrompt,
weak_ptr_factory_.GetWeakPtr()));
main_thread_task_runner_->PostDelayedTask(
FROM_HERE, external_prompt_timeout_task_.callback(),
kPermissionPromptTimeout);
}
void VRUiHostImpl::OnBubbleRemoved() {
RemoveHeadsetNotificationPrompt(current_prompt_sequence_num_);
external_prompt_timeout_task_.Cancel();
RemoveHeadsetNotificationPrompt();
}
void VRUiHostImpl::RemoveHeadsetNotificationPrompt(int prompt_sequence_num) {
if (!is_prompt_showing_in_headset_)
return;
if (prompt_sequence_num != current_prompt_sequence_num_)
void VRUiHostImpl::RemoveHeadsetNotificationPrompt() {
if (!is_external_prompt_showing_in_headset_)
return;
is_prompt_showing_in_headset_ = false;
is_external_prompt_showing_in_headset_ = false;
ui_rendering_thread_->SetVisibleExternalPromptNotification(
ExternalPromptNotificationType::kPromptNone);
indicators_shown_start_time_ = base::Time::Now();
}
void VRUiHostImpl::InitCapturingStates() {
active_capturing_ = g_default_capturing_state;
potential_capturing_ = g_default_capturing_state;
DCHECK(web_contents_);
PermissionManager* permission_manager = PermissionManager::Get(
Profile::FromBrowserContext(web_contents_->GetBrowserContext()));
const GURL& origin = web_contents_->GetLastCommittedURL();
content::RenderFrameHost* rfh = web_contents_->GetMainFrame();
potential_capturing_.audio_capture_enabled =
permission_manager
->GetPermissionStatusForFrame(
ContentSettingsType::CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, rfh,
origin)
.content_setting == CONTENT_SETTING_ALLOW;
potential_capturing_.video_capture_enabled =
permission_manager
->GetPermissionStatusForFrame(
ContentSettingsType::CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
rfh, origin)
.content_setting == CONTENT_SETTING_ALLOW;
potential_capturing_.location_access_enabled =
permission_manager
->GetPermissionStatusForFrame(
ContentSettingsType::CONTENT_SETTINGS_TYPE_GEOLOCATION, rfh,
origin)
.content_setting == CONTENT_SETTING_ALLOW;
indicators_shown_start_time_ = base::Time::Now();
indicators_visible_ = false;
}
void VRUiHostImpl::PollCapturingState() {
poll_capturing_state_task_.Reset(base::BindRepeating(
&VRUiHostImpl::PollCapturingState, base::Unretained(this)));
main_thread_task_runner_->PostDelayedTask(
FROM_HERE, poll_capturing_state_task_.callback(),
kPollCapturingStateInterval);
// Microphone, Camera, location.
CapturingStateModel active_capturing = active_capturing_;
TabSpecificContentSettings* settings =
TabSpecificContentSettings::FromWebContents(web_contents_);
if (settings) {
const ContentSettingsUsagesState& usages_state =
settings->geolocation_usages_state();
if (!usages_state.state_map().empty()) {
unsigned int state_flags = 0;
usages_state.GetDetailedInfo(nullptr, &state_flags);
active_capturing.location_access_enabled = !!(
state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED);
}
active_capturing.audio_capture_enabled =
(settings->GetMicrophoneCameraState() &
TabSpecificContentSettings::MICROPHONE_ACCESSED) &&
!(settings->GetMicrophoneCameraState() &
TabSpecificContentSettings::MICROPHONE_BLOCKED);
active_capturing.video_capture_enabled =
(settings->GetMicrophoneCameraState() &
TabSpecificContentSettings::CAMERA_ACCESSED) &
!(settings->GetMicrophoneCameraState() &
TabSpecificContentSettings::CAMERA_BLOCKED);
}
// Screen capture, bluetooth.
scoped_refptr<MediaStreamCaptureIndicator> indicator =
MediaCaptureDevicesDispatcher::GetInstance()
->GetMediaStreamCaptureIndicator();
active_capturing.screen_capture_enabled =
indicator->IsBeingMirrored(web_contents_);
active_capturing.bluetooth_connected =
web_contents_->IsConnectedToBluetoothDevice();
if (active_capturing_ != active_capturing) {
indicators_shown_start_time_ = base::Time::Now();
}
active_capturing_ = active_capturing;
ui_rendering_thread_->SetCapturingState(
active_capturing_, g_default_capturing_state, potential_capturing_);
if (indicators_shown_start_time_ + kPermissionPromptTimeout >
base::Time::Now()) {
if (!indicators_visible_ && !is_external_prompt_showing_in_headset_) {
indicators_visible_ = true;
ui_rendering_thread_->SetIndicatorsVisible(true);
}
} else {
if (indicators_visible_) {
indicators_visible_ = false;
ui_rendering_thread_->SetIndicatorsVisible(false);
}
}
}
} // namespace vr
......@@ -5,13 +5,17 @@
#ifndef CHROME_BROWSER_VR_UI_HOST_VR_UI_HOST_IMPL_H_
#define CHROME_BROWSER_VR_UI_HOST_VR_UI_HOST_IMPL_H_
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/permissions/permission_request_manager.h"
#include "chrome/browser/vr/model/capturing_state_model.h"
#include "chrome/browser/vr/service/browser_xr_runtime.h"
#include "chrome/browser/vr/service/vr_ui_host.h"
#include "content/public/browser/web_contents.h"
#include "services/device/public/mojom/geolocation_config.mojom.h"
namespace vr {
......@@ -46,17 +50,28 @@ class VRUiHostImpl : public VRUiHost,
void OnBubbleAdded() override;
void OnBubbleRemoved() override;
void RemoveHeadsetNotificationPrompt(int prompt_sequence_num);
void RemoveHeadsetNotificationPrompt();
void SetLocationInfoOnUi();
void InitCapturingStates();
void PollCapturingState();
device::mojom::XRCompositorHostPtr compositor_;
std::unique_ptr<VRBrowserRendererThreadWin> ui_rendering_thread_;
device::mojom::VRDisplayInfoPtr info_;
content::WebContents* web_contents_ = nullptr;
PermissionRequestManager* permission_request_manager_ = nullptr;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
base::CancelableClosure external_prompt_timeout_task_;
bool is_external_prompt_showing_in_headset_ = false;
bool is_prompt_showing_in_headset_ = false;
int current_prompt_sequence_num_ = 0;
CapturingStateModel active_capturing_;
CapturingStateModel potential_capturing_;
device::mojom::GeolocationConfigPtr geolocation_config_;
base::CancelableClosure poll_capturing_state_task_;
base::Time indicators_shown_start_time_;
bool indicators_visible_ = false;
THREAD_CHECKER(thread_checker_);
......
This diff is collapsed.
......@@ -1307,6 +1307,7 @@ TEST_F(UiTest, RepositionHostedUi) {
// Ensures that permissions do not appear after showing hosted UI.
TEST_F(UiTest, DoNotShowIndicatorsAfterHostedUi) {
#if !defined(OS_WIN)
CreateScene(kInWebVr);
auto browser_ui = ui_->GetBrowserUiWeakPtr();
browser_ui->SetWebVrMode(true);
......@@ -1323,12 +1324,14 @@ TEST_F(UiTest, DoNotShowIndicatorsAfterHostedUi) {
model_->web_vr.showing_hosted_ui = false;
OnBeginFrame();
EXPECT_FALSE(IsVisible(kWebVrExclusiveScreenToast));
#endif
}
// Ensures that permissions appear on long press, and that when the menu button
// is released that we do not show the exclusive screen toast. Distinguishing
// these cases requires knowledge of the previous state.
TEST_F(UiTest, LongPressMenuButtonInWebVrMode) {
#if !defined(OS_WIN)
CreateScene(kInWebVr);
auto browser_ui = ui_->GetBrowserUiWeakPtr();
browser_ui->SetWebVrMode(true);
......@@ -1360,6 +1363,7 @@ TEST_F(UiTest, LongPressMenuButtonInWebVrMode) {
std::make_unique<InputEvent>(InputEvent::kMenuButtonLongPressEnd));
ui_->HandleMenuButtonEvents(&events);
EXPECT_FALSE(model_->menu_button_long_pressed);
#endif
}
TEST_F(UiTest, MenuItems) {
......
......@@ -304,7 +304,7 @@ void GraphicsDelegateWin::PrepareBufferForContentQuadLayer(
}
void GraphicsDelegateWin::PrepareBufferForBrowserUi() {
gl_->ClearColor(0, 1, 0, 1);
gl_->ClearColor(0, 0, 0, 0);
gl_->Clear(GL_COLOR_BUFFER_BIT);
DCHECK(prepared_drawing_buffer_ == DrawingBufferMode::kNone);
......
......@@ -13,13 +13,14 @@ SchedulerDelegateWin::~SchedulerDelegateWin() {}
void SchedulerDelegateWin::OnPose(base::OnceCallback<void()> on_frame_ended,
gfx::Transform head_pose,
bool draw_overlay,
bool draw_ui) {
on_frame_ended_ = std::move(on_frame_ended);
base::TimeTicks now = base::TimeTicks::Now();
if (draw_ui)
browser_renderer_->DrawBrowserFrame(now);
else
if (draw_overlay)
browser_renderer_->DrawWebXrFrame(now, head_pose);
else if (draw_ui)
browser_renderer_->DrawBrowserFrame(now);
}
void SchedulerDelegateWin::OnPause() {
......
......@@ -17,6 +17,7 @@ class SchedulerDelegateWin : public SchedulerDelegate {
// Tell browser when poses available, when we rendered, etc.
void OnPose(base::OnceCallback<void()> on_frame_ended,
gfx::Transform head_pose,
bool draw_overlay,
bool draw_ui);
private:
......
......@@ -57,6 +57,8 @@ void VRBrowserRendererThreadWin::StopOverlay() {
started_ = false;
graphics_ = nullptr;
scheduler_ = nullptr;
ui_ = nullptr;
scheduler_ui_ = nullptr;
}
void VRBrowserRendererThreadWin::SetVRDisplayInfo(
......@@ -115,6 +117,13 @@ void VRBrowserRendererThreadWin::StopWebXrTimeout() {
OnSpinnerVisibilityChanged(false);
}
int VRBrowserRendererThreadWin::GetNextRequestId() {
current_request_id_++;
if (current_request_id_ >= 0x10000)
current_request_id_ = 0;
return current_request_id_;
}
void VRBrowserRendererThreadWin::OnWebXrTimeoutImminent() {
OnSpinnerVisibilityChanged(true);
scheduler_ui_->OnWebXrTimeoutImminent();
......@@ -135,16 +144,48 @@ void VRBrowserRendererThreadWin::SetVisibleExternalPromptNotification(
ui_->SetVisibleExternalPromptNotification(prompt);
overlay_->SetOverlayAndWebXRVisibility(draw_state_.ShouldDrawUI(),
draw_state_.ShouldDrawWebXR());
if (overlay_)
overlay_->SetOverlayAndWebXRVisibility(draw_state_.ShouldDrawUI(),
draw_state_.ShouldDrawWebXR());
if (draw_state_.ShouldDrawUI()) {
overlay_->RequestNextOverlayPose(base::BindOnce(
&VRBrowserRendererThreadWin::OnPose, base::Unretained(this)));
if (overlay_) // False only while testing
overlay_->RequestNextOverlayPose(
base::BindOnce(&VRBrowserRendererThreadWin::OnPose,
base::Unretained(this), GetNextRequestId()));
} else {
StopOverlay();
}
}
void VRBrowserRendererThreadWin::SetIndicatorsVisible(bool visible) {
if (!draw_state_.SetIndicatorsVisible(visible))
return;
if (draw_state_.ShouldDrawUI())
StartOverlay();
if (overlay_)
overlay_->SetOverlayAndWebXRVisibility(draw_state_.ShouldDrawUI(),
draw_state_.ShouldDrawWebXR());
if (draw_state_.ShouldDrawUI()) {
if (overlay_) // False only while testing
overlay_->RequestNextOverlayPose(
base::BindOnce(&VRBrowserRendererThreadWin::OnPose,
base::Unretained(this), GetNextRequestId()));
} else {
StopOverlay();
}
}
void VRBrowserRendererThreadWin::SetCapturingState(
const CapturingStateModel& active_capturing,
const CapturingStateModel& background_capturing,
const CapturingStateModel& potential_capturing) {
if (ui_)
ui_->SetCapturingState(active_capturing, background_capturing,
potential_capturing);
}
VRBrowserRendererThreadWin*
VRBrowserRendererThreadWin::GetInstanceForTesting() {
return instance_for_testing_;
......@@ -263,22 +304,24 @@ void VRBrowserRendererThreadWin::StartOverlay() {
}
void VRBrowserRendererThreadWin::OnSpinnerVisibilityChanged(bool visible) {
if (draw_state_.SetSpinnerVisible(visible)) {
if (draw_state_.ShouldDrawUI()) {
StartOverlay();
}
if (overlay_) {
overlay_->SetOverlayAndWebXRVisibility(draw_state_.ShouldDrawUI(),
draw_state_.ShouldDrawWebXR());
}
if (draw_state_.ShouldDrawUI()) {
overlay_->RequestNextOverlayPose(base::BindOnce(
&VRBrowserRendererThreadWin::OnPose, base::Unretained(this)));
} else {
StopOverlay();
}
if (!draw_state_.SetSpinnerVisible(visible))
return;
if (draw_state_.ShouldDrawUI()) {
StartOverlay();
}
if (overlay_) {
overlay_->SetOverlayAndWebXRVisibility(draw_state_.ShouldDrawUI(),
draw_state_.ShouldDrawWebXR());
}
if (draw_state_.ShouldDrawUI()) {
if (overlay_) // False only while testing.
overlay_->RequestNextOverlayPose(
base::BindOnce(&VRBrowserRendererThreadWin::OnPose,
base::Unretained(this), GetNextRequestId()));
} else {
StopOverlay();
}
}
......@@ -288,12 +331,16 @@ void VRBrowserRendererThreadWin::OnWebXRSubmitted() {
StopWebXrTimeout();
}
void VRBrowserRendererThreadWin::OnPose(device::mojom::XRFrameDataPtr data) {
void VRBrowserRendererThreadWin::OnPose(int request_id,
device::mojom::XRFrameDataPtr data) {
if (request_id != current_request_id_) {
// Old request. Do nothing.
return;
}
if (!draw_state_.ShouldDrawUI()) {
// We shouldn't be showing UI.
overlay_->SetOverlayAndWebXRVisibility(draw_state_.ShouldDrawUI(),
draw_state_.ShouldDrawWebXR());
if (graphics_)
graphics_->ResetMemoryBuffer();
return;
......@@ -330,7 +377,8 @@ void VRBrowserRendererThreadWin::OnPose(device::mojom::XRFrameDataPtr data) {
// calling the callback if we are destroyed.
scheduler_->OnPose(base::BindOnce(&VRBrowserRendererThreadWin::SubmitFrame,
base::Unretained(this), std::move(data)),
head_from_world, draw_state_.ShouldDrawUI());
head_from_world, draw_state_.ShouldDrawWebXR(),
draw_state_.ShouldDrawUI());
}
void VRBrowserRendererThreadWin::SubmitFrame(
......@@ -345,24 +393,28 @@ void VRBrowserRendererThreadWin::SubmitFrame(
}
void VRBrowserRendererThreadWin::SubmitResult(bool success) {
if (!success) {
if (!success && graphics_) {
graphics_->ResetMemoryBuffer();
}
if (scheduler_ui_ && success)
scheduler_ui_->OnWebXrFrameAvailable();
if (draw_state_.ShouldDrawUI() && started_) {
overlay_->RequestNextOverlayPose(base::BindOnce(
&VRBrowserRendererThreadWin::OnPose, base::Unretained(this)));
overlay_->RequestNextOverlayPose(
base::BindOnce(&VRBrowserRendererThreadWin::OnPose,
base::Unretained(this), GetNextRequestId()));
}
}
// VRBrowserRendererThreadWin::DrawContentType functions.
bool VRBrowserRendererThreadWin::DrawState::ShouldDrawUI() {
return prompt_ != ExternalPromptNotificationType::kPromptNone ||
spinner_visible_;
spinner_visible_ || indicators_visible_;
}
bool VRBrowserRendererThreadWin::DrawState::ShouldDrawWebXR() {
return prompt_ == ExternalPromptNotificationType::kPromptNone &&
!spinner_visible_;
return (prompt_ == ExternalPromptNotificationType::kPromptNone &&
!spinner_visible_) ||
indicators_visible_;
}
bool VRBrowserRendererThreadWin::DrawState::SetPrompt(
......@@ -380,4 +432,11 @@ bool VRBrowserRendererThreadWin::DrawState::SetSpinnerVisible(bool visible) {
return old_ui != ShouldDrawUI() || old_webxr != ShouldDrawWebXR();
}
bool VRBrowserRendererThreadWin::DrawState::SetIndicatorsVisible(bool visible) {
bool old_ui = ShouldDrawUI();
bool old_webxr = ShouldDrawWebXR();
indicators_visible_ = visible;
return old_ui != ShouldDrawUI() || old_webxr != ShouldDrawWebXR();
}
} // namespace vr
......@@ -9,6 +9,7 @@
#include "base/threading/thread.h"
#include "chrome/browser/vr/browser_renderer.h"
#include "chrome/browser/vr/model/capturing_state_model.h"
#include "chrome/browser/vr/model/web_vr_model.h"
#include "chrome/browser/vr/service/browser_xr_runtime.h"
#include "chrome/browser/vr/vr_export.h"
......@@ -37,6 +38,10 @@ class VR_EXPORT VRBrowserRendererThreadWin {
// The below function(s) affect(s) whether UI is drawn or not.
void SetVisibleExternalPromptNotification(
ExternalPromptNotificationType prompt);
void SetIndicatorsVisible(bool visible);
void SetCapturingState(const CapturingStateModel& active_capturing,
const CapturingStateModel& background_capturing,
const CapturingStateModel& potential_capturing);
static VRBrowserRendererThreadWin* GetInstanceForTesting();
BrowserRenderer* GetBrowserRendererForTesting();
......@@ -48,6 +53,7 @@ class VR_EXPORT VRBrowserRendererThreadWin {
// State changing methods.
bool SetPrompt(ExternalPromptNotificationType prompt);
bool SetSpinnerVisible(bool visible);
bool SetIndicatorsVisible(bool visible);
// State querying methods.
bool ShouldDrawUI();
......@@ -58,9 +64,10 @@ class VR_EXPORT VRBrowserRendererThreadWin {
ExternalPromptNotificationType::kPromptNone;
bool spinner_visible_ = false;
bool indicators_visible_ = false;
};
void OnPose(device::mojom::XRFrameDataPtr data);
void OnPose(int request_id, device::mojom::XRFrameDataPtr data);
void SubmitResult(bool success);
void SubmitFrame(device::mojom::XRFrameDataPtr data);
void StartOverlay();
......@@ -71,6 +78,7 @@ class VR_EXPORT VRBrowserRendererThreadWin {
void OnWebXrTimedOut();
void StartWebXrTimeout();
void StopWebXrTimeout();
int GetNextRequestId();
// We need to do some initialization of GraphicsDelegateWin before
// browser_renderer_, so we first store it in a unique_ptr, then transition
......@@ -94,6 +102,7 @@ class VR_EXPORT VRBrowserRendererThreadWin {
DrawState draw_state_;
bool started_ = false;
bool webxr_presenting_ = false;
int current_request_id_ = 0;
device::mojom::ImmersiveOverlayPtr overlay_;
device::mojom::VRDisplayInfoPtr display_info_;
......
......@@ -64,10 +64,6 @@ void XRCompositorCommon::ClearPendingFrame() {
// frame, we allow the renderer to receive poses.
std::move(delayed_get_frame_data_callback_).Run();
}
if (delayed_overlay_get_frame_data_callback_ && overlay_visible_) {
std::move(delayed_overlay_get_frame_data_callback_).Run();
}
}
void XRCompositorCommon::SubmitFrameMissing(int16_t frame_index,
......@@ -250,7 +246,6 @@ void XRCompositorCommon::ExitPresent() {
// Kill outstanding overlays:
overlay_visible_ = false;
delayed_overlay_get_frame_data_callback_.Reset();
overlay_binding_.Close();
texture_helper_.SetSourceAndOverlayVisible(false, false);
......@@ -402,16 +397,6 @@ void XRCompositorCommon::RequestNextOverlayPose(
DCHECK(overlay_visible_);
TRACE_EVENT_INSTANT0("xr", "RequestOverlayPose", TRACE_EVENT_SCOPE_THREAD);
// If we've already given out a pose for the current frame delay giving out a
// pose until the next frame we are visible.
if (pending_frame_ && pending_frame_->overlay_has_pose_) {
DCHECK(!delayed_overlay_get_frame_data_callback_);
delayed_overlay_get_frame_data_callback_ =
base::BindOnce(&XRCompositorCommon::RequestNextOverlayPose,
base::Unretained(this), std::move(callback));
return;
}
// Ensure we have a pending frame.
StartPendingFrame();
pending_frame_->overlay_has_pose_ = true;
......
......@@ -150,7 +150,6 @@ class XRCompositorCommon : public base::Thread,
bool webxr_visible_ = true; // The browser may hide a presenting session.
bool overlay_visible_ = false;
base::OnceCallback<void()> delayed_get_frame_data_callback_;
base::OnceCallback<void()> delayed_overlay_get_frame_data_callback_;
gfx::RectF left_webxr_bounds_;
gfx::RectF right_webxr_bounds_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment