OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
| 7 #include "base/memory/weak_ptr.h" |
7 #include "cc/base/thread_impl.h" | 8 #include "cc/base/thread_impl.h" |
8 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
9 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
10 #include "cc/layers/layer_impl.h" | 11 #include "cc/layers/layer_impl.h" |
11 #include "cc/test/fake_content_layer_client.h" | 12 #include "cc/test/fake_content_layer_client.h" |
12 #include "cc/test/fake_layer_tree_host_client.h" | 13 #include "cc/test/fake_layer_tree_host_client.h" |
13 #include "cc/test/geometry_test_utils.h" | 14 #include "cc/test/geometry_test_utils.h" |
14 #include "cc/test/layer_tree_test.h" | 15 #include "cc/test/layer_tree_test.h" |
15 #include "cc/trees/layer_tree_impl.h" | 16 #include "cc/trees/layer_tree_impl.h" |
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerScrollClien
t.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerScrollClien
t.h" |
17 #include "ui/gfx/point_conversions.h" | 18 #include "ui/gfx/point_conversions.h" |
18 #include "ui/gfx/size_conversions.h" | 19 #include "ui/gfx/size_conversions.h" |
19 #include "ui/gfx/vector2d_conversions.h" | 20 #include "ui/gfx/vector2d_conversions.h" |
20 | 21 |
21 namespace cc { | 22 namespace cc { |
22 namespace { | 23 namespace { |
23 | 24 |
24 class LayerTreeHostScrollTest : public LayerTreeTest {}; | 25 class LayerTreeHostScrollTest : public LayerTreeTest {}; |
25 | 26 |
26 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest { | 27 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest { |
27 public: | 28 public: |
28 LayerTreeHostScrollTestScrollSimple() | 29 LayerTreeHostScrollTestScrollSimple() |
29 : initial_scroll_(10, 20), | 30 : initial_scroll_(10, 20), |
30 second_scroll_(40, 5), | 31 second_scroll_(40, 5), |
31 scroll_amount_(2, -1), | 32 scroll_amount_(2, -1), |
32 num_scrolls_(0) { | 33 num_scrolls_(0) {} |
33 } | |
34 | 34 |
35 virtual void BeginTest() OVERRIDE { | 35 virtual void BeginTest() OVERRIDE { |
36 layer_tree_host()->root_layer()->SetScrollable(true); | 36 layer_tree_host()->root_layer()->SetScrollable(true); |
37 layer_tree_host()->root_layer()->SetScrollOffset(initial_scroll_); | 37 layer_tree_host()->root_layer()->SetScrollOffset(initial_scroll_); |
38 PostSetNeedsCommitToMainThread(); | 38 PostSetNeedsCommitToMainThread(); |
39 } | 39 } |
40 | 40 |
41 virtual void Layout() OVERRIDE { | 41 virtual void Layout() OVERRIDE { |
42 Layer* root = layer_tree_host()->root_layer(); | 42 Layer* root = layer_tree_host()->root_layer(); |
43 if (!layer_tree_host()->commit_number()) { | 43 if (!layer_tree_host()->commit_number()) { |
(...skipping 21 matching lines...) Expand all Loading... |
65 PostSetNeedsCommitToMainThread(); | 65 PostSetNeedsCommitToMainThread(); |
66 break; | 66 break; |
67 case 1: | 67 case 1: |
68 EXPECT_VECTOR_EQ(root->scroll_offset(), second_scroll_); | 68 EXPECT_VECTOR_EQ(root->scroll_offset(), second_scroll_); |
69 EXPECT_VECTOR_EQ(root->ScrollDelta(), scroll_amount_); | 69 EXPECT_VECTOR_EQ(root->ScrollDelta(), scroll_amount_); |
70 EndTest(); | 70 EndTest(); |
71 break; | 71 break; |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 virtual void ApplyScrollAndScale( | 75 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) |
76 gfx::Vector2d scroll_delta, float scale) OVERRIDE { | 76 OVERRIDE { |
77 gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); | 77 gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); |
78 layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); | 78 layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); |
79 num_scrolls_++; | 79 num_scrolls_++; |
80 } | 80 } |
81 | 81 |
82 virtual void AfterTest() OVERRIDE { | 82 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } |
83 EXPECT_EQ(1, num_scrolls_); | |
84 } | |
85 | 83 |
86 private: | 84 private: |
87 gfx::Vector2d initial_scroll_; | 85 gfx::Vector2d initial_scroll_; |
88 gfx::Vector2d second_scroll_; | 86 gfx::Vector2d second_scroll_; |
89 gfx::Vector2d scroll_amount_; | 87 gfx::Vector2d scroll_amount_; |
90 int num_scrolls_; | 88 int num_scrolls_; |
91 }; | 89 }; |
92 | 90 |
93 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSimple); | 91 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSimple); |
94 | 92 |
95 class LayerTreeHostScrollTestScrollMultipleRedraw | 93 class LayerTreeHostScrollTestScrollMultipleRedraw |
96 : public LayerTreeHostScrollTest { | 94 : public LayerTreeHostScrollTest { |
97 public: | 95 public: |
98 LayerTreeHostScrollTestScrollMultipleRedraw() | 96 LayerTreeHostScrollTestScrollMultipleRedraw() |
99 : initial_scroll_(40, 10), | 97 : initial_scroll_(40, 10), scroll_amount_(-3, 17), num_scrolls_(0) {} |
100 scroll_amount_(-3, 17), | |
101 num_scrolls_(0) { | |
102 } | |
103 | 98 |
104 virtual void BeginTest() OVERRIDE { | 99 virtual void BeginTest() OVERRIDE { |
105 layer_tree_host()->root_layer()->SetScrollable(true); | 100 layer_tree_host()->root_layer()->SetScrollable(true); |
106 layer_tree_host()->root_layer()->SetScrollOffset(initial_scroll_); | 101 layer_tree_host()->root_layer()->SetScrollOffset(initial_scroll_); |
107 PostSetNeedsCommitToMainThread(); | 102 PostSetNeedsCommitToMainThread(); |
108 } | 103 } |
109 | 104 |
110 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 105 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
111 Layer* root = layer_tree_host()->root_layer(); | 106 Layer* root = layer_tree_host()->root_layer(); |
112 switch (layer_tree_host()->commit_number()) { | 107 switch (layer_tree_host()->commit_number()) { |
113 case 0: | 108 case 0: |
114 EXPECT_VECTOR_EQ(root->scroll_offset(), initial_scroll_); | 109 EXPECT_VECTOR_EQ(root->scroll_offset(), initial_scroll_); |
115 break; | 110 break; |
116 case 1: | 111 case 1: |
117 EXPECT_VECTOR_EQ( | 112 EXPECT_VECTOR_EQ(root->scroll_offset(), |
118 root->scroll_offset(), | 113 initial_scroll_ + scroll_amount_ + scroll_amount_); |
119 initial_scroll_ + scroll_amount_ + scroll_amount_); | |
120 case 2: | 114 case 2: |
121 EXPECT_VECTOR_EQ( | 115 EXPECT_VECTOR_EQ(root->scroll_offset(), |
122 root->scroll_offset(), | 116 initial_scroll_ + scroll_amount_ + scroll_amount_); |
123 initial_scroll_ + scroll_amount_ + scroll_amount_); | |
124 break; | 117 break; |
125 } | 118 } |
126 } | 119 } |
127 | 120 |
128 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 121 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
129 LayerImpl* root = impl->active_tree()->root_layer(); | 122 LayerImpl* root = impl->active_tree()->root_layer(); |
130 root->SetScrollable(true); | 123 root->SetScrollable(true); |
131 root->SetMaxScrollOffset(gfx::Vector2d(100, 100)); | 124 root->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
132 | 125 |
133 if (impl->active_tree()->source_frame_number() == 0 && | 126 if (impl->active_tree()->source_frame_number() == 0 && |
(...skipping 11 matching lines...) Expand all Loading... |
145 EXPECT_EQ(root->ScrollDelta(), scroll_amount_); | 138 EXPECT_EQ(root->ScrollDelta(), scroll_amount_); |
146 root->ScrollBy(scroll_amount_); | 139 root->ScrollBy(scroll_amount_); |
147 EXPECT_VECTOR_EQ(root->ScrollDelta(), scroll_amount_ + scroll_amount_); | 140 EXPECT_VECTOR_EQ(root->ScrollDelta(), scroll_amount_ + scroll_amount_); |
148 | 141 |
149 EXPECT_VECTOR_EQ(root->scroll_offset(), initial_scroll_); | 142 EXPECT_VECTOR_EQ(root->scroll_offset(), initial_scroll_); |
150 PostSetNeedsCommitToMainThread(); | 143 PostSetNeedsCommitToMainThread(); |
151 } else if (impl->active_tree()->source_frame_number() == 1) { | 144 } else if (impl->active_tree()->source_frame_number() == 1) { |
152 // Third or later draw after second commit. | 145 // Third or later draw after second commit. |
153 EXPECT_GE(impl->SourceAnimationFrameNumber(), 3); | 146 EXPECT_GE(impl->SourceAnimationFrameNumber(), 3); |
154 EXPECT_VECTOR_EQ(root->ScrollDelta(), gfx::Vector2d()); | 147 EXPECT_VECTOR_EQ(root->ScrollDelta(), gfx::Vector2d()); |
155 EXPECT_VECTOR_EQ( | 148 EXPECT_VECTOR_EQ(root->scroll_offset(), |
156 root->scroll_offset(), | 149 initial_scroll_ + scroll_amount_ + scroll_amount_); |
157 initial_scroll_ + scroll_amount_ + scroll_amount_); | |
158 EndTest(); | 150 EndTest(); |
159 } | 151 } |
160 } | 152 } |
161 | 153 |
162 virtual void ApplyScrollAndScale( | 154 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) |
163 gfx::Vector2d scroll_delta, float scale) OVERRIDE { | 155 OVERRIDE { |
164 gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); | 156 gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); |
165 layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); | 157 layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); |
166 num_scrolls_++; | 158 num_scrolls_++; |
167 } | 159 } |
168 | 160 |
169 virtual void AfterTest() OVERRIDE { | 161 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } |
170 EXPECT_EQ(1, num_scrolls_); | 162 |
171 } | |
172 private: | 163 private: |
173 gfx::Vector2d initial_scroll_; | 164 gfx::Vector2d initial_scroll_; |
174 gfx::Vector2d scroll_amount_; | 165 gfx::Vector2d scroll_amount_; |
175 int num_scrolls_; | 166 int num_scrolls_; |
176 }; | 167 }; |
177 | 168 |
178 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollMultipleRedraw); | 169 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollMultipleRedraw); |
179 | 170 |
180 class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest { | 171 class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest { |
181 public: | 172 public: |
182 LayerTreeHostScrollTestFractionalScroll() | 173 LayerTreeHostScrollTestFractionalScroll() : scroll_amount_(1.75, 0) {} |
183 : scroll_amount_(1.75, 0) { | |
184 } | |
185 | 174 |
186 virtual void BeginTest() OVERRIDE { | 175 virtual void BeginTest() OVERRIDE { |
187 layer_tree_host()->root_layer()->SetScrollable(true); | 176 layer_tree_host()->root_layer()->SetScrollable(true); |
188 PostSetNeedsCommitToMainThread(); | 177 PostSetNeedsCommitToMainThread(); |
189 } | 178 } |
190 | 179 |
191 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 180 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
192 LayerImpl* root = impl->active_tree()->root_layer(); | 181 LayerImpl* root = impl->active_tree()->root_layer(); |
193 root->SetMaxScrollOffset(gfx::Vector2d(100, 100)); | 182 root->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
194 | 183 |
195 // Check that a fractional scroll delta is correctly accumulated over | 184 // Check that a fractional scroll delta is correctly accumulated over |
196 // multiple commits. | 185 // multiple commits. |
197 switch (impl->active_tree()->source_frame_number()) { | 186 switch (impl->active_tree()->source_frame_number()) { |
198 case 0: | 187 case 0: |
199 EXPECT_VECTOR_EQ(root->scroll_offset(), gfx::Vector2d(0, 0)); | 188 EXPECT_VECTOR_EQ(root->scroll_offset(), gfx::Vector2d(0, 0)); |
200 EXPECT_VECTOR_EQ(root->ScrollDelta(), gfx::Vector2d(0, 0)); | 189 EXPECT_VECTOR_EQ(root->ScrollDelta(), gfx::Vector2d(0, 0)); |
201 PostSetNeedsCommitToMainThread(); | 190 PostSetNeedsCommitToMainThread(); |
202 break; | 191 break; |
203 case 1: | 192 case 1: |
204 EXPECT_VECTOR_EQ( | 193 EXPECT_VECTOR_EQ(root->scroll_offset(), |
205 root->scroll_offset(), | 194 gfx::ToFlooredVector2d(scroll_amount_)); |
206 gfx::ToFlooredVector2d(scroll_amount_)); | 195 EXPECT_VECTOR_EQ(root->ScrollDelta(), |
207 EXPECT_VECTOR_EQ( | 196 gfx::Vector2dF(fmod(scroll_amount_.x(), 1.0f), 0.0f)); |
208 root->ScrollDelta(), | |
209 gfx::Vector2dF(fmod(scroll_amount_.x(), 1.0f), 0.0f)); | |
210 PostSetNeedsCommitToMainThread(); | 197 PostSetNeedsCommitToMainThread(); |
211 break; | 198 break; |
212 case 2: | 199 case 2: |
213 EXPECT_VECTOR_EQ( | 200 EXPECT_VECTOR_EQ( |
214 root->scroll_offset(), | 201 root->scroll_offset(), |
215 gfx::ToFlooredVector2d(scroll_amount_ + scroll_amount_)); | 202 gfx::ToFlooredVector2d(scroll_amount_ + scroll_amount_)); |
216 EXPECT_VECTOR_EQ( | 203 EXPECT_VECTOR_EQ( |
217 root->ScrollDelta(), | 204 root->ScrollDelta(), |
218 gfx::Vector2dF(fmod(2.0f * scroll_amount_.x(), 1.0f), 0.0f)); | 205 gfx::Vector2dF(fmod(2.0f * scroll_amount_.x(), 1.0f), 0.0f)); |
219 EndTest(); | 206 EndTest(); |
220 break; | 207 break; |
221 } | 208 } |
222 root->ScrollBy(scroll_amount_); | 209 root->ScrollBy(scroll_amount_); |
223 } | 210 } |
224 | 211 |
225 virtual void ApplyScrollAndScale( | 212 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) |
226 gfx::Vector2d scroll_delta, float scale) OVERRIDE { | 213 OVERRIDE { |
227 gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); | 214 gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); |
228 layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); | 215 layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); |
229 } | 216 } |
230 | 217 |
231 virtual void AfterTest() OVERRIDE {} | 218 virtual void AfterTest() OVERRIDE {} |
232 | 219 |
233 private: | 220 private: |
234 gfx::Vector2dF scroll_amount_; | 221 gfx::Vector2dF scroll_amount_; |
235 }; | 222 }; |
236 | 223 |
237 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll); | 224 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll); |
238 | 225 |
239 class LayerTreeHostScrollTestCaseWithChild | 226 class LayerTreeHostScrollTestCaseWithChild |
240 : public LayerTreeHostScrollTest, | 227 : public LayerTreeHostScrollTest, |
241 public WebKit::WebLayerScrollClient { | 228 public WebKit::WebLayerScrollClient { |
242 public: | 229 public: |
243 LayerTreeHostScrollTestCaseWithChild() | 230 LayerTreeHostScrollTestCaseWithChild() |
244 : initial_offset_(10, 20), | 231 : initial_offset_(10, 20), |
245 javascript_scroll_(40, 5), | 232 javascript_scroll_(40, 5), |
246 scroll_amount_(2, -1), | 233 scroll_amount_(2, -1), |
247 num_scrolls_(0) { | 234 num_scrolls_(0) {} |
248 } | |
249 | 235 |
250 virtual void SetupTree() OVERRIDE { | 236 virtual void SetupTree() OVERRIDE { |
251 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); | 237 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); |
252 | 238 |
253 scoped_refptr<Layer> root_layer = Layer::Create(); | 239 scoped_refptr<Layer> root_layer = Layer::Create(); |
254 root_layer->SetBounds(gfx::Size(10, 10)); | 240 root_layer->SetBounds(gfx::Size(10, 10)); |
255 | 241 |
256 root_scroll_layer_ = ContentLayer::Create(&fake_content_layer_client_); | 242 root_scroll_layer_ = ContentLayer::Create(&fake_content_layer_client_); |
257 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); | 243 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); |
258 | 244 |
(...skipping 27 matching lines...) Expand all Loading... |
286 expected_scroll_layer_ = root_scroll_layer_; | 272 expected_scroll_layer_ = root_scroll_layer_; |
287 expected_no_scroll_layer_ = child_layer_; | 273 expected_no_scroll_layer_ = child_layer_; |
288 } | 274 } |
289 | 275 |
290 expected_scroll_layer_->SetScrollOffset(initial_offset_); | 276 expected_scroll_layer_->SetScrollOffset(initial_offset_); |
291 | 277 |
292 layer_tree_host()->SetRootLayer(root_layer); | 278 layer_tree_host()->SetRootLayer(root_layer); |
293 LayerTreeHostScrollTest::SetupTree(); | 279 LayerTreeHostScrollTest::SetupTree(); |
294 } | 280 } |
295 | 281 |
296 virtual void BeginTest() OVERRIDE { | 282 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
297 PostSetNeedsCommitToMainThread(); | |
298 } | |
299 | 283 |
300 virtual void didScroll() OVERRIDE { | 284 virtual void didScroll() OVERRIDE { |
301 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); | 285 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); |
302 } | 286 } |
303 | 287 |
304 virtual void ApplyScrollAndScale( | 288 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) |
305 gfx::Vector2d scroll_delta, float scale) OVERRIDE { | 289 OVERRIDE { |
306 gfx::Vector2d offset = root_scroll_layer_->scroll_offset(); | 290 gfx::Vector2d offset = root_scroll_layer_->scroll_offset(); |
307 root_scroll_layer_->SetScrollOffset(offset + scroll_delta); | 291 root_scroll_layer_->SetScrollOffset(offset + scroll_delta); |
308 num_scrolls_++; | 292 num_scrolls_++; |
309 } | 293 } |
310 | 294 |
311 virtual void Layout() OVERRIDE { | 295 virtual void Layout() OVERRIDE { |
312 EXPECT_VECTOR_EQ( | 296 EXPECT_VECTOR_EQ(gfx::Vector2d(), |
313 gfx::Vector2d(), expected_no_scroll_layer_->scroll_offset()); | 297 expected_no_scroll_layer_->scroll_offset()); |
314 | 298 |
315 switch (layer_tree_host()->commit_number()) { | 299 switch (layer_tree_host()->commit_number()) { |
316 case 0: | 300 case 0: |
317 EXPECT_VECTOR_EQ( | 301 EXPECT_VECTOR_EQ(initial_offset_, |
318 initial_offset_, | 302 expected_scroll_layer_->scroll_offset()); |
319 expected_scroll_layer_->scroll_offset()); | |
320 break; | 303 break; |
321 case 1: | 304 case 1: |
322 EXPECT_VECTOR_EQ( | 305 EXPECT_VECTOR_EQ(initial_offset_ + scroll_amount_, |
323 initial_offset_ + scroll_amount_, | 306 expected_scroll_layer_->scroll_offset()); |
324 expected_scroll_layer_->scroll_offset()); | |
325 | 307 |
326 // Pretend like Javascript updated the scroll position itself. | 308 // Pretend like Javascript updated the scroll position itself. |
327 expected_scroll_layer_->SetScrollOffset(javascript_scroll_); | 309 expected_scroll_layer_->SetScrollOffset(javascript_scroll_); |
328 break; | 310 break; |
329 case 2: | 311 case 2: |
330 EXPECT_VECTOR_EQ( | 312 EXPECT_VECTOR_EQ(javascript_scroll_ + scroll_amount_, |
331 javascript_scroll_ + scroll_amount_, | 313 expected_scroll_layer_->scroll_offset()); |
332 expected_scroll_layer_->scroll_offset()); | |
333 break; | 314 break; |
334 } | 315 } |
335 } | 316 } |
336 | 317 |
337 virtual void TreeActivatedOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 318 virtual void TreeActivatedOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
338 LayerImpl* root_impl = impl->active_tree()->root_layer(); | 319 LayerImpl* root_impl = impl->active_tree()->root_layer(); |
339 LayerImpl* root_scroll_layer_impl = root_impl->children()[0]; | 320 LayerImpl* root_scroll_layer_impl = root_impl->children()[0]; |
340 LayerImpl* child_layer_impl = root_scroll_layer_impl->children()[0]; | 321 LayerImpl* child_layer_impl = root_scroll_layer_impl->children()[0]; |
341 | 322 |
342 LayerImpl* expected_scroll_layer_impl = NULL; | 323 LayerImpl* expected_scroll_layer_impl = NULL; |
343 LayerImpl* expected_no_scroll_layer_impl = NULL; | 324 LayerImpl* expected_no_scroll_layer_impl = NULL; |
344 if (scroll_child_layer_) { | 325 if (scroll_child_layer_) { |
345 expected_scroll_layer_impl = child_layer_impl; | 326 expected_scroll_layer_impl = child_layer_impl; |
346 expected_no_scroll_layer_impl = root_scroll_layer_impl; | 327 expected_no_scroll_layer_impl = root_scroll_layer_impl; |
347 } else { | 328 } else { |
348 expected_scroll_layer_impl = root_scroll_layer_impl; | 329 expected_scroll_layer_impl = root_scroll_layer_impl; |
349 expected_no_scroll_layer_impl = child_layer_impl; | 330 expected_no_scroll_layer_impl = child_layer_impl; |
350 } | 331 } |
351 | 332 |
352 EXPECT_VECTOR_EQ(gfx::Vector2d(), root_impl->ScrollDelta()); | 333 EXPECT_VECTOR_EQ(gfx::Vector2d(), root_impl->ScrollDelta()); |
353 EXPECT_VECTOR_EQ( | 334 EXPECT_VECTOR_EQ(gfx::Vector2d(), |
354 gfx::Vector2d(), | 335 expected_no_scroll_layer_impl->ScrollDelta()); |
355 expected_no_scroll_layer_impl->ScrollDelta()); | |
356 | 336 |
357 // Ensure device scale factor is affecting the layers. | 337 // Ensure device scale factor is affecting the layers. |
358 gfx::Size expected_content_bounds = gfx::ToCeiledSize( | 338 gfx::Size expected_content_bounds = gfx::ToCeiledSize( |
359 gfx::ScaleSize(root_scroll_layer_impl->bounds(), device_scale_factor_)); | 339 gfx::ScaleSize(root_scroll_layer_impl->bounds(), device_scale_factor_)); |
360 EXPECT_SIZE_EQ( | 340 EXPECT_SIZE_EQ(expected_content_bounds, |
361 expected_content_bounds, | 341 root_scroll_layer_->content_bounds()); |
362 root_scroll_layer_->content_bounds()); | |
363 | 342 |
364 expected_content_bounds = gfx::ToCeiledSize( | 343 expected_content_bounds = gfx::ToCeiledSize( |
365 gfx::ScaleSize(child_layer_impl->bounds(), device_scale_factor_)); | 344 gfx::ScaleSize(child_layer_impl->bounds(), device_scale_factor_)); |
366 EXPECT_SIZE_EQ(expected_content_bounds, child_layer_->content_bounds()); | 345 EXPECT_SIZE_EQ(expected_content_bounds, child_layer_->content_bounds()); |
367 | 346 |
368 switch (impl->active_tree()->source_frame_number()) { | 347 switch (impl->active_tree()->source_frame_number()) { |
369 case 0: { | 348 case 0: { |
370 // Gesture scroll on impl thread. | 349 // Gesture scroll on impl thread. |
371 InputHandler::ScrollStatus status = impl->ScrollBegin( | 350 InputHandler::ScrollStatus status = impl->ScrollBegin( |
372 gfx::ToCeiledPoint( | 351 gfx::ToCeiledPoint(expected_scroll_layer_impl->position() + |
373 expected_scroll_layer_impl->position() + | 352 gfx::Vector2dF(0.5f, 0.5f)), |
374 gfx::Vector2dF(0.5f, 0.5f)), | |
375 InputHandler::Gesture); | 353 InputHandler::Gesture); |
376 EXPECT_EQ(InputHandler::ScrollStarted, status); | 354 EXPECT_EQ(InputHandler::ScrollStarted, status); |
377 impl->ScrollBy(gfx::Point(), scroll_amount_); | 355 impl->ScrollBy(gfx::Point(), scroll_amount_); |
378 impl->ScrollEnd(); | 356 impl->ScrollEnd(); |
379 | 357 |
380 // Check the scroll is applied as a delta. | 358 // Check the scroll is applied as a delta. |
381 EXPECT_VECTOR_EQ( | 359 EXPECT_VECTOR_EQ(initial_offset_, |
382 initial_offset_, | 360 expected_scroll_layer_impl->scroll_offset()); |
383 expected_scroll_layer_impl->scroll_offset()); | 361 EXPECT_VECTOR_EQ(scroll_amount_, |
384 EXPECT_VECTOR_EQ( | 362 expected_scroll_layer_impl->ScrollDelta()); |
385 scroll_amount_, | |
386 expected_scroll_layer_impl->ScrollDelta()); | |
387 break; | 363 break; |
388 } | 364 } |
389 case 1: { | 365 case 1: { |
390 // Wheel scroll on impl thread. | 366 // Wheel scroll on impl thread. |
391 InputHandler::ScrollStatus status = impl->ScrollBegin( | 367 InputHandler::ScrollStatus status = impl->ScrollBegin( |
392 gfx::ToCeiledPoint( | 368 gfx::ToCeiledPoint(expected_scroll_layer_impl->position() + |
393 expected_scroll_layer_impl->position() + | 369 gfx::Vector2dF(0.5f, 0.5f)), |
394 gfx::Vector2dF(0.5f, 0.5f)), | |
395 InputHandler::Wheel); | 370 InputHandler::Wheel); |
396 EXPECT_EQ(InputHandler::ScrollStarted, status); | 371 EXPECT_EQ(InputHandler::ScrollStarted, status); |
397 impl->ScrollBy(gfx::Point(), scroll_amount_); | 372 impl->ScrollBy(gfx::Point(), scroll_amount_); |
398 impl->ScrollEnd(); | 373 impl->ScrollEnd(); |
399 | 374 |
400 // Check the scroll is applied as a delta. | 375 // Check the scroll is applied as a delta. |
401 EXPECT_VECTOR_EQ( | 376 EXPECT_VECTOR_EQ(javascript_scroll_, |
402 javascript_scroll_, | 377 expected_scroll_layer_impl->scroll_offset()); |
403 expected_scroll_layer_impl->scroll_offset()); | 378 EXPECT_VECTOR_EQ(scroll_amount_, |
404 EXPECT_VECTOR_EQ( | 379 expected_scroll_layer_impl->ScrollDelta()); |
405 scroll_amount_, | |
406 expected_scroll_layer_impl->ScrollDelta()); | |
407 break; | 380 break; |
408 } | 381 } |
409 case 2: | 382 case 2: |
410 | 383 |
411 EXPECT_VECTOR_EQ( | 384 EXPECT_VECTOR_EQ(javascript_scroll_ + scroll_amount_, |
412 javascript_scroll_ + scroll_amount_, | 385 expected_scroll_layer_impl->scroll_offset()); |
413 expected_scroll_layer_impl->scroll_offset()); | 386 EXPECT_VECTOR_EQ(gfx::Vector2d(), |
414 EXPECT_VECTOR_EQ( | 387 expected_scroll_layer_impl->ScrollDelta()); |
415 gfx::Vector2d(), | |
416 expected_scroll_layer_impl->ScrollDelta()); | |
417 | 388 |
418 EndTest(); | 389 EndTest(); |
419 break; | 390 break; |
420 } | 391 } |
421 } | 392 } |
422 | 393 |
423 virtual void AfterTest() OVERRIDE { | 394 virtual void AfterTest() OVERRIDE { |
424 if (scroll_child_layer_) { | 395 if (scroll_child_layer_) { |
425 EXPECT_EQ(0, num_scrolls_); | 396 EXPECT_EQ(0, num_scrolls_); |
426 EXPECT_VECTOR_EQ( | 397 EXPECT_VECTOR_EQ(javascript_scroll_ + scroll_amount_, |
427 javascript_scroll_ + scroll_amount_, | 398 final_scroll_offset_); |
428 final_scroll_offset_); | |
429 } else { | 399 } else { |
430 EXPECT_EQ(2, num_scrolls_); | 400 EXPECT_EQ(2, num_scrolls_); |
431 EXPECT_VECTOR_EQ(gfx::Vector2d(), final_scroll_offset_); | 401 EXPECT_VECTOR_EQ(gfx::Vector2d(), final_scroll_offset_); |
432 } | 402 } |
433 } | 403 } |
434 | 404 |
435 protected: | 405 protected: |
436 float device_scale_factor_; | 406 float device_scale_factor_; |
437 bool scroll_child_layer_; | 407 bool scroll_child_layer_; |
438 | 408 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 }; | 539 }; |
570 | 540 |
571 class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest { | 541 class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest { |
572 public: | 542 public: |
573 ImplSidePaintingScrollTestSimple() | 543 ImplSidePaintingScrollTestSimple() |
574 : initial_scroll_(10, 20), | 544 : initial_scroll_(10, 20), |
575 main_thread_scroll_(40, 5), | 545 main_thread_scroll_(40, 5), |
576 impl_thread_scroll1_(2, -1), | 546 impl_thread_scroll1_(2, -1), |
577 impl_thread_scroll2_(-3, 10), | 547 impl_thread_scroll2_(-3, 10), |
578 num_scrolls_(0), | 548 num_scrolls_(0), |
579 can_activate_(true) { | 549 can_activate_(true) {} |
580 } | |
581 | 550 |
582 virtual void BeginTest() OVERRIDE { | 551 virtual void BeginTest() OVERRIDE { |
583 layer_tree_host()->root_layer()->SetScrollable(true); | 552 layer_tree_host()->root_layer()->SetScrollable(true); |
584 layer_tree_host()->root_layer()->SetScrollOffset(initial_scroll_); | 553 layer_tree_host()->root_layer()->SetScrollOffset(initial_scroll_); |
585 PostSetNeedsCommitToMainThread(); | 554 PostSetNeedsCommitToMainThread(); |
586 } | 555 } |
587 | 556 |
588 virtual void Layout() OVERRIDE { | 557 virtual void Layout() OVERRIDE { |
589 Layer* root = layer_tree_host()->root_layer(); | 558 Layer* root = layer_tree_host()->root_layer(); |
590 if (!layer_tree_host()->commit_number()) { | 559 if (!layer_tree_host()->commit_number()) { |
591 EXPECT_VECTOR_EQ(root->scroll_offset(), initial_scroll_); | 560 EXPECT_VECTOR_EQ(root->scroll_offset(), initial_scroll_); |
592 } else { | 561 } else { |
593 EXPECT_VECTOR_EQ(root->scroll_offset(), | 562 EXPECT_VECTOR_EQ(root->scroll_offset(), |
594 initial_scroll_ + impl_thread_scroll1_); | 563 initial_scroll_ + impl_thread_scroll1_); |
595 | 564 |
596 // Pretend like Javascript updated the scroll position itself with a | 565 // Pretend like Javascript updated the scroll position itself with a |
597 // change of main_thread_scroll. | 566 // change of main_thread_scroll. |
598 root->SetScrollOffset(initial_scroll_ + | 567 root->SetScrollOffset(initial_scroll_ + main_thread_scroll_ + |
599 main_thread_scroll_ + | |
600 impl_thread_scroll1_); | 568 impl_thread_scroll1_); |
601 } | 569 } |
602 } | 570 } |
603 | 571 |
604 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { | 572 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { |
605 return can_activate_; | 573 return can_activate_; |
606 } | 574 } |
607 | 575 |
608 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 576 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
609 // We force a second draw here of the first commit before activating | 577 // We force a second draw here of the first commit before activating |
(...skipping 27 matching lines...) Expand all Loading... |
637 // CommitCompleteOnThread will trigger this function again | 605 // CommitCompleteOnThread will trigger this function again |
638 // and cause us to take the else clause. | 606 // and cause us to take the else clause. |
639 } else { | 607 } else { |
640 can_activate_ = true; | 608 can_activate_ = true; |
641 ASSERT_TRUE(pending_root); | 609 ASSERT_TRUE(pending_root); |
642 EXPECT_EQ(impl->pending_tree()->source_frame_number(), 1); | 610 EXPECT_EQ(impl->pending_tree()->source_frame_number(), 1); |
643 | 611 |
644 root->ScrollBy(impl_thread_scroll2_); | 612 root->ScrollBy(impl_thread_scroll2_); |
645 EXPECT_VECTOR_EQ(root->scroll_offset(), initial_scroll_); | 613 EXPECT_VECTOR_EQ(root->scroll_offset(), initial_scroll_); |
646 EXPECT_VECTOR_EQ(root->ScrollDelta(), | 614 EXPECT_VECTOR_EQ(root->ScrollDelta(), |
647 impl_thread_scroll1_ + impl_thread_scroll2_); | 615 impl_thread_scroll1_ + impl_thread_scroll2_); |
648 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), impl_thread_scroll1_); | 616 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), impl_thread_scroll1_); |
649 | 617 |
650 EXPECT_VECTOR_EQ(pending_root->scroll_offset(), | 618 EXPECT_VECTOR_EQ( |
| 619 pending_root->scroll_offset(), |
651 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); | 620 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); |
652 EXPECT_VECTOR_EQ(pending_root->ScrollDelta(), impl_thread_scroll2_); | 621 EXPECT_VECTOR_EQ(pending_root->ScrollDelta(), impl_thread_scroll2_); |
653 EXPECT_VECTOR_EQ(pending_root->sent_scroll_delta(), gfx::Vector2d()); | 622 EXPECT_VECTOR_EQ(pending_root->sent_scroll_delta(), gfx::Vector2d()); |
654 } | 623 } |
655 break; | 624 break; |
656 case 1: | 625 case 1: |
657 EXPECT_FALSE(impl->pending_tree()); | 626 EXPECT_FALSE(impl->pending_tree()); |
658 EXPECT_VECTOR_EQ(root->scroll_offset(), | 627 EXPECT_VECTOR_EQ( |
| 628 root->scroll_offset(), |
659 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); | 629 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); |
660 EXPECT_VECTOR_EQ(root->ScrollDelta(), impl_thread_scroll2_); | 630 EXPECT_VECTOR_EQ(root->ScrollDelta(), impl_thread_scroll2_); |
661 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), gfx::Vector2d()); | 631 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), gfx::Vector2d()); |
662 EndTest(); | 632 EndTest(); |
663 break; | 633 break; |
664 } | 634 } |
665 } | 635 } |
666 | 636 |
667 virtual void ApplyScrollAndScale( | 637 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) |
668 gfx::Vector2d scroll_delta, float scale) OVERRIDE { | 638 OVERRIDE { |
669 gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); | 639 gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); |
670 layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); | 640 layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); |
671 num_scrolls_++; | 641 num_scrolls_++; |
672 } | 642 } |
673 | 643 |
674 virtual void AfterTest() OVERRIDE { | 644 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } |
675 EXPECT_EQ(1, num_scrolls_); | |
676 } | |
677 | 645 |
678 private: | 646 private: |
679 gfx::Vector2d initial_scroll_; | 647 gfx::Vector2d initial_scroll_; |
680 gfx::Vector2d main_thread_scroll_; | 648 gfx::Vector2d main_thread_scroll_; |
681 gfx::Vector2d impl_thread_scroll1_; | 649 gfx::Vector2d impl_thread_scroll1_; |
682 gfx::Vector2d impl_thread_scroll2_; | 650 gfx::Vector2d impl_thread_scroll2_; |
683 int num_scrolls_; | 651 int num_scrolls_; |
684 bool can_activate_; | 652 bool can_activate_; |
685 }; | 653 }; |
686 | 654 |
687 MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestSimple); | 655 MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestSimple); |
688 | 656 |
689 class LayerTreeHostScrollTestScrollZeroMaxScrollOffset | 657 class LayerTreeHostScrollTestScrollZeroMaxScrollOffset |
690 : public LayerTreeHostScrollTest { | 658 : public LayerTreeHostScrollTest { |
691 public: | 659 public: |
692 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {} | 660 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {} |
693 | 661 |
694 virtual void BeginTest() OVERRIDE { | 662 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
695 PostSetNeedsCommitToMainThread(); | |
696 } | |
697 | 663 |
698 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 664 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
699 LayerImpl* root = impl->active_tree()->root_layer(); | 665 LayerImpl* root = impl->active_tree()->root_layer(); |
700 root->SetScrollable(true); | 666 root->SetScrollable(true); |
701 | 667 |
702 root->SetMaxScrollOffset(gfx::Vector2d(100, 100)); | 668 root->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
703 EXPECT_EQ( | 669 EXPECT_EQ(InputHandler::ScrollStarted, |
704 InputHandler::ScrollStarted, | 670 root->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::Gesture)); |
705 root->TryScroll( | |
706 gfx::PointF(0.0f, 1.0f), | |
707 InputHandler::Gesture)); | |
708 | 671 |
709 root->SetMaxScrollOffset(gfx::Vector2d(0, 0)); | 672 root->SetMaxScrollOffset(gfx::Vector2d(0, 0)); |
710 EXPECT_EQ( | 673 EXPECT_EQ(InputHandler::ScrollIgnored, |
711 InputHandler::ScrollIgnored, | 674 root->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::Gesture)); |
712 root->TryScroll( | |
713 gfx::PointF(0.0f, 1.0f), | |
714 InputHandler::Gesture)); | |
715 | 675 |
716 root->SetMaxScrollOffset(gfx::Vector2d(-100, -100)); | 676 root->SetMaxScrollOffset(gfx::Vector2d(-100, -100)); |
717 EXPECT_EQ( | 677 EXPECT_EQ(InputHandler::ScrollIgnored, |
718 InputHandler::ScrollIgnored, | 678 root->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::Gesture)); |
719 root->TryScroll( | |
720 gfx::PointF(0.0f, 1.0f), | |
721 InputHandler::Gesture)); | |
722 | 679 |
723 EndTest(); | 680 EndTest(); |
724 } | 681 } |
725 | 682 |
726 virtual void AfterTest() OVERRIDE {} | 683 virtual void AfterTest() OVERRIDE {} |
727 }; | 684 }; |
728 | 685 |
729 SINGLE_AND_MULTI_THREAD_TEST_F( | 686 SINGLE_AND_MULTI_THREAD_TEST_F( |
730 LayerTreeHostScrollTestScrollZeroMaxScrollOffset); | 687 LayerTreeHostScrollTestScrollZeroMaxScrollOffset); |
731 | 688 |
732 class ThreadCheckingInputHandlerClient : public InputHandlerClient { | 689 class ThreadCheckingInputHandlerClient : public InputHandlerClient { |
733 public: | 690 public: |
734 ThreadCheckingInputHandlerClient(base::SingleThreadTaskRunner* runner, | 691 ThreadCheckingInputHandlerClient(base::SingleThreadTaskRunner* runner, |
735 bool* received_stop_flinging) | 692 bool* received_stop_flinging) |
736 : task_runner_(runner) , | 693 : task_runner_(runner), received_stop_flinging_(received_stop_flinging) {} |
737 received_stop_flinging_(received_stop_flinging) {} | |
738 | 694 |
739 virtual void BindToHandler(InputHandler* handler) OVERRIDE { | 695 virtual void WillShutdown() OVERRIDE { |
740 if (!task_runner_->BelongsToCurrentThread()) | 696 if (!received_stop_flinging_) |
741 ADD_FAILURE() << "BindToClient called on wrong thread"; | 697 ADD_FAILURE() << "WillShutdown() called before fling stopped"; |
742 } | 698 } |
743 | 699 |
744 virtual void Animate(base::TimeTicks time) OVERRIDE { | 700 virtual void Animate(base::TimeTicks time) OVERRIDE { |
745 if (!task_runner_->BelongsToCurrentThread()) | 701 if (!task_runner_->BelongsToCurrentThread()) |
746 ADD_FAILURE() << "Animate called on wrong thread"; | 702 ADD_FAILURE() << "Animate called on wrong thread"; |
747 } | 703 } |
748 | 704 |
749 virtual void MainThreadHasStoppedFlinging() OVERRIDE { | 705 virtual void MainThreadHasStoppedFlinging() OVERRIDE { |
750 if (!task_runner_->BelongsToCurrentThread()) | 706 if (!task_runner_->BelongsToCurrentThread()) |
751 ADD_FAILURE() << "MainThreadHasStoppedFlinging called on wrong thread"; | 707 ADD_FAILURE() << "MainThreadHasStoppedFlinging called on wrong thread"; |
752 *received_stop_flinging_ = true; | 708 *received_stop_flinging_ = true; |
753 } | 709 } |
754 | 710 |
755 private: | 711 private: |
756 base::SingleThreadTaskRunner* task_runner_; | 712 base::SingleThreadTaskRunner* task_runner_; |
757 bool* received_stop_flinging_; | 713 bool* received_stop_flinging_; |
758 }; | 714 }; |
759 | 715 |
760 class ThreadCheckingFakeLayerTreeHostClient : public FakeLayerTreeHostClient { | 716 void BindInputHandlerOnCompositorThread( |
761 public: | 717 const base::WeakPtr<InputHandler>& input_handler, |
762 ThreadCheckingFakeLayerTreeHostClient( | 718 ThreadCheckingInputHandlerClient* client) { |
763 base::SingleThreadTaskRunner* task_runner, | 719 input_handler->BindToClient(client); |
764 bool* received_stop_flinging) | 720 } |
765 : FakeLayerTreeHostClient(DIRECT_3D) , | |
766 task_runner_(task_runner), | |
767 received_stop_flinging_(received_stop_flinging) {} | |
768 | |
769 virtual scoped_ptr<InputHandlerClient> CreateInputHandlerClient() OVERRIDE { | |
770 return scoped_ptr<InputHandlerClient>(new ThreadCheckingInputHandlerClient( | |
771 task_runner_, received_stop_flinging_)).Pass(); | |
772 } | |
773 | |
774 private: | |
775 base::SingleThreadTaskRunner* task_runner_; | |
776 bool* received_stop_flinging_; | |
777 }; | |
778 | 721 |
779 TEST(LayerTreeHostFlingTest, DidStopFlingingThread) { | 722 TEST(LayerTreeHostFlingTest, DidStopFlingingThread) { |
780 base::Thread impl_thread("cc"); | 723 base::Thread impl_thread("cc"); |
781 impl_thread.Start(); | 724 impl_thread.Start(); |
782 scoped_ptr<cc::Thread> impl_ccthread = | 725 scoped_ptr<Thread> impl_ccthread = |
783 cc::ThreadImpl::CreateForDifferentThread( | 726 ThreadImpl::CreateForDifferentThread(impl_thread.message_loop_proxy()); |
784 impl_thread.message_loop_proxy()); | |
785 | 727 |
786 bool received_stop_flinging = false; | 728 bool received_stop_flinging = false; |
787 ThreadCheckingFakeLayerTreeHostClient client( | |
788 impl_thread.message_loop_proxy().get(), | |
789 &received_stop_flinging); | |
790 LayerTreeSettings settings; | 729 LayerTreeSettings settings; |
791 | 730 |
| 731 ThreadCheckingInputHandlerClient input_handler_client( |
| 732 impl_thread.message_loop_proxy().get(), &received_stop_flinging); |
| 733 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 734 |
792 scoped_ptr<LayerTreeHost> layer_tree_host = | 735 scoped_ptr<LayerTreeHost> layer_tree_host = |
793 LayerTreeHost::Create(&client, settings, impl_ccthread.Pass()); | 736 LayerTreeHost::Create(&client, settings, impl_ccthread.Pass()); |
794 | 737 |
| 738 impl_thread.message_loop_proxy() |
| 739 ->PostTask(FROM_HERE, |
| 740 base::Bind(&BindInputHandlerOnCompositorThread, |
| 741 layer_tree_host->GetInputHandler(), |
| 742 base::Unretained(&input_handler_client))); |
| 743 |
795 layer_tree_host->DidStopFlinging(); | 744 layer_tree_host->DidStopFlinging(); |
796 layer_tree_host.reset(); | 745 layer_tree_host.reset(); |
797 impl_thread.Stop(); | 746 impl_thread.Stop(); |
798 EXPECT_TRUE(received_stop_flinging); | 747 EXPECT_TRUE(received_stop_flinging); |
799 } | 748 } |
800 | 749 |
801 } // namespace | 750 } // namespace |
802 } // namespace cc | 751 } // namespace cc |
OLD | NEW |