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 "base/memory/weak_ptr.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 scroll_layer->SetScrollClipLayerId(root_layer->id()); | 45 scroll_layer->SetScrollClipLayerId(root_layer->id()); |
46 scroll_layer->SetScrollOffset(initial_scroll_); | 46 scroll_layer->SetScrollOffset(initial_scroll_); |
47 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer, NULL); | 47 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer, NULL); |
48 PostSetNeedsCommitToMainThread(); | 48 PostSetNeedsCommitToMainThread(); |
49 } | 49 } |
50 | 50 |
51 virtual void Layout() OVERRIDE { | 51 virtual void Layout() OVERRIDE { |
52 Layer* root = layer_tree_host()->root_layer(); | 52 Layer* root = layer_tree_host()->root_layer(); |
53 Layer* scroll_layer = root->children()[0].get(); | 53 Layer* scroll_layer = root->children()[0].get(); |
54 if (!layer_tree_host()->source_frame_number()) { | 54 if (!layer_tree_host()->source_frame_number()) { |
55 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); | 55 EXPECT_VECTOR2DF_EQ(initial_scroll_, scroll_layer->scroll_offset()); |
danakj
2014/09/18 21:23:49
EXPECT_EQ?
Yufeng Shen (Slow to review)
2014/09/18 22:47:55
Done.
| |
56 } else { | 56 } else { |
57 EXPECT_VECTOR_EQ(initial_scroll_ + scroll_amount_, | 57 EXPECT_VECTOR2DF_EQ(initial_scroll_ + scroll_amount_, |
58 scroll_layer->scroll_offset()); | 58 scroll_layer->scroll_offset()); |
59 | 59 |
60 // Pretend like Javascript updated the scroll position itself. | 60 // Pretend like Javascript updated the scroll position itself. |
61 scroll_layer->SetScrollOffset(second_scroll_); | 61 scroll_layer->SetScrollOffset(second_scroll_); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 65 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
66 LayerImpl* root = impl->active_tree()->root_layer(); | 66 LayerImpl* root = impl->active_tree()->root_layer(); |
67 LayerImpl* scroll_layer = root->children()[0]; | 67 LayerImpl* scroll_layer = root->children()[0]; |
68 EXPECT_VECTOR_EQ(gfx::Vector2d(), scroll_layer->ScrollDelta()); | 68 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(), scroll_layer->ScrollDelta()); |
69 | 69 |
70 scroll_layer->SetScrollClipLayer(root->id()); | 70 scroll_layer->SetScrollClipLayer(root->id()); |
71 scroll_layer->SetBounds( | 71 scroll_layer->SetBounds( |
72 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); | 72 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); |
73 scroll_layer->ScrollBy(scroll_amount_); | 73 scroll_layer->ScrollBy(scroll_amount_); |
74 | 74 |
75 switch (impl->active_tree()->source_frame_number()) { | 75 switch (impl->active_tree()->source_frame_number()) { |
76 case 0: | 76 case 0: |
77 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); | 77 EXPECT_VECTOR2DF_EQ(initial_scroll_, scroll_layer->scroll_offset()); |
78 EXPECT_VECTOR_EQ(scroll_amount_, scroll_layer->ScrollDelta()); | 78 EXPECT_VECTOR2DF_EQ(scroll_amount_, scroll_layer->ScrollDelta()); |
79 PostSetNeedsCommitToMainThread(); | 79 PostSetNeedsCommitToMainThread(); |
80 break; | 80 break; |
81 case 1: | 81 case 1: |
82 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), second_scroll_); | 82 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), second_scroll_); |
83 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_); | 83 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), scroll_amount_); |
84 EndTest(); | 84 EndTest(); |
85 break; | 85 break; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 89 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
90 float scale, | 90 float scale, |
91 float top_controls_delta) OVERRIDE { | 91 float top_controls_delta) OVERRIDE { |
92 num_scrolls_++; | 92 num_scrolls_++; |
93 } | 93 } |
(...skipping 26 matching lines...) Expand all Loading... | |
120 scroll_layer_->SetIsContainerForFixedPositionLayers(true); | 120 scroll_layer_->SetIsContainerForFixedPositionLayers(true); |
121 scroll_layer_->SetScrollClipLayerId(root_layer->id()); | 121 scroll_layer_->SetScrollClipLayerId(root_layer->id()); |
122 scroll_layer_->SetScrollOffset(initial_scroll_); | 122 scroll_layer_->SetScrollOffset(initial_scroll_); |
123 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer_, NULL); | 123 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer_, NULL); |
124 PostSetNeedsCommitToMainThread(); | 124 PostSetNeedsCommitToMainThread(); |
125 } | 125 } |
126 | 126 |
127 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 127 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
128 switch (layer_tree_host()->source_frame_number()) { | 128 switch (layer_tree_host()->source_frame_number()) { |
129 case 0: | 129 case 0: |
130 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), initial_scroll_); | 130 EXPECT_VECTOR2DF_EQ(scroll_layer_->scroll_offset(), initial_scroll_); |
131 break; | 131 break; |
132 case 1: | 132 case 1: |
133 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), | 133 EXPECT_VECTOR2DF_EQ(scroll_layer_->scroll_offset(), |
134 initial_scroll_ + scroll_amount_ + scroll_amount_); | 134 initial_scroll_ + scroll_amount_ + scroll_amount_); |
135 case 2: | 135 case 2: |
136 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), | 136 EXPECT_VECTOR2DF_EQ(scroll_layer_->scroll_offset(), |
137 initial_scroll_ + scroll_amount_ + scroll_amount_); | 137 initial_scroll_ + scroll_amount_ + scroll_amount_); |
138 break; | 138 break; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 142 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
143 LayerImpl* scroll_layer = | 143 LayerImpl* scroll_layer = |
144 impl->active_tree()->LayerById(scroll_layer_->id()); | 144 impl->active_tree()->LayerById(scroll_layer_->id()); |
145 if (impl->active_tree()->source_frame_number() == 0 && | 145 if (impl->active_tree()->source_frame_number() == 0 && |
146 impl->SourceAnimationFrameNumber() == 1) { | 146 impl->SourceAnimationFrameNumber() == 1) { |
147 // First draw after first commit. | 147 // First draw after first commit. |
148 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d()); | 148 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF()); |
149 scroll_layer->ScrollBy(scroll_amount_); | 149 scroll_layer->ScrollBy(scroll_amount_); |
150 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_); | 150 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), scroll_amount_); |
151 | 151 |
152 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 152 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
153 PostSetNeedsRedrawToMainThread(); | 153 PostSetNeedsRedrawToMainThread(); |
154 } else if (impl->active_tree()->source_frame_number() == 0 && | 154 } else if (impl->active_tree()->source_frame_number() == 0 && |
155 impl->SourceAnimationFrameNumber() == 2) { | 155 impl->SourceAnimationFrameNumber() == 2) { |
156 // Second draw after first commit. | 156 // Second draw after first commit. |
157 EXPECT_EQ(scroll_layer->ScrollDelta(), scroll_amount_); | 157 EXPECT_EQ(scroll_layer->ScrollDelta(), scroll_amount_); |
158 scroll_layer->ScrollBy(scroll_amount_); | 158 scroll_layer->ScrollBy(scroll_amount_); |
159 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), | 159 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), |
160 scroll_amount_ + scroll_amount_); | 160 scroll_amount_ + scroll_amount_); |
161 | 161 |
162 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), initial_scroll_); | 162 EXPECT_VECTOR2DF_EQ(scroll_layer_->scroll_offset(), initial_scroll_); |
163 PostSetNeedsCommitToMainThread(); | 163 PostSetNeedsCommitToMainThread(); |
164 } else if (impl->active_tree()->source_frame_number() == 1) { | 164 } else if (impl->active_tree()->source_frame_number() == 1) { |
165 // Third or later draw after second commit. | 165 // Third or later draw after second commit. |
166 EXPECT_GE(impl->SourceAnimationFrameNumber(), 3); | 166 EXPECT_GE(impl->SourceAnimationFrameNumber(), 3); |
167 EXPECT_VECTOR_EQ(scroll_layer_->ScrollDelta(), gfx::Vector2d()); | 167 EXPECT_VECTOR2DF_EQ(scroll_layer_->ScrollDelta(), gfx::Vector2dF()); |
168 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), | 168 EXPECT_VECTOR2DF_EQ(scroll_layer_->scroll_offset(), |
169 initial_scroll_ + scroll_amount_ + scroll_amount_); | 169 initial_scroll_ + scroll_amount_ + scroll_amount_); |
170 EndTest(); | 170 EndTest(); |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 174 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
175 float scale, | 175 float scale, |
176 float top_controls_delta) OVERRIDE { | 176 float top_controls_delta) OVERRIDE { |
177 num_scrolls_++; | 177 num_scrolls_++; |
178 } | 178 } |
179 | 179 |
180 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } | 180 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } |
181 | 181 |
182 private: | 182 private: |
183 gfx::Vector2d initial_scroll_; | 183 gfx::Vector2dF initial_scroll_; |
184 gfx::Vector2d scroll_amount_; | 184 gfx::Vector2dF scroll_amount_; |
185 int num_scrolls_; | 185 int num_scrolls_; |
186 scoped_refptr<Layer> scroll_layer_; | 186 scoped_refptr<Layer> scroll_layer_; |
187 }; | 187 }; |
188 | 188 |
189 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollMultipleRedraw); | 189 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollMultipleRedraw); |
190 | 190 |
191 class LayerTreeHostScrollTestScrollAbortedCommit | 191 class LayerTreeHostScrollTestScrollAbortedCommit |
192 : public LayerTreeHostScrollTest { | 192 : public LayerTreeHostScrollTest { |
193 public: | 193 public: |
194 LayerTreeHostScrollTestScrollAbortedCommit() | 194 LayerTreeHostScrollTestScrollAbortedCommit() |
(...skipping 28 matching lines...) Expand all Loading... | |
223 | 223 |
224 virtual void WillBeginMainFrame() OVERRIDE { | 224 virtual void WillBeginMainFrame() OVERRIDE { |
225 num_will_begin_main_frames_++; | 225 num_will_begin_main_frames_++; |
226 Layer* root_scroll_layer = | 226 Layer* root_scroll_layer = |
227 layer_tree_host()->root_layer()->children()[0].get(); | 227 layer_tree_host()->root_layer()->children()[0].get(); |
228 switch (num_will_begin_main_frames_) { | 228 switch (num_will_begin_main_frames_) { |
229 case 1: | 229 case 1: |
230 // This will not be aborted because of the initial prop changes. | 230 // This will not be aborted because of the initial prop changes. |
231 EXPECT_EQ(0, num_impl_scrolls_); | 231 EXPECT_EQ(0, num_impl_scrolls_); |
232 EXPECT_EQ(0, layer_tree_host()->source_frame_number()); | 232 EXPECT_EQ(0, layer_tree_host()->source_frame_number()); |
233 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), initial_scroll_); | 233 EXPECT_VECTOR2DF_EQ(root_scroll_layer->scroll_offset(), |
234 initial_scroll_); | |
234 EXPECT_EQ(1.f, layer_tree_host()->page_scale_factor()); | 235 EXPECT_EQ(1.f, layer_tree_host()->page_scale_factor()); |
235 break; | 236 break; |
236 case 2: | 237 case 2: |
237 // This commit will be aborted, and another commit will be | 238 // This commit will be aborted, and another commit will be |
238 // initiated from the redraw. | 239 // initiated from the redraw. |
239 EXPECT_EQ(1, num_impl_scrolls_); | 240 EXPECT_EQ(1, num_impl_scrolls_); |
240 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); | 241 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); |
241 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), | 242 EXPECT_VECTOR2DF_EQ(root_scroll_layer->scroll_offset(), |
242 initial_scroll_ + impl_scroll_); | 243 initial_scroll_ + impl_scroll_); |
243 EXPECT_EQ(impl_scale_, layer_tree_host()->page_scale_factor()); | 244 EXPECT_EQ(impl_scale_, layer_tree_host()->page_scale_factor()); |
244 PostSetNeedsRedrawToMainThread(); | 245 PostSetNeedsRedrawToMainThread(); |
245 break; | 246 break; |
246 case 3: | 247 case 3: |
247 // This commit will not be aborted because of the scroll change. | 248 // This commit will not be aborted because of the scroll change. |
248 EXPECT_EQ(2, num_impl_scrolls_); | 249 EXPECT_EQ(2, num_impl_scrolls_); |
249 // The source frame number still increases even with the abort. | 250 // The source frame number still increases even with the abort. |
250 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); | 251 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); |
251 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), | 252 EXPECT_VECTOR2DF_EQ(root_scroll_layer->scroll_offset(), |
252 initial_scroll_ + impl_scroll_ + impl_scroll_); | 253 initial_scroll_ + impl_scroll_ + impl_scroll_); |
253 EXPECT_EQ(impl_scale_ * impl_scale_, | 254 EXPECT_EQ(impl_scale_ * impl_scale_, |
254 layer_tree_host()->page_scale_factor()); | 255 layer_tree_host()->page_scale_factor()); |
255 root_scroll_layer->SetScrollOffset(root_scroll_layer->scroll_offset() + | 256 root_scroll_layer->SetScrollOffset(root_scroll_layer->scroll_offset() + |
256 second_main_scroll_); | 257 second_main_scroll_); |
257 break; | 258 break; |
258 case 4: | 259 case 4: |
259 // This commit will also be aborted. | 260 // This commit will also be aborted. |
260 EXPECT_EQ(3, num_impl_scrolls_); | 261 EXPECT_EQ(3, num_impl_scrolls_); |
261 EXPECT_EQ(3, layer_tree_host()->source_frame_number()); | 262 EXPECT_EQ(3, layer_tree_host()->source_frame_number()); |
262 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), | 263 EXPECT_VECTOR2DF_EQ(root_scroll_layer->scroll_offset(), |
263 initial_scroll_ + impl_scroll_ + impl_scroll_ + | 264 initial_scroll_ + impl_scroll_ + impl_scroll_ + |
264 impl_scroll_ + second_main_scroll_); | 265 impl_scroll_ + second_main_scroll_); |
265 // End the test by drawing to verify this commit is also aborted. | 266 // End the test by drawing to verify this commit is also aborted. |
266 PostSetNeedsRedrawToMainThread(); | 267 PostSetNeedsRedrawToMainThread(); |
267 break; | 268 break; |
268 } | 269 } |
269 } | 270 } |
270 | 271 |
271 virtual void DidBeginMainFrame() OVERRIDE { num_did_begin_main_frames_++; } | 272 virtual void DidBeginMainFrame() OVERRIDE { num_did_begin_main_frames_++; } |
272 | 273 |
273 virtual void WillCommit() OVERRIDE { num_will_commits_++; } | 274 virtual void WillCommit() OVERRIDE { num_will_commits_++; } |
274 | 275 |
275 virtual void DidCommit() OVERRIDE { num_did_commits_++; } | 276 virtual void DidCommit() OVERRIDE { num_did_commits_++; } |
276 | 277 |
277 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 278 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
278 num_impl_commits_++; | 279 num_impl_commits_++; |
279 } | 280 } |
280 | 281 |
281 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 282 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
282 LayerImpl* root_scroll_layer = | 283 LayerImpl* root_scroll_layer = |
283 impl->active_tree()->root_layer()->children()[0]; | 284 impl->active_tree()->root_layer()->children()[0]; |
284 | 285 |
285 if (impl->active_tree()->source_frame_number() == 0 && | 286 if (impl->active_tree()->source_frame_number() == 0 && |
286 impl->SourceAnimationFrameNumber() == 1) { | 287 impl->SourceAnimationFrameNumber() == 1) { |
287 // First draw | 288 // First draw |
288 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); | 289 EXPECT_VECTOR2DF_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2dF()); |
289 root_scroll_layer->ScrollBy(impl_scroll_); | 290 root_scroll_layer->ScrollBy(impl_scroll_); |
290 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_); | 291 EXPECT_VECTOR2DF_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_); |
291 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), initial_scroll_); | 292 EXPECT_VECTOR2DF_EQ(root_scroll_layer->scroll_offset(), initial_scroll_); |
292 | 293 |
293 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta()); | 294 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta()); |
294 EXPECT_EQ(1.f, impl->active_tree()->total_page_scale_factor()); | 295 EXPECT_EQ(1.f, impl->active_tree()->total_page_scale_factor()); |
295 impl->active_tree()->SetPageScaleDelta(impl_scale_); | 296 impl->active_tree()->SetPageScaleDelta(impl_scale_); |
296 EXPECT_EQ(impl_scale_, impl->active_tree()->page_scale_delta()); | 297 EXPECT_EQ(impl_scale_, impl->active_tree()->page_scale_delta()); |
297 EXPECT_EQ(impl_scale_, impl->active_tree()->total_page_scale_factor()); | 298 EXPECT_EQ(impl_scale_, impl->active_tree()->total_page_scale_factor()); |
298 | 299 |
299 // To simplify the testing flow, don't redraw here, just commit. | 300 // To simplify the testing flow, don't redraw here, just commit. |
300 impl->SetNeedsCommit(); | 301 impl->SetNeedsCommit(); |
301 } else if (impl->active_tree()->source_frame_number() == 0 && | 302 } else if (impl->active_tree()->source_frame_number() == 0 && |
302 impl->SourceAnimationFrameNumber() == 2) { | 303 impl->SourceAnimationFrameNumber() == 2) { |
303 // Test a second draw after an aborted commit. | 304 // Test a second draw after an aborted commit. |
304 // The scroll/scale values should be baked into the offset/scale factor | 305 // The scroll/scale values should be baked into the offset/scale factor |
305 // since the main thread consumed but aborted the begin frame. | 306 // since the main thread consumed but aborted the begin frame. |
306 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); | 307 EXPECT_VECTOR2DF_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2dF()); |
307 root_scroll_layer->ScrollBy(impl_scroll_); | 308 root_scroll_layer->ScrollBy(impl_scroll_); |
308 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_); | 309 EXPECT_VECTOR2DF_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_); |
309 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), | 310 EXPECT_VECTOR2DF_EQ(root_scroll_layer->scroll_offset(), |
310 initial_scroll_ + impl_scroll_); | 311 initial_scroll_ + impl_scroll_); |
311 | 312 |
312 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta()); | 313 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta()); |
313 EXPECT_EQ(impl_scale_, impl->active_tree()->total_page_scale_factor()); | 314 EXPECT_EQ(impl_scale_, impl->active_tree()->total_page_scale_factor()); |
314 impl->active_tree()->SetPageScaleDelta(impl_scale_); | 315 impl->active_tree()->SetPageScaleDelta(impl_scale_); |
315 EXPECT_EQ(impl_scale_, impl->active_tree()->page_scale_delta()); | 316 EXPECT_EQ(impl_scale_, impl->active_tree()->page_scale_delta()); |
316 EXPECT_EQ(impl_scale_ * impl_scale_, | 317 EXPECT_EQ(impl_scale_ * impl_scale_, |
317 impl->active_tree()->total_page_scale_factor()); | 318 impl->active_tree()->total_page_scale_factor()); |
318 | 319 |
319 impl->SetNeedsCommit(); | 320 impl->SetNeedsCommit(); |
320 } else if (impl->active_tree()->source_frame_number() == 1) { | 321 } else if (impl->active_tree()->source_frame_number() == 1) { |
321 // Commit for source frame 1 is aborted. | 322 // Commit for source frame 1 is aborted. |
322 NOTREACHED(); | 323 NOTREACHED(); |
323 } else if (impl->active_tree()->source_frame_number() == 2 && | 324 } else if (impl->active_tree()->source_frame_number() == 2 && |
324 impl->SourceAnimationFrameNumber() == 3) { | 325 impl->SourceAnimationFrameNumber() == 3) { |
325 // Third draw after the second full commit. | 326 // Third draw after the second full commit. |
326 EXPECT_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); | 327 EXPECT_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2dF()); |
327 root_scroll_layer->ScrollBy(impl_scroll_); | 328 root_scroll_layer->ScrollBy(impl_scroll_); |
328 impl->SetNeedsCommit(); | 329 impl->SetNeedsCommit(); |
329 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_); | 330 EXPECT_VECTOR2DF_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_); |
330 EXPECT_VECTOR_EQ( | 331 EXPECT_VECTOR2DF_EQ( |
331 root_scroll_layer->scroll_offset(), | 332 root_scroll_layer->scroll_offset(), |
332 initial_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_); | 333 initial_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_); |
333 } else if (impl->active_tree()->source_frame_number() == 2 && | 334 } else if (impl->active_tree()->source_frame_number() == 2 && |
334 impl->SourceAnimationFrameNumber() == 4) { | 335 impl->SourceAnimationFrameNumber() == 4) { |
335 // Final draw after the second aborted commit. | 336 // Final draw after the second aborted commit. |
336 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); | 337 EXPECT_VECTOR2DF_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2dF()); |
337 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), | 338 EXPECT_VECTOR2DF_EQ(root_scroll_layer->scroll_offset(), |
338 initial_scroll_ + impl_scroll_ + impl_scroll_ + | 339 initial_scroll_ + impl_scroll_ + impl_scroll_ + |
339 impl_scroll_ + second_main_scroll_); | 340 impl_scroll_ + second_main_scroll_); |
340 EndTest(); | 341 EndTest(); |
341 } else { | 342 } else { |
342 // Commit for source frame 3 is aborted. | 343 // Commit for source frame 3 is aborted. |
343 NOTREACHED(); | 344 NOTREACHED(); |
344 } | 345 } |
345 } | 346 } |
346 | 347 |
347 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 348 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 } | 403 } |
403 | 404 |
404 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 405 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
405 LayerImpl* root = impl->active_tree()->root_layer(); | 406 LayerImpl* root = impl->active_tree()->root_layer(); |
406 LayerImpl* scroll_layer = root->children()[0]; | 407 LayerImpl* scroll_layer = root->children()[0]; |
407 | 408 |
408 // Check that a fractional scroll delta is correctly accumulated over | 409 // Check that a fractional scroll delta is correctly accumulated over |
409 // multiple commits. | 410 // multiple commits. |
410 switch (impl->active_tree()->source_frame_number()) { | 411 switch (impl->active_tree()->source_frame_number()) { |
411 case 0: | 412 case 0: |
412 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), gfx::Vector2d(0, 0)); | 413 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), |
413 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d(0, 0)); | 414 gfx::Vector2dF(0, 0)); |
415 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF(0, 0)); | |
414 PostSetNeedsCommitToMainThread(); | 416 PostSetNeedsCommitToMainThread(); |
415 break; | 417 break; |
416 case 1: | 418 case 1: |
417 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), | 419 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), scroll_amount_); |
418 gfx::ToFlooredVector2d(scroll_amount_)); | 420 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF(0, 0)); |
419 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), | |
420 gfx::Vector2dF(fmod(scroll_amount_.x(), 1.0f), 0.0f)); | |
421 PostSetNeedsCommitToMainThread(); | 421 PostSetNeedsCommitToMainThread(); |
422 break; | 422 break; |
423 case 2: | 423 case 2: |
424 EXPECT_VECTOR_EQ( | 424 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), |
425 scroll_layer->scroll_offset(), | 425 scroll_amount_ + scroll_amount_); |
426 gfx::ToFlooredVector2d(scroll_amount_ + scroll_amount_)); | 426 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF(0, 0)); |
427 EXPECT_VECTOR_EQ( | |
428 scroll_layer->ScrollDelta(), | |
429 gfx::Vector2dF(fmod(2.0f * scroll_amount_.x(), 1.0f), 0.0f)); | |
430 EndTest(); | 427 EndTest(); |
431 break; | 428 break; |
432 } | 429 } |
433 scroll_layer->ScrollBy(scroll_amount_); | 430 scroll_layer->ScrollBy(scroll_amount_); |
434 } | 431 } |
435 | 432 |
436 virtual void AfterTest() OVERRIDE {} | 433 virtual void AfterTest() OVERRIDE {} |
437 | 434 |
438 private: | 435 private: |
439 gfx::Vector2dF scroll_amount_; | 436 gfx::Vector2dF scroll_amount_; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); | 513 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); |
517 } | 514 } |
518 | 515 |
519 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 516 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
520 float scale, | 517 float scale, |
521 float top_controls_delta) OVERRIDE { | 518 float top_controls_delta) OVERRIDE { |
522 num_scrolls_++; | 519 num_scrolls_++; |
523 } | 520 } |
524 | 521 |
525 virtual void Layout() OVERRIDE { | 522 virtual void Layout() OVERRIDE { |
526 EXPECT_VECTOR_EQ(gfx::Vector2d(), | 523 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(), |
527 expected_no_scroll_layer_->scroll_offset()); | 524 expected_no_scroll_layer_->scroll_offset()); |
528 | 525 |
529 switch (layer_tree_host()->source_frame_number()) { | 526 switch (layer_tree_host()->source_frame_number()) { |
530 case 0: | 527 case 0: |
531 EXPECT_VECTOR_EQ(initial_offset_, | 528 EXPECT_VECTOR2DF_EQ(initial_offset_, |
532 expected_scroll_layer_->scroll_offset()); | 529 expected_scroll_layer_->scroll_offset()); |
533 break; | 530 break; |
534 case 1: | 531 case 1: |
535 EXPECT_VECTOR_EQ(initial_offset_ + scroll_amount_, | 532 EXPECT_VECTOR2DF_EQ(initial_offset_ + scroll_amount_, |
536 expected_scroll_layer_->scroll_offset()); | 533 expected_scroll_layer_->scroll_offset()); |
537 | 534 |
538 // Pretend like Javascript updated the scroll position itself. | 535 // Pretend like Javascript updated the scroll position itself. |
539 expected_scroll_layer_->SetScrollOffset(javascript_scroll_); | 536 expected_scroll_layer_->SetScrollOffset(javascript_scroll_); |
540 break; | 537 break; |
541 case 2: | 538 case 2: |
542 EXPECT_VECTOR_EQ(javascript_scroll_ + scroll_amount_, | 539 EXPECT_VECTOR2DF_EQ(javascript_scroll_ + scroll_amount_, |
543 expected_scroll_layer_->scroll_offset()); | 540 expected_scroll_layer_->scroll_offset()); |
544 break; | 541 break; |
545 } | 542 } |
546 } | 543 } |
547 | 544 |
548 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 545 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
549 LayerImpl* root_impl = impl->active_tree()->root_layer(); | 546 LayerImpl* root_impl = impl->active_tree()->root_layer(); |
550 FakePictureLayerImpl* root_scroll_layer_impl = | 547 FakePictureLayerImpl* root_scroll_layer_impl = |
551 static_cast<FakePictureLayerImpl*>(root_impl->children()[0]); | 548 static_cast<FakePictureLayerImpl*>(root_impl->children()[0]); |
552 FakePictureLayerImpl* child_layer_impl = static_cast<FakePictureLayerImpl*>( | 549 FakePictureLayerImpl* child_layer_impl = static_cast<FakePictureLayerImpl*>( |
553 root_scroll_layer_impl->children()[0]); | 550 root_scroll_layer_impl->children()[0]); |
554 | 551 |
555 LayerImpl* expected_scroll_layer_impl = NULL; | 552 LayerImpl* expected_scroll_layer_impl = NULL; |
556 LayerImpl* expected_no_scroll_layer_impl = NULL; | 553 LayerImpl* expected_no_scroll_layer_impl = NULL; |
557 if (scroll_child_layer_) { | 554 if (scroll_child_layer_) { |
558 expected_scroll_layer_impl = child_layer_impl; | 555 expected_scroll_layer_impl = child_layer_impl; |
559 expected_no_scroll_layer_impl = root_scroll_layer_impl; | 556 expected_no_scroll_layer_impl = root_scroll_layer_impl; |
560 } else { | 557 } else { |
561 expected_scroll_layer_impl = root_scroll_layer_impl; | 558 expected_scroll_layer_impl = root_scroll_layer_impl; |
562 expected_no_scroll_layer_impl = child_layer_impl; | 559 expected_no_scroll_layer_impl = child_layer_impl; |
563 } | 560 } |
564 | 561 |
565 EXPECT_VECTOR_EQ(gfx::Vector2d(), root_impl->ScrollDelta()); | 562 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(), root_impl->ScrollDelta()); |
566 EXPECT_VECTOR_EQ(gfx::Vector2d(), | 563 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(), |
567 expected_no_scroll_layer_impl->ScrollDelta()); | 564 expected_no_scroll_layer_impl->ScrollDelta()); |
568 | 565 |
569 // Ensure device scale factor is affecting the layers. | 566 // Ensure device scale factor is affecting the layers. |
570 EXPECT_FLOAT_EQ(device_scale_factor_, | 567 EXPECT_FLOAT_EQ(device_scale_factor_, |
571 root_scroll_layer_impl->HighResTiling()->contents_scale()); | 568 root_scroll_layer_impl->HighResTiling()->contents_scale()); |
572 | 569 |
573 EXPECT_FLOAT_EQ(device_scale_factor_, | 570 EXPECT_FLOAT_EQ(device_scale_factor_, |
574 child_layer_impl->HighResTiling()->contents_scale()); | 571 child_layer_impl->HighResTiling()->contents_scale()); |
575 | 572 |
576 switch (impl->active_tree()->source_frame_number()) { | 573 switch (impl->active_tree()->source_frame_number()) { |
577 case 0: { | 574 case 0: { |
578 // Gesture scroll on impl thread. | 575 // Gesture scroll on impl thread. |
579 InputHandler::ScrollStatus status = impl->ScrollBegin( | 576 InputHandler::ScrollStatus status = impl->ScrollBegin( |
580 gfx::ToCeiledPoint(expected_scroll_layer_impl->position() - | 577 gfx::ToCeiledPoint(expected_scroll_layer_impl->position() - |
581 gfx::Vector2dF(0.5f, 0.5f)), | 578 gfx::Vector2dF(0.5f, 0.5f)), |
582 InputHandler::Gesture); | 579 InputHandler::Gesture); |
583 EXPECT_EQ(InputHandler::ScrollStarted, status); | 580 EXPECT_EQ(InputHandler::ScrollStarted, status); |
584 impl->ScrollBy(gfx::Point(), scroll_amount_); | 581 impl->ScrollBy(gfx::Point(), scroll_amount_); |
585 impl->ScrollEnd(); | 582 impl->ScrollEnd(); |
586 | 583 |
587 // Check the scroll is applied as a delta. | 584 // Check the scroll is applied as a delta. |
588 EXPECT_VECTOR_EQ(initial_offset_, | 585 EXPECT_VECTOR2DF_EQ(initial_offset_, |
589 expected_scroll_layer_impl->scroll_offset()); | 586 expected_scroll_layer_impl->scroll_offset()); |
590 EXPECT_VECTOR_EQ(scroll_amount_, | 587 EXPECT_VECTOR2DF_EQ(scroll_amount_, |
591 expected_scroll_layer_impl->ScrollDelta()); | 588 expected_scroll_layer_impl->ScrollDelta()); |
592 break; | 589 break; |
593 } | 590 } |
594 case 1: { | 591 case 1: { |
595 // Wheel scroll on impl thread. | 592 // Wheel scroll on impl thread. |
596 InputHandler::ScrollStatus status = impl->ScrollBegin( | 593 InputHandler::ScrollStatus status = impl->ScrollBegin( |
597 gfx::ToCeiledPoint(expected_scroll_layer_impl->position() + | 594 gfx::ToCeiledPoint(expected_scroll_layer_impl->position() + |
598 gfx::Vector2dF(0.5f, 0.5f)), | 595 gfx::Vector2dF(0.5f, 0.5f)), |
599 InputHandler::Wheel); | 596 InputHandler::Wheel); |
600 EXPECT_EQ(InputHandler::ScrollStarted, status); | 597 EXPECT_EQ(InputHandler::ScrollStarted, status); |
601 impl->ScrollBy(gfx::Point(), scroll_amount_); | 598 impl->ScrollBy(gfx::Point(), scroll_amount_); |
602 impl->ScrollEnd(); | 599 impl->ScrollEnd(); |
603 | 600 |
604 // Check the scroll is applied as a delta. | 601 // Check the scroll is applied as a delta. |
605 EXPECT_VECTOR_EQ(javascript_scroll_, | 602 EXPECT_VECTOR2DF_EQ(javascript_scroll_, |
606 expected_scroll_layer_impl->scroll_offset()); | 603 expected_scroll_layer_impl->scroll_offset()); |
607 EXPECT_VECTOR_EQ(scroll_amount_, | 604 EXPECT_VECTOR2DF_EQ(scroll_amount_, |
608 expected_scroll_layer_impl->ScrollDelta()); | 605 expected_scroll_layer_impl->ScrollDelta()); |
609 break; | 606 break; |
610 } | 607 } |
611 case 2: | 608 case 2: |
612 | 609 |
613 EXPECT_VECTOR_EQ(javascript_scroll_ + scroll_amount_, | 610 EXPECT_VECTOR2DF_EQ(javascript_scroll_ + scroll_amount_, |
614 expected_scroll_layer_impl->scroll_offset()); | 611 expected_scroll_layer_impl->scroll_offset()); |
615 EXPECT_VECTOR_EQ(gfx::Vector2d(), | 612 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(), |
616 expected_scroll_layer_impl->ScrollDelta()); | 613 expected_scroll_layer_impl->ScrollDelta()); |
617 | 614 |
618 EndTest(); | 615 EndTest(); |
619 break; | 616 break; |
620 } | 617 } |
621 } | 618 } |
622 | 619 |
623 virtual void AfterTest() OVERRIDE { | 620 virtual void AfterTest() OVERRIDE { |
624 if (scroll_child_layer_) { | 621 if (scroll_child_layer_) { |
625 EXPECT_EQ(0, num_scrolls_); | 622 EXPECT_EQ(0, num_scrolls_); |
626 EXPECT_VECTOR_EQ(javascript_scroll_ + scroll_amount_, | 623 EXPECT_VECTOR_EQ(javascript_scroll_ + scroll_amount_, |
627 final_scroll_offset_); | 624 final_scroll_offset_); |
628 } else { | 625 } else { |
629 EXPECT_EQ(2, num_scrolls_); | 626 EXPECT_EQ(2, num_scrolls_); |
630 EXPECT_VECTOR_EQ(gfx::Vector2d(), final_scroll_offset_); | 627 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(), final_scroll_offset_); |
631 } | 628 } |
632 } | 629 } |
633 | 630 |
634 protected: | 631 protected: |
635 float device_scale_factor_; | 632 float device_scale_factor_; |
636 bool scroll_child_layer_; | 633 bool scroll_child_layer_; |
637 | 634 |
638 gfx::Vector2d initial_offset_; | 635 gfx::Vector2dF initial_offset_; |
639 gfx::Vector2d javascript_scroll_; | 636 gfx::Vector2dF javascript_scroll_; |
640 gfx::Vector2d scroll_amount_; | 637 gfx::Vector2dF scroll_amount_; |
641 int num_scrolls_; | 638 int num_scrolls_; |
642 gfx::Vector2d final_scroll_offset_; | 639 gfx::Vector2dF final_scroll_offset_; |
643 | 640 |
644 FakeContentLayerClient fake_content_layer_client_; | 641 FakeContentLayerClient fake_content_layer_client_; |
645 | 642 |
646 scoped_refptr<Layer> root_scroll_layer_; | 643 scoped_refptr<Layer> root_scroll_layer_; |
647 scoped_refptr<Layer> child_layer_; | 644 scoped_refptr<Layer> child_layer_; |
648 scoped_refptr<Layer> expected_scroll_layer_; | 645 scoped_refptr<Layer> expected_scroll_layer_; |
649 scoped_refptr<Layer> expected_no_scroll_layer_; | 646 scoped_refptr<Layer> expected_no_scroll_layer_; |
650 }; | 647 }; |
651 | 648 |
652 TEST_F(LayerTreeHostScrollTestCaseWithChild, | 649 TEST_F(LayerTreeHostScrollTestCaseWithChild, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
773 } | 770 } |
774 | 771 |
775 virtual void BeginTest() OVERRIDE { | 772 virtual void BeginTest() OVERRIDE { |
776 PostSetNeedsCommitToMainThread(); | 773 PostSetNeedsCommitToMainThread(); |
777 } | 774 } |
778 | 775 |
779 virtual void Layout() OVERRIDE { | 776 virtual void Layout() OVERRIDE { |
780 Layer* root = layer_tree_host()->root_layer(); | 777 Layer* root = layer_tree_host()->root_layer(); |
781 Layer* scroll_layer = root->children()[0].get(); | 778 Layer* scroll_layer = root->children()[0].get(); |
782 if (!layer_tree_host()->source_frame_number()) { | 779 if (!layer_tree_host()->source_frame_number()) { |
783 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 780 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
784 } else { | 781 } else { |
785 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), | 782 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), |
786 initial_scroll_ + impl_thread_scroll1_); | 783 initial_scroll_ + impl_thread_scroll1_); |
787 | 784 |
788 // Pretend like Javascript updated the scroll position itself with a | 785 // Pretend like Javascript updated the scroll position itself with a |
789 // change of main_thread_scroll. | 786 // change of main_thread_scroll. |
790 scroll_layer->SetScrollOffset(initial_scroll_ + main_thread_scroll_ + | 787 scroll_layer->SetScrollOffset(initial_scroll_ + main_thread_scroll_ + |
791 impl_thread_scroll1_); | 788 impl_thread_scroll1_); |
792 } | 789 } |
793 } | 790 } |
794 | 791 |
795 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 792 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
796 // We force a second draw here of the first commit before activating | 793 // We force a second draw here of the first commit before activating |
797 // the second commit. | 794 // the second commit. |
798 if (impl->active_tree()->source_frame_number() == 0) | 795 if (impl->active_tree()->source_frame_number() == 0) |
799 impl->SetNeedsRedraw(); | 796 impl->SetNeedsRedraw(); |
800 } | 797 } |
801 | 798 |
802 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 799 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
803 ImplSidePaintingScrollTest::DrawLayersOnThread(impl); | 800 ImplSidePaintingScrollTest::DrawLayersOnThread(impl); |
804 | 801 |
805 LayerImpl* root = impl->active_tree()->root_layer(); | 802 LayerImpl* root = impl->active_tree()->root_layer(); |
806 LayerImpl* scroll_layer = root->children()[0]; | 803 LayerImpl* scroll_layer = root->children()[0]; |
807 LayerImpl* pending_root = | 804 LayerImpl* pending_root = |
808 impl->active_tree()->FindPendingTreeLayerById(root->id()); | 805 impl->active_tree()->FindPendingTreeLayerById(root->id()); |
809 | 806 |
810 switch (impl->active_tree()->source_frame_number()) { | 807 switch (impl->active_tree()->source_frame_number()) { |
811 case 0: | 808 case 0: |
812 if (!impl->pending_tree()) { | 809 if (!impl->pending_tree()) { |
813 impl->BlockNotifyReadyToActivateForTesting(true); | 810 impl->BlockNotifyReadyToActivateForTesting(true); |
814 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d()); | 811 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF()); |
815 scroll_layer->ScrollBy(impl_thread_scroll1_); | 812 scroll_layer->ScrollBy(impl_thread_scroll1_); |
816 | 813 |
817 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 814 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
818 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll1_); | 815 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), |
819 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); | 816 impl_thread_scroll1_); |
817 EXPECT_VECTOR2DF_EQ(scroll_layer->sent_scroll_delta(), | |
818 gfx::Vector2dF()); | |
820 PostSetNeedsCommitToMainThread(); | 819 PostSetNeedsCommitToMainThread(); |
821 | 820 |
822 // CommitCompleteOnThread will trigger this function again | 821 // CommitCompleteOnThread will trigger this function again |
823 // and cause us to take the else clause. | 822 // and cause us to take the else clause. |
824 } else { | 823 } else { |
825 impl->BlockNotifyReadyToActivateForTesting(false); | 824 impl->BlockNotifyReadyToActivateForTesting(false); |
826 ASSERT_TRUE(pending_root); | 825 ASSERT_TRUE(pending_root); |
827 EXPECT_EQ(impl->pending_tree()->source_frame_number(), 1); | 826 EXPECT_EQ(impl->pending_tree()->source_frame_number(), 1); |
828 | 827 |
829 scroll_layer->ScrollBy(impl_thread_scroll2_); | 828 scroll_layer->ScrollBy(impl_thread_scroll2_); |
830 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 829 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
831 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), | 830 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), |
832 impl_thread_scroll1_ + impl_thread_scroll2_); | 831 impl_thread_scroll1_ + impl_thread_scroll2_); |
833 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), | 832 EXPECT_VECTOR2DF_EQ(scroll_layer->sent_scroll_delta(), |
834 impl_thread_scroll1_); | 833 impl_thread_scroll1_); |
835 | 834 |
836 LayerImpl* pending_scroll_layer = pending_root->children()[0]; | 835 LayerImpl* pending_scroll_layer = pending_root->children()[0]; |
837 EXPECT_VECTOR_EQ( | 836 EXPECT_VECTOR2DF_EQ( |
838 pending_scroll_layer->scroll_offset(), | 837 pending_scroll_layer->scroll_offset(), |
839 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); | 838 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); |
840 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), | 839 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->ScrollDelta(), |
841 impl_thread_scroll2_); | 840 impl_thread_scroll2_); |
842 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(), | 841 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->sent_scroll_delta(), |
843 gfx::Vector2d()); | 842 gfx::Vector2dF()); |
844 } | 843 } |
845 break; | 844 break; |
846 case 1: | 845 case 1: |
847 EXPECT_FALSE(impl->pending_tree()); | 846 EXPECT_FALSE(impl->pending_tree()); |
848 EXPECT_VECTOR_EQ( | 847 EXPECT_VECTOR2DF_EQ( |
849 scroll_layer->scroll_offset(), | 848 scroll_layer->scroll_offset(), |
850 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); | 849 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); |
851 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_); | 850 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_); |
852 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); | 851 EXPECT_VECTOR2DF_EQ(scroll_layer->sent_scroll_delta(), |
852 gfx::Vector2dF()); | |
853 EndTest(); | 853 EndTest(); |
854 break; | 854 break; |
855 } | 855 } |
856 } | 856 } |
857 | 857 |
858 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 858 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
859 float scale, | 859 float scale, |
860 float top_controls_delta) OVERRIDE { | 860 float top_controls_delta) OVERRIDE { |
861 num_scrolls_++; | 861 num_scrolls_++; |
862 } | 862 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
938 LayerImpl* active_root = impl->active_tree()->root_layer(); | 938 LayerImpl* active_root = impl->active_tree()->root_layer(); |
939 LayerImpl* active_scroll_layer = | 939 LayerImpl* active_scroll_layer = |
940 active_root ? active_root->children()[0] : NULL; | 940 active_root ? active_root->children()[0] : NULL; |
941 LayerImpl* pending_root = impl->pending_tree()->root_layer(); | 941 LayerImpl* pending_root = impl->pending_tree()->root_layer(); |
942 LayerImpl* pending_scroll_layer = pending_root->children()[0]; | 942 LayerImpl* pending_scroll_layer = pending_root->children()[0]; |
943 | 943 |
944 ASSERT_TRUE(pending_root); | 944 ASSERT_TRUE(pending_root); |
945 ASSERT_TRUE(pending_scroll_layer); | 945 ASSERT_TRUE(pending_scroll_layer); |
946 switch (impl->pending_tree()->source_frame_number()) { | 946 switch (impl->pending_tree()->source_frame_number()) { |
947 case 0: | 947 case 0: |
948 EXPECT_VECTOR_EQ(pending_scroll_layer->scroll_offset(), | 948 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->scroll_offset(), |
949 initial_scroll_); | 949 initial_scroll_); |
950 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), gfx::Vector2d()); | 950 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->ScrollDelta(), |
951 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(), | 951 gfx::Vector2dF()); |
952 gfx::Vector2d()); | 952 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->sent_scroll_delta(), |
953 gfx::Vector2dF()); | |
953 EXPECT_FALSE(active_root); | 954 EXPECT_FALSE(active_root); |
954 break; | 955 break; |
955 case 1: | 956 case 1: |
956 // Even though the scroll happened during the commit, both layers | 957 // Even though the scroll happened during the commit, both layers |
957 // should have the appropriate scroll delta. | 958 // should have the appropriate scroll delta. |
958 EXPECT_VECTOR_EQ(pending_scroll_layer->scroll_offset(), | 959 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->scroll_offset(), |
959 initial_scroll_); | 960 initial_scroll_); |
960 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), | 961 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->ScrollDelta(), |
961 impl_thread_scroll_); | 962 impl_thread_scroll_); |
962 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(), | 963 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->sent_scroll_delta(), |
963 gfx::Vector2d()); | 964 gfx::Vector2dF()); |
964 ASSERT_TRUE(active_root); | 965 ASSERT_TRUE(active_root); |
965 EXPECT_VECTOR_EQ(active_scroll_layer->scroll_offset(), initial_scroll_); | 966 EXPECT_VECTOR2DF_EQ(active_scroll_layer->scroll_offset(), |
966 EXPECT_VECTOR_EQ(active_scroll_layer->ScrollDelta(), | 967 initial_scroll_); |
968 EXPECT_VECTOR2DF_EQ(active_scroll_layer->ScrollDelta(), | |
967 impl_thread_scroll_); | 969 impl_thread_scroll_); |
968 EXPECT_VECTOR_EQ(active_scroll_layer->sent_scroll_delta(), | 970 EXPECT_VECTOR2DF_EQ(active_scroll_layer->sent_scroll_delta(), |
969 gfx::Vector2d()); | 971 gfx::Vector2dF()); |
970 break; | 972 break; |
971 case 2: | 973 case 2: |
972 // On the next commit, this delta should have been sent and applied. | 974 // On the next commit, this delta should have been sent and applied. |
973 EXPECT_VECTOR_EQ(pending_scroll_layer->scroll_offset(), | 975 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->scroll_offset(), |
974 initial_scroll_ + impl_thread_scroll_); | 976 initial_scroll_ + impl_thread_scroll_); |
975 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), gfx::Vector2d()); | 977 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->ScrollDelta(), |
976 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(), | 978 gfx::Vector2dF()); |
977 gfx::Vector2d()); | 979 EXPECT_VECTOR2DF_EQ(pending_scroll_layer->sent_scroll_delta(), |
980 gfx::Vector2dF()); | |
978 EndTest(); | 981 EndTest(); |
979 break; | 982 break; |
980 } | 983 } |
981 } | 984 } |
982 | 985 |
983 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 986 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
984 ImplSidePaintingScrollTest::DrawLayersOnThread(impl); | 987 ImplSidePaintingScrollTest::DrawLayersOnThread(impl); |
985 | 988 |
986 LayerImpl* root = impl->active_tree()->root_layer(); | 989 LayerImpl* root = impl->active_tree()->root_layer(); |
987 LayerImpl* scroll_layer = root->children()[0]; | 990 LayerImpl* scroll_layer = root->children()[0]; |
988 | 991 |
989 switch (impl->active_tree()->source_frame_number()) { | 992 switch (impl->active_tree()->source_frame_number()) { |
990 case 0: | 993 case 0: |
991 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 994 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
992 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d()); | 995 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF()); |
993 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); | 996 EXPECT_VECTOR2DF_EQ(scroll_layer->sent_scroll_delta(), |
997 gfx::Vector2dF()); | |
994 PostSetNeedsCommitToMainThread(); | 998 PostSetNeedsCommitToMainThread(); |
995 break; | 999 break; |
996 case 1: | 1000 case 1: |
997 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 1001 EXPECT_VECTOR2DF_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
998 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll_); | 1002 EXPECT_VECTOR2DF_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll_); |
999 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); | 1003 EXPECT_VECTOR2DF_EQ(scroll_layer->sent_scroll_delta(), |
1004 gfx::Vector2dF()); | |
1000 PostSetNeedsCommitToMainThread(); | 1005 PostSetNeedsCommitToMainThread(); |
1001 break; | 1006 break; |
1002 } | 1007 } |
1003 } | 1008 } |
1004 | 1009 |
1005 virtual void AfterTest() OVERRIDE {} | 1010 virtual void AfterTest() OVERRIDE {} |
1006 | 1011 |
1007 private: | 1012 private: |
1008 gfx::Vector2d initial_scroll_; | 1013 gfx::Vector2d initial_scroll_; |
1009 gfx::Vector2d impl_thread_scroll_; | 1014 gfx::Vector2d impl_thread_scroll_; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 RunTest(true, false, true); | 1225 RunTest(true, false, true); |
1221 } | 1226 } |
1222 | 1227 |
1223 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 1228 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
1224 scroll_destroy_whole_tree_ = true; | 1229 scroll_destroy_whole_tree_ = true; |
1225 RunTest(true, false, true); | 1230 RunTest(true, false, true); |
1226 } | 1231 } |
1227 | 1232 |
1228 } // namespace | 1233 } // namespace |
1229 } // namespace cc | 1234 } // namespace cc |
OLD | NEW |