Skip to content

Commit

Permalink
cc: Split Proxy to eliminate unnecessary dependencies on the impl side
Browse files Browse the repository at this point in the history
The impl side of the compositor uses Proxy to only access the
task runners and make debug assertions. Move those parts to
TaskRunnerProvider to seperate these dependencies.

BUG=527200
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1411663002

Cr-Commit-Position: refs/heads/master@{#355370}
  • Loading branch information
khushalsagar authored and Commit bot committed Oct 21, 2015
1 parent d502b83 commit b64b360
Show file tree
Hide file tree
Showing 62 changed files with 641 additions and 516 deletions.
4 changes: 3 additions & 1 deletion cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ component("cc") {
"trees/single_thread_proxy.h",
"trees/swap_promise_monitor.cc",
"trees/swap_promise_monitor.h",
"trees/task_runner_provider.cc",
"trees/task_runner_provider.h",
"trees/thread_proxy.cc",
"trees/thread_proxy.h",
"trees/threaded_channel.cc",
Expand Down Expand Up @@ -557,7 +559,7 @@ source_set("test_support") {
"test/fake_display_list_recording_source.h",
"test/fake_external_begin_frame_source.cc",
"test/fake_external_begin_frame_source.h",
"test/fake_impl_proxy.h",
"test/fake_impl_task_runner_provider.h",
"test/fake_layer_tree_host.cc",
"test/fake_layer_tree_host.h",
"test/fake_layer_tree_host_client.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "cc/animation/scrollbar_animation_controller_linear_fade.h"

#include "cc/layers/solid_color_scrollbar_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
Expand All @@ -21,7 +21,9 @@ class ScrollbarAnimationControllerLinearFadeTest
public ScrollbarAnimationControllerClient {
public:
ScrollbarAnimationControllerLinearFadeTest()
: host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_),
: host_impl_(&task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_),
did_request_redraw_(false),
did_request_animate_(false) {}

Expand Down Expand Up @@ -73,7 +75,7 @@ class ScrollbarAnimationControllerLinearFadeTest

virtual ScrollbarOrientation orientation() const { return HORIZONTAL; }

FakeImplProxy proxy_;
FakeImplTaskRunnerProvider task_runner_provider_;
TestSharedBitmapManager shared_bitmap_manager_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "cc/animation/scrollbar_animation_controller_thinning.h"

#include "cc/layers/solid_color_scrollbar_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
Expand All @@ -21,7 +21,9 @@ class ScrollbarAnimationControllerThinningTest
public ScrollbarAnimationControllerClient {
public:
ScrollbarAnimationControllerThinningTest()
: host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {}
: host_impl_(&task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_) {}

void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade,
base::TimeDelta delay) override {
Expand Down Expand Up @@ -70,7 +72,7 @@ class ScrollbarAnimationControllerThinningTest
base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3));
}

FakeImplProxy proxy_;
FakeImplTaskRunnerProvider task_runner_provider_;
TestSharedBitmapManager shared_bitmap_manager_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;
Expand Down
6 changes: 4 additions & 2 deletions cc/cc.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,12 @@
'trees/single_thread_proxy.h',
'trees/swap_promise_monitor.cc',
'trees/swap_promise_monitor.h',
'trees/threaded_channel.cc',
'trees/threaded_channel.h',
'trees/thread_proxy.cc',
'trees/thread_proxy.h',
'trees/task_runner_provider.cc',
'trees/task_runner_provider.h',
'trees/threaded_channel.cc',
'trees/threaded_channel.h',
'trees/tree_synchronizer.cc',
'trees/tree_synchronizer.h',
],
Expand Down
2 changes: 1 addition & 1 deletion cc/cc_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
'test/fake_display_list_recording_source.h',
'test/fake_external_begin_frame_source.cc',
'test/fake_external_begin_frame_source.h',
'test/fake_impl_proxy.h',
'test/fake_impl_task_runner_provider.h',
'test/fake_layer_tree_host.cc',
'test/fake_layer_tree_host.h',
'test/fake_layer_tree_host_client.cc',
Expand Down
7 changes: 2 additions & 5 deletions cc/debug/frame_timing_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ scoped_ptr<FrameTimingTracker> FrameTimingTracker::Create(
FrameTimingTracker::FrameTimingTracker(LayerTreeHostImpl* layer_tree_host_impl)
: layer_tree_host_impl_(layer_tree_host_impl),
post_events_notifier_(
layer_tree_host_impl_->proxy()->HasImplThread()
? layer_tree_host_impl_->proxy()->ImplThreadTaskRunner()
: layer_tree_host_impl_->proxy()->MainThreadTaskRunner(),
layer_tree_host_impl_->GetTaskRunner(),
base::Bind(&FrameTimingTracker::PostEvents, base::Unretained(this)),
base::TimeDelta::FromMilliseconds(kSendTimingIntervalMS)) {
}
base::TimeDelta::FromMilliseconds(kSendTimingIntervalMS)) {}

FrameTimingTracker::~FrameTimingTracker() {
}
Expand Down
38 changes: 19 additions & 19 deletions cc/debug/frame_timing_tracker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "base/trace_event/trace_event_argument.h"
#include "base/values.h"
#include "cc/debug/frame_timing_tracker.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
Expand Down Expand Up @@ -74,10 +74,10 @@ std::string MainFrameToString(
}

TEST(FrameTimingTrackerTest, DefaultTrackerIsEmpty) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<FrameTimingTracker> tracker(
Expand All @@ -89,10 +89,10 @@ TEST(FrameTimingTrackerTest, DefaultTrackerIsEmpty) {
}

TEST(FrameTimingTrackerTest, NoFrameIdsIsEmpty) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<FrameTimingTracker> tracker(
Expand All @@ -104,10 +104,10 @@ TEST(FrameTimingTrackerTest, NoFrameIdsIsEmpty) {
}

TEST(FrameTimingTrackerTest, NoRectIdsYieldsNoMainFrameEvents) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<FrameTimingTracker> tracker(
Expand All @@ -120,10 +120,10 @@ TEST(FrameTimingTrackerTest, NoRectIdsYieldsNoMainFrameEvents) {
}

TEST(FrameTimingTrackerTest, OneFrameId) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<FrameTimingTracker> tracker(
Expand All @@ -138,10 +138,10 @@ TEST(FrameTimingTrackerTest, OneFrameId) {
}

TEST(FrameTimingTrackerTest, OneMainFrameRect) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<FrameTimingTracker> tracker(
Expand All @@ -158,10 +158,10 @@ TEST(FrameTimingTrackerTest, OneMainFrameRect) {
}

TEST(FrameTimingTrackerTest, UnsortedTimestampsIds) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<FrameTimingTracker> tracker(
Expand All @@ -180,10 +180,10 @@ TEST(FrameTimingTrackerTest, UnsortedTimestampsIds) {
}

TEST(FrameTimingTrackerTest, MainFrameUnsortedTimestamps) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<FrameTimingTracker> tracker(
Expand All @@ -208,10 +208,10 @@ TEST(FrameTimingTrackerTest, MainFrameUnsortedTimestamps) {
}

TEST(FrameTimingTrackerTest, MultipleFrameIds) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<FrameTimingTracker> tracker(
Expand Down Expand Up @@ -247,10 +247,10 @@ TEST(FrameTimingTrackerTest, MultipleFrameIds) {
}

TEST(FrameTimingTrackerTest, MultipleMainFrameEvents) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<FrameTimingTracker> tracker(
Expand Down
11 changes: 7 additions & 4 deletions cc/debug/micro_benchmark_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "cc/debug/micro_benchmark.h"
#include "cc/debug/micro_benchmark_controller.h"
#include "cc/layers/layer.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_proxy.h"
Expand All @@ -22,9 +23,11 @@ class MicroBenchmarkControllerTest : public testing::Test {
: layer_tree_host_client_(FakeLayerTreeHostClient::DIRECT_3D) {}

void SetUp() override {
impl_proxy_ = make_scoped_ptr(new FakeImplProxy);
impl_task_runner_provider_ =
make_scoped_ptr(new FakeImplTaskRunnerProvider);
layer_tree_host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl(
impl_proxy_.get(), &shared_bitmap_manager_, &task_graph_runner_));
impl_task_runner_provider_.get(), &shared_bitmap_manager_,
&task_graph_runner_));

layer_tree_host_ = FakeLayerTreeHost::Create(&layer_tree_host_client_,
&task_graph_runner_);
Expand All @@ -35,15 +38,15 @@ class MicroBenchmarkControllerTest : public testing::Test {
void TearDown() override {
layer_tree_host_impl_ = nullptr;
layer_tree_host_ = nullptr;
impl_proxy_ = nullptr;
impl_task_runner_provider_ = nullptr;
}

FakeLayerTreeHostClient layer_tree_host_client_;
TestTaskGraphRunner task_graph_runner_;
TestSharedBitmapManager shared_bitmap_manager_;
scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
scoped_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_;
scoped_ptr<FakeImplProxy> impl_proxy_;
scoped_ptr<FakeImplTaskRunnerProvider> impl_task_runner_provider_;
};

void Noop(scoped_ptr<base::Value> value) {
Expand Down
6 changes: 3 additions & 3 deletions cc/input/scroll_state_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "cc/input/scroll_state.h"

#include "cc/layers/layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
Expand Down Expand Up @@ -57,10 +57,10 @@ TEST_F(ScrollStateTest, ConsumeDeltaNative) {
TEST_F(ScrollStateTest, CurrentNativeScrollingScrollable) {
ScrollState scrollState(0, 0, 0, 0, false, false, false);

FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);

scoped_ptr<LayerImpl> layer_impl =
Expand Down
8 changes: 5 additions & 3 deletions cc/input/top_controls_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "base/time/time.h"
#include "cc/input/top_controls_manager_client.h"
#include "cc/layers/layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
Expand All @@ -28,7 +28,9 @@ class MockTopControlsManagerClient : public TopControlsManagerClient {
MockTopControlsManagerClient(float top_controls_height,
float top_controls_show_threshold,
float top_controls_hide_threshold)
: host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_),
: host_impl_(&task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_),
redraw_needed_(false),
update_draw_properties_needed_(false),
top_controls_shown_ratio_(1.f),
Expand Down Expand Up @@ -81,7 +83,7 @@ class MockTopControlsManagerClient : public TopControlsManagerClient {
void SetTopControlsHeight(float height) { top_controls_height_ = height; }

private:
FakeImplProxy proxy_;
FakeImplTaskRunnerProvider task_runner_provider_;
TestSharedBitmapManager shared_bitmap_manager_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;
Expand Down
13 changes: 7 additions & 6 deletions cc/layers/delegated_renderer_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/solid_color_draw_quad.h"
#include "cc/test/fake_delegated_renderer_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_layer_tree_host_impl_client.h"
#include "cc/test/fake_output_surface.h"
Expand All @@ -31,21 +31,22 @@ namespace {
class DelegatedRendererLayerImplTest : public testing::Test {
public:
DelegatedRendererLayerImplTest()
: proxy_(),
always_impl_thread_and_main_thread_blocked_(&proxy_),
: task_runner_provider_(),
always_impl_thread_and_main_thread_blocked_(&task_runner_provider_),
output_surface_(FakeOutputSurface::Create3d()) {
LayerTreeSettings settings;
settings.minimum_occlusion_tracking_size = gfx::Size();

host_impl_.reset(new FakeLayerTreeHostImpl(
settings, &proxy_, &shared_bitmap_manager_, &task_graph_runner_));
host_impl_.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_));
host_impl_->SetVisible(true);
host_impl_->InitializeRenderer(output_surface_.get());
host_impl_->SetViewportSize(gfx::Size(10, 10));
}

protected:
FakeImplProxy proxy_;
FakeImplTaskRunnerProvider task_runner_provider_;
DebugScopedSetImplThreadAndMainThreadBlocked
always_impl_thread_and_main_thread_blocked_;
TestSharedBitmapManager shared_bitmap_manager_;
Expand Down
6 changes: 3 additions & 3 deletions cc/layers/heads_up_display_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "cc/layers/append_quads_data.h"
#include "cc/layers/heads_up_display_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/test_shared_bitmap_manager.h"
Expand All @@ -31,11 +31,11 @@ void CheckDrawLayer(HeadsUpDisplayLayerImpl* layer,
}

TEST(HeadsUpDisplayLayerImplTest, ResourcelessSoftwareDrawAfterResourceLoss) {
FakeImplProxy proxy;
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);
host_impl.CreatePendingTree();
host_impl.SetVisible(true);
Expand Down
Loading

0 comments on commit b64b360

Please sign in to comment.