Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: cc/test/remote_compositor_test.cc

Issue 2494623002: cc: Remove client/engine LayerTreeHostInProcess. (Closed)
Patch Set: .. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/remote_compositor_test.h ('k') | cc/test/remote_proto_channel_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/test/remote_compositor_test.h"
6
7 #include "base/threading/thread_task_runner_handle.h"
8 #include "cc/animation/animation_host.h"
9 #include "cc/blimp/compositor_proto_state.h"
10 #include "cc/blimp/layer_tree_host_remote.h"
11 #include "cc/proto/compositor_message.pb.h"
12 #include "cc/test/fake_layer_tree_host.h"
13 #include "cc/test/fake_proxy.h"
14 #include "cc/test/fake_remote_compositor_bridge.h"
15
16 namespace cc {
17 namespace {
18
19 class ProxyForCommitRequest : public FakeProxy {
20 public:
21 bool CommitRequested() const override { return true; }
22 };
23
24 class RemoteCompositorBridgeForTest : public FakeRemoteCompositorBridge {
25 public:
26 using ProtoFrameCallback = base::Callback<void(
27 std::unique_ptr<CompositorProtoState> compositor_proto_state)>;
28
29 RemoteCompositorBridgeForTest(
30 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
31 ProtoFrameCallback proto_frame_callback)
32 : FakeRemoteCompositorBridge(main_task_runner),
33 proto_frame_callback_(proto_frame_callback) {}
34
35 ~RemoteCompositorBridgeForTest() override = default;
36
37 void ProcessCompositorStateUpdate(
38 std::unique_ptr<CompositorProtoState> compositor_proto_state) override {
39 proto_frame_callback_.Run(std::move(compositor_proto_state));
40 }
41
42 private:
43 ProtoFrameCallback proto_frame_callback_;
44 };
45
46 } // namespace
47
48 RemoteCompositorTest::RemoteCompositorTest() = default;
49
50 RemoteCompositorTest::~RemoteCompositorTest() = default;
51
52 void RemoteCompositorTest::SetUp() {
53 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner =
54 base::ThreadTaskRunnerHandle::Get();
55
56 animation_host_ = AnimationHost::CreateForTesting(ThreadInstance::MAIN);
57
58 // Engine side setup.
59 LayerTreeHostRemote::InitParams params;
60 params.client = &layer_tree_host_client_remote_;
61 params.main_task_runner = main_task_runner;
62 params.mutator_host = animation_host_.get();
63 params.remote_compositor_bridge =
64 base::MakeUnique<RemoteCompositorBridgeForTest>(
65 main_task_runner,
66 base::Bind(&RemoteCompositorTest::ProcessCompositorStateUpdate,
67 base::Unretained(this)));
68 params.engine_picture_cache =
69 image_serialization_processor_.CreateEnginePictureCache();
70 LayerTreeSettings settings;
71 params.settings = &settings;
72
73 layer_tree_host_remote_ = base::MakeUnique<LayerTreeHostRemote>(&params);
74
75 // Client side setup.
76 layer_tree_host_in_process_ = FakeLayerTreeHost::Create(
77 this, &task_graph_runner_, animation_host_.get(), settings,
78 CompositorMode::THREADED);
79 layer_tree_host_in_process_->InitializeForTesting(
80 TaskRunnerProvider::Create(base::ThreadTaskRunnerHandle::Get(),
81 base::ThreadTaskRunnerHandle::Get()),
82 base::MakeUnique<ProxyForCommitRequest>());
83 std::unique_ptr<ClientPictureCache> client_picture_cache =
84 image_serialization_processor_.CreateClientPictureCache();
85 compositor_state_deserializer_ =
86 base::MakeUnique<CompositorStateDeserializer>(
87 layer_tree_host_in_process_.get(), std::move(client_picture_cache),
88 this);
89 }
90
91 void RemoteCompositorTest::TearDown() {
92 layer_tree_host_remote_ = nullptr;
93 compositor_state_deserializer_ = nullptr;
94 layer_tree_host_in_process_ = nullptr;
95 animation_host_ = nullptr;
96 }
97
98 // CompositorStateDeserializer implementation.
99 void RemoteCompositorTest::DidUpdateLocalState() {
100 client_state_dirty_ = true;
101 }
102
103 void RemoteCompositorTest::ApplyViewportDeltas(
104 const gfx::Vector2dF& inner_delta,
105 const gfx::Vector2dF& outer_delta,
106 const gfx::Vector2dF& elastic_overscroll_delta,
107 float page_scale,
108 float top_controls_delta) {
109 compositor_state_deserializer_->ApplyViewportDeltas(
110 inner_delta, outer_delta, elastic_overscroll_delta, page_scale,
111 top_controls_delta);
112 }
113
114 void RemoteCompositorTest::ProcessCompositorStateUpdate(
115 std::unique_ptr<CompositorProtoState> compositor_proto_state) {
116 compositor_state_deserializer_->DeserializeCompositorUpdate(
117 compositor_proto_state->compositor_message->layer_tree_host());
118 }
119
120 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/remote_compositor_test.h ('k') | cc/test/remote_proto_channel_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698