Commit e4a13ed9 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

[cros] Treat windows as visible while they are being captured.

On CrOS, a window can be occluded by another window, causing content running
in full-occluded windows not be rendered.  Windows that are being
captured (e.g. for screen-sharing) should continue to render even
when fully-occluded.

Bug: 935971
Test: covered by unittests
Change-Id: Ib3098f2a85aa0bb3924924732d22b7c51d125c60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1540101Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646671}
parent 69cb45df
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "content/browser/media/capture/mouse_cursor_overlay_controller.h" #include "content/browser/media/capture/mouse_cursor_overlay_controller.h"
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/strong_binding.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/aura/window_occlusion_tracker.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "content/browser/media/capture/lame_window_capturer_chromeos.h" #include "content/browser/media/capture/lame_window_capturer_chromeos.h"
...@@ -86,6 +88,9 @@ class AuraWindowVideoCaptureDevice::WindowTracker ...@@ -86,6 +88,9 @@ class AuraWindowVideoCaptureDevice::WindowTracker
target_window_->GetFrameSinkId().is_valid() && target_window_->GetFrameSinkId().is_valid() &&
#endif #endif
true) { true) {
#if defined(OS_CHROMEOS)
force_visible_.emplace(target_window_);
#endif
target_window_->AddObserver(this); target_window_->AddObserver(this);
device_task_runner_->PostTask( device_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
...@@ -111,6 +116,9 @@ class AuraWindowVideoCaptureDevice::WindowTracker ...@@ -111,6 +116,9 @@ class AuraWindowVideoCaptureDevice::WindowTracker
target_window_->RemoveObserver(this); target_window_->RemoveObserver(this);
target_window_ = nullptr; target_window_ = nullptr;
#if defined(OS_CHROMEOS)
force_visible_.reset();
#endif
device_task_runner_->PostTask( device_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
...@@ -132,6 +140,10 @@ class AuraWindowVideoCaptureDevice::WindowTracker ...@@ -132,6 +140,10 @@ class AuraWindowVideoCaptureDevice::WindowTracker
const DesktopMediaID::Type target_type_; const DesktopMediaID::Type target_type_;
aura::Window* target_window_ = nullptr; aura::Window* target_window_ = nullptr;
#if defined(OS_CHROMEOS)
base::Optional<aura::WindowOcclusionTracker::ScopedForceVisible>
force_visible_;
#endif
DISALLOW_COPY_AND_ASSIGN(WindowTracker); DISALLOW_COPY_AND_ASSIGN(WindowTracker);
}; };
......
...@@ -311,6 +311,34 @@ IN_PROC_BROWSER_TEST_F(AuraWindowVideoCaptureDeviceBrowserTest, ...@@ -311,6 +311,34 @@ IN_PROC_BROWSER_TEST_F(AuraWindowVideoCaptureDeviceBrowserTest,
StopAndDeAllocate(); StopAndDeAllocate();
} }
#if defined(OS_CHROMEOS)
// On ChromeOS, another window may occlude a window that is being captured.
// Make sure the visibility is set to visible during capture if it's occluded.
IN_PROC_BROWSER_TEST_F(AuraWindowVideoCaptureDeviceBrowserTest,
CapturesOccludedWindows) {
// TODO(crbug.com/877172): CopyOutputRequests not allowed.
if (features::IsSingleProcessMash())
return;
NavigateToInitialDocument();
AllocateAndStartAndWaitForFirstFrame();
ASSERT_EQ(aura::Window::OcclusionState::VISIBLE,
shell()->web_contents()->GetNativeView()->occlusion_state());
// Create a window on top of the window being captured with same size so that
// it is occluded.
auto window = std::make_unique<aura::Window>(nullptr);
window->Init(ui::LAYER_TEXTURED);
shell()->window()->GetRootWindow()->AddChild(window.get());
window->SetBounds(shell()->window()->bounds());
window->Show();
EXPECT_EQ(aura::Window::OcclusionState::VISIBLE,
shell()->web_contents()->GetNativeView()->occlusion_state());
window.reset();
StopAndDeAllocate();
}
#endif // defined(OS_CHROMEOS)
class AuraWindowVideoCaptureDeviceBrowserTestP class AuraWindowVideoCaptureDeviceBrowserTestP
: public AuraWindowVideoCaptureDeviceBrowserTest, : public AuraWindowVideoCaptureDeviceBrowserTest,
public testing::WithParamInterface<std::tuple<bool, bool>> { public testing::WithParamInterface<std::tuple<bool, bool>> {
......
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