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

Side by Side Diff: cc/test/layer_tree_test.h

Issue 1506023008: [NOT LANDED] Revert of cc: Split ThreadProxy into ProxyMain and ProxyImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/test/layer_tree_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_TEST_LAYER_TREE_TEST_H_ 5 #ifndef CC_TEST_LAYER_TREE_TEST_H_
6 #define CC_TEST_LAYER_TREE_TEST_H_ 6 #define CC_TEST_LAYER_TREE_TEST_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "cc/animation/animation_delegate.h" 10 #include "cc/animation/animation_delegate.h"
11 #include "cc/layers/layer_settings.h" 11 #include "cc/layers/layer_settings.h"
12 #include "cc/test/proxy_impl_for_test.h"
13 #include "cc/test/proxy_main_for_test.h"
14 #include "cc/test/test_hooks.h"
15 #include "cc/trees/layer_tree_host.h" 12 #include "cc/trees/layer_tree_host.h"
16 #include "cc/trees/layer_tree_host_impl.h" 13 #include "cc/trees/layer_tree_host_impl.h"
17 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
18 15
19 namespace cc { 16 namespace cc {
20 class AnimationPlayer; 17 class AnimationPlayer;
21 class FakeExternalBeginFrameSource; 18 class FakeExternalBeginFrameSource;
22 class FakeLayerTreeHostClient; 19 class FakeLayerTreeHostClient;
23 class FakeOutputSurface; 20 class FakeOutputSurface;
24 class LayerImpl; 21 class LayerImpl;
(...skipping 17 matching lines...) Expand all
42 39
43 // Creates the virtual viewport layer hierarchy under the given root_layer. 40 // Creates the virtual viewport layer hierarchy under the given root_layer.
44 // Uses the given scroll layer as the content "outer viewport scroll layer". 41 // Uses the given scroll layer as the content "outer viewport scroll layer".
45 void CreateVirtualViewportLayers(Layer* root_layer, 42 void CreateVirtualViewportLayers(Layer* root_layer,
46 scoped_refptr<Layer> outer_scroll_layer, 43 scoped_refptr<Layer> outer_scroll_layer,
47 const gfx::Size& outer_bounds, 44 const gfx::Size& outer_bounds,
48 const gfx::Size& scroll_bounds, 45 const gfx::Size& scroll_bounds,
49 LayerTreeHost* host, 46 LayerTreeHost* host,
50 const LayerSettings& layer_settings); 47 const LayerSettings& layer_settings);
51 48
49 // Used by test stubs to notify the test when something interesting happens.
50 class TestHooks : public AnimationDelegate {
51 public:
52 TestHooks();
53 ~TestHooks() override;
54
55 void ReadSettings(const LayerTreeSettings& settings);
56
57 virtual void CreateResourceAndTileTaskWorkerPool(
58 LayerTreeHostImpl* host_impl,
59 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
60 scoped_ptr<ResourcePool>* resource_pool);
61 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
62 const BeginFrameArgs& args) {}
63 virtual void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) {}
64 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
65 CommitEarlyOutReason reason) {}
66 virtual void WillPrepareTiles(LayerTreeHostImpl* host_impl) {}
67 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) {}
68 virtual void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) {}
69 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) {}
70 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) {}
71 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) {}
72 virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
73 bool success) {}
74 virtual DrawResult PrepareToDrawOnThread(
75 LayerTreeHostImpl* host_impl,
76 LayerTreeHostImpl::FrameData* frame_data,
77 DrawResult draw_result);
78 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) {}
79 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) {}
80 virtual void SwapBuffersCompleteOnThread(LayerTreeHostImpl* host_impl) {}
81 virtual void NotifyReadyToActivateOnThread(LayerTreeHostImpl* host_impl) {}
82 virtual void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) {}
83 virtual void NotifyAllTileTasksCompleted(LayerTreeHostImpl* host_impl) {}
84 virtual void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl,
85 const Tile* tile) {}
86 virtual void AnimateLayers(LayerTreeHostImpl* host_impl,
87 base::TimeTicks monotonic_time) {}
88 virtual void UpdateAnimationState(LayerTreeHostImpl* host_impl,
89 bool has_unfinished_animation) {}
90 virtual void WillAnimateLayers(LayerTreeHostImpl* host_impl,
91 base::TimeTicks monotonic_time) {}
92 virtual void ApplyViewportDeltas(
93 const gfx::Vector2dF& inner_delta,
94 const gfx::Vector2dF& outer_delta,
95 const gfx::Vector2dF& elastic_overscroll_delta,
96 float scale,
97 float top_controls_delta) {}
98 virtual void BeginMainFrame(const BeginFrameArgs& args) {}
99 virtual void WillBeginMainFrame() {}
100 virtual void DidBeginMainFrame() {}
101 virtual void UpdateLayerTreeHost() {}
102 virtual void DidInitializeOutputSurface() {}
103 virtual void DidFailToInitializeOutputSurface() {}
104 virtual void DidAddAnimation() {}
105 virtual void WillCommit() {}
106 virtual void DidCommit() {}
107 virtual void DidCommitAndDrawFrame() {}
108 virtual void DidCompleteSwapBuffers() {}
109 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl,
110 bool visible) {}
111 virtual void ScheduleComposite() {}
112 virtual void DidSetNeedsUpdateLayers() {}
113 virtual void DidActivateSyncTree() {}
114
115 // Hooks for SchedulerClient.
116 virtual void ScheduledActionWillSendBeginMainFrame() {}
117 virtual void ScheduledActionSendBeginMainFrame() {}
118 virtual void ScheduledActionDrawAndSwapIfPossible() {}
119 virtual void ScheduledActionCommit() {}
120 virtual void ScheduledActionBeginOutputSurfaceCreation() {}
121 virtual void ScheduledActionPrepareTiles() {}
122 virtual void ScheduledActionInvalidateOutputSurface() {}
123 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) {}
124 virtual void SendBeginMainFrameNotExpectedSoon() {}
125
126 // Hooks for ProxyImpl
127 virtual void SetThrottleFrameProductionOnImpl(bool throttle) {}
128 virtual void UpdateTopControlsStateOnImpl(TopControlsState constraints,
129 TopControlsState current,
130 bool animate) {}
131 virtual void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) {}
132 virtual void MainThreadHasStoppedFlingingOnImpl() {}
133 virtual void SetInputThrottledUntilCommitOnImpl(bool is_throttled) {}
134 virtual void SetDeferCommitsOnImpl(bool defer_commits) {}
135 virtual void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) {}
136 virtual void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) {}
137 virtual void SetNeedsCommitOnImpl() {}
138 virtual void FinishAllRenderingOnImpl() {}
139 virtual void SetVisibleOnImpl(bool visible) {}
140 virtual void ReleaseOutputSurfaceOnImpl() {}
141 virtual void FinishGLOnImpl() {}
142 virtual void StartCommitOnImpl() {}
143 virtual void InitializeImplOnImpl() {}
144 virtual void WillCloseLayerTreeHostOnImpl() {}
145
146 // Hooks for ProxyMain
147 virtual void ReceivedDidCompleteSwapBuffers() {}
148 virtual void ReceivedSetRendererCapabilitiesMainCopy(
149 const RendererCapabilities& capabilities) {}
150 virtual void ReceivedBeginMainFrameNotExpectedSoon() {}
151 virtual void ReceivedDidCommitAndDrawFrame() {}
152 virtual void ReceivedSetAnimationEvents() {}
153 virtual void ReceivedDidLoseOutputSurface() {}
154 virtual void ReceivedRequestNewOutputSurface() {}
155 virtual void ReceivedDidInitializeOutputSurface(
156 bool success,
157 const RendererCapabilities& capabilities) {}
158 virtual void ReceivedDidCompletePageScaleAnimation() {}
159 virtual void ReceivedPostFrameTimingEventsOnMain() {}
160 virtual void ReceivedBeginMainFrame() {}
161
162 // Implementation of AnimationDelegate:
163 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
164 Animation::TargetProperty target_property,
165 int group) override {}
166 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
167 Animation::TargetProperty target_property,
168 int group) override {}
169
170 virtual void RequestNewOutputSurface() = 0;
171 };
172
52 class BeginTask; 173 class BeginTask;
53 class LayerTreeHostClientForTesting; 174 class LayerTreeHostClientForTesting;
54 class TimeoutTask; 175 class TimeoutTask;
55 176
56 // The LayerTreeTests runs with the main loop running. It instantiates a single 177 // The LayerTreeTests runs with the main loop running. It instantiates a single
57 // LayerTreeHostForTesting and associated LayerTreeHostImplForTesting and 178 // LayerTreeHostForTesting and associated LayerTreeHostImplForTesting and
58 // LayerTreeHostClientForTesting. 179 // LayerTreeHostClientForTesting.
59 // 180 //
60 // BeginTest() is called once the main message loop is running and the layer 181 // BeginTest() is called once the main message loop is running and the layer
61 // tree host is initialized. 182 // tree host is initialized.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void DispatchSetVisible(bool visible); 243 void DispatchSetVisible(bool visible);
123 void DispatchSetNextCommitForcesRedraw(); 244 void DispatchSetNextCommitForcesRedraw();
124 void DispatchDidAddAnimation(); 245 void DispatchDidAddAnimation();
125 void DispatchCompositeImmediately(); 246 void DispatchCompositeImmediately();
126 247
127 virtual void AfterTest() = 0; 248 virtual void AfterTest() = 0;
128 virtual void WillBeginTest(); 249 virtual void WillBeginTest();
129 virtual void BeginTest() = 0; 250 virtual void BeginTest() = 0;
130 virtual void SetupTree(); 251 virtual void SetupTree();
131 252
132 // TODO(khushalsagar): Add mode for running remote channel tests.
133 virtual void RunTest(CompositorMode mode, bool delegating_renderer); 253 virtual void RunTest(CompositorMode mode, bool delegating_renderer);
134 254
135 bool HasImplThread() const { return !!impl_thread_; } 255 bool HasImplThread() { return !!impl_thread_; }
136 base::SingleThreadTaskRunner* ImplThreadTaskRunner() { 256 base::SingleThreadTaskRunner* ImplThreadTaskRunner() {
137 DCHECK(task_runner_provider()); 257 DCHECK(task_runner_provider());
138 base::SingleThreadTaskRunner* impl_thread_task_runner = 258 base::SingleThreadTaskRunner* impl_thread_task_runner =
139 task_runner_provider()->ImplThreadTaskRunner(); 259 task_runner_provider()->ImplThreadTaskRunner();
140 return impl_thread_task_runner ? impl_thread_task_runner 260 return impl_thread_task_runner ? impl_thread_task_runner
141 : main_task_runner_.get(); 261 : main_task_runner_.get();
142 } 262 }
143 base::SingleThreadTaskRunner* MainThreadTaskRunner() { 263 base::SingleThreadTaskRunner* MainThreadTaskRunner() {
144 return main_task_runner_.get(); 264 return main_task_runner_.get();
145 } 265 }
146 Proxy* proxy() const { 266 Proxy* proxy() const {
147 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; 267 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL;
148 } 268 }
149 TaskRunnerProvider* task_runner_provider() const { 269 TaskRunnerProvider* task_runner_provider() const {
150 return layer_tree_host_ ? layer_tree_host_->task_runner_provider() 270 return layer_tree_host_ ? layer_tree_host_->task_runner_provider()
151 : nullptr; 271 : nullptr;
152 } 272 }
153 TaskGraphRunner* task_graph_runner() const; 273 TaskGraphRunner* task_graph_runner() const;
154 bool TestEnded() const { return ended_; } 274 bool TestEnded() const { return ended_; }
155 275
156 LayerTreeHost* layer_tree_host(); 276 LayerTreeHost* layer_tree_host();
157 bool delegating_renderer() const { return delegating_renderer_; } 277 bool delegating_renderer() const { return delegating_renderer_; }
158 FakeOutputSurface* output_surface() { return output_surface_; } 278 FakeOutputSurface* output_surface() { return output_surface_; }
159 int LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) const; 279 int LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) const;
160 280
161 // Use these only for ProxyMain tests in threaded mode.
162 // TODO(khushalsagar): Update these when adding support for remote channel
163 // tests.
164 ProxyMainForTest* GetProxyMainForTest() const;
165 ProxyImplForTest* GetProxyImplForTest() const;
166
167 void DestroyLayerTreeHost(); 281 void DestroyLayerTreeHost();
168 282
169 // By default, output surface recreation is synchronous. 283 // By default, output surface recreation is synchronous.
170 void RequestNewOutputSurface() override; 284 void RequestNewOutputSurface() override;
171 // Override this for pixel tests, where you need a real output surface. 285 // Override this for pixel tests, where you need a real output surface.
172 virtual scoped_ptr<OutputSurface> CreateOutputSurface(); 286 virtual scoped_ptr<OutputSurface> CreateOutputSurface();
173 // Override this for unit tests, which should not produce pixel output. 287 // Override this for unit tests, which should not produce pixel output.
174 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(); 288 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface();
175 289
176 TestWebGraphicsContext3D* TestContext(); 290 TestWebGraphicsContext3D* TestContext();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ 371 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \
258 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ 372 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \
259 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) 373 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME)
260 374
261 // Some tests want to control when notify ready for activation occurs, 375 // Some tests want to control when notify ready for activation occurs,
262 // but this is not supported in the single-threaded case. 376 // but this is not supported in the single-threaded case.
263 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ 377 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \
264 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) 378 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME)
265 379
266 #endif // CC_TEST_LAYER_TREE_TEST_H_ 380 #endif // CC_TEST_LAYER_TREE_TEST_H_
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/test/layer_tree_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698