Commit ddc70361 authored by Fady Samuel's avatar Fady Samuel Committed by Commit Bot

Surface Synchronization: Delete CompositorResizeLock.

This is no longer used.

Bug: 672962
Change-Id: Ib97ca682e2c5eb1252972af9068da5afbff9fb81
TBR: piman@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/1053588Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Commit-Queue: Fady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557453}
parent 77d93ba0
......@@ -2319,8 +2319,6 @@ jumbo_source_set("browser") {
"context_factory.cc",
"renderer_host/browser_compositor_view_mac.h",
"renderer_host/browser_compositor_view_mac.mm",
"renderer_host/compositor_resize_lock.cc",
"renderer_host/compositor_resize_lock.h",
"renderer_host/delegated_frame_host.cc",
"renderer_host/delegated_frame_host.h",
]
......
......@@ -14,7 +14,6 @@
#include "base/trace_event/trace_event.h"
#include "components/viz/common/features.h"
#include "content/browser/compositor/image_transport_factory.h"
#include "content/browser/renderer_host/compositor_resize_lock.h"
#include "content/browser/renderer_host/display_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/context_factory.h"
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/renderer_host/compositor_resize_lock.h"
#include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h"
#include "content/public/browser/browser_thread.h"
#include "ui/compositor/compositor.h"
namespace content {
CompositorResizeLock::CompositorResizeLock(CompositorResizeLockClient* client,
const gfx::Size& new_size)
: client_(client),
expected_size_(new_size),
acquisition_time_(base::TimeTicks::Now()) {
TRACE_EVENT_ASYNC_BEGIN2("ui", "CompositorResizeLock", this, "width",
expected_size().width(), "height",
expected_size().height());
}
CompositorResizeLock::~CompositorResizeLock() {
compositor_lock_ = nullptr;
if (client_)
client_->CompositorResizeLockEnded();
TRACE_EVENT_ASYNC_END2("ui", "CompositorResizeLock", this, "width",
expected_size().width(), "height",
expected_size().height());
UMA_HISTOGRAM_TIMES("UI.CompositorResizeLock.Duration",
base::TimeTicks::Now() - acquisition_time_);
UMA_HISTOGRAM_BOOLEAN("UI.CompositorResizeLock.TimedOut", timed_out_);
}
bool CompositorResizeLock::Lock() {
if (unlocked_ || compositor_lock_)
return false;
compositor_lock_ = client_->GetCompositorLock(this);
return true;
}
void CompositorResizeLock::UnlockCompositor() {
unlocked_ = true;
compositor_lock_ = nullptr;
}
void CompositorResizeLock::CompositorLockTimedOut() {
timed_out_ = true;
UnlockCompositor();
if (client_) {
client_->CompositorResizeLockEnded();
client_ = nullptr;
}
}
} // namespace content
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_RESIZE_LOCK_H_
#define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_RESIZE_LOCK_H_
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "ui/compositor/compositor_lock.h"
#include "ui/gfx/geometry/size.h"
namespace content {
class CompositorResizeLockClient {
public:
virtual ~CompositorResizeLockClient() {}
// Creates and returns a CompositorLock for the CompositoResizeLock to
// hold.
virtual std::unique_ptr<ui::CompositorLock> GetCompositorLock(
ui::CompositorLockClient* client) = 0;
// Called when the CompositorResizeLock ends. This can happen
// before the CompositorResizeLock is destroyed if it times out.
virtual void CompositorResizeLockEnded() = 0;
};
// Used to prevent further resizes while a resize is pending.
class CONTENT_EXPORT CompositorResizeLock : public ui::CompositorLockClient {
public:
CompositorResizeLock(CompositorResizeLockClient* client,
const gfx::Size& new_size);
~CompositorResizeLock() override;
// Returns |true| if the call locks the compositor, or false if it was ever
// locked/unlocked.
bool Lock();
// Releases the lock on the compositor without releasing the whole resize
// lock. The client is not told about this. If called before locking, it will
// prevent locking from happening.
void UnlockCompositor();
bool timed_out() const { return timed_out_; }
const gfx::Size& expected_size() const { return expected_size_; }
private:
// ui::CompositorLockClient implementation.
void CompositorLockTimedOut() override;
CompositorResizeLockClient* client_;
const gfx::Size expected_size_;
std::unique_ptr<ui::CompositorLock> compositor_lock_;
bool unlocked_ = false;
bool timed_out_ = false;
const base::TimeTicks acquisition_time_;
DISALLOW_COPY_AND_ASSIGN(CompositorResizeLock);
};
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_RESIZE_LOCK_AURA_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/renderer_host/compositor_resize_lock.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/test/null_task_runner.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
namespace {
class FakeCompositorResizeLockClient : public CompositorResizeLockClient,
public ui::CompositorLockManagerClient {
public:
FakeCompositorResizeLockClient()
: lock_manager_(new base::NullTaskRunner(), this) {}
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
ui::CompositorLockClient* client) override {
created_ = true;
return lock_manager_.GetCompositorLock(client, base::TimeDelta());
}
// CompositorResizeLockClient implementation.
void CompositorResizeLockEnded() override {
// This informs when the CompositorResizeLock ends for the client to
// release anything else it is holding.
ended_ = true;
}
// ui::CompositorLockManagerClient implementation.
void OnCompositorLockStateChanged(bool locked) override {
if (!locked) {
// This is where the ui::Compositor would be physically unlocked.
unlocked_ = true;
}
}
void CauseTimeout() { lock_manager_.TimeoutLocksForTesting(); }
bool created() const { return created_; }
bool unlocked() const { return unlocked_; }
bool ended() const { return ended_; }
private:
bool created_ = false;
bool unlocked_ = false;
bool ended_ = false;
ui::CompositorLockManager lock_manager_;
};
TEST(CompositorResizeLockTest, EndWithoutLock) {
FakeCompositorResizeLockClient resize_client;
gfx::Size resize_to(10, 11);
{
CompositorResizeLock resize_lock(&resize_client, resize_to);
EXPECT_FALSE(resize_client.created());
EXPECT_FALSE(resize_client.unlocked());
EXPECT_FALSE(resize_client.ended());
}
// The compositor was never locked.
EXPECT_FALSE(resize_client.unlocked());
// The resize lock tells the client when it is destroyed.
EXPECT_TRUE(resize_client.ended());
}
TEST(CompositorResizeLockTest, EndAfterLock) {
FakeCompositorResizeLockClient resize_client;
gfx::Size resize_to(10, 11);
{
CompositorResizeLock resize_lock(&resize_client, resize_to);
EXPECT_FALSE(resize_client.created());
EXPECT_FALSE(resize_client.ended());
resize_lock.Lock();
EXPECT_TRUE(resize_client.created());
EXPECT_FALSE(resize_client.ended());
}
// The resize lock unlocks the compositor when it ends.
EXPECT_TRUE(resize_client.unlocked());
// The resize lock tells the client when it ends.
EXPECT_TRUE(resize_client.ended());
}
TEST(CompositorResizeLockTest, EndAfterUnlock) {
FakeCompositorResizeLockClient resize_client;
gfx::Size resize_to(10, 11);
{
CompositorResizeLock resize_lock(&resize_client, resize_to);
EXPECT_FALSE(resize_client.created());
EXPECT_FALSE(resize_client.ended());
resize_lock.Lock();
EXPECT_TRUE(resize_client.created());
EXPECT_FALSE(resize_client.ended());
// Unlocking the compositor but keeping the resize lock.
resize_lock.UnlockCompositor();
EXPECT_TRUE(resize_client.unlocked());
EXPECT_FALSE(resize_client.ended());
}
// The resize lock tells the client when it ends.
EXPECT_TRUE(resize_client.ended());
}
TEST(CompositorResizeLockTest, EndAfterTimeout) {
FakeCompositorResizeLockClient resize_client;
gfx::Size resize_to(10, 11);
{
CompositorResizeLock resize_lock(&resize_client, resize_to);
EXPECT_FALSE(resize_client.created());
EXPECT_FALSE(resize_client.ended());
resize_lock.Lock();
EXPECT_TRUE(resize_client.created());
EXPECT_FALSE(resize_client.ended());
// A timeout tells the client that the lock ended.
resize_client.CauseTimeout();
EXPECT_TRUE(resize_client.unlocked());
EXPECT_TRUE(resize_client.ended());
}
}
class CallbackClient : public FakeCompositorResizeLockClient {
public:
CallbackClient() = default;
void CompositorResizeLockEnded() override {
std::move(resize_lock_ended_).Run();
}
void set_resize_lock_ended(base::OnceClosure c) {
resize_lock_ended_ = std::move(c);
}
private:
base::OnceClosure resize_lock_ended_;
};
TEST(CompositorResizeLockTest, TimeoutSetBeforeClientTold) {
CallbackClient resize_client;
gfx::Size resize_to(10, 11);
{
CompositorResizeLock resize_lock(&resize_client, resize_to);
resize_lock.Lock();
// When the resize lock times out, it should report that before telling
// the client about that.
bool saw_resize_lock_end = false;
auto resize_lock_ended = [](CompositorResizeLock* resize_lock, bool* saw) {
EXPECT_TRUE(resize_lock->timed_out());
*saw = true;
};
resize_client.set_resize_lock_ended(
base::BindOnce(resize_lock_ended, &resize_lock, &saw_resize_lock_end));
// A timeout tells the client that the lock ended.
resize_client.CauseTimeout();
EXPECT_TRUE(saw_resize_lock_end);
}
}
} // namespace
} // namespace content
......@@ -51,19 +51,6 @@ void DelegatedFrameHostClientAura::OnFrameTokenChanged(uint32_t frame_token) {
render_widget_host_view_->OnFrameTokenChangedForView(frame_token);
}
std::unique_ptr<ui::CompositorLock>
DelegatedFrameHostClientAura::GetCompositorLock(
ui::CompositorLockClient* client) {
auto* window_host = render_widget_host_view_->window_->GetHost();
return window_host->compositor()->GetCompositorLock(client);
}
void DelegatedFrameHostClientAura::CompositorResizeLockEnded() {
auto* window_host = render_widget_host_view_->window_->GetHost();
window_host->dispatcher()->ReleasePointerMoves();
render_widget_host_view_->host_->SynchronizeVisualProperties();
}
void DelegatedFrameHostClientAura::DidReceiveFirstFrameAfterNavigation() {
render_widget_host_view_->host_->DidReceiveFirstFrameAfterNavigation();
}
......
......@@ -6,7 +6,6 @@
#define CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_CLIENT_AURA_H_
#include "base/macros.h"
#include "content/browser/renderer_host/compositor_resize_lock.h"
#include "content/browser/renderer_host/delegated_frame_host.h"
#include "content/common/content_export.h"
......@@ -16,8 +15,7 @@ class RenderWidgetHostViewAura;
// DelegatedFrameHostClient implementation for aura, not used in mus.
class CONTENT_EXPORT DelegatedFrameHostClientAura
: public DelegatedFrameHostClient,
public CompositorResizeLockClient {
: public DelegatedFrameHostClient {
public:
explicit DelegatedFrameHostClientAura(
RenderWidgetHostViewAura* render_widget_host_view);
......@@ -37,11 +35,6 @@ class CONTENT_EXPORT DelegatedFrameHostClientAura
void OnFrameTokenChanged(uint32_t frame_token) override;
void DidReceiveFirstFrameAfterNavigation() override;
// CompositorResizeLockClient implementation.
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
ui::CompositorLockClient* client) override;
void CompositorResizeLockEnded() override;
private:
RenderWidgetHostViewAura* render_widget_host_view_;
......
......@@ -237,48 +237,14 @@ class FakeWindowEventDispatcher : public aura::WindowEventDispatcher {
size_t processed_touch_event_count_;
};
class FakeDelegatedFrameHostClientAura
: public DelegatedFrameHostClientAura,
public ui::CompositorLockManagerClient {
class FakeDelegatedFrameHostClientAura : public DelegatedFrameHostClientAura {
public:
explicit FakeDelegatedFrameHostClientAura(
RenderWidgetHostViewAura* render_widget_host_view)
: DelegatedFrameHostClientAura(render_widget_host_view),
lock_manager_(new base::NullTaskRunner(), this) {}
: DelegatedFrameHostClientAura(render_widget_host_view) {}
~FakeDelegatedFrameHostClientAura() override = default;
void DisableResizeLock() { can_create_resize_lock_ = false; }
bool resize_locked() const { return resize_locked_; }
bool compositor_locked() const { return compositor_locked_; }
private:
// CompositorResizeLockClient implemention. Overrides from
// DelegatedFrameHostClientAura, to prevent the lock from timing out.
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
ui::CompositorLockClient* client) override {
resize_locked_ = compositor_locked_ = true;
return lock_manager_.GetCompositorLock(nullptr, base::TimeDelta());
}
// CompositorResizeLockClient implemention. Overrides from
// // DelegatedFrameHostClientAura.
void CompositorResizeLockEnded() override {
resize_locked_ = false;
DelegatedFrameHostClientAura::CompositorResizeLockEnded();
}
// ui::CompositorLockManagerClient implementation.
void OnCompositorLockStateChanged(bool locked) override {
if (!locked) {
compositor_locked_ = false;
}
}
bool can_create_resize_lock_ = true;
bool resize_locked_ = false;
bool compositor_locked_ = false;
ui::CompositorLockManager lock_manager_;
DISALLOW_COPY_AND_ASSIGN(FakeDelegatedFrameHostClientAura);
};
......@@ -312,10 +278,6 @@ class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura {
renderer_compositor_frame_sink_ptr_.get());
}
void DisableResizeLock() {
delegated_frame_host_client_->DisableResizeLock();
}
void UseFakeDispatcher() {
dispatcher_ = new FakeWindowEventDispatcher(window()->GetHost());
std::unique_ptr<aura::WindowEventDispatcher> dispatcher(dispatcher_);
......@@ -354,12 +316,6 @@ class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura {
metadata);
}
bool resize_locked() const {
return delegated_frame_host_client_->resize_locked();
}
bool compositor_locked() const {
return delegated_frame_host_client_->compositor_locked();
}
bool is_guest_view_hack() { return is_guest_view_hack_; }
gfx::Size last_frame_size_;
......@@ -3278,9 +3234,6 @@ TEST_F(RenderWidgetHostViewAuraTest, ZeroSizeStillGetsLocalSurfaceId) {
viz::LocalSurfaceId local_surface_id =
parent_local_surface_id_allocator_.GenerateId();
// Prevent the DelegatedFrameHost from skipping frames.
view_->DisableResizeLock();
view_->InitAsChild(nullptr);
aura::client::ParentWindowWithContext(
view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
......@@ -3312,9 +3265,6 @@ TEST_F(RenderWidgetHostViewAuraTest, BackgroundColorMatchesCompositorFrame) {
viz::LocalSurfaceId local_surface_id =
parent_local_surface_id_allocator_.GenerateId();
// Prevent the DelegatedFrameHost from skipping frames.
view_->DisableResizeLock();
view_->InitAsChild(nullptr);
aura::client::ParentWindowWithContext(
view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
......@@ -3530,8 +3480,6 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, SurfaceChanges) {
view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
gfx::Rect());
// Prevent the DelegatedFrameHost from skipping frames.
view_->DisableResizeLock();
ASSERT_TRUE(view_->delegated_frame_host_);
view_->SetSize(gfx::Size(300, 300));
......@@ -3569,9 +3517,6 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
gfx::Rect());
// Prevent the DelegatedFrameHost from skipping frames.
view_->DisableResizeLock();
view_->SetSize(gfx::Size(300, 300));
ASSERT_TRUE(view_->HasPrimarySurface());
EXPECT_EQ(gfx::Size(300, 300), view_->window_->layer()->size());
......@@ -3656,7 +3601,6 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
// run a UI compositor so the DelegatedFrameHost doesn't get the chance
// to release its resize lock once it receives a frame of the expected
// size.
views[i]->DisableResizeLock();
views[i]->InitAsChild(nullptr);
aura::client::ParentWindowWithContext(
views[i]->GetNativeView(),
......
......@@ -1393,7 +1393,6 @@ test("content_unittests") {
"../browser/payments/payment_manager_unittest.cc",
"../browser/presentation/presentation_service_impl_unittest.cc",
"../browser/renderer_host/clipboard_host_impl_unittest.cc",
"../browser/renderer_host/compositor_resize_lock_unittest.cc",
"../browser/renderer_host/cursor_manager_unittest.cc",
"../browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc",
"../browser/renderer_host/embedded_frame_sink_provider_impl_unittest.cc",
......@@ -2031,7 +2030,6 @@ test("content_unittests") {
"../browser/compositor/gpu_vsync_begin_frame_source_unittest.cc",
"../browser/compositor/reflector_impl_unittest.cc",
"../browser/compositor/software_browser_compositor_output_surface_unittest.cc",
"../browser/renderer_host/compositor_resize_lock_unittest.cc",
]
}
......
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