Commit ec6a3c6b authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Revert "Revert "Fix exo for IsMusHostingVis() == false""

This reverts commit e763ffcb.

Reason for revert: The problem for reverting https://crrev.com/c/806689
has been fixed by https://crrev.com/c/824434.

Original change's description:
> Revert "Fix exo for IsMusHostingVis() == false"
> 
> This reverts commit fe678147.
> 
> Reason for revert: Breaks several tests in ash_unittests-mus on Builder Linux Chromium OS ASan LSan Tests
> See https://uberchromegw.corp.google.com/i/chromium.memory/builders/Linux%20Chromium%20OS%20ASan%20LSan%20Tests%20%281%29/builds/25187
> 
> Original change's description:
> > Fix exo for IsMusHostingVis() == false
> > 
> > Bug: 792479, 793924
> > Test: Test on device with android apps
> > Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
> > Change-Id: I8c9beb8f835c294b6e2eb1dec4654a8d501c0952
> > Reviewed-on: https://chromium-review.googlesource.com/806689
> > Commit-Queue: Peng Huang <penghuang@chromium.org>
> > Reviewed-by: Scott Violet <sky@chromium.org>
> > Reviewed-by: Antoine Labour <piman@chromium.org>
> > Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#523647}
> 
> TBR=penghuang@chromium.org,sadrul@chromium.org,sky@chromium.org,piman@chromium.org
> 
> Change-Id: If258d1188a54f4406b6f0edf0c37ead6c89379b4
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 792479, 793924
> Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
> Reviewed-on: https://chromium-review.googlesource.com/823925
> Reviewed-by: Christos Froussios <cfroussios@chromium.org>
> Commit-Queue: Christos Froussios <cfroussios@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#523764}

TBR=penghuang@chromium.org,sadrul@chromium.org,sky@chromium.org,piman@chromium.org,cfroussios@chromium.org

Change-Id: I5ec6e8befda01fbbd320ee048aab998623e2b830
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 792479, 793924
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
Reviewed-on: https://chromium-review.googlesource.com/825282Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523830}
parent 7d4f4638
...@@ -115,6 +115,17 @@ void AshTestHelper::SetUp(bool start_session, bool provide_local_state) { ...@@ -115,6 +115,17 @@ void AshTestHelper::SetUp(bool start_session, bool provide_local_state) {
ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
ui::InitializeInputMethodForTesting(); ui::InitializeInputMethodForTesting();
if (config_ == Config::MUS && !::switches::IsMusHostingViz()) {
ui::ContextFactory* context_factory = nullptr;
ui::ContextFactoryPrivate* context_factory_private = nullptr;
ui::InitializeContextFactoryForTests(false /* enable_pixel_output */,
&context_factory,
&context_factory_private);
auto* env = aura::Env::GetInstance();
env->set_context_factory(context_factory);
env->set_context_factory_private(context_factory_private);
}
// Creates Shell and hook with Desktop. // Creates Shell and hook with Desktop.
if (!test_shell_delegate_) if (!test_shell_delegate_)
test_shell_delegate_ = new TestShellDelegate; test_shell_delegate_ = new TestShellDelegate;
...@@ -221,8 +232,7 @@ void AshTestHelper::TearDown() { ...@@ -221,8 +232,7 @@ void AshTestHelper::TearDown() {
dbus_thread_manager_initialized_ = false; dbus_thread_manager_initialized_ = false;
} }
if (config_ == Config::CLASSIC) ui::TerminateContextFactoryForTests();
ui::TerminateContextFactoryForTests();
ui::ShutdownInputMethodForTesting(); ui::ShutdownInputMethodForTesting();
zero_duration_mode_.reset(); zero_duration_mode_.reset();
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#include "ui/compositor/test/context_factories_for_test.h"
#include "ui/gfx/gfx_paths.h" #include "ui/gfx/gfx_paths.h"
#include "ui/gl/test/gl_surface_test_support.h" #include "ui/gl/test/gl_surface_test_support.h"
...@@ -70,15 +71,13 @@ void AshTestSuite::Initialize() { ...@@ -70,15 +71,13 @@ void AshTestSuite::Initialize() {
env_ = aura::Env::CreateInstance(is_mus || is_mash ? aura::Env::Mode::MUS env_ = aura::Env::CreateInstance(is_mus || is_mash ? aura::Env::Mode::MUS
: aura::Env::Mode::LOCAL); : aura::Env::Mode::LOCAL);
if (is_mus || is_mash) { if (is_mash) {
context_factory_ = std::make_unique<aura::test::AuraTestContextFactory>(); context_factory_ = std::make_unique<aura::test::AuraTestContextFactory>();
env_->set_context_factory(context_factory_.get()); env_->set_context_factory(context_factory_.get());
env_->set_context_factory_private(nullptr); env_->set_context_factory_private(nullptr);
// mus needs to host viz, because ash by itself cannot. // mus needs to host viz, because ash by itself cannot.
if (is_mash) { base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( switches::kMus, switches::kMusHostVizValue);
switches::kMus, switches::kMusHostVizValue);
}
} }
} }
......
...@@ -44,6 +44,10 @@ class LayerTreeFrameSinkLocal : public cc::LayerTreeFrameSink, ...@@ -44,6 +44,10 @@ class LayerTreeFrameSinkLocal : public cc::LayerTreeFrameSink,
base::WeakPtr<LayerTreeFrameSinkLocal> GetWeakPtr(); base::WeakPtr<LayerTreeFrameSinkLocal> GetWeakPtr();
const viz::LocalSurfaceId& local_surface_id() const {
return local_surface_id_;
}
// cc::LayerTreeFrameSink: // cc::LayerTreeFrameSink:
bool BindToClient(cc::LayerTreeFrameSinkClient* client) override; bool BindToClient(cc::LayerTreeFrameSinkClient* client) override;
void DetachFromClient() override; void DetachFromClient() override;
......
...@@ -7,6 +7,7 @@ include_rules = [ ...@@ -7,6 +7,7 @@ include_rules = [
"+components/discardable_memory/client/client_discardable_shared_memory_manager.h", "+components/discardable_memory/client/client_discardable_shared_memory_manager.h",
"+components/viz/client", "+components/viz/client",
"+components/viz/common", "+components/viz/common",
"+components/viz/service/frame_sinks/frame_sink_manager_impl.h",
"+gpu/command_buffer/client/gpu_memory_buffer_manager.h", "+gpu/command_buffer/client/gpu_memory_buffer_manager.h",
"+gpu/ipc/client/gpu_channel_host.h", "+gpu/ipc/client/gpu_channel_host.h",
"+mojo/public/cpp/system/buffer.h", "+mojo/public/cpp/system/buffer.h",
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "components/viz/client/local_surface_id_provider.h" #include "components/viz/client/local_surface_id_provider.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/transient_window_client.h" #include "ui/aura/client/transient_window_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
...@@ -36,7 +37,9 @@ WindowMus* WindowMus::Get(Window* window) { ...@@ -36,7 +37,9 @@ WindowMus* WindowMus::Get(Window* window) {
WindowPortMus::WindowPortMus(WindowTreeClient* client, WindowPortMus::WindowPortMus(WindowTreeClient* client,
WindowMusType window_mus_type) WindowMusType window_mus_type)
: WindowMus(window_mus_type), window_tree_client_(client) {} : WindowMus(window_mus_type),
window_tree_client_(client),
weak_ptr_factory_(this) {}
WindowPortMus::~WindowPortMus() { WindowPortMus::~WindowPortMus() {
client_surface_embedder_.reset(); client_surface_embedder_.reset();
...@@ -550,25 +553,64 @@ std::unique_ptr<cc::LayerTreeFrameSink> ...@@ -550,25 +553,64 @@ std::unique_ptr<cc::LayerTreeFrameSink>
WindowPortMus::CreateLayerTreeFrameSink() { WindowPortMus::CreateLayerTreeFrameSink() {
DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL); DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL);
DCHECK(!local_layer_tree_frame_sink_); DCHECK(!local_layer_tree_frame_sink_);
auto frame_sink = RequestLayerTreeFrameSink(
nullptr, std::unique_ptr<cc::LayerTreeFrameSink> frame_sink;
aura::Env::GetInstance()->context_factory()->GetGpuMemoryBufferManager()); if (switches::IsMusHostingViz()) {
local_layer_tree_frame_sink_ = frame_sink->GetWeakPtr(); auto client_layer_tree_frame_sink =
auto size_in_pixel = RequestLayerTreeFrameSink(nullptr, aura::Env::GetInstance()
->context_factory()
->GetGpuMemoryBufferManager());
local_layer_tree_frame_sink_ = client_layer_tree_frame_sink->GetWeakPtr();
frame_sink = std::move(client_layer_tree_frame_sink);
} else {
auto* context_factory_private =
aura::Env::GetInstance()->context_factory_private();
auto frame_sink_id = GetFrameSinkId();
DCHECK(frame_sink_id.is_valid());
auto layer_tree_frame_sink_local =
std::make_unique<LayerTreeFrameSinkLocal>(
frame_sink_id, context_factory_private->GetHostFrameSinkManager(),
window_->GetName());
layer_tree_frame_sink_local->SetSurfaceChangedCallback(base::BindRepeating(
&WindowPortMus::OnSurfaceChanged, weak_ptr_factory_.GetWeakPtr()));
if (window_->layer()->GetCompositor()) {
window_->layer()->GetCompositor()->AddFrameSink(GetFrameSinkId());
is_frame_sink_id_added_to_compositor_ = true;
}
local_layer_tree_frame_sink_ = layer_tree_frame_sink_local->GetWeakPtr();
frame_sink = std::move(layer_tree_frame_sink_local);
}
gfx::Size size_in_pixel =
gfx::ConvertSizeToPixel(GetDeviceScaleFactor(), window_->bounds().size()); gfx::ConvertSizeToPixel(GetDeviceScaleFactor(), window_->bounds().size());
// Make sure |local_surface_id_| and |last_surface_size_in_pixels_| are // Make sure |local_surface_id_| and |last_surface_size_in_pixels_| are
// correct for the new created |frame_sink|. // correct for the new created |local_layer_tree_frame_sink_|.
GetOrAllocateLocalSurfaceId(size_in_pixel); GetOrAllocateLocalSurfaceId(size_in_pixel);
return std::move(frame_sink); return frame_sink;
} }
viz::SurfaceId WindowPortMus::GetSurfaceId() const { viz::SurfaceId WindowPortMus::GetSurfaceId() const {
return viz::SurfaceId(window_->embed_frame_sink_id(), local_surface_id_); return viz::SurfaceId(window_->embed_frame_sink_id(), local_surface_id_);
} }
void WindowPortMus::OnWindowAddedToRootWindow() {} void WindowPortMus::OnWindowAddedToRootWindow() {
if (switches::IsMusHostingViz())
return;
if (local_layer_tree_frame_sink_) {
DCHECK(!is_frame_sink_id_added_to_compositor_);
window_->layer()->GetCompositor()->AddFrameSink(GetFrameSinkId());
is_frame_sink_id_added_to_compositor_ = true;
}
}
void WindowPortMus::OnWillRemoveWindowFromRootWindow() {} void WindowPortMus::OnWillRemoveWindowFromRootWindow() {
if (switches::IsMusHostingViz())
return;
if (is_frame_sink_id_added_to_compositor_) {
window_->layer()->GetCompositor()->RemoveFrameSink(GetFrameSinkId());
is_frame_sink_id_added_to_compositor_ = false;
}
}
void WindowPortMus::OnEventTargetingPolicyChanged() { void WindowPortMus::OnEventTargetingPolicyChanged() {
SetEventTargetingPolicy(window_->event_targeting_policy()); SetEventTargetingPolicy(window_->event_targeting_policy());
...@@ -614,4 +656,19 @@ void WindowPortMus::UpdateClientSurfaceEmbedder() { ...@@ -614,4 +656,19 @@ void WindowPortMus::UpdateClientSurfaceEmbedder() {
client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_); client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_);
} }
void WindowPortMus::OnSurfaceChanged(const viz::SurfaceInfo& surface_info) {
DCHECK(!switches::IsMusHostingViz());
DCHECK_EQ(surface_info.id().frame_sink_id(), GetFrameSinkId());
DCHECK_EQ(surface_info.id().local_surface_id(), local_surface_id_);
scoped_refptr<viz::SurfaceReferenceFactory> reference_factory =
aura::Env::GetInstance()
->context_factory_private()
->GetFrameSinkManager()
->surface_manager()
->reference_factory();
window_->layer()->SetShowPrimarySurface(
surface_info.id(), window_->bounds().size(), reference_factory);
window_->layer()->SetFallbackSurfaceId(surface_info.id());
}
} // namespace aura } // namespace aura
...@@ -12,12 +12,14 @@ ...@@ -12,12 +12,14 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/viz/client/client_layer_tree_frame_sink.h" #include "components/viz/client/client_layer_tree_frame_sink.h"
#include "components/viz/common/surfaces/surface_info.h" #include "components/viz/common/surfaces/surface_info.h"
#include "services/ui/public/interfaces/cursor/cursor.mojom.h" #include "services/ui/public/interfaces/cursor/cursor.mojom.h"
#include "services/ui/public/interfaces/window_tree.mojom.h" #include "services/ui/public/interfaces/window_tree.mojom.h"
#include "services/ui/public/interfaces/window_tree_constants.mojom.h" #include "services/ui/public/interfaces/window_tree_constants.mojom.h"
#include "ui/aura/aura_export.h" #include "ui/aura/aura_export.h"
#include "ui/aura/local/layer_tree_frame_sink_local.h"
#include "ui/aura/mus/mus_types.h" #include "ui/aura/mus/mus_types.h"
#include "ui/aura/mus/window_mus.h" #include "ui/aura/mus/window_mus.h"
#include "ui/aura/window_port.h" #include "ui/aura/window_port.h"
...@@ -280,6 +282,8 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus { ...@@ -280,6 +282,8 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
void UpdatePrimarySurfaceId(); void UpdatePrimarySurfaceId();
void UpdateClientSurfaceEmbedder(); void UpdateClientSurfaceEmbedder();
void OnSurfaceChanged(const viz::SurfaceInfo& surface_info);
WindowTreeClient* window_tree_client_; WindowTreeClient* window_tree_client_;
Window* window_ = nullptr; Window* window_ = nullptr;
...@@ -305,7 +309,10 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus { ...@@ -305,7 +309,10 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
// When a frame sink is created // When a frame sink is created
// for a local aura::Window, we need keep a weak ptr of it, so we can update // for a local aura::Window, we need keep a weak ptr of it, so we can update
// the local surface id when necessary. // the local surface id when necessary.
base::WeakPtr<viz::ClientLayerTreeFrameSink> local_layer_tree_frame_sink_; base::WeakPtr<cc::LayerTreeFrameSink> local_layer_tree_frame_sink_;
bool is_frame_sink_id_added_to_compositor_ = false;
base::WeakPtrFactory<WindowPortMus> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WindowPortMus); DISALLOW_COPY_AND_ASSIGN(WindowPortMus);
}; };
......
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
#include "components/viz/client/client_layer_tree_frame_sink.h" #include "components/viz/client/client_layer_tree_frame_sink.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/local/layer_tree_frame_sink_local.h"
#include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/aura_test_base.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/ui_base_switches_util.h"
namespace aura { namespace aura {
...@@ -17,7 +19,7 @@ class WindowPortMusTest : public test::AuraTestBase { ...@@ -17,7 +19,7 @@ class WindowPortMusTest : public test::AuraTestBase {
~WindowPortMusTest() override = default; ~WindowPortMusTest() override = default;
base::WeakPtr<viz::ClientLayerTreeFrameSink> GetFrameSinkFor(Window* window) { base::WeakPtr<cc::LayerTreeFrameSink> GetFrameSinkFor(Window* window) {
auto* window_mus = WindowPortMus::Get(window); auto* window_mus = WindowPortMus::Get(window);
return window_mus->local_layer_tree_frame_sink_; return window_mus->local_layer_tree_frame_sink_;
} }
...@@ -43,8 +45,14 @@ TEST_F(WindowPortMusTest, LayerTreeFrameSinkGetsCorrectLocalSurfaceId) { ...@@ -43,8 +45,14 @@ TEST_F(WindowPortMusTest, LayerTreeFrameSinkGetsCorrectLocalSurfaceId) {
auto mus_frame_sink = GetFrameSinkFor(&window); auto mus_frame_sink = GetFrameSinkFor(&window);
ASSERT_TRUE(mus_frame_sink); ASSERT_TRUE(mus_frame_sink);
EXPECT_TRUE(mus_frame_sink->local_surface_id().is_valid()); auto frame_sink_local_surface_id =
EXPECT_EQ(mus_frame_sink->local_surface_id(), local_surface_id); switches::IsMusHostingViz()
? static_cast<viz::ClientLayerTreeFrameSink*>(mus_frame_sink.get())
->local_surface_id()
: static_cast<LayerTreeFrameSinkLocal*>(mus_frame_sink.get())
->local_surface_id();
EXPECT_TRUE(frame_sink_local_surface_id.is_valid());
EXPECT_EQ(frame_sink_local_surface_id, local_surface_id);
} }
} // namespace aura } // namespace aura
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui/compositor/test/in_process_context_factory.h" #include "ui/compositor/test/in_process_context_factory.h"
#include <limits>
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
...@@ -45,8 +46,8 @@ ...@@ -45,8 +46,8 @@
namespace ui { namespace ui {
namespace { namespace {
// The client_id used here should not conflict with the client_id generated // The client_id used here should not conflict with the client_id generated
// from RenderWidgetHostImpl. // from RenderWidgetHostImpl and client_id(0) used by aura::WindowPortMus.
constexpr uint32_t kDefaultClientId = 0u; constexpr uint32_t kDefaultClientId = std::numeric_limits<uint32_t>::max();
class FakeReflector : public Reflector { class FakeReflector : public Reflector {
public: public:
......
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