From 34b7a15218828edc105d4c408556b05c52994840 Mon Sep 17 00:00:00 2001 From: reveman Date: Mon, 23 Mar 2015 13:27:47 -0700 Subject: cc: Move worker threads to RenderThreadImpl. This allows us to Join the threads when RenderThreadImpl is shutdown. BUG=468785 TEST=cc_unittests Review URL: https://codereview.chromium.org/999173004 Cr-Commit-Position: refs/heads/master@{#321836} --- cc/BUILD.gn | 2 + ...ar_animation_controller_linear_fade_unittest.cc | 4 +- ...llbar_animation_controller_thinning_unittest.cc | 4 +- cc/cc_tests.gyp | 2 + cc/debug/micro_benchmark_controller_unittest.cc | 2 +- cc/input/top_controls_manager_unittest.cc | 4 +- .../delegated_renderer_layer_impl_unittest.cc | 6 +- cc/layers/heads_up_display_layer_impl_unittest.cc | 2 +- cc/layers/layer_impl_unittest.cc | 22 ++++++-- cc/layers/layer_perftest.cc | 5 +- cc/layers/layer_position_constraint_unittest.cc | 5 +- cc/layers/layer_unittest.cc | 26 ++++----- cc/layers/layer_utils_unittest.cc | 4 +- cc/layers/picture_image_layer_impl_unittest.cc | 7 ++- cc/layers/picture_layer.cc | 1 + cc/layers/picture_layer_impl_perftest.cc | 5 +- cc/layers/picture_layer_impl_unittest.cc | 12 +++- cc/layers/picture_layer_unittest.cc | 8 +-- cc/layers/render_surface_unittest.cc | 6 +- cc/layers/scrollbar_layer_unittest.cc | 7 ++- cc/layers/solid_color_layer_impl_unittest.cc | 8 +-- cc/layers/texture_layer_unittest.cc | 6 +- cc/layers/tiled_layer_impl_unittest.cc | 5 +- cc/layers/tiled_layer_unittest.cc | 6 +- cc/resources/display_list_recording_source.cc | 5 ++ cc/resources/display_list_recording_source.h | 2 + cc/resources/picture_pile.cc | 14 ++--- cc/resources/picture_pile.h | 2 + cc/resources/recording_source.h | 1 + cc/resources/tile_manager_perftest.cc | 5 +- cc/resources/tile_manager_unittest.cc | 7 ++- cc/resources/tile_task_worker_pool.cc | 66 ---------------------- cc/resources/tile_task_worker_pool.h | 15 ----- cc/resources/tile_task_worker_pool_unittest.cc | 25 ++++---- cc/test/fake_layer_tree_host.cc | 4 +- cc/test/fake_layer_tree_host_impl.cc | 8 ++- cc/test/fake_layer_tree_host_impl.h | 7 ++- cc/test/fake_ui_resource_layer_tree_host_impl.cc | 4 +- cc/test/layer_tree_json_parser_unittest.cc | 4 +- cc/test/layer_tree_pixel_resource_test.cc | 16 +++--- cc/test/layer_tree_test.cc | 61 +++++++++++--------- cc/test/layer_tree_test.h | 7 +++ cc/test/test_task_graph_runner.cc | 23 ++++++++ cc/test/test_task_graph_runner.h | 30 ++++++++++ cc/trees/damage_tracker_unittest.cc | 5 +- cc/trees/layer_tree_host.cc | 23 ++++---- cc/trees/layer_tree_host.h | 5 ++ cc/trees/layer_tree_host_common_unittest.cc | 36 ++++++------ cc/trees/layer_tree_host_impl.cc | 27 ++++----- cc/trees/layer_tree_host_impl.h | 3 + cc/trees/layer_tree_host_impl_unittest.cc | 47 +++++++-------- cc/trees/layer_tree_host_unittest.cc | 46 +++++---------- .../layer_tree_host_unittest_no_message_loop.cc | 2 +- cc/trees/layer_tree_host_unittest_scroll.cc | 12 ++-- cc/trees/layer_tree_impl_unittest.cc | 6 +- cc/trees/layer_tree_settings.cc | 3 +- cc/trees/layer_tree_settings.h | 1 + cc/trees/occlusion_tracker_perftest.cc | 10 +--- cc/trees/tree_synchronizer_unittest.cc | 27 ++------- 59 files changed, 371 insertions(+), 347 deletions(-) create mode 100644 cc/test/test_task_graph_runner.cc create mode 100644 cc/test/test_task_graph_runner.h (limited to 'cc') diff --git a/cc/BUILD.gn b/cc/BUILD.gn index 71cc6d0..df9f262 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn @@ -671,6 +671,8 @@ source_set("test_support") { "test/test_occlusion_tracker.h", "test/test_shared_bitmap_manager.cc", "test/test_shared_bitmap_manager.h", + "test/test_task_graph_runner.cc", + "test/test_task_graph_runner.h", "test/test_texture.cc", "test/test_texture.h", "test/test_tile_priorities.cc", diff --git a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc index f7a5878..6d2d3e8 100644 --- a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc +++ b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc @@ -9,6 +9,7 @@ #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,7 +21,7 @@ class ScrollbarAnimationControllerLinearFadeTest public ScrollbarAnimationControllerClient { public: ScrollbarAnimationControllerLinearFadeTest() - : host_impl_(&proxy_, &shared_bitmap_manager_) {} + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {} void StartAnimatingScrollbarAnimationController( ScrollbarAnimationController* controller) override { @@ -75,6 +76,7 @@ class ScrollbarAnimationControllerLinearFadeTest FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; scoped_ptr scrollbar_controller_; scoped_ptr clip_layer_; diff --git a/cc/animation/scrollbar_animation_controller_thinning_unittest.cc b/cc/animation/scrollbar_animation_controller_thinning_unittest.cc index 01763c9..04f81d3 100644 --- a/cc/animation/scrollbar_animation_controller_thinning_unittest.cc +++ b/cc/animation/scrollbar_animation_controller_thinning_unittest.cc @@ -9,6 +9,7 @@ #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,7 +21,7 @@ class ScrollbarAnimationControllerThinningTest public ScrollbarAnimationControllerClient { public: ScrollbarAnimationControllerThinningTest() - : host_impl_(&proxy_, &shared_bitmap_manager_) {} + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {} void StartAnimatingScrollbarAnimationController( ScrollbarAnimationController* controller) override { @@ -74,6 +75,7 @@ class ScrollbarAnimationControllerThinningTest FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; scoped_ptr scrollbar_controller_; scoped_ptr clip_layer_; diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index 72c37f8..cb84033 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -260,6 +260,8 @@ 'test/test_occlusion_tracker.h', 'test/test_shared_bitmap_manager.cc', 'test/test_shared_bitmap_manager.h', + 'test/test_task_graph_runner.cc', + 'test/test_task_graph_runner.h', 'test/test_texture.cc', 'test/test_texture.h', 'test/test_tile_priorities.cc', diff --git a/cc/debug/micro_benchmark_controller_unittest.cc b/cc/debug/micro_benchmark_controller_unittest.cc index 31494ac..2a8dce4 100644 --- a/cc/debug/micro_benchmark_controller_unittest.cc +++ b/cc/debug/micro_benchmark_controller_unittest.cc @@ -25,7 +25,7 @@ class MicroBenchmarkControllerTest : public testing::Test { impl_proxy_ = make_scoped_ptr(new FakeImplProxy); shared_bitmap_manager_.reset(new TestSharedBitmapManager()); layer_tree_host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl( - impl_proxy_.get(), shared_bitmap_manager_.get())); + impl_proxy_.get(), shared_bitmap_manager_.get(), nullptr)); layer_tree_host_ = FakeLayerTreeHost::Create(&layer_tree_host_client_); layer_tree_host_->SetRootLayer(Layer::Create()); diff --git a/cc/input/top_controls_manager_unittest.cc b/cc/input/top_controls_manager_unittest.cc index 4145cac..52e46e6 100644 --- a/cc/input/top_controls_manager_unittest.cc +++ b/cc/input/top_controls_manager_unittest.cc @@ -15,6 +15,7 @@ #include "cc/test/fake_impl_proxy.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" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/frame_time.h" @@ -28,7 +29,7 @@ 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_), + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), redraw_needed_(false), update_draw_properties_needed_(false), top_controls_shown_ratio_(1.f), @@ -83,6 +84,7 @@ class MockTopControlsManagerClient : public TopControlsManagerClient { private: FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; scoped_ptr active_tree_; scoped_ptr root_scroll_layer_; diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc index 87e559a..9e2d553 100644 --- a/cc/layers/delegated_renderer_layer_impl_unittest.cc +++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc @@ -18,6 +18,7 @@ #include "cc/test/render_pass_test_common.h" #include "cc/test/render_pass_test_utils.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/test/test_web_graphics_context_3d.h" #include "cc/trees/layer_tree_host_impl.h" #include "cc/trees/layer_tree_impl.h" @@ -37,8 +38,8 @@ class DelegatedRendererLayerImplTest : public testing::Test { LayerTreeSettings settings; settings.minimum_occlusion_tracking_size = gfx::Size(); - host_impl_.reset( - new FakeLayerTreeHostImpl(settings, &proxy_, &shared_bitmap_manager_)); + host_impl_.reset(new FakeLayerTreeHostImpl( + settings, &proxy_, &shared_bitmap_manager_, &task_graph_runner_)); host_impl_->InitializeRenderer(FakeOutputSurface::Create3d()); host_impl_->SetViewportSize(gfx::Size(10, 10)); } @@ -48,6 +49,7 @@ class DelegatedRendererLayerImplTest : public testing::Test { DebugScopedSetImplThreadAndMainThreadBlocked always_impl_thread_and_main_thread_blocked_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; scoped_ptr host_impl_; }; diff --git a/cc/layers/heads_up_display_layer_impl_unittest.cc b/cc/layers/heads_up_display_layer_impl_unittest.cc index 4b07323..ab38fdd 100644 --- a/cc/layers/heads_up_display_layer_impl_unittest.cc +++ b/cc/layers/heads_up_display_layer_impl_unittest.cc @@ -32,7 +32,7 @@ void CheckDrawLayer(HeadsUpDisplayLayerImpl* layer, TEST(HeadsUpDisplayLayerImplTest, ResourcelessSoftwareDrawAfterResourceLoss) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); scoped_ptr layer = diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc index 0dbf356..1cdbd59 100644 --- a/cc/layers/layer_impl_unittest.cc +++ b/cc/layers/layer_impl_unittest.cc @@ -13,6 +13,7 @@ #include "cc/test/fake_output_surface.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_impl.h" #include "cc/trees/single_thread_proxy.h" #include "cc/trees/tree_synchronizer.h" @@ -87,7 +88,7 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { // Create a simple LayerImpl tree: FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); scoped_ptr root_clip = LayerImpl::Create(host_impl.active_tree(), 1); @@ -250,7 +251,7 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); host_impl.active_tree()->SetRootLayer( LayerImpl::Create(host_impl.active_tree(), 1)); @@ -368,7 +369,7 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { TEST(LayerImplTest, SafeOpaqueBackgroundColor) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); scoped_ptr layer = LayerImpl::Create(host_impl.active_tree(), 1); @@ -399,7 +400,7 @@ TEST(LayerImplTest, SafeOpaqueBackgroundColor) { TEST(LayerImplTest, TransformInvertibility) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr layer = LayerImpl::Create(host_impl.active_tree(), 1); EXPECT_TRUE(layer->transform().IsInvertible()); @@ -429,7 +430,11 @@ TEST(LayerImplTest, TransformInvertibility) { class LayerImplScrollTest : public testing::Test { public: LayerImplScrollTest() - : host_impl_(settings(), &proxy_, &shared_bitmap_manager_), root_id_(7) { + : host_impl_(settings(), + &proxy_, + &shared_bitmap_manager_, + &task_graph_runner_), + root_id_(7) { host_impl_.active_tree()->SetRootLayer( LayerImpl::Create(host_impl_.active_tree(), root_id_)); host_impl_.active_tree()->root_layer()->AddChild( @@ -460,6 +465,7 @@ class LayerImplScrollTest : public testing::Test { private: FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; int root_id_; }; @@ -771,7 +777,10 @@ class LayerImplScrollbarSyncTest : public testing::Test { }; LayerImplScrollbarSyncTest() - : host_impl_(settings(), &proxy_, &shared_bitmap_manager_) { + : host_impl_(settings(), + &proxy_, + &shared_bitmap_manager_, + &task_graph_runner_) { host_impl_.CreatePendingTree(); CreateLayers(host_impl_.pending_tree()); @@ -836,6 +845,7 @@ class LayerImplScrollbarSyncTest : public testing::Test { private: FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; }; diff --git a/cc/layers/layer_perftest.cc b/cc/layers/layer_perftest.cc index 0b4c852..72b2e13 100644 --- a/cc/layers/layer_perftest.cc +++ b/cc/layers/layer_perftest.cc @@ -10,7 +10,7 @@ #include "cc/test/fake_layer_tree_host.h" #include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_layer_tree_host_impl.h" - +#include "cc/test/test_task_graph_runner.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/perf/perf_test.h" @@ -30,7 +30,7 @@ class MockLayerPainter : public LayerPainter { class LayerPerfTest : public testing::Test { public: LayerPerfTest() - : host_impl_(&proxy_, &shared_bitmap_manager_), + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), fake_client_(FakeLayerTreeHostClient::DIRECT_3D), timer_(kWarmupRuns, base::TimeDelta::FromMilliseconds(kTimeLimitMillis), @@ -50,6 +50,7 @@ class LayerPerfTest : public testing::Test { FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; FakeLayerTreeHostClient fake_client_; diff --git a/cc/layers/layer_position_constraint_unittest.cc b/cc/layers/layer_position_constraint_unittest.cc index 1c0619b..1eea9c9 100644 --- a/cc/layers/layer_position_constraint_unittest.cc +++ b/cc/layers/layer_position_constraint_unittest.cc @@ -11,6 +11,7 @@ #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_host_common.h" #include "testing/gtest/include/gtest/gtest.h" @@ -63,7 +64,8 @@ void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { class LayerPositionConstraintTest : public testing::Test { public: - LayerPositionConstraintTest() : host_impl_(&proxy_, &shared_bitmap_manager_) { + LayerPositionConstraintTest() + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) { root_ = CreateTreeForTest(); scroll_ = root_->children()[0]; fixed_to_top_left_.set_is_fixed_position(true); @@ -127,6 +129,7 @@ class LayerPositionConstraintTest : public testing::Test { protected: FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; scoped_ptr root_; LayerImpl* scroll_; diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc index 8a61510..10d774c 100644 --- a/cc/layers/layer_unittest.cc +++ b/cc/layers/layer_unittest.cc @@ -16,6 +16,7 @@ #include "cc/test/layer_test_common.h" #include "cc/test/test_gpu_memory_buffer_manager.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/single_thread_proxy.h" #include "testing/gmock/include/gmock/gmock.h" @@ -41,7 +42,7 @@ namespace { class MockLayerTreeHost : public LayerTreeHost { public: explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) - : LayerTreeHost(client, nullptr, nullptr, LayerTreeSettings()) { + : LayerTreeHost(client, nullptr, nullptr, nullptr, LayerTreeSettings()) { InitializeSingleThreaded(client, base::MessageLoopProxy::current(), nullptr); @@ -60,7 +61,7 @@ class MockLayerPainter : public LayerPainter { class LayerTest : public testing::Test { public: LayerTest() - : host_impl_(&proxy_, &shared_bitmap_manager_), + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} protected: @@ -131,6 +132,7 @@ class LayerTest : public testing::Test { FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; FakeLayerTreeHostClient fake_client_; @@ -935,24 +937,16 @@ class LayerTreeHostFactory { scoped_ptr Create() { return LayerTreeHost::CreateSingleThreaded( - &client_, - &client_, - shared_bitmap_manager_.get(), - gpu_memory_buffer_manager_.get(), - LayerTreeSettings(), - base::MessageLoopProxy::current(), - nullptr); + &client_, &client_, shared_bitmap_manager_.get(), + gpu_memory_buffer_manager_.get(), nullptr, LayerTreeSettings(), + base::MessageLoopProxy::current(), nullptr); } scoped_ptr Create(LayerTreeSettings settings) { return LayerTreeHost::CreateSingleThreaded( - &client_, - &client_, - shared_bitmap_manager_.get(), - gpu_memory_buffer_manager_.get(), - settings, - base::MessageLoopProxy::current(), - nullptr); + &client_, &client_, shared_bitmap_manager_.get(), + gpu_memory_buffer_manager_.get(), nullptr, settings, + base::MessageLoopProxy::current(), nullptr); } private: diff --git a/cc/layers/layer_utils_unittest.cc b/cc/layers/layer_utils_unittest.cc index 5764bc6..534a691 100644 --- a/cc/layers/layer_utils_unittest.cc +++ b/cc/layers/layer_utils_unittest.cc @@ -10,6 +10,7 @@ #include "cc/test/fake_impl_proxy.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" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/geometry/box_f.h" #include "ui/gfx/test/gfx_util.h" @@ -24,7 +25,7 @@ float diagonal(float width, float height) { class LayerUtilsGetAnimationBoundsTest : public testing::Test { public: LayerUtilsGetAnimationBoundsTest() - : host_impl_(&proxy_, &shared_bitmap_manager_), + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), root_(CreateThreeNodeTree(&host_impl_)), parent_(root_->children()[0]), child_(parent_->children()[0]) {} @@ -45,6 +46,7 @@ class LayerUtilsGetAnimationBoundsTest : public testing::Test { FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; scoped_ptr root_; LayerImpl* parent_; diff --git a/cc/layers/picture_image_layer_impl_unittest.cc b/cc/layers/picture_image_layer_impl_unittest.cc index 3d2d38e..87c4e58 100644 --- a/cc/layers/picture_image_layer_impl_unittest.cc +++ b/cc/layers/picture_image_layer_impl_unittest.cc @@ -13,6 +13,7 @@ #include "cc/test/fake_picture_pile_impl.h" #include "cc/test/impl_side_painting_settings.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -37,7 +38,8 @@ class PictureImageLayerImplTest : public testing::Test { : proxy_(base::MessageLoopProxy::current()), host_impl_(ImplSidePaintingSettings(), &proxy_, - &shared_bitmap_manager_) { + &shared_bitmap_manager_, + &task_graph_runner_) { host_impl_.CreatePendingTree(); host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); } @@ -82,8 +84,9 @@ class PictureImageLayerImplTest : public testing::Test { protected: FakeImplProxy proxy_; - FakeLayerTreeHostImpl host_impl_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; + FakeLayerTreeHostImpl host_impl_; }; TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index 672aab4..a0d06eb 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -95,6 +95,7 @@ void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { recording_source_->DidMoveToNewCompositor(); recording_source_->SetSlowdownRasterScaleFactor( host->debug_state().slow_down_raster_scale_factor); + recording_source_->SetGatherPixelRefs(host->settings().gather_pixel_refs); DCHECK(host->settings().raster_enabled); } diff --git a/cc/layers/picture_layer_impl_perftest.cc b/cc/layers/picture_layer_impl_perftest.cc index ea73cb2..47f49be 100644 --- a/cc/layers/picture_layer_impl_perftest.cc +++ b/cc/layers/picture_layer_impl_perftest.cc @@ -13,6 +13,7 @@ #include "cc/test/fake_picture_pile_impl.h" #include "cc/test/impl_side_painting_settings.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/perf/perf_test.h" @@ -41,7 +42,8 @@ class PictureLayerImplPerfTest : public testing::Test { : proxy_(base::MessageLoopProxy::current()), host_impl_(ImplSidePaintingSettings(), &proxy_, - &shared_bitmap_manager_), + &shared_bitmap_manager_, + &task_graph_runner_), timer_(kWarmupRuns, base::TimeDelta::FromMilliseconds(kTimeLimitMillis), kTimeCheckInterval) {} @@ -170,6 +172,7 @@ class PictureLayerImplPerfTest : public testing::Test { protected: TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeImplProxy proxy_; FakeLayerTreeHostImpl host_impl_; FakePictureLayerImpl* pending_layer_; diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 26f3be5..8c2b3ab 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -27,6 +27,7 @@ #include "cc/test/impl_side_painting_settings.h" #include "cc/test/layer_test_common.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/test/test_web_graphics_context_3d.h" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -71,7 +72,10 @@ class PictureLayerImplTest : public testing::Test { public: PictureLayerImplTest() : proxy_(base::MessageLoopProxy::current()), - host_impl_(LowResTilingsSettings(), &proxy_, &shared_bitmap_manager_), + host_impl_(LowResTilingsSettings(), + &proxy_, + &shared_bitmap_manager_, + &task_graph_runner_), root_id_(6), id_(7), pending_layer_(nullptr), @@ -82,7 +86,10 @@ class PictureLayerImplTest : public testing::Test { explicit PictureLayerImplTest(const LayerTreeSettings& settings) : proxy_(base::MessageLoopProxy::current()), - host_impl_(settings, &proxy_, &shared_bitmap_manager_), + host_impl_(settings, + &proxy_, + &shared_bitmap_manager_, + &task_graph_runner_), root_id_(6), id_(7) { host_impl_.SetViewportSize(gfx::Size(10000, 10000)); @@ -309,6 +316,7 @@ class PictureLayerImplTest : public testing::Test { FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; int root_id_; int id_; diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index ab06bb0..48d4abc 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -62,8 +62,8 @@ TEST(PictureLayerTest, NoTilesIfEmptyBounds) { DebugScopedSetImplThread impl_thread(&proxy); TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl( - ImplSidePaintingSettings(), &proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(ImplSidePaintingSettings(), &proxy, + &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); scoped_ptr layer_impl = FakePictureLayerImpl::Create(host_impl.pending_tree(), 1); @@ -130,12 +130,12 @@ TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { scoped_ptr host1 = LayerTreeHost::CreateSingleThreaded( &host_client1, &host_client1, shared_bitmap_manager.get(), nullptr, - settings, base::MessageLoopProxy::current(), nullptr); + nullptr, settings, base::MessageLoopProxy::current(), nullptr); host_client1.SetLayerTreeHost(host1.get()); scoped_ptr host2 = LayerTreeHost::CreateSingleThreaded( &host_client2, &host_client2, shared_bitmap_manager.get(), nullptr, - settings, base::MessageLoopProxy::current(), nullptr); + nullptr, settings, base::MessageLoopProxy::current(), nullptr); host_client2.SetLayerTreeHost(host2.get()); // The PictureLayer is put in one LayerTreeHost. diff --git a/cc/layers/render_surface_unittest.cc b/cc/layers/render_surface_unittest.cc index 81b15ad..929407c 100644 --- a/cc/layers/render_surface_unittest.cc +++ b/cc/layers/render_surface_unittest.cc @@ -38,7 +38,7 @@ TEST(RenderSurfaceTest, VerifySurfaceChangesAreTrackedProperly) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr owning_layer = LayerImpl::Create(host_impl.active_tree(), 1); owning_layer->SetHasRenderSurface(true); @@ -83,7 +83,7 @@ TEST(RenderSurfaceTest, VerifySurfaceChangesAreTrackedProperly) { TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr root_layer = LayerImpl::Create(host_impl.active_tree(), 1); @@ -147,7 +147,7 @@ class TestRenderPassSink : public RenderPassSink { TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectRenderPass) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr root_layer = LayerImpl::Create(host_impl.active_tree(), 1); diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc index 36c37e9..009ec3b 100644 --- a/cc/layers/scrollbar_layer_unittest.cc +++ b/cc/layers/scrollbar_layer_unittest.cc @@ -21,6 +21,7 @@ #include "cc/test/geometry_test_utils.h" #include "cc/test/layer_tree_test.h" #include "cc/test/mock_occlusion_tracker.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/test/test_web_graphics_context_3d.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_impl.h" @@ -516,8 +517,9 @@ class ScrollbarLayerSolidColorThumbTest : public testing::Test { public: ScrollbarLayerSolidColorThumbTest() { LayerTreeSettings layer_tree_settings; - host_impl_.reset(new FakeLayerTreeHostImpl( - layer_tree_settings, &proxy_, &shared_bitmap_manager_)); + host_impl_.reset(new FakeLayerTreeHostImpl(layer_tree_settings, &proxy_, + &shared_bitmap_manager_, + &task_graph_runner_)); const int kThumbThickness = 3; const int kTrackStart = 0; @@ -545,6 +547,7 @@ class ScrollbarLayerSolidColorThumbTest : public testing::Test { protected: FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; scoped_ptr host_impl_; scoped_ptr horizontal_scrollbar_layer_; scoped_ptr vertical_scrollbar_layer_; diff --git a/cc/layers/solid_color_layer_impl_unittest.cc b/cc/layers/solid_color_layer_impl_unittest.cc index d10f35d..f35b82a 100644 --- a/cc/layers/solid_color_layer_impl_unittest.cc +++ b/cc/layers/solid_color_layer_impl_unittest.cc @@ -28,7 +28,7 @@ TEST(SolidColorLayerImplTest, VerifyTilingCompleteAndNoOverlap) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr layer = SolidColorLayerImpl::Create(host_impl.active_tree(), 1); layer->draw_properties().visible_content_rect = visible_content_rect; @@ -54,7 +54,7 @@ TEST(SolidColorLayerImplTest, VerifyCorrectBackgroundColorInQuad) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr layer = SolidColorLayerImpl::Create(host_impl.active_tree(), 1); layer->draw_properties().visible_content_rect = visible_content_rect; @@ -83,7 +83,7 @@ TEST(SolidColorLayerImplTest, VerifyCorrectOpacityInQuad) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr layer = SolidColorLayerImpl::Create(host_impl.active_tree(), 1); layer->draw_properties().visible_content_rect = visible_content_rect; @@ -112,7 +112,7 @@ TEST(SolidColorLayerImplTest, VerifyCorrectBlendModeInQuad) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr layer = SolidColorLayerImpl::Create(host_impl.active_tree(), 1); layer->SetBounds(layer_size); diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index 6405db3..b088f6f 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -24,6 +24,7 @@ #include "cc/test/fake_output_surface.h" #include "cc/test/layer_test_common.h" #include "cc/test/layer_tree_test.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/test/test_web_graphics_context_3d.h" #include "cc/trees/blocking_task_runner.h" #include "cc/trees/layer_tree_host.h" @@ -51,7 +52,7 @@ gpu::Mailbox MailboxFromChar(char value) { class MockLayerTreeHost : public LayerTreeHost { public: explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) - : LayerTreeHost(client, nullptr, nullptr, LayerTreeSettings()) { + : LayerTreeHost(client, nullptr, nullptr, nullptr, LayerTreeSettings()) { InitializeSingleThreaded(client, base::MessageLoopProxy::current(), nullptr); @@ -172,7 +173,7 @@ class TextureLayerTest : public testing::Test { TextureLayerTest() : fake_client_( FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)), - host_impl_(&proxy_, &shared_bitmap_manager_), + host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), test_data_(&shared_bitmap_manager_) {} protected: @@ -195,6 +196,7 @@ class TextureLayerTest : public testing::Test { FakeImplProxy proxy_; FakeLayerTreeHostClient fake_client_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; CommonMailboxObjects test_data_; }; diff --git a/cc/layers/tiled_layer_impl_unittest.cc b/cc/layers/tiled_layer_impl_unittest.cc index e98fd09..7a47887 100644 --- a/cc/layers/tiled_layer_impl_unittest.cc +++ b/cc/layers/tiled_layer_impl_unittest.cc @@ -10,6 +10,7 @@ #include "cc/test/fake_impl_proxy.h" #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/layer_test_common.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/single_thread_proxy.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -19,7 +20,8 @@ namespace { class TiledLayerImplTest : public testing::Test { public: - TiledLayerImplTest() : host_impl_(&proxy_, &shared_bitmap_manager_) {} + TiledLayerImplTest() + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {} scoped_ptr CreateLayerNoTiles( const gfx::Size& tile_size, @@ -77,6 +79,7 @@ class TiledLayerImplTest : public testing::Test { protected: FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; }; diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc index 99cc0ca..511df0a 100644 --- a/cc/layers/tiled_layer_unittest.cc +++ b/cc/layers/tiled_layer_unittest.cc @@ -95,7 +95,7 @@ class TiledLayerTest : public testing::Test { shared_bitmap_manager_.reset(new TestSharedBitmapManager()); layer_tree_host_ = LayerTreeHost::CreateThreaded( &synchonous_output_surface_client_, shared_bitmap_manager_.get(), - nullptr, settings_, base::MessageLoopProxy::current(), + nullptr, nullptr, settings_, base::MessageLoopProxy::current(), impl_thread_.message_loop_proxy(), nullptr); synchonous_output_surface_client_.SetLayerTreeHost(layer_tree_host_.get()); proxy_ = layer_tree_host_->proxy(); @@ -116,8 +116,8 @@ class TiledLayerTest : public testing::Test { 0, false, 1); - host_impl_ = make_scoped_ptr( - new FakeLayerTreeHostImpl(proxy_, shared_bitmap_manager_.get())); + host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl( + proxy_, shared_bitmap_manager_.get(), nullptr)); } ~TiledLayerTest() override { diff --git a/cc/resources/display_list_recording_source.cc b/cc/resources/display_list_recording_source.cc index 367b23d..296036d 100644 --- a/cc/resources/display_list_recording_source.cc +++ b/cc/resources/display_list_recording_source.cc @@ -28,6 +28,7 @@ namespace cc { DisplayListRecordingSource::DisplayListRecordingSource() : slow_down_raster_scale_factor_for_debug_(0), + gather_pixel_refs_(false), requires_clear_(false), is_solid_color_(false), solid_color_(SK_ColorTRANSPARENT), @@ -135,6 +136,10 @@ void DisplayListRecordingSource::SetSlowdownRasterScaleFactor(int factor) { slow_down_raster_scale_factor_for_debug_ = factor; } +void DisplayListRecordingSource::SetGatherPixelRefs(bool gather_pixel_refs) { + gather_pixel_refs_ = gather_pixel_refs; +} + void DisplayListRecordingSource::SetBackgroundColor(SkColor background_color) { background_color_ = background_color; } diff --git a/cc/resources/display_list_recording_source.h b/cc/resources/display_list_recording_source.h index e827d29..53d7fa5 100644 --- a/cc/resources/display_list_recording_source.h +++ b/cc/resources/display_list_recording_source.h @@ -30,6 +30,7 @@ class CC_EXPORT DisplayListRecordingSource : public RecordingSource { gfx::Size GetSize() const final; void SetEmptyBounds() override; void SetSlowdownRasterScaleFactor(int factor) override; + void SetGatherPixelRefs(bool gather_pixel_refs) override; void SetBackgroundColor(SkColor background_color) override; void SetRequiresClear(bool requires_clear) override; bool IsSuitableForGpuRasterization() const override; @@ -42,6 +43,7 @@ class CC_EXPORT DisplayListRecordingSource : public RecordingSource { gfx::Rect recorded_viewport_; gfx::Size size_; int slow_down_raster_scale_factor_for_debug_; + bool gather_pixel_refs_; bool requires_clear_; bool is_solid_color_; SkColor solid_color_; diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc index 04e0801..b5b9c79 100644 --- a/cc/resources/picture_pile.cc +++ b/cc/resources/picture_pile.cc @@ -10,7 +10,6 @@ #include "cc/base/region.h" #include "cc/resources/picture_pile_impl.h" -#include "cc/resources/tile_task_worker_pool.h" #include "skia/ext/analysis_canvas.h" namespace { @@ -166,6 +165,7 @@ PicturePile::PicturePile(float min_contents_scale, const gfx::Size& tile_grid_size) : min_contents_scale_(0), slow_down_raster_scale_factor_for_debug_(0), + gather_pixel_refs_(false), has_any_recordings_(false), clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), requires_clear_(true), @@ -539,15 +539,9 @@ void PicturePile::CreatePictures(ContentLayerClient* painter, int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); scoped_refptr picture; - // Note: Currently, gathering of pixel refs when using a single - // raster thread doesn't provide any benefit. This might change - // in the future but we avoid it for now to reduce the cost of - // Picture::Create. - bool gather_pixel_refs = TileTaskWorkerPool::GetNumWorkerThreads() > 1; - for (int i = 0; i < repeat_count; i++) { picture = Picture::Create(padded_record_rect, painter, tile_grid_size_, - gather_pixel_refs, recording_mode); + gather_pixel_refs_, recording_mode); // Note the '&&' with previous is-suitable state. // This means that once a picture-pile becomes unsuitable for gpu // rasterization due to some content, it will continue to be unsuitable @@ -623,6 +617,10 @@ void PicturePile::SetSlowdownRasterScaleFactor(int factor) { slow_down_raster_scale_factor_for_debug_ = factor; } +void PicturePile::SetGatherPixelRefs(bool gather_pixel_refs) { + gather_pixel_refs_ = gather_pixel_refs; +} + void PicturePile::SetBackgroundColor(SkColor background_color) { background_color_ = background_color; } diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h index bdba579..f3c9569 100644 --- a/cc/resources/picture_pile.h +++ b/cc/resources/picture_pile.h @@ -35,6 +35,7 @@ class CC_EXPORT PicturePile : public RecordingSource { gfx::Size GetSize() const final; void SetEmptyBounds() override; void SetSlowdownRasterScaleFactor(int factor) override; + void SetGatherPixelRefs(bool gather_pixel_refs) override; void SetBackgroundColor(SkColor background_color) override; void SetRequiresClear(bool requires_clear) override; bool IsSuitableForGpuRasterization() const override; @@ -98,6 +99,7 @@ class CC_EXPORT PicturePile : public RecordingSource { float min_contents_scale_; gfx::Size tile_grid_size_; int slow_down_raster_scale_factor_for_debug_; + bool gather_pixel_refs_; // A hint about whether there are any recordings. This may be a false // positive. bool has_any_recordings_; diff --git a/cc/resources/recording_source.h b/cc/resources/recording_source.h index a202e63..98e4e87 100644 --- a/cc/resources/recording_source.h +++ b/cc/resources/recording_source.h @@ -47,6 +47,7 @@ class CC_EXPORT RecordingSource { virtual gfx::Size GetSize() const = 0; virtual void SetEmptyBounds() = 0; virtual void SetSlowdownRasterScaleFactor(int factor) = 0; + virtual void SetGatherPixelRefs(bool gather_pixel_refs) = 0; virtual void SetBackgroundColor(SkColor background_color) = 0; virtual void SetRequiresClear(bool requires_clear) = 0; virtual bool IsSuitableForGpuRasterization() const = 0; diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index 87d1837..236f918 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -18,6 +18,7 @@ #include "cc/test/fake_tile_manager_client.h" #include "cc/test/impl_side_painting_settings.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/test/test_tile_priorities.h" #include "cc/trees/layer_tree_impl.h" @@ -90,7 +91,8 @@ class TileManagerPerfTest : public testing::Test { proxy_(base::MessageLoopProxy::current()), host_impl_(ImplSidePaintingSettings(10000), &proxy_, - &shared_bitmap_manager_), + &shared_bitmap_manager_, + &task_graph_runner_), timer_(kWarmupRuns, base::TimeDelta::FromMilliseconds(kTimeLimitMillis), kTimeCheckInterval) {} @@ -407,6 +409,7 @@ class TileManagerPerfTest : public testing::Test { GlobalStateThatImpactsTilePriority global_state_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; TileMemoryLimitPolicy memory_limit_policy_; int max_tiles_; int id_; diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc index 2aa786f..e826f55 100644 --- a/cc/resources/tile_manager_unittest.cc +++ b/cc/resources/tile_manager_unittest.cc @@ -18,6 +18,7 @@ #include "cc/test/fake_tile_manager.h" #include "cc/test/impl_side_painting_settings.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/test/test_tile_priorities.h" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -38,7 +39,10 @@ class TileManagerTilePriorityQueueTest : public testing::Test { ready_to_activate_(false), id_(7), proxy_(base::MessageLoopProxy::current()), - host_impl_(LowResTilingsSettings(), &proxy_, &shared_bitmap_manager_) {} + host_impl_(LowResTilingsSettings(), + &proxy_, + &shared_bitmap_manager_, + &task_graph_runner_) {} void SetTreePriority(TreePriority tree_priority) { GlobalStateThatImpactsTilePriority state; @@ -137,6 +141,7 @@ class TileManagerTilePriorityQueueTest : public testing::Test { GlobalStateThatImpactsTilePriority global_state_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; TileMemoryLimitPolicy memory_limit_policy_; int max_tiles_; bool ready_to_activate_; diff --git a/cc/resources/tile_task_worker_pool.cc b/cc/resources/tile_task_worker_pool.cc index 2775386..0fbc7be 100644 --- a/cc/resources/tile_task_worker_pool.cc +++ b/cc/resources/tile_task_worker_pool.cc @@ -6,11 +6,7 @@ #include -#include "base/lazy_instance.h" -#include "base/strings/stringprintf.h" -#include "base/threading/simple_thread.h" #include "base/trace_event/trace_event.h" -#include "cc/base/scoped_ptr_deque.h" #include "cc/resources/raster_source.h" #include "skia/ext/refptr.h" #include "third_party/skia/include/core/SkCanvas.h" @@ -19,41 +15,6 @@ namespace cc { namespace { -base::ThreadPriority g_worker_thread_priority = base::kThreadPriority_Normal; - -class TileTaskGraphRunner : public TaskGraphRunner, - public base::DelegateSimpleThread::Delegate { - public: - TileTaskGraphRunner() { - size_t num_threads = TileTaskWorkerPool::GetNumWorkerThreads(); - while (workers_.size() < num_threads) { - scoped_ptr worker = - make_scoped_ptr(new base::DelegateSimpleThread( - this, base::StringPrintf( - "CompositorTileWorker%u", - static_cast(workers_.size() + 1)).c_str())); - worker->Start(); - worker->SetThreadPriority(g_worker_thread_priority); - workers_.push_back(worker.Pass()); - } - } - - ~TileTaskGraphRunner() override { NOTREACHED(); } - - private: - // Overridden from base::DelegateSimpleThread::Delegate: - void Run() override { TaskGraphRunner::Run(); } - - ScopedPtrDeque workers_; -}; - -base::LazyInstance::Leaky g_task_graph_runner = - LAZY_INSTANCE_INITIALIZER; - -const int kDefaultNumWorkerThreads = 1; - -int g_num_worker_threads = 0; - class TaskSetFinishedTaskImpl : public TileTask { public: explicit TaskSetFinishedTaskImpl( @@ -107,33 +68,6 @@ TileTaskWorkerPool::~TileTaskWorkerPool() { } // static -void TileTaskWorkerPool::SetNumWorkerThreads(int num_threads) { - DCHECK_LT(0, num_threads); - DCHECK_EQ(0, g_num_worker_threads); - - g_num_worker_threads = num_threads; -} - -// static -int TileTaskWorkerPool::GetNumWorkerThreads() { - if (!g_num_worker_threads) - g_num_worker_threads = kDefaultNumWorkerThreads; - - return g_num_worker_threads; -} - -// static -void TileTaskWorkerPool::SetWorkerThreadPriority( - base::ThreadPriority priority) { - g_worker_thread_priority = priority; -} - -// static -TaskGraphRunner* TileTaskWorkerPool::GetTaskGraphRunner() { - return g_task_graph_runner.Pointer(); -} - -// static scoped_refptr TileTaskWorkerPool::CreateTaskSetFinishedTask( base::SequencedTaskRunner* task_runner, const base::Closure& on_task_set_finished_callback) { diff --git a/cc/resources/tile_task_worker_pool.h b/cc/resources/tile_task_worker_pool.h index 915a3fa..90adfd1 100644 --- a/cc/resources/tile_task_worker_pool.h +++ b/cc/resources/tile_task_worker_pool.h @@ -5,7 +5,6 @@ #ifndef CC_RESOURCES_TILE_TASK_WORKER_POOL_H_ #define CC_RESOURCES_TILE_TASK_WORKER_POOL_H_ -#include "base/threading/platform_thread.h" #include "cc/resources/tile_task_runner.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" @@ -27,20 +26,6 @@ class CC_EXPORT TileTaskWorkerPool { TileTaskWorkerPool(); virtual ~TileTaskWorkerPool(); - // Set the number of threads to use for the global TaskGraphRunner instance. - // This can only be called once and must be called prior to - // GetNumWorkerThreads(). - static void SetNumWorkerThreads(int num_threads); - - // Returns the number of threads used for the global TaskGraphRunner instance. - static int GetNumWorkerThreads(); - - // Set the priority of worker threads. - static void SetWorkerThreadPriority(base::ThreadPriority priority); - - // Returns a pointer to the global TaskGraphRunner instance. - static TaskGraphRunner* GetTaskGraphRunner(); - // Utility function that can be used to create a "Task set finished" task that // posts |callback| to |task_runner| when run. static scoped_refptr CreateTaskSetFinishedTask( diff --git a/cc/resources/tile_task_worker_pool_unittest.cc b/cc/resources/tile_task_worker_pool_unittest.cc index 72f9d20..3d74daf 100644 --- a/cc/resources/tile_task_worker_pool_unittest.cc +++ b/cc/resources/tile_task_worker_pool_unittest.cc @@ -27,6 +27,7 @@ #include "cc/test/fake_picture_pile_impl.h" #include "cc/test/test_gpu_memory_buffer_manager.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/test/test_web_graphics_context_3d.h" #include "gpu/GLES2/gl2extchromium.h" #include "testing/gtest/include/gtest/gtest.h" @@ -142,39 +143,38 @@ class TileTaskWorkerPoolTest case TILE_TASK_WORKER_POOL_TYPE_PIXEL_BUFFER: Create3dOutputSurfaceAndResourceProvider(); tile_task_worker_pool_ = PixelBufferTileTaskWorkerPool::Create( - base::MessageLoopProxy::current().get(), - TileTaskWorkerPool::GetTaskGraphRunner(), context_provider_.get(), - resource_provider_.get(), kMaxTransferBufferUsageBytes); + base::MessageLoopProxy::current().get(), &task_graph_runner_, + context_provider_.get(), resource_provider_.get(), + kMaxTransferBufferUsageBytes); break; case TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY: Create3dOutputSurfaceAndResourceProvider(); tile_task_worker_pool_ = ZeroCopyTileTaskWorkerPool::Create( - base::MessageLoopProxy::current().get(), - TileTaskWorkerPool::GetTaskGraphRunner(), resource_provider_.get()); + base::MessageLoopProxy::current().get(), &task_graph_runner_, + resource_provider_.get()); break; case TILE_TASK_WORKER_POOL_TYPE_ONE_COPY: Create3dOutputSurfaceAndResourceProvider(); staging_resource_pool_ = ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); tile_task_worker_pool_ = OneCopyTileTaskWorkerPool::Create( - base::MessageLoopProxy::current().get(), - TileTaskWorkerPool::GetTaskGraphRunner(), context_provider_.get(), - resource_provider_.get(), staging_resource_pool_.get()); + base::MessageLoopProxy::current().get(), &task_graph_runner_, + context_provider_.get(), resource_provider_.get(), + staging_resource_pool_.get()); break; case TILE_TASK_WORKER_POOL_TYPE_GPU: Create3dOutputSurfaceAndResourceProvider(); rasterizer_ = GpuRasterizer::Create( context_provider_.get(), resource_provider_.get(), false, false, 0); tile_task_worker_pool_ = GpuTileTaskWorkerPool::Create( - base::MessageLoopProxy::current().get(), - TileTaskWorkerPool::GetTaskGraphRunner(), + base::MessageLoopProxy::current().get(), &task_graph_runner_, static_cast(rasterizer_.get())); break; case TILE_TASK_WORKER_POOL_TYPE_BITMAP: CreateSoftwareOutputSurfaceAndResourceProvider(); tile_task_worker_pool_ = BitmapTileTaskWorkerPool::Create( - base::MessageLoopProxy::current().get(), - TileTaskWorkerPool::GetTaskGraphRunner(), resource_provider_.get()); + base::MessageLoopProxy::current().get(), &task_graph_runner_, + resource_provider_.get()); break; } @@ -331,6 +331,7 @@ class TileTaskWorkerPoolTest scoped_ptr tile_task_worker_pool_; TestGpuMemoryBufferManager gpu_memory_buffer_manager_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; base::CancelableClosure timeout_; UniqueNotifier all_tile_tasks_finished_; int timeout_seconds_; diff --git a/cc/test/fake_layer_tree_host.cc b/cc/test/fake_layer_tree_host.cc index fe0351d..143d22e 100644 --- a/cc/test/fake_layer_tree_host.cc +++ b/cc/test/fake_layer_tree_host.cc @@ -7,9 +7,9 @@ namespace cc { FakeLayerTreeHost::FakeLayerTreeHost(FakeLayerTreeHostClient* client, const LayerTreeSettings& settings) - : LayerTreeHost(client, NULL, NULL, settings), + : LayerTreeHost(client, NULL, NULL, NULL, settings), client_(client), - host_impl_(settings, &proxy_, &manager_), + host_impl_(settings, &proxy_, &manager_, nullptr), needs_commit_(false) { client_->SetLayerTreeHost(this); } diff --git a/cc/test/fake_layer_tree_host_impl.cc b/cc/test/fake_layer_tree_host_impl.cc index ccfb203..d026120 100644 --- a/cc/test/fake_layer_tree_host_impl.cc +++ b/cc/test/fake_layer_tree_host_impl.cc @@ -10,13 +10,15 @@ namespace cc { FakeLayerTreeHostImpl::FakeLayerTreeHostImpl(Proxy* proxy, - SharedBitmapManager* manager) + SharedBitmapManager* manager, + TaskGraphRunner* task_graph_runner) : LayerTreeHostImpl(LayerTreeSettings(), &client_, proxy, &stats_instrumentation_, manager, NULL, + task_graph_runner, 0) { // Explicitly clear all debug settings. SetDebugState(LayerTreeDebugState()); @@ -30,13 +32,15 @@ FakeLayerTreeHostImpl::FakeLayerTreeHostImpl(Proxy* proxy, FakeLayerTreeHostImpl::FakeLayerTreeHostImpl(const LayerTreeSettings& settings, Proxy* proxy, - SharedBitmapManager* manager) + SharedBitmapManager* manager, + TaskGraphRunner* task_graph_runner) : LayerTreeHostImpl(settings, &client_, proxy, &stats_instrumentation_, manager, NULL, + task_graph_runner, 0) { // Explicitly clear all debug settings. SetDebugState(LayerTreeDebugState()); diff --git a/cc/test/fake_layer_tree_host_impl.h b/cc/test/fake_layer_tree_host_impl.h index ee9232e..9c8f649 100644 --- a/cc/test/fake_layer_tree_host_impl.h +++ b/cc/test/fake_layer_tree_host_impl.h @@ -14,10 +14,13 @@ namespace cc { class FakeLayerTreeHostImpl : public LayerTreeHostImpl { public: - FakeLayerTreeHostImpl(Proxy* proxy, SharedBitmapManager* manager); + FakeLayerTreeHostImpl(Proxy* proxy, + SharedBitmapManager* manager, + TaskGraphRunner* task_graph_runner); FakeLayerTreeHostImpl(const LayerTreeSettings& settings, Proxy* proxy, - SharedBitmapManager* manager); + SharedBitmapManager* manager, + TaskGraphRunner* task_graph_runner); ~FakeLayerTreeHostImpl() override; void ForcePrepareToDraw() { diff --git a/cc/test/fake_ui_resource_layer_tree_host_impl.cc b/cc/test/fake_ui_resource_layer_tree_host_impl.cc index 9e7adde..43617a6 100644 --- a/cc/test/fake_ui_resource_layer_tree_host_impl.cc +++ b/cc/test/fake_ui_resource_layer_tree_host_impl.cc @@ -12,7 +12,9 @@ namespace cc { FakeUIResourceLayerTreeHostImpl::FakeUIResourceLayerTreeHostImpl( Proxy* proxy, SharedBitmapManager* manager) - : FakeLayerTreeHostImpl(proxy, manager), fake_next_resource_id_(1) {} + : FakeLayerTreeHostImpl(proxy, manager, nullptr), + fake_next_resource_id_(1) { +} FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {} diff --git a/cc/test/layer_tree_json_parser_unittest.cc b/cc/test/layer_tree_json_parser_unittest.cc index a11d545..8286a0f 100644 --- a/cc/test/layer_tree_json_parser_unittest.cc +++ b/cc/test/layer_tree_json_parser_unittest.cc @@ -65,7 +65,7 @@ class LayerTreeJsonParserSanityCheck : public testing::Test { TEST_F(LayerTreeJsonParserSanityCheck, Basic) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); LayerTreeImpl* tree = host_impl.active_tree(); scoped_ptr root_impl(LayerImpl::Create(tree, 1)); @@ -94,7 +94,7 @@ TEST_F(LayerTreeJsonParserSanityCheck, Basic) { TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); LayerTreeImpl* tree = host_impl.active_tree(); scoped_ptr root_impl(LayerImpl::Create(tree, 1)); diff --git a/cc/test/layer_tree_pixel_resource_test.cc b/cc/test/layer_tree_pixel_resource_test.cc index 6b6c00b..2e12953 100644 --- a/cc/test/layer_tree_pixel_resource_test.cc +++ b/cc/test/layer_tree_pixel_resource_test.cc @@ -171,8 +171,7 @@ void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( draw_texture_target_); *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( - task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), - resource_provider); + task_runner, task_graph_runner(), resource_provider); break; case GPU_TILE_TASK_WORKER_POOL: EXPECT_TRUE(context_provider); @@ -182,7 +181,7 @@ void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( draw_texture_target_); *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( - task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), + task_runner, task_graph_runner(), static_cast(host_impl->rasterizer())); break; case ZERO_COPY_TILE_TASK_WORKER_POOL: @@ -193,8 +192,7 @@ void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( ResourcePool::Create(resource_provider, draw_texture_target_); *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( - task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), - resource_provider); + task_runner, task_graph_runner(), resource_provider); break; case ONE_COPY_TILE_TASK_WORKER_POOL: EXPECT_TRUE(context_provider); @@ -207,8 +205,8 @@ void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( ResourcePool::Create(resource_provider, draw_texture_target_); *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( - task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), - context_provider, resource_provider, staging_resource_pool->get()); + task_runner, task_graph_runner(), context_provider, resource_provider, + staging_resource_pool->get()); break; case PIXEL_BUFFER_TILE_TASK_WORKER_POOL: EXPECT_TRUE(context_provider); @@ -217,8 +215,8 @@ void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( resource_provider, draw_texture_target_); *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( - task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), - context_provider, resource_provider, max_transfer_buffer_usage_bytes); + task_runner, task_graph_runner(), context_provider, resource_provider, + max_transfer_buffer_usage_bytes); break; } } diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index 56ef2c1..2fff95f 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -22,6 +22,7 @@ #include "cc/test/test_context_provider.h" #include "cc/test/test_gpu_memory_buffer_manager.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/test/tiled_layer_test_common.h" #include "cc/trees/layer_tree_host_client.h" #include "cc/trees/layer_tree_host_impl.h" @@ -209,15 +210,11 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl { Proxy* proxy, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, RenderingStatsInstrumentation* stats_instrumentation) { - return make_scoped_ptr( - new LayerTreeHostImplForTesting(test_hooks, - settings, - host_impl_client, - proxy, - shared_bitmap_manager, - gpu_memory_buffer_manager, - stats_instrumentation)); + return make_scoped_ptr(new LayerTreeHostImplForTesting( + test_hooks, settings, host_impl_client, proxy, shared_bitmap_manager, + gpu_memory_buffer_manager, task_graph_runner, stats_instrumentation)); } protected: @@ -228,6 +225,7 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl { Proxy* proxy, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, RenderingStatsInstrumentation* stats_instrumentation) : LayerTreeHostImpl(settings, host_impl_client, @@ -235,6 +233,7 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl { stats_instrumentation, shared_bitmap_manager, gpu_memory_buffer_manager, + task_graph_runner, 0), test_hooks_(test_hooks), block_notify_ready_to_activate_for_testing_(false), @@ -455,12 +454,17 @@ class LayerTreeHostForTesting : public LayerTreeHost { static scoped_ptr Create( TestHooks* test_hooks, LayerTreeHostClientForTesting* client, + SharedBitmapManager* shared_bitmap_manager, + gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, const LayerTreeSettings& settings, scoped_refptr main_task_runner, scoped_refptr impl_task_runner, scoped_ptr external_begin_frame_source) { scoped_ptr layer_tree_host( - new LayerTreeHostForTesting(test_hooks, client, settings)); + new LayerTreeHostForTesting(test_hooks, client, shared_bitmap_manager, + gpu_memory_buffer_manager, + task_graph_runner, settings)); if (impl_task_runner.get()) { layer_tree_host->InitializeForTesting( ThreadProxyForTest::Create(test_hooks, @@ -483,12 +487,8 @@ class LayerTreeHostForTesting : public LayerTreeHost { scoped_ptr CreateLayerTreeHostImpl( LayerTreeHostImplClient* host_impl_client) override { return LayerTreeHostImplForTesting::Create( - test_hooks_, - settings(), - host_impl_client, - proxy(), - shared_bitmap_manager_.get(), - gpu_memory_buffer_manager_.get(), + test_hooks_, settings(), host_impl_client, proxy(), + shared_bitmap_manager_, gpu_memory_buffer_manager_, task_graph_runner_, rendering_stats_instrumentation()); } @@ -501,17 +501,23 @@ class LayerTreeHostForTesting : public LayerTreeHost { void set_test_started(bool started) { test_started_ = started; } private: - LayerTreeHostForTesting(TestHooks* test_hooks, - LayerTreeHostClient* client, - const LayerTreeSettings& settings) - : LayerTreeHost(client, NULL, NULL, settings), - shared_bitmap_manager_(new TestSharedBitmapManager), - gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), + LayerTreeHostForTesting( + TestHooks* test_hooks, + LayerTreeHostClient* client, + SharedBitmapManager* shared_bitmap_manager, + gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, + const LayerTreeSettings& settings) + : LayerTreeHost(client, NULL, NULL, NULL, settings), + shared_bitmap_manager_(shared_bitmap_manager), + gpu_memory_buffer_manager_(gpu_memory_buffer_manager), + task_graph_runner_(task_graph_runner), test_hooks_(test_hooks), test_started_(false) {} - scoped_ptr shared_bitmap_manager_; - scoped_ptr gpu_memory_buffer_manager_; + SharedBitmapManager* shared_bitmap_manager_; + gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; + TaskGraphRunner* task_graph_runner_; TestHooks* test_hooks_; bool test_started_; }; @@ -663,9 +669,8 @@ void LayerTreeTest::DoBeginTest() { DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); layer_tree_host_ = LayerTreeHostForTesting::Create( - this, - client_.get(), - settings_, + this, client_.get(), shared_bitmap_manager_.get(), + gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, base::MessageLoopProxy::current(), impl_thread_ ? impl_thread_->message_loop_proxy() : NULL, external_begin_frame_source.Pass()); @@ -793,6 +798,10 @@ void LayerTreeTest::RunTest(bool threaded, main_task_runner_ = base::MessageLoopProxy::current(); + shared_bitmap_manager_.reset(new TestSharedBitmapManager); + gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); + task_graph_runner_.reset(new TestTaskGraphRunner); + delegating_renderer_ = delegating_renderer; // Spend less time waiting for BeginFrame because the output is diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index 1ce3dcf..35a3546 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h @@ -21,6 +21,7 @@ class LayerTreeHost; class LayerTreeHostClient; class LayerTreeHostImpl; class TestContextProvider; +class TestGpuMemoryBufferManager; class TestWebGraphicsContext3D; // Used by test stubs to notify the test when something interesting happens. @@ -195,6 +196,9 @@ class LayerTreeTest : public testing::Test, public TestHooks { Proxy* proxy() const { return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; } + TaskGraphRunner* task_graph_runner() const { + return task_graph_runner_.get(); + } bool TestEnded() const { return ended_; } @@ -234,6 +238,9 @@ class LayerTreeTest : public testing::Test, public TestHooks { scoped_refptr main_task_runner_; scoped_ptr impl_thread_; + scoped_ptr shared_bitmap_manager_; + scoped_ptr gpu_memory_buffer_manager_; + scoped_ptr task_graph_runner_; base::CancelableClosure timeout_; scoped_refptr compositor_contexts_; base::WeakPtr main_thread_weak_ptr_; diff --git a/cc/test/test_task_graph_runner.cc b/cc/test/test_task_graph_runner.cc new file mode 100644 index 0000000..fe9734e --- /dev/null +++ b/cc/test/test_task_graph_runner.cc @@ -0,0 +1,23 @@ +// Copyright 2015 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 "cc/test/test_task_graph_runner.h" + +namespace cc { + +TestTaskGraphRunner::TestTaskGraphRunner() + : worker_thread_(this, "CompositorWorker") { + worker_thread_.Start(); +} + +TestTaskGraphRunner::~TestTaskGraphRunner() { + TaskGraphRunner::Shutdown(); + worker_thread_.Join(); +} + +void TestTaskGraphRunner::Run() { + TaskGraphRunner::Run(); +} + +} // namespace cc diff --git a/cc/test/test_task_graph_runner.h b/cc/test/test_task_graph_runner.h new file mode 100644 index 0000000..8314e11 --- /dev/null +++ b/cc/test/test_task_graph_runner.h @@ -0,0 +1,30 @@ +// Copyright 2015 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 CC_TEST_TEST_TASK_GRAPH_RUNNER_H_ +#define CC_TEST_TEST_TASK_GRAPH_RUNNER_H_ + +#include "base/threading/simple_thread.h" +#include "cc/resources/task_graph_runner.h" + +namespace cc { + +class TestTaskGraphRunner : public TaskGraphRunner, + public base::DelegateSimpleThread::Delegate { + public: + TestTaskGraphRunner(); + ~TestTaskGraphRunner() override; + + // Overridden from base::DelegateSimpleThread::Delegate: + void Run() override; + + private: + base::DelegateSimpleThread worker_thread_; + + DISALLOW_COPY_AND_ASSIGN(TestTaskGraphRunner); +}; + +} // namespace cc + +#endif // CC_TEST_TEST_TASK_GRAPH_RUNNER_H_ diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc index 95609d3..2df71dd 100644 --- a/cc/trees/damage_tracker_unittest.cc +++ b/cc/trees/damage_tracker_unittest.cc @@ -12,6 +12,7 @@ #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_host_common.h" #include "cc/trees/single_thread_proxy.h" #include "testing/gtest/include/gtest/gtest.h" @@ -74,7 +75,8 @@ void EmulateDrawingOneFrame(LayerImpl* root) { class DamageTrackerTest : public testing::Test { public: - DamageTrackerTest() : host_impl_(&proxy_, &shared_bitmap_manager_) {} + DamageTrackerTest() + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {} scoped_ptr CreateTestTreeWithOneSurface() { scoped_ptr root = @@ -176,6 +178,7 @@ class DamageTrackerTest : public testing::Test { protected: FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; }; diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 7814dac..9d2be10 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -56,6 +56,7 @@ scoped_ptr LayerTreeHost::CreateThreaded( LayerTreeHostClient* client, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, const LayerTreeSettings& settings, scoped_refptr main_task_runner, scoped_refptr impl_task_runner, @@ -63,7 +64,8 @@ scoped_ptr LayerTreeHost::CreateThreaded( DCHECK(main_task_runner.get()); DCHECK(impl_task_runner.get()); scoped_ptr layer_tree_host(new LayerTreeHost( - client, shared_bitmap_manager, gpu_memory_buffer_manager, settings)); + client, shared_bitmap_manager, gpu_memory_buffer_manager, + task_graph_runner, settings)); layer_tree_host->InitializeThreaded(main_task_runner, impl_task_runner, external_begin_frame_source.Pass()); @@ -75,11 +77,13 @@ scoped_ptr LayerTreeHost::CreateSingleThreaded( LayerTreeHostSingleThreadClient* single_thread_client, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, const LayerTreeSettings& settings, scoped_refptr main_task_runner, scoped_ptr external_begin_frame_source) { scoped_ptr layer_tree_host(new LayerTreeHost( - client, shared_bitmap_manager, gpu_memory_buffer_manager, settings)); + client, shared_bitmap_manager, gpu_memory_buffer_manager, + task_graph_runner, settings)); layer_tree_host->InitializeSingleThreaded(single_thread_client, main_task_runner, external_begin_frame_source.Pass()); @@ -90,6 +94,7 @@ LayerTreeHost::LayerTreeHost( LayerTreeHostClient* client, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, const LayerTreeSettings& settings) : micro_benchmark_controller_(this), next_ui_resource_id_(1), @@ -121,6 +126,7 @@ LayerTreeHost::LayerTreeHost( next_commit_forces_redraw_(false), shared_bitmap_manager_(shared_bitmap_manager), gpu_memory_buffer_manager_(gpu_memory_buffer_manager), + task_graph_runner_(task_graph_runner), surface_id_namespace_(0u), next_surface_sequence_(1u) { if (settings_.accelerated_animation_enabled) @@ -430,17 +436,14 @@ void LayerTreeHost::DidFailToInitializeOutputSurface() { scoped_ptr LayerTreeHost::CreateLayerTreeHostImpl( LayerTreeHostImplClient* client) { DCHECK(proxy_->IsImplThread()); - scoped_ptr host_impl = - LayerTreeHostImpl::Create(settings_, - client, - proxy_.get(), - rendering_stats_instrumentation_.get(), - shared_bitmap_manager_, - gpu_memory_buffer_manager_, - id_); + scoped_ptr host_impl = LayerTreeHostImpl::Create( + settings_, client, proxy_.get(), rendering_stats_instrumentation_.get(), + shared_bitmap_manager_, gpu_memory_buffer_manager_, task_graph_runner_, + id_); host_impl->SetUseGpuRasterization(UseGpuRasterization()); shared_bitmap_manager_ = NULL; gpu_memory_buffer_manager_ = NULL; + task_graph_runner_ = NULL; top_controls_manager_weak_ptr_ = host_impl->top_controls_manager()->AsWeakPtr(); input_handler_weak_ptr_ = host_impl->AsWeakPtr(); diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 1379d08..e1bcad5 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -61,6 +61,7 @@ class RenderingStatsInstrumentation; class ResourceProvider; class ResourceUpdateQueue; class SharedBitmapManager; +class TaskGraphRunner; class TopControlsManager; class UIResourceRequest; struct PendingPageScaleAnimation; @@ -75,6 +76,7 @@ class CC_EXPORT LayerTreeHost { LayerTreeHostClient* client, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, const LayerTreeSettings& settings, scoped_refptr main_task_runner, scoped_refptr impl_task_runner, @@ -85,6 +87,7 @@ class CC_EXPORT LayerTreeHost { LayerTreeHostSingleThreadClient* single_thread_client, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, const LayerTreeSettings& settings, scoped_refptr main_task_runner, scoped_ptr external_begin_frame_source); @@ -307,6 +310,7 @@ class CC_EXPORT LayerTreeHost { LayerTreeHost(LayerTreeHostClient* client, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, const LayerTreeSettings& settings); void InitializeThreaded( scoped_refptr main_task_runner, @@ -440,6 +444,7 @@ class CC_EXPORT LayerTreeHost { SharedBitmapManager* shared_bitmap_manager_; gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; + TaskGraphRunner* task_graph_runner_; ScopedPtrVector swap_promise_list_; std::set swap_promise_monitor_; diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index d18c1c8..082d14f 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -28,6 +28,7 @@ #include "cc/test/fake_picture_layer_impl.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/layer_tree_host_common_test.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_impl.h" #include "cc/trees/proxy.h" #include "cc/trees/single_thread_proxy.h" @@ -315,7 +316,7 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); gfx::Transform identity_matrix; scoped_ptr sublayer_scoped_ptr( @@ -5721,7 +5722,7 @@ TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); scoped_ptr root = LayerImpl::Create(host_impl.pending_tree(), 1); @@ -5763,7 +5764,7 @@ class LCDTextTest public testing::TestWithParam { public: LCDTextTest() - : host_impl_(&proxy_, &shared_bitmap_manager_), + : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), root_(nullptr), child_(nullptr), grand_child_(nullptr) {} @@ -5810,6 +5811,7 @@ class LCDTextTest FakeImplProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeLayerTreeHostImpl host_impl_; LayerImpl* root_; @@ -5947,7 +5949,7 @@ INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); const gfx::Transform identity_matrix; @@ -6005,7 +6007,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) { TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); const gfx::Transform identity_matrix; @@ -6050,7 +6052,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); const gfx::Transform identity_matrix; @@ -6107,7 +6109,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) { TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); const gfx::Transform identity_matrix; @@ -6152,7 +6154,7 @@ void EmptyCopyOutputCallback(scoped_ptr result) {} TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); const gfx::Transform identity_matrix; @@ -6299,7 +6301,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); const gfx::Transform identity_matrix; @@ -6374,7 +6376,7 @@ TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); const gfx::Transform identity_matrix; @@ -6985,7 +6987,7 @@ TEST_F(LayerTreeHostCommonTest, TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr root = LayerImpl::Create(host_impl.active_tree(), 12345); scoped_ptr child1 = @@ -7706,7 +7708,7 @@ TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) { // FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); scoped_ptr root = LayerImpl::Create(host_impl.active_tree(), 1); scoped_ptr container = @@ -7850,7 +7852,7 @@ TEST_F(LayerTreeHostCommonTest, // FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); host_impl.CreatePendingTree(); scoped_ptr root = LayerImpl::Create(host_impl.active_tree(), 1); scoped_ptr container = @@ -7944,7 +7946,7 @@ class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); gfx::Transform identity_matrix; scoped_ptr grand_parent = AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 1); @@ -8161,7 +8163,7 @@ static void GatherDrawnLayers(LayerImplList* rsll, TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); gfx::Transform identity_matrix; scoped_ptr grand_parent = @@ -8404,7 +8406,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); scoped_ptr root = LayerImpl::Create(host_impl.active_tree(), 1); LayerImpl* root_layer = root.get(); @@ -8684,7 +8686,7 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) { TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) { FakeImplProxy proxy; TestSharedBitmapManager shared_bitmap_manager; - FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); + FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); // Set two layers: the root layer clips it's child, // the child draws its content. diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 9965d7a..2c13fcb 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -170,14 +170,11 @@ scoped_ptr LayerTreeHostImpl::Create( RenderingStatsInstrumentation* rendering_stats_instrumentation, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, int id) { - return make_scoped_ptr(new LayerTreeHostImpl(settings, - client, - proxy, - rendering_stats_instrumentation, - shared_bitmap_manager, - gpu_memory_buffer_manager, - id)); + return make_scoped_ptr(new LayerTreeHostImpl( + settings, client, proxy, rendering_stats_instrumentation, + shared_bitmap_manager, gpu_memory_buffer_manager, task_graph_runner, id)); } LayerTreeHostImpl::LayerTreeHostImpl( @@ -187,6 +184,7 @@ LayerTreeHostImpl::LayerTreeHostImpl( RenderingStatsInstrumentation* rendering_stats_instrumentation, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, int id) : client_(client), proxy_(proxy), @@ -225,6 +223,7 @@ LayerTreeHostImpl::LayerTreeHostImpl( micro_benchmark_controller_(this), shared_bitmap_manager_(shared_bitmap_manager), gpu_memory_buffer_manager_(gpu_memory_buffer_manager), + task_graph_runner_(task_graph_runner), id_(id), requires_high_res_to_draw_(false), is_likely_to_require_a_draw_(false), @@ -2032,8 +2031,7 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( - task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), - resource_provider_.get()); + task_runner, task_graph_runner_, resource_provider_.get()); return; } @@ -2042,7 +2040,7 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( - task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), + task_runner, task_graph_runner_, static_cast(rasterizer_.get())); return; } @@ -2066,7 +2064,7 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( single_thread_synchronous_task_graph_runner_.reset(new TaskGraphRunner); task_graph_runner = single_thread_synchronous_task_graph_runner_.get(); } else { - task_graph_runner = TileTaskWorkerPool::GetTaskGraphRunner(); + task_graph_runner = task_graph_runner_; } *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( @@ -2082,9 +2080,8 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( - task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), - context_provider, resource_provider_.get(), - staging_resource_pool_.get()); + task_runner, task_graph_runner_, context_provider, + resource_provider_.get(), staging_resource_pool_.get()); return; } } @@ -2098,7 +2095,7 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( resource_provider_.get(), GL_TEXTURE_2D); *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( - task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), context_provider, + task_runner, task_graph_runner_, context_provider, resource_provider_.get(), GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(), settings_.renderer_settings.refresh_rate)); diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index b6e5903..2efe2da 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -142,6 +142,7 @@ class CC_EXPORT LayerTreeHostImpl RenderingStatsInstrumentation* rendering_stats_instrumentation, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, int id); ~LayerTreeHostImpl() override; @@ -531,6 +532,7 @@ class CC_EXPORT LayerTreeHostImpl RenderingStatsInstrumentation* rendering_stats_instrumentation, SharedBitmapManager* shared_bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + TaskGraphRunner* task_graph_runner, int id); // Virtual for testing. @@ -734,6 +736,7 @@ class CC_EXPORT LayerTreeHostImpl SharedBitmapManager* shared_bitmap_manager_; gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; + TaskGraphRunner* task_graph_runner_; int id_; std::set swap_promise_monitor_; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 1526f93..49628d1 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -54,6 +54,7 @@ #include "cc/test/render_pass_test_common.h" #include "cc/test/test_gpu_memory_buffer_manager.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/test/test_web_graphics_context_3d.h" #include "cc/trees/layer_tree_impl.h" #include "cc/trees/single_thread_proxy.h" @@ -86,6 +87,7 @@ class LayerTreeHostImplTest : public testing::Test, always_main_thread_blocked_(&proxy_), shared_bitmap_manager_(new TestSharedBitmapManager), gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), + task_graph_runner_(new TestTaskGraphRunner), on_can_draw_state_changed_called_(false), did_notify_ready_to_activate_(false), did_request_commit_(false), @@ -167,13 +169,10 @@ class LayerTreeHostImplTest : public testing::Test, virtual bool CreateHostImpl(const LayerTreeSettings& settings, scoped_ptr output_surface) { - host_impl_ = LayerTreeHostImpl::Create(settings, - this, - &proxy_, - &stats_instrumentation_, - shared_bitmap_manager_.get(), - gpu_memory_buffer_manager_.get(), - 0); + host_impl_ = LayerTreeHostImpl::Create( + settings, this, &proxy_, &stats_instrumentation_, + shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), + task_graph_runner_.get(), 0); bool init = host_impl_->InitializeRenderer(output_surface.Pass()); host_impl_->SetViewportSize(gfx::Size(10, 10)); return init; @@ -395,6 +394,7 @@ class LayerTreeHostImplTest : public testing::Test, scoped_ptr shared_bitmap_manager_; scoped_ptr gpu_memory_buffer_manager_; + scoped_ptr task_graph_runner_; scoped_ptr host_impl_; FakeRenderingStatsInstrumentation stats_instrumentation_; bool on_can_draw_state_changed_called_; @@ -1547,6 +1547,7 @@ class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { rendering_stats_instrumentation, manager, NULL, + NULL, 0) {} BeginFrameArgs CurrentBeginFrameArgs() const override { @@ -5046,16 +5047,10 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { // that we can force partial swap enabled. LayerTreeSettings settings; settings.renderer_settings.partial_swap_enabled = true; - scoped_ptr shared_bitmap_manager( - new TestSharedBitmapManager()); scoped_ptr layer_tree_host_impl = - LayerTreeHostImpl::Create(settings, - this, - &proxy_, - &stats_instrumentation_, - shared_bitmap_manager.get(), - NULL, - 0); + LayerTreeHostImpl::Create( + settings, this, &proxy_, &stats_instrumentation_, + shared_bitmap_manager_.get(), NULL, task_graph_runner_.get(), 0); layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); @@ -5343,7 +5338,7 @@ static scoped_ptr SetupLayersForOpacity( LayerTreeSettings settings; settings.renderer_settings.partial_swap_enabled = partial_swap; scoped_ptr my_host_impl = LayerTreeHostImpl::Create( - settings, client, proxy, stats_instrumentation, manager, NULL, 0); + settings, client, proxy, stats_instrumentation, manager, NULL, NULL, 0); my_host_impl->InitializeRenderer(output_surface.Pass()); my_host_impl->SetViewportSize(gfx::Size(100, 100)); @@ -6669,13 +6664,10 @@ TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails) { // doesn't support memory management extensions. TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { LayerTreeSettings settings; - host_impl_ = LayerTreeHostImpl::Create(settings, - this, - &proxy_, - &stats_instrumentation_, - shared_bitmap_manager_.get(), - gpu_memory_buffer_manager_.get(), - 0); + host_impl_ = LayerTreeHostImpl::Create( + settings, this, &proxy_, &stats_instrumentation_, + shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), + task_graph_runner_.get(), 0); scoped_ptr output_surface( FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); @@ -6716,7 +6708,7 @@ TEST_F(LayerTreeHostImplTest, MemoryPolicy) { LayerTreeSettings settings; settings.gpu_rasterization_enabled = true; host_impl_ = LayerTreeHostImpl::Create( - settings, this, &proxy_, &stats_instrumentation_, NULL, NULL, 0); + settings, this, &proxy_, &stats_instrumentation_, NULL, NULL, NULL, 0); host_impl_->SetUseGpuRasterization(true); host_impl_->SetVisible(true); host_impl_->SetMemoryPolicy(policy1); @@ -6779,8 +6771,9 @@ class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { LayerTreeSettings settings; settings.impl_side_painting = true; - fake_host_impl_ = new FakeLayerTreeHostImpl( - settings, &proxy_, shared_bitmap_manager_.get()); + fake_host_impl_ = new FakeLayerTreeHostImpl(settings, &proxy_, + shared_bitmap_manager_.get(), + task_graph_runner_.get()); host_impl_.reset(fake_host_impl_); host_impl_->InitializeRenderer(CreateOutputSurface()); host_impl_->SetViewportSize(gfx::Size(10, 10)); diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 20ef496..415b23e 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -2209,7 +2209,7 @@ class LayerTreeHostWithProxy : public LayerTreeHost { LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, const LayerTreeSettings& settings, scoped_ptr proxy) - : LayerTreeHost(client, NULL, NULL, settings) { + : LayerTreeHost(client, NULL, NULL, NULL, settings) { proxy->SetLayerTreeHost(this); client->SetLayerTreeHost(this); InitializeForTesting(proxy.Pass()); @@ -2281,14 +2281,9 @@ TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { scoped_ptr shared_bitmap_manager( new TestSharedBitmapManager()); - scoped_ptr host = - LayerTreeHost::CreateSingleThreaded(&client, - &client, - shared_bitmap_manager.get(), - NULL, - settings, - base::MessageLoopProxy::current(), - nullptr); + scoped_ptr host = LayerTreeHost::CreateSingleThreaded( + &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, + base::MessageLoopProxy::current(), nullptr); client.SetLayerTreeHost(host.get()); host->Composite(base::TimeTicks::Now()); @@ -2305,14 +2300,9 @@ TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { scoped_ptr shared_bitmap_manager( new TestSharedBitmapManager()); - scoped_ptr host = - LayerTreeHost::CreateSingleThreaded(&client, - &client, - shared_bitmap_manager.get(), - NULL, - settings, - base::MessageLoopProxy::current(), - nullptr); + scoped_ptr host = LayerTreeHost::CreateSingleThreaded( + &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, + base::MessageLoopProxy::current(), nullptr); client.SetLayerTreeHost(host.get()); host->Composite(base::TimeTicks::Now()); @@ -2329,14 +2319,9 @@ TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { scoped_ptr shared_bitmap_manager( new TestSharedBitmapManager()); - scoped_ptr host = - LayerTreeHost::CreateSingleThreaded(&client, - &client, - shared_bitmap_manager.get(), - NULL, - settings, - base::MessageLoopProxy::current(), - nullptr); + scoped_ptr host = LayerTreeHost::CreateSingleThreaded( + &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, + base::MessageLoopProxy::current(), nullptr); client.SetLayerTreeHost(host.get()); host->Composite(base::TimeTicks::Now()); @@ -2354,14 +2339,9 @@ TEST(LayerTreeHostTest, scoped_ptr shared_bitmap_manager( new TestSharedBitmapManager()); - scoped_ptr host = - LayerTreeHost::CreateSingleThreaded(&client, - &client, - shared_bitmap_manager.get(), - NULL, - settings, - base::MessageLoopProxy::current(), - nullptr); + scoped_ptr host = LayerTreeHost::CreateSingleThreaded( + &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, + base::MessageLoopProxy::current(), nullptr); client.SetLayerTreeHost(host.get()); host->Composite(base::TimeTicks::Now()); diff --git a/cc/trees/layer_tree_host_unittest_no_message_loop.cc b/cc/trees/layer_tree_host_unittest_no_message_loop.cc index 622143d..3abc4dc 100644 --- a/cc/trees/layer_tree_host_unittest_no_message_loop.cc +++ b/cc/trees/layer_tree_host_unittest_no_message_loop.cc @@ -106,7 +106,7 @@ class LayerTreeHostNoMessageLoopTest settings.verify_property_trees = true; settings.raster_enabled = false; layer_tree_host_ = LayerTreeHost::CreateSingleThreaded( - this, this, nullptr, nullptr, settings, nullptr, nullptr); + this, this, nullptr, nullptr, nullptr, settings, nullptr, nullptr); layer_tree_host_->SetViewportSize(size_); layer_tree_host_->SetRootLayer(root_layer_); } diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc index fce09d4..be972e9 100644 --- a/cc/trees/layer_tree_host_unittest_scroll.cc +++ b/cc/trees/layer_tree_host_unittest_scroll.cc @@ -1126,14 +1126,10 @@ TEST(LayerTreeHostFlingTest, DidStopFlingingThread) { ASSERT_TRUE(impl_thread.message_loop_proxy().get()); scoped_ptr shared_bitmap_manager( new TestSharedBitmapManager()); - scoped_ptr layer_tree_host = - LayerTreeHost::CreateThreaded(&client, - shared_bitmap_manager.get(), - NULL, - settings, - base::MessageLoopProxy::current(), - impl_thread.message_loop_proxy(), - nullptr); + scoped_ptr layer_tree_host = LayerTreeHost::CreateThreaded( + &client, shared_bitmap_manager.get(), NULL, NULL, settings, + base::MessageLoopProxy::current(), impl_thread.message_loop_proxy(), + nullptr); impl_thread.message_loop_proxy() ->PostTask(FROM_HERE, diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index 06df3c2..c4abd52 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc @@ -13,6 +13,7 @@ #include "cc/test/geometry_test_utils.h" #include "cc/test/layer_tree_host_common_test.h" #include "cc/test/test_shared_bitmap_manager.h" +#include "cc/test/test_task_graph_runner.h" #include "cc/trees/layer_tree_host_impl.h" #include "ui/gfx/geometry/size_conversions.h" @@ -25,8 +26,8 @@ class LayerTreeImplTest : public LayerTreeHostCommonTest { LayerTreeSettings settings; settings.layer_transforms_should_scale_layer_contents = true; settings.scrollbar_show_scale_threshold = 1.1f; - host_impl_.reset( - new FakeLayerTreeHostImpl(settings, &proxy_, &shared_bitmap_manager_)); + host_impl_.reset(new FakeLayerTreeHostImpl( + settings, &proxy_, &shared_bitmap_manager_, &task_graph_runner_)); EXPECT_TRUE(host_impl_->InitializeRenderer(FakeOutputSurface::Create3d())); } @@ -40,6 +41,7 @@ class LayerTreeImplTest : public LayerTreeHostCommonTest { private: TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; FakeImplProxy proxy_; scoped_ptr host_impl_; }; diff --git a/cc/trees/layer_tree_settings.cc b/cc/trees/layer_tree_settings.cc index d10a141..09314adc 100644 --- a/cc/trees/layer_tree_settings.cc +++ b/cc/trees/layer_tree_settings.cc @@ -70,7 +70,8 @@ LayerTreeSettings::LayerTreeSettings() use_occlusion_for_tile_prioritization(false), record_full_layer(false), use_display_lists(false), - verify_property_trees(false) { + verify_property_trees(false), + gather_pixel_refs(false) { } LayerTreeSettings::~LayerTreeSettings() {} diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h index c3dd38e5..1f61f89 100644 --- a/cc/trees/layer_tree_settings.h +++ b/cc/trees/layer_tree_settings.h @@ -83,6 +83,7 @@ class CC_EXPORT LayerTreeSettings { bool record_full_layer; bool use_display_lists; bool verify_property_trees; + bool gather_pixel_refs; LayerTreeDebugState initial_debug_state; diff --git a/cc/trees/occlusion_tracker_perftest.cc b/cc/trees/occlusion_tracker_perftest.cc index e53a05f..854dacd 100644 --- a/cc/trees/occlusion_tracker_perftest.cc +++ b/cc/trees/occlusion_tracker_perftest.cc @@ -36,13 +36,9 @@ class OcclusionTrackerPerfTest : public testing::Test { void CreateHost() { LayerTreeSettings settings; shared_bitmap_manager_.reset(new TestSharedBitmapManager()); - host_impl_ = LayerTreeHostImpl::Create(settings, - &client_, - &proxy_, - &stats_, - shared_bitmap_manager_.get(), - NULL, - 1); + host_impl_ = + LayerTreeHostImpl::Create(settings, &client_, &proxy_, &stats_, + shared_bitmap_manager_.get(), NULL, NULL, 1); host_impl_->InitializeRenderer(FakeOutputSurface::Create3d()); scoped_ptr root_layer = LayerImpl::Create(active_tree(), 1); diff --git a/cc/trees/tree_synchronizer_unittest.cc b/cc/trees/tree_synchronizer_unittest.cc index d48f821..a17bec8 100644 --- a/cc/trees/tree_synchronizer_unittest.cc +++ b/cc/trees/tree_synchronizer_unittest.cc @@ -556,13 +556,8 @@ TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { scoped_ptr shared_bitmap_manager( new TestSharedBitmapManager()); scoped_ptr host_impl = - LayerTreeHostImpl::Create(settings, - NULL, - &proxy, - &stats_instrumentation, - shared_bitmap_manager.get(), - NULL, - 0); + LayerTreeHostImpl::Create(settings, NULL, &proxy, &stats_instrumentation, + shared_bitmap_manager.get(), NULL, NULL, 0); scoped_refptr layer_tree_root = Layer::Create(); host_->SetRootLayer(layer_tree_root); @@ -595,13 +590,8 @@ TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { scoped_ptr shared_bitmap_manager( new TestSharedBitmapManager()); scoped_ptr host_impl = - LayerTreeHostImpl::Create(settings, - NULL, - &proxy, - &stats_instrumentation, - shared_bitmap_manager.get(), - NULL, - 0); + LayerTreeHostImpl::Create(settings, NULL, &proxy, &stats_instrumentation, + shared_bitmap_manager.get(), NULL, NULL, 0); scoped_refptr layer_tree_root = Layer::Create(); scoped_refptr scroll_parent = Layer::Create(); @@ -668,13 +658,8 @@ TEST_F(TreeSynchronizerTest, SynchronizeClipParent) { scoped_ptr shared_bitmap_manager( new TestSharedBitmapManager()); scoped_ptr host_impl = - LayerTreeHostImpl::Create(settings, - NULL, - &proxy, - &stats_instrumentation, - shared_bitmap_manager.get(), - NULL, - 0); + LayerTreeHostImpl::Create(settings, NULL, &proxy, &stats_instrumentation, + shared_bitmap_manager.get(), NULL, NULL, 0); scoped_refptr layer_tree_root = Layer::Create(); scoped_refptr clip_parent = Layer::Create(); -- cgit v1.1