Skip to content

Commit

Permalink
Move GpuMemoryBufferManager and SharedBitmapManager to CompositorFram…
Browse files Browse the repository at this point in the history
…eSink

They're only used by the ResourceProvider, so there's no fundamental reason for
them to take a separate path through the compositor. Besides, it is natural that
the CompositorFrameSink contains all the objects needed to create resources, all
at the same place. Finally, it's less code overall.

BUG=None
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel

Review-Url: https://codereview.chromium.org/2452483002
Cr-Commit-Position: refs/heads/master@{#428551}
  • Loading branch information
pimanttr authored and Commit bot committed Oct 29, 2016
1 parent 614913e commit c44437a
Show file tree
Hide file tree
Showing 98 changed files with 273 additions and 514 deletions.
7 changes: 3 additions & 4 deletions blimp/client/core/compositor/blimp_compositor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ void BlimpCompositor::OnContextProvidersCreated(

auto compositor_frame_sink = base::MakeUnique<BlimpCompositorFrameSink>(
std::move(compositor_context_provider),
std::move(worker_context_provider), base::ThreadTaskRunnerHandle::Get(),
weak_ptr_factory_.GetWeakPtr());
std::move(worker_context_provider),
GetEmbedderDeps()->GetGpuMemoryBufferManager(), nullptr,
base::ThreadTaskRunnerHandle::Get(), weak_ptr_factory_.GetWeakPtr());

host_->SetCompositorFrameSink(std::move(compositor_frame_sink));
}
Expand Down Expand Up @@ -363,8 +364,6 @@ void BlimpCompositor::CreateLayerTreeHost() {
cc::LayerTreeHostInProcess::InitParams params;
params.client = this;
params.task_graph_runner = compositor_dependencies_->GetTaskGraphRunner();
params.gpu_memory_buffer_manager =
GetEmbedderDeps()->GetGpuMemoryBufferManager();
params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
if (!use_threaded_layer_tree_host_) {
params.image_serialization_processor =
Expand Down
6 changes: 5 additions & 1 deletion blimp/client/core/compositor/blimp_compositor_frame_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ namespace client {
BlimpCompositorFrameSink::BlimpCompositorFrameSink(
scoped_refptr<cc::ContextProvider> compositor_context_provider,
scoped_refptr<cc::ContextProvider> worker_context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
cc::SharedBitmapManager* shared_bitmap_manager,
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
base::WeakPtr<BlimpCompositorFrameSinkProxy> main_thread_proxy)
: cc::CompositorFrameSink(std::move(compositor_context_provider),
std::move(worker_context_provider)),
std::move(worker_context_provider),
gpu_memory_buffer_manager,
shared_bitmap_manager),
main_task_runner_(std::move(main_task_runner)),
main_thread_proxy_(main_thread_proxy),
weak_factory_(this) {
Expand Down
2 changes: 2 additions & 0 deletions blimp/client/core/compositor/blimp_compositor_frame_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class BlimpCompositorFrameSink : public cc::CompositorFrameSink,
BlimpCompositorFrameSink(
scoped_refptr<cc::ContextProvider> compositor_context_provider,
scoped_refptr<cc::ContextProvider> worker_context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
cc::SharedBitmapManager* shared_bitmap_manager,
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
base::WeakPtr<BlimpCompositorFrameSinkProxy> main_thread_proxy);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class BlimpCompositorFrameSinkTest : public testing::Test {
main_thread_proxy_ = base::MakeUnique<FakeBlimpCompositorFrameSinkProxy>(
compositor_task_runner_);
compositor_frame_sink_ = base::MakeUnique<BlimpCompositorFrameSink>(
TestContextProvider::Create(bind_should_fail), nullptr,
main_task_runner_, main_thread_proxy_->GetWeakPtr());
TestContextProvider::Create(bind_should_fail), nullptr, nullptr,
nullptr, main_task_runner_, main_thread_proxy_->GetWeakPtr());

base::WaitableEvent init_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
Expand Down
8 changes: 4 additions & 4 deletions blimp/client/support/compositor/blimp_embedder_compositor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ BlimpEmbedderCompositor::BlimpEmbedderCompositor(

cc::LayerTreeHostInProcess::InitParams params;
params.client = this;
params.gpu_memory_buffer_manager =
compositor_dependencies_->GetGpuMemoryBufferManager();
params.task_graph_runner = g_task_graph_runner.Pointer();
cc::LayerTreeSettings settings;
params.settings = &settings;
Expand Down Expand Up @@ -203,6 +201,7 @@ void BlimpEmbedderCompositor::HandlePendingCompositorFrameSinkRequest() {

gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager =
compositor_dependencies_->GetGpuMemoryBufferManager();
cc::SharedBitmapManager* shared_bitmap_manager = nullptr;

auto task_runner = base::ThreadTaskRunnerHandle::Get();
auto display_output_surface =
Expand All @@ -216,7 +215,7 @@ void BlimpEmbedderCompositor::HandlePendingCompositorFrameSinkRequest() {
display_output_surface->capabilities().max_frames_pending));

display_ = base::MakeUnique<cc::Display>(
nullptr /*shared_bitmap_manager*/, gpu_memory_buffer_manager,
shared_bitmap_manager, gpu_memory_buffer_manager,
host_->GetSettings().renderer_settings, std::move(begin_frame_source),
std::move(display_output_surface), std::move(scheduler),
base::MakeUnique<cc::TextureMailboxDeleter>(task_runner.get()));
Expand All @@ -226,7 +225,8 @@ void BlimpEmbedderCompositor::HandlePendingCompositorFrameSinkRequest() {
// The Browser compositor and display share the same context provider.
auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>(
frame_sink_id_, compositor_dependencies_->GetSurfaceManager(),
display_.get(), context_provider_, nullptr);
display_.get(), context_provider_, nullptr, gpu_memory_buffer_manager,
shared_bitmap_manager);

host_->SetCompositorFrameSink(std::move(compositor_frame_sink));
}
Expand Down
4 changes: 1 addition & 3 deletions cc/debug/micro_benchmark_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class MicroBenchmarkControllerTest : public testing::Test {
impl_task_runner_provider_ =
base::WrapUnique(new FakeImplTaskRunnerProvider);
layer_tree_host_impl_ = base::MakeUnique<FakeLayerTreeHostImpl>(
impl_task_runner_provider_.get(), &shared_bitmap_manager_,
&task_graph_runner_);
impl_task_runner_provider_.get(), &task_graph_runner_);

layer_tree_host_ = FakeLayerTreeHost::Create(&layer_tree_host_client_,
&task_graph_runner_);
Expand All @@ -46,7 +45,6 @@ class MicroBenchmarkControllerTest : public testing::Test {

FakeLayerTreeHostClient layer_tree_host_client_;
TestTaskGraphRunner task_graph_runner_;
TestSharedBitmapManager shared_bitmap_manager_;
std::unique_ptr<FakeLayerTreeHost> layer_tree_host_;
std::unique_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_;
std::unique_ptr<FakeImplTaskRunnerProvider> impl_task_runner_provider_;
Expand Down
3 changes: 0 additions & 3 deletions cc/input/browser_controls_offset_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "cc/layers/layer_impl.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -30,7 +29,6 @@ class MockBrowserControlsOffsetManagerClient
float browser_controls_show_threshold,
float browser_controls_hide_threshold)
: host_impl_(&task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_),
redraw_needed_(false),
update_draw_properties_needed_(false),
Expand Down Expand Up @@ -92,7 +90,6 @@ class MockBrowserControlsOffsetManagerClient

private:
FakeImplTaskRunnerProvider task_runner_provider_;
TestSharedBitmapManager shared_bitmap_manager_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;
std::unique_ptr<LayerTreeImpl> active_tree_;
Expand Down
4 changes: 1 addition & 3 deletions cc/input/scroll_state_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ TEST_F(ScrollStateTest, CurrentNativeScrollingScrollable) {
ScrollState scroll_state(scroll_state_data);

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

std::unique_ptr<LayerImpl> layer_impl =
LayerImpl::Create(host_impl.active_tree(), 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -22,7 +21,6 @@ class ScrollbarAnimationControllerLinearFadeTest
public:
ScrollbarAnimationControllerLinearFadeTest()
: host_impl_(&task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_),
did_request_redraw_(false),
did_request_animate_(false) {}
Expand Down Expand Up @@ -79,7 +77,6 @@ class ScrollbarAnimationControllerLinearFadeTest
virtual ScrollbarOrientation orientation() const { return HORIZONTAL; }

FakeImplTaskRunnerProvider task_runner_provider_;
TestSharedBitmapManager shared_bitmap_manager_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;
std::unique_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_;
Expand Down
3 changes: 0 additions & 3 deletions cc/input/scrollbar_animation_controller_thinning_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -27,7 +26,6 @@ class ScrollbarAnimationControllerThinningTest
public:
ScrollbarAnimationControllerThinningTest()
: host_impl_(&task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_) {}

void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade,
Expand Down Expand Up @@ -89,7 +87,6 @@ class ScrollbarAnimationControllerThinningTest
}

FakeImplTaskRunnerProvider task_runner_provider_;
TestSharedBitmapManager shared_bitmap_manager_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;
std::unique_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_;
Expand Down
5 changes: 1 addition & 4 deletions cc/layers/heads_up_display_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "cc/test/fake_compositor_frame_sink.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -35,12 +34,10 @@ void CheckDrawLayer(HeadsUpDisplayLayerImpl* layer,

TEST(HeadsUpDisplayLayerImplTest, ResourcelessSoftwareDrawAfterResourceLoss) {
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
FakeCompositorFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
host_impl.CreatePendingTree();
host_impl.SetVisible(true);
host_impl.InitializeRenderer(compositor_frame_sink.get());
Expand Down
15 changes: 3 additions & 12 deletions cc/layers/layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
Expand Down Expand Up @@ -124,12 +123,10 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {
// The constructor on this will fake that we are on the correct thread.
// Create a simple LayerImpl tree:
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
FakeCompositorFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
host_impl.SetVisible(true);
EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
std::unique_ptr<LayerImpl> root_clip_ptr =
Expand Down Expand Up @@ -244,12 +241,10 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {

TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
FakeCompositorFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
host_impl.SetVisible(true);
EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
host_impl.active_tree()->SetRootLayerForTesting(
Expand Down Expand Up @@ -374,12 +369,10 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {

TEST(LayerImplTest, SafeOpaqueBackgroundColor) {
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
FakeCompositorFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
host_impl.SetVisible(true);
EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
host_impl.active_tree()->SetRootLayerForTesting(
Expand Down Expand Up @@ -417,7 +410,6 @@ class LayerImplScrollTest : public testing::Test {
LayerImplScrollTest()
: host_impl_(settings(),
&task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_),
root_id_(7) {
host_impl_.active_tree()->SetRootLayerForTesting(
Expand Down Expand Up @@ -460,7 +452,6 @@ class LayerImplScrollTest : public testing::Test {

private:
FakeImplTaskRunnerProvider task_runner_provider_;
TestSharedBitmapManager shared_bitmap_manager_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;
int root_id_;
Expand Down
6 changes: 1 addition & 5 deletions cc/layers/layer_iterator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,14 @@ void IterateFrontToBack(LayerImplList* render_surface_layer_list) {
class LayerIteratorTest : public testing::Test {
public:
LayerIteratorTest()
: host_impl_(&task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_),
id_(1) {}
: host_impl_(&task_runner_provider_, &task_graph_runner_), id_(1) {}

std::unique_ptr<TestLayerImpl> CreateLayer() {
return TestLayerImpl::Create(host_impl_.active_tree(), id_++);
}

protected:
FakeImplTaskRunnerProvider task_runner_provider_;
TestSharedBitmapManager shared_bitmap_manager_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;

Expand Down
17 changes: 4 additions & 13 deletions cc/layers/layer_list_iterator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/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"
Expand Down Expand Up @@ -198,12 +197,10 @@ TEST(LayerListReverseIteratorTest, VerifyNullFirstLayer) {
TEST(LayerListIteratorTest, VerifyTraversalOrderImpl) {
// Unfortunate preamble.
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
FakeCompositorFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
host_impl.SetVisible(true);
EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));

Expand Down Expand Up @@ -253,12 +250,10 @@ TEST(LayerListIteratorTest, VerifyTraversalOrderImpl) {
TEST(LayerListIteratorTest, VerifySingleLayerImpl) {
// Unfortunate preamble.
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
FakeCompositorFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
host_impl.SetVisible(true);
EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));

Expand Down Expand Up @@ -290,12 +285,10 @@ TEST(LayerListIteratorTest, VerifyNullFirstLayerImpl) {
TEST(LayerListReverseIteratorTest, VerifyTraversalOrderImpl) {
// Unfortunate preamble.
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
FakeCompositorFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
host_impl.SetVisible(true);
EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));

Expand Down Expand Up @@ -347,12 +340,10 @@ TEST(LayerListReverseIteratorTest, VerifyTraversalOrderImpl) {
TEST(LayerListReverseIteratorTest, VerifySingleLayerImpl) {
// Unfortunate preamble.
FakeImplTaskRunnerProvider task_runner_provider;
TestSharedBitmapManager shared_bitmap_manager;
TestTaskGraphRunner task_graph_runner;
std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
FakeCompositorFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
&task_graph_runner);
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
host_impl.SetVisible(true);
EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));

Expand Down
5 changes: 1 addition & 4 deletions cc/layers/layer_perftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ static const int kTimeCheckInterval = 10;
class LayerPerfTest : public testing::Test {
public:
LayerPerfTest()
: host_impl_(&task_runner_provider_,
&shared_bitmap_manager_,
&task_graph_runner_),
: host_impl_(&task_runner_provider_, &task_graph_runner_),
timer_(kWarmupRuns,
base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
kTimeCheckInterval) {}
Expand All @@ -46,7 +44,6 @@ class LayerPerfTest : public testing::Test {
}

FakeImplTaskRunnerProvider task_runner_provider_;
TestSharedBitmapManager shared_bitmap_manager_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;

Expand Down
Loading

0 comments on commit c44437a

Please sign in to comment.