OLD | NEW |
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 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/memory/ptr_util.h" |
16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
17 #include "cc/animation/animation_events.h" | 18 #include "cc/animation/animation_events.h" |
18 #include "cc/animation/animation_host.h" | 19 #include "cc/animation/animation_host.h" |
19 #include "cc/animation/animation_id_provider.h" | 20 #include "cc/animation/animation_id_provider.h" |
20 #include "cc/animation/transform_operations.h" | 21 #include "cc/animation/transform_operations.h" |
21 #include "cc/base/math_util.h" | 22 #include "cc/base/math_util.h" |
22 #include "cc/input/main_thread_scrolling_reason.h" | 23 #include "cc/input/main_thread_scrolling_reason.h" |
23 #include "cc/input/page_scale_animation.h" | 24 #include "cc/input/page_scale_animation.h" |
24 #include "cc/input/scrollbar_animation_controller_thinning.h" | 25 #include "cc/input/scrollbar_animation_controller_thinning.h" |
25 #include "cc/input/top_controls_manager.h" | 26 #include "cc/input/top_controls_manager.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 142 } |
142 void SetNeedsOneBeginImplFrameOnImplThread() override { | 143 void SetNeedsOneBeginImplFrameOnImplThread() override { |
143 did_request_next_frame_ = true; | 144 did_request_next_frame_ = true; |
144 } | 145 } |
145 void SetNeedsPrepareTilesOnImplThread() override { | 146 void SetNeedsPrepareTilesOnImplThread() override { |
146 did_request_prepare_tiles_ = true; | 147 did_request_prepare_tiles_ = true; |
147 } | 148 } |
148 void SetNeedsCommitOnImplThread() override { did_request_commit_ = true; } | 149 void SetNeedsCommitOnImplThread() override { did_request_commit_ = true; } |
149 void SetVideoNeedsBeginFrames(bool needs_begin_frames) override {} | 150 void SetVideoNeedsBeginFrames(bool needs_begin_frames) override {} |
150 void PostAnimationEventsToMainThreadOnImplThread( | 151 void PostAnimationEventsToMainThreadOnImplThread( |
151 scoped_ptr<AnimationEvents> events) override {} | 152 std::unique_ptr<AnimationEvents> events) override {} |
152 bool IsInsideDraw() override { return false; } | 153 bool IsInsideDraw() override { return false; } |
153 void RenewTreePriority() override {} | 154 void RenewTreePriority() override {} |
154 void PostDelayedAnimationTaskOnImplThread(const base::Closure& task, | 155 void PostDelayedAnimationTaskOnImplThread(const base::Closure& task, |
155 base::TimeDelta delay) override { | 156 base::TimeDelta delay) override { |
156 animation_task_ = task; | 157 animation_task_ = task; |
157 requested_animation_delay_ = delay; | 158 requested_animation_delay_ = delay; |
158 } | 159 } |
159 void DidActivateSyncTree() override {} | 160 void DidActivateSyncTree() override {} |
160 void WillPrepareTiles() override {} | 161 void WillPrepareTiles() override {} |
161 void DidPrepareTiles() override {} | 162 void DidPrepareTiles() override {} |
162 void DidCompletePageScaleAnimationOnImplThread() override { | 163 void DidCompletePageScaleAnimationOnImplThread() override { |
163 did_complete_page_scale_animation_ = true; | 164 did_complete_page_scale_animation_ = true; |
164 } | 165 } |
165 void OnDrawForOutputSurface(bool resourceless_software_draw) override { | 166 void OnDrawForOutputSurface(bool resourceless_software_draw) override { |
166 scoped_ptr<LayerTreeHostImpl::FrameData> frame( | 167 std::unique_ptr<LayerTreeHostImpl::FrameData> frame( |
167 new LayerTreeHostImpl::FrameData); | 168 new LayerTreeHostImpl::FrameData); |
168 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(frame.get())); | 169 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(frame.get())); |
169 last_on_draw_render_passes_.clear(); | 170 last_on_draw_render_passes_.clear(); |
170 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_); | 171 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_); |
171 if (!skip_draw_layers_in_on_draw_) | 172 if (!skip_draw_layers_in_on_draw_) |
172 host_impl_->DrawLayers(frame.get()); | 173 host_impl_->DrawLayers(frame.get()); |
173 host_impl_->DidDrawAllLayers(*frame); | 174 host_impl_->DidDrawAllLayers(*frame); |
174 host_impl_->SwapBuffers(*frame); | 175 host_impl_->SwapBuffers(*frame); |
175 last_on_draw_frame_ = std::move(frame); | 176 last_on_draw_frame_ = std::move(frame); |
176 } | 177 } |
177 void PostFrameTimingEventsOnImplThread( | 178 void PostFrameTimingEventsOnImplThread( |
178 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 179 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
179 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) | 180 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) |
180 override {} | 181 override {} |
181 | 182 |
182 void set_reduce_memory_result(bool reduce_memory_result) { | 183 void set_reduce_memory_result(bool reduce_memory_result) { |
183 reduce_memory_result_ = reduce_memory_result; | 184 reduce_memory_result_ = reduce_memory_result; |
184 } | 185 } |
185 | 186 |
186 virtual bool CreateHostImpl(const LayerTreeSettings& settings, | 187 virtual bool CreateHostImpl(const LayerTreeSettings& settings, |
187 scoped_ptr<OutputSurface> output_surface) { | 188 std::unique_ptr<OutputSurface> output_surface) { |
188 return CreateHostImplWithTaskRunnerProvider( | 189 return CreateHostImplWithTaskRunnerProvider( |
189 settings, std::move(output_surface), &task_runner_provider_); | 190 settings, std::move(output_surface), &task_runner_provider_); |
190 } | 191 } |
191 | 192 |
192 virtual bool CreateHostImplWithTaskRunnerProvider( | 193 virtual bool CreateHostImplWithTaskRunnerProvider( |
193 const LayerTreeSettings& settings, | 194 const LayerTreeSettings& settings, |
194 scoped_ptr<OutputSurface> output_surface, | 195 std::unique_ptr<OutputSurface> output_surface, |
195 TaskRunnerProvider* task_runner_provider) { | 196 TaskRunnerProvider* task_runner_provider) { |
196 host_impl_ = LayerTreeHostImpl::Create( | 197 host_impl_ = LayerTreeHostImpl::Create( |
197 settings, this, task_runner_provider, &stats_instrumentation_, | 198 settings, this, task_runner_provider, &stats_instrumentation_, |
198 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, | 199 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, |
199 &task_graph_runner_, 0); | 200 &task_graph_runner_, 0); |
200 output_surface_ = std::move(output_surface); | 201 output_surface_ = std::move(output_surface); |
201 host_impl_->SetVisible(true); | 202 host_impl_->SetVisible(true); |
202 bool init = host_impl_->InitializeRenderer(output_surface_.get()); | 203 bool init = host_impl_->InitializeRenderer(output_surface_.get()); |
203 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 204 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
204 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 205 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
205 // Set the BeginFrameArgs so that methods which use it are able to. | 206 // Set the BeginFrameArgs so that methods which use it are able to. |
206 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( | 207 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( |
207 BEGINFRAME_FROM_HERE, | 208 BEGINFRAME_FROM_HERE, |
208 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); | 209 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); |
209 host_impl_->DidFinishImplFrame(); | 210 host_impl_->DidFinishImplFrame(); |
210 | 211 |
211 timeline_ = | 212 timeline_ = |
212 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 213 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
213 host_impl_->animation_host()->AddAnimationTimeline(timeline_); | 214 host_impl_->animation_host()->AddAnimationTimeline(timeline_); |
214 | 215 |
215 return init; | 216 return init; |
216 } | 217 } |
217 | 218 |
218 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 219 void SetupRootLayerImpl(std::unique_ptr<LayerImpl> root) { |
219 root->SetPosition(gfx::PointF()); | 220 root->SetPosition(gfx::PointF()); |
220 root->SetBounds(gfx::Size(10, 10)); | 221 root->SetBounds(gfx::Size(10, 10)); |
221 root->SetDrawsContent(true); | 222 root->SetDrawsContent(true); |
222 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); | 223 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); |
223 root->SetForceRenderSurface(true); | 224 root->SetForceRenderSurface(true); |
224 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 225 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
225 } | 226 } |
226 | 227 |
227 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { | 228 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { |
228 gfx::ScrollOffset delta = | 229 gfx::ScrollOffset delta = |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // Create both an inner viewport scroll layer and an outer viewport scroll | 279 // Create both an inner viewport scroll layer and an outer viewport scroll |
279 // layer. The MaxScrollOffset of the outer viewport scroll layer will be | 280 // layer. The MaxScrollOffset of the outer viewport scroll layer will be |
280 // 0x0, so the scrolls will be applied directly to the inner viewport. | 281 // 0x0, so the scrolls will be applied directly to the inner viewport. |
281 const int kOuterViewportClipLayerId = 116; | 282 const int kOuterViewportClipLayerId = 116; |
282 const int kOuterViewportScrollLayerId = 117; | 283 const int kOuterViewportScrollLayerId = 117; |
283 const int kContentLayerId = 118; | 284 const int kContentLayerId = 118; |
284 const int kInnerViewportScrollLayerId = 2; | 285 const int kInnerViewportScrollLayerId = 2; |
285 const int kInnerViewportClipLayerId = 4; | 286 const int kInnerViewportClipLayerId = 4; |
286 const int kPageScaleLayerId = 5; | 287 const int kPageScaleLayerId = 5; |
287 | 288 |
288 scoped_ptr<LayerImpl> root = | 289 std::unique_ptr<LayerImpl> root = LayerImpl::Create(layer_tree_impl, 1); |
289 LayerImpl::Create(layer_tree_impl, 1); | |
290 root->SetBounds(content_size); | 290 root->SetBounds(content_size); |
291 root->SetPosition(gfx::PointF()); | 291 root->SetPosition(gfx::PointF()); |
292 root->SetForceRenderSurface(true); | 292 root->SetForceRenderSurface(true); |
293 | 293 |
294 scoped_ptr<LayerImpl> inner_scroll = | 294 std::unique_ptr<LayerImpl> inner_scroll = |
295 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 295 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
296 inner_scroll->SetIsContainerForFixedPositionLayers(true); | 296 inner_scroll->SetIsContainerForFixedPositionLayers(true); |
297 inner_scroll->layer_tree_impl() | 297 inner_scroll->layer_tree_impl() |
298 ->property_trees() | 298 ->property_trees() |
299 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), | 299 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), |
300 gfx::ScrollOffset()); | 300 gfx::ScrollOffset()); |
301 | 301 |
302 scoped_ptr<LayerImpl> inner_clip = | 302 std::unique_ptr<LayerImpl> inner_clip = |
303 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 303 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
304 inner_clip->SetBounds( | 304 inner_clip->SetBounds( |
305 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 305 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
306 | 306 |
307 scoped_ptr<LayerImpl> page_scale = | 307 std::unique_ptr<LayerImpl> page_scale = |
308 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 308 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); |
309 | 309 |
310 inner_scroll->SetScrollClipLayer(inner_clip->id()); | 310 inner_scroll->SetScrollClipLayer(inner_clip->id()); |
311 inner_scroll->SetBounds(content_size); | 311 inner_scroll->SetBounds(content_size); |
312 inner_scroll->SetPosition(gfx::PointF()); | 312 inner_scroll->SetPosition(gfx::PointF()); |
313 | 313 |
314 scoped_ptr<LayerImpl> outer_clip = | 314 std::unique_ptr<LayerImpl> outer_clip = |
315 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); | 315 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); |
316 outer_clip->SetBounds(content_size); | 316 outer_clip->SetBounds(content_size); |
317 outer_clip->SetIsContainerForFixedPositionLayers(true); | 317 outer_clip->SetIsContainerForFixedPositionLayers(true); |
318 | 318 |
319 scoped_ptr<LayerImpl> outer_scroll = | 319 std::unique_ptr<LayerImpl> outer_scroll = |
320 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); | 320 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); |
321 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 321 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
322 outer_scroll->layer_tree_impl() | 322 outer_scroll->layer_tree_impl() |
323 ->property_trees() | 323 ->property_trees() |
324 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(), | 324 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(), |
325 gfx::ScrollOffset()); | 325 gfx::ScrollOffset()); |
326 outer_scroll->SetBounds(content_size); | 326 outer_scroll->SetBounds(content_size); |
327 outer_scroll->SetPosition(gfx::PointF()); | 327 outer_scroll->SetPosition(gfx::PointF()); |
328 | 328 |
329 scoped_ptr<LayerImpl> contents = | 329 std::unique_ptr<LayerImpl> contents = |
330 LayerImpl::Create(layer_tree_impl, kContentLayerId); | 330 LayerImpl::Create(layer_tree_impl, kContentLayerId); |
331 contents->SetDrawsContent(true); | 331 contents->SetDrawsContent(true); |
332 contents->SetBounds(content_size); | 332 contents->SetBounds(content_size); |
333 contents->SetPosition(gfx::PointF()); | 333 contents->SetPosition(gfx::PointF()); |
334 | 334 |
335 outer_scroll->AddChild(std::move(contents)); | 335 outer_scroll->AddChild(std::move(contents)); |
336 outer_clip->AddChild(std::move(outer_scroll)); | 336 outer_clip->AddChild(std::move(outer_scroll)); |
337 inner_scroll->AddChild(std::move(outer_clip)); | 337 inner_scroll->AddChild(std::move(outer_clip)); |
338 page_scale->AddChild(std::move(inner_scroll)); | 338 page_scale->AddChild(std::move(inner_scroll)); |
339 inner_clip->AddChild(std::move(page_scale)); | 339 inner_clip->AddChild(std::move(page_scale)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 inner_clip_layer->SetBounds(viewport_size); | 379 inner_clip_layer->SetBounds(viewport_size); |
380 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); | 380 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); |
381 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 381 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
382 | 382 |
383 host_impl_->SetViewportSize(viewport_size); | 383 host_impl_->SetViewportSize(viewport_size); |
384 host_impl_->active_tree()->DidBecomeActive(); | 384 host_impl_->active_tree()->DidBecomeActive(); |
385 | 385 |
386 return content_layer; | 386 return content_layer; |
387 } | 387 } |
388 | 388 |
389 scoped_ptr<LayerImpl> CreateScrollableLayer(int id, | 389 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, |
390 const gfx::Size& size, | 390 const gfx::Size& size, |
391 LayerImpl* clip_layer) { | 391 LayerImpl* clip_layer) { |
392 DCHECK(clip_layer); | 392 DCHECK(clip_layer); |
393 DCHECK(id != clip_layer->id()); | 393 DCHECK(id != clip_layer->id()); |
394 scoped_ptr<LayerImpl> layer = | 394 std::unique_ptr<LayerImpl> layer = |
395 LayerImpl::Create(host_impl_->active_tree(), id); | 395 LayerImpl::Create(host_impl_->active_tree(), id); |
396 layer->SetScrollClipLayer(clip_layer->id()); | 396 layer->SetScrollClipLayer(clip_layer->id()); |
397 layer->SetDrawsContent(true); | 397 layer->SetDrawsContent(true); |
398 layer->SetBounds(size); | 398 layer->SetBounds(size); |
399 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); | 399 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); |
400 return layer; | 400 return layer; |
401 } | 401 } |
402 | 402 |
403 scoped_ptr<ScrollState> BeginState(const gfx::Point& point) { | 403 std::unique_ptr<ScrollState> BeginState(const gfx::Point& point) { |
404 ScrollStateData scroll_state_data; | 404 ScrollStateData scroll_state_data; |
405 scroll_state_data.is_beginning = true; | 405 scroll_state_data.is_beginning = true; |
406 scroll_state_data.start_position_x = point.x(); | 406 scroll_state_data.start_position_x = point.x(); |
407 scroll_state_data.start_position_y = point.y(); | 407 scroll_state_data.start_position_y = point.y(); |
408 scoped_ptr<ScrollState> scroll_state(new ScrollState(scroll_state_data)); | 408 std::unique_ptr<ScrollState> scroll_state( |
| 409 new ScrollState(scroll_state_data)); |
409 return scroll_state; | 410 return scroll_state; |
410 } | 411 } |
411 | 412 |
412 scoped_ptr<ScrollState> UpdateState(const gfx::Point& point, | 413 std::unique_ptr<ScrollState> UpdateState(const gfx::Point& point, |
413 const gfx::Vector2dF& delta) { | 414 const gfx::Vector2dF& delta) { |
414 ScrollStateData scroll_state_data; | 415 ScrollStateData scroll_state_data; |
415 scroll_state_data.delta_x = delta.x(); | 416 scroll_state_data.delta_x = delta.x(); |
416 scroll_state_data.delta_y = delta.y(); | 417 scroll_state_data.delta_y = delta.y(); |
417 scroll_state_data.start_position_x = point.x(); | 418 scroll_state_data.start_position_x = point.x(); |
418 scroll_state_data.start_position_y = point.y(); | 419 scroll_state_data.start_position_y = point.y(); |
419 scoped_ptr<ScrollState> scroll_state(new ScrollState(scroll_state_data)); | 420 std::unique_ptr<ScrollState> scroll_state( |
| 421 new ScrollState(scroll_state_data)); |
420 return scroll_state; | 422 return scroll_state; |
421 } | 423 } |
422 | 424 |
423 scoped_ptr<ScrollState> EndState() { | 425 std::unique_ptr<ScrollState> EndState() { |
424 ScrollStateData scroll_state_data; | 426 ScrollStateData scroll_state_data; |
425 scroll_state_data.is_ending = true; | 427 scroll_state_data.is_ending = true; |
426 scoped_ptr<ScrollState> scroll_state(new ScrollState(scroll_state_data)); | 428 std::unique_ptr<ScrollState> scroll_state( |
| 429 new ScrollState(scroll_state_data)); |
427 return scroll_state; | 430 return scroll_state; |
428 } | 431 } |
429 | 432 |
430 void DrawFrame() { | 433 void DrawFrame() { |
431 LayerTreeHostImpl::FrameData frame; | 434 LayerTreeHostImpl::FrameData frame; |
432 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 435 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
433 host_impl_->DrawLayers(&frame); | 436 host_impl_->DrawLayers(&frame); |
434 host_impl_->DidDrawAllLayers(frame); | 437 host_impl_->DidDrawAllLayers(frame); |
435 } | 438 } |
436 | 439 |
(...skipping 16 matching lines...) Expand all Loading... |
453 void pinch_zoom_pan_viewport_test(float device_scale_factor); | 456 void pinch_zoom_pan_viewport_test(float device_scale_factor); |
454 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); | 457 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); |
455 void pinch_zoom_pan_viewport_and_scroll_boundary_test( | 458 void pinch_zoom_pan_viewport_and_scroll_boundary_test( |
456 float device_scale_factor); | 459 float device_scale_factor); |
457 | 460 |
458 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); | 461 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); |
459 | 462 |
460 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } | 463 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } |
461 | 464 |
462 protected: | 465 protected: |
463 virtual scoped_ptr<OutputSurface> CreateOutputSurface() { | 466 virtual std::unique_ptr<OutputSurface> CreateOutputSurface() { |
464 return FakeOutputSurface::Create3d(); | 467 return FakeOutputSurface::Create3d(); |
465 } | 468 } |
466 | 469 |
467 void DrawOneFrame() { | 470 void DrawOneFrame() { |
468 LayerTreeHostImpl::FrameData frame_data; | 471 LayerTreeHostImpl::FrameData frame_data; |
469 PrepareToDrawFrame(&frame_data); | 472 PrepareToDrawFrame(&frame_data); |
470 host_impl_->DidDrawAllLayers(frame_data); | 473 host_impl_->DidDrawAllLayers(frame_data); |
471 } | 474 } |
472 | 475 |
473 static void SetScrollOffsetDelta(LayerImpl* layer_impl, | 476 static void SetScrollOffsetDelta(LayerImpl* layer_impl, |
(...skipping 14 matching lines...) Expand all Loading... |
488 host_impl_->UpdateAnimationState(true); | 491 host_impl_->UpdateAnimationState(true); |
489 host_impl_->DidFinishImplFrame(); | 492 host_impl_->DidFinishImplFrame(); |
490 } | 493 } |
491 | 494 |
492 FakeImplTaskRunnerProvider task_runner_provider_; | 495 FakeImplTaskRunnerProvider task_runner_provider_; |
493 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; | 496 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; |
494 | 497 |
495 TestSharedBitmapManager shared_bitmap_manager_; | 498 TestSharedBitmapManager shared_bitmap_manager_; |
496 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; | 499 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
497 TestTaskGraphRunner task_graph_runner_; | 500 TestTaskGraphRunner task_graph_runner_; |
498 scoped_ptr<OutputSurface> output_surface_; | 501 std::unique_ptr<OutputSurface> output_surface_; |
499 scoped_ptr<LayerTreeHostImpl> host_impl_; | 502 std::unique_ptr<LayerTreeHostImpl> host_impl_; |
500 FakeRenderingStatsInstrumentation stats_instrumentation_; | 503 FakeRenderingStatsInstrumentation stats_instrumentation_; |
501 bool on_can_draw_state_changed_called_; | 504 bool on_can_draw_state_changed_called_; |
502 bool did_notify_ready_to_activate_; | 505 bool did_notify_ready_to_activate_; |
503 bool did_request_commit_; | 506 bool did_request_commit_; |
504 bool did_request_redraw_; | 507 bool did_request_redraw_; |
505 bool did_request_next_frame_; | 508 bool did_request_next_frame_; |
506 bool did_request_prepare_tiles_; | 509 bool did_request_prepare_tiles_; |
507 bool did_complete_page_scale_animation_; | 510 bool did_complete_page_scale_animation_; |
508 bool reduce_memory_result_; | 511 bool reduce_memory_result_; |
509 base::Closure animation_task_; | 512 base::Closure animation_task_; |
510 base::TimeDelta requested_animation_delay_; | 513 base::TimeDelta requested_animation_delay_; |
511 bool skip_draw_layers_in_on_draw_; | 514 bool skip_draw_layers_in_on_draw_; |
512 scoped_ptr<LayerTreeHostImpl::FrameData> last_on_draw_frame_; | 515 std::unique_ptr<LayerTreeHostImpl::FrameData> last_on_draw_frame_; |
513 RenderPassList last_on_draw_render_passes_; | 516 RenderPassList last_on_draw_render_passes_; |
514 scoped_refptr<AnimationTimeline> timeline_; | 517 scoped_refptr<AnimationTimeline> timeline_; |
515 }; | 518 }; |
516 | 519 |
517 // A test fixture for new animation timelines tests. | 520 // A test fixture for new animation timelines tests. |
518 class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest { | 521 class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest { |
519 public: | 522 public: |
520 void SetUp() override { | 523 void SetUp() override { |
521 CreateHostImpl(DefaultSettings(), CreateOutputSurface()); | 524 CreateHostImpl(DefaultSettings(), CreateOutputSurface()); |
522 } | 525 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 557 |
555 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 558 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
556 EXPECT_TRUE(host_impl_->CanDraw()); | 559 EXPECT_TRUE(host_impl_->CanDraw()); |
557 EXPECT_TRUE(on_can_draw_state_changed_called_); | 560 EXPECT_TRUE(on_can_draw_state_changed_called_); |
558 on_can_draw_state_changed_called_ = false; | 561 on_can_draw_state_changed_called_ = false; |
559 } | 562 } |
560 | 563 |
561 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { | 564 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { |
562 CreateHostImpl(DefaultSettings(), | 565 CreateHostImpl(DefaultSettings(), |
563 FakeOutputSurface::CreateSoftware( | 566 FakeOutputSurface::CreateSoftware( |
564 make_scoped_ptr(new SoftwareOutputDevice()))); | 567 base::WrapUnique(new SoftwareOutputDevice()))); |
565 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 568 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
566 EXPECT_TRUE(host_impl_->CanDraw()); | 569 EXPECT_TRUE(host_impl_->CanDraw()); |
567 host_impl_->SetViewportSize(gfx::Size()); | 570 host_impl_->SetViewportSize(gfx::Size()); |
568 EXPECT_FALSE(host_impl_->CanDraw()); | 571 EXPECT_FALSE(host_impl_->CanDraw()); |
569 | 572 |
570 FakeOutputSurface* fake_output_surface = | 573 FakeOutputSurface* fake_output_surface = |
571 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 574 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
572 EXPECT_EQ(fake_output_surface->num_sent_frames(), 0u); | 575 EXPECT_EQ(fake_output_surface->num_sent_frames(), 0u); |
573 gfx::Transform identity; | 576 gfx::Transform identity; |
574 gfx::Rect viewport(100, 100); | 577 gfx::Rect viewport(100, 100); |
575 const bool resourceless_software_draw = true; | 578 const bool resourceless_software_draw = true; |
576 host_impl_->OnDraw(identity, viewport, viewport, resourceless_software_draw); | 579 host_impl_->OnDraw(identity, viewport, viewport, resourceless_software_draw); |
577 ASSERT_EQ(fake_output_surface->num_sent_frames(), 1u); | 580 ASSERT_EQ(fake_output_surface->num_sent_frames(), 1u); |
578 EXPECT_EQ(gfx::SizeF(100.f, 100.f), | 581 EXPECT_EQ(gfx::SizeF(100.f, 100.f), |
579 fake_output_surface->last_sent_frame().metadata.root_layer_size); | 582 fake_output_surface->last_sent_frame().metadata.root_layer_size); |
580 } | 583 } |
581 | 584 |
582 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { | 585 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { |
583 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); | 586 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); |
584 | 587 |
585 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 588 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 589 host_impl_->ProcessScrollDeltas(); |
586 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 590 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
587 } | 591 } |
588 | 592 |
589 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { | 593 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { |
590 { | 594 { |
591 scoped_ptr<LayerImpl> root = | 595 std::unique_ptr<LayerImpl> root = |
592 LayerImpl::Create(host_impl_->active_tree(), 1); | 596 LayerImpl::Create(host_impl_->active_tree(), 1); |
593 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 597 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
594 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3)); | 598 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3)); |
595 root->children()[1]->AddChild( | 599 root->children()[1]->AddChild( |
596 LayerImpl::Create(host_impl_->active_tree(), 4)); | 600 LayerImpl::Create(host_impl_->active_tree(), 4)); |
597 root->children()[1]->AddChild( | 601 root->children()[1]->AddChild( |
598 LayerImpl::Create(host_impl_->active_tree(), 5)); | 602 LayerImpl::Create(host_impl_->active_tree(), 5)); |
599 root->children()[1]->children()[0]->AddChild( | 603 root->children()[1]->children()[0]->AddChild( |
600 LayerImpl::Create(host_impl_->active_tree(), 6)); | 604 LayerImpl::Create(host_impl_->active_tree(), 6)); |
601 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 605 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
602 } | 606 } |
603 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 607 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
604 | 608 |
605 ExpectClearedScrollDeltasRecursive(root); | 609 ExpectClearedScrollDeltasRecursive(root); |
606 | 610 |
607 scoped_ptr<ScrollAndScaleSet> scroll_info; | 611 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
608 | 612 |
609 scroll_info = host_impl_->ProcessScrollDeltas(); | 613 scroll_info = host_impl_->ProcessScrollDeltas(); |
610 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 614 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
611 ExpectClearedScrollDeltasRecursive(root); | 615 ExpectClearedScrollDeltasRecursive(root); |
612 | 616 |
613 scroll_info = host_impl_->ProcessScrollDeltas(); | 617 scroll_info = host_impl_->ProcessScrollDeltas(); |
614 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 618 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
615 ExpectClearedScrollDeltasRecursive(root); | 619 ExpectClearedScrollDeltasRecursive(root); |
616 } | 620 } |
617 | 621 |
618 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { | 622 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { |
619 gfx::ScrollOffset scroll_offset(20, 30); | 623 gfx::ScrollOffset scroll_offset(20, 30); |
620 gfx::Vector2d scroll_delta(11, -15); | 624 gfx::Vector2d scroll_delta(11, -15); |
621 { | 625 { |
622 scoped_ptr<LayerImpl> root_clip = | 626 std::unique_ptr<LayerImpl> root_clip = |
623 LayerImpl::Create(host_impl_->active_tree(), 2); | 627 LayerImpl::Create(host_impl_->active_tree(), 2); |
624 scoped_ptr<LayerImpl> root = | 628 std::unique_ptr<LayerImpl> root = |
625 LayerImpl::Create(host_impl_->active_tree(), 1); | 629 LayerImpl::Create(host_impl_->active_tree(), 1); |
626 root_clip->SetBounds(gfx::Size(10, 10)); | 630 root_clip->SetBounds(gfx::Size(10, 10)); |
627 LayerImpl* root_layer = root.get(); | 631 LayerImpl* root_layer = root.get(); |
628 root_clip->AddChild(std::move(root)); | 632 root_clip->AddChild(std::move(root)); |
629 root_layer->SetBounds(gfx::Size(110, 110)); | 633 root_layer->SetBounds(gfx::Size(110, 110)); |
630 root_layer->SetScrollClipLayer(root_clip->id()); | 634 root_layer->SetScrollClipLayer(root_clip->id()); |
631 root_layer->layer_tree_impl() | 635 root_layer->layer_tree_impl() |
632 ->property_trees() | 636 ->property_trees() |
633 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), | 637 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), |
634 scroll_offset); | 638 scroll_offset); |
635 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); | 639 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
636 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 640 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
637 root_layer->ScrollBy(scroll_delta); | 641 root_layer->ScrollBy(scroll_delta); |
638 } | 642 } |
639 | 643 |
640 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0]; | 644 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0]; |
641 | 645 |
642 scoped_ptr<ScrollAndScaleSet> scroll_info; | 646 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
643 | 647 |
644 scroll_info = host_impl_->ProcessScrollDeltas(); | 648 scroll_info = host_impl_->ProcessScrollDeltas(); |
645 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 649 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
646 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); | 650 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); |
647 | 651 |
648 gfx::Vector2d scroll_delta2(-5, 27); | 652 gfx::Vector2d scroll_delta2(-5, 27); |
649 root->ScrollBy(scroll_delta2); | 653 root->ScrollBy(scroll_delta2); |
650 scroll_info = host_impl_->ProcessScrollDeltas(); | 654 scroll_info = host_impl_->ProcessScrollDeltas(); |
651 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 655 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
652 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), | 656 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { | 706 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { |
703 // We should not crash when trying to scroll an empty layer tree. | 707 // We should not crash when trying to scroll an empty layer tree. |
704 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 708 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
705 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 709 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
706 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 710 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
707 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 711 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
708 status.main_thread_scrolling_reasons); | 712 status.main_thread_scrolling_reasons); |
709 } | 713 } |
710 | 714 |
711 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { | 715 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { |
712 scoped_ptr<TestWebGraphicsContext3D> context_owned = | 716 std::unique_ptr<TestWebGraphicsContext3D> context_owned = |
713 TestWebGraphicsContext3D::Create(); | 717 TestWebGraphicsContext3D::Create(); |
714 context_owned->set_context_lost(true); | 718 context_owned->set_context_lost(true); |
715 | 719 |
716 // Initialization will fail. | 720 // Initialization will fail. |
717 EXPECT_FALSE( | 721 EXPECT_FALSE( |
718 CreateHostImpl(DefaultSettings(), | 722 CreateHostImpl(DefaultSettings(), |
719 FakeOutputSurface::Create3d(std::move(context_owned)))); | 723 FakeOutputSurface::Create3d(std::move(context_owned)))); |
720 | 724 |
721 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 725 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
722 | 726 |
(...skipping 18 matching lines...) Expand all Loading... |
741 .thread); | 745 .thread); |
742 host_impl_->active_tree()->ClearLayers(); | 746 host_impl_->active_tree()->ClearLayers(); |
743 | 747 |
744 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 748 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
745 | 749 |
746 // We should still be scrolling, because the scrolled layer also exists in the | 750 // We should still be scrolling, because the scrolled layer also exists in the |
747 // new tree. | 751 // new tree. |
748 gfx::Vector2d scroll_delta(0, 10); | 752 gfx::Vector2d scroll_delta(0, 10); |
749 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 753 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
750 host_impl_->ScrollEnd(EndState().get()); | 754 host_impl_->ScrollEnd(EndState().get()); |
751 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 755 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 756 host_impl_->ProcessScrollDeltas(); |
752 EXPECT_TRUE( | 757 EXPECT_TRUE( |
753 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); | 758 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); |
754 } | 759 } |
755 | 760 |
756 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { | 761 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { |
757 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 762 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
758 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 763 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
759 DrawFrame(); | 764 DrawFrame(); |
760 | 765 |
761 // With registered event handlers, wheel scrolls don't necessarily | 766 // With registered event handlers, wheel scrolls don't necessarily |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 } | 804 } |
800 | 805 |
801 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { | 806 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
802 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 807 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
803 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 808 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
804 DrawFrame(); | 809 DrawFrame(); |
805 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 810 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
806 | 811 |
807 LayerImpl* child = 0; | 812 LayerImpl* child = 0; |
808 { | 813 { |
809 scoped_ptr<LayerImpl> child_layer = | 814 std::unique_ptr<LayerImpl> child_layer = |
810 LayerImpl::Create(host_impl_->active_tree(), 6); | 815 LayerImpl::Create(host_impl_->active_tree(), 6); |
811 child = child_layer.get(); | 816 child = child_layer.get(); |
812 child_layer->SetDrawsContent(true); | 817 child_layer->SetDrawsContent(true); |
813 child_layer->SetPosition(gfx::PointF(0, 20)); | 818 child_layer->SetPosition(gfx::PointF(0, 20)); |
814 child_layer->SetBounds(gfx::Size(50, 50)); | 819 child_layer->SetBounds(gfx::Size(50, 50)); |
815 scroll->AddChild(std::move(child_layer)); | 820 scroll->AddChild(std::move(child_layer)); |
816 SetNeedsRebuildPropertyTrees(); | 821 SetNeedsRebuildPropertyTrees(); |
817 RebuildPropertyTrees(); | 822 RebuildPropertyTrees(); |
818 } | 823 } |
819 | 824 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 | 1403 |
1399 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { | 1404 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { |
1400 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1405 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1401 | 1406 |
1402 host_impl_->active_tree()->SetRootLayer( | 1407 host_impl_->active_tree()->SetRootLayer( |
1403 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1408 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1404 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1409 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
1405 root->SetBounds(gfx::Size(50, 50)); | 1410 root->SetBounds(gfx::Size(50, 50)); |
1406 root->SetHasRenderSurface(true); | 1411 root->SetHasRenderSurface(true); |
1407 | 1412 |
1408 root->AddChild(scoped_ptr<MissingTilesLayer>( | 1413 root->AddChild(std::unique_ptr<MissingTilesLayer>( |
1409 new MissingTilesLayer(host_impl_->active_tree(), 2))); | 1414 new MissingTilesLayer(host_impl_->active_tree(), 2))); |
1410 MissingTilesLayer* child = | 1415 MissingTilesLayer* child = |
1411 static_cast<MissingTilesLayer*>(root->children()[0]); | 1416 static_cast<MissingTilesLayer*>(root->children()[0]); |
1412 child->SetBounds(gfx::Size(10, 10)); | 1417 child->SetBounds(gfx::Size(10, 10)); |
1413 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1418 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1414 child->SetDrawsContent(true); | 1419 child->SetDrawsContent(true); |
1415 | 1420 |
1416 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1421 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
1417 | 1422 |
1418 // Add a translate from 6,7 to 8,9. | 1423 // Add a translate from 6,7 to 8,9. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 InputHandler::TOUCHSCREEN); | 1511 InputHandler::TOUCHSCREEN); |
1507 host_impl_->PinchGestureBegin(); | 1512 host_impl_->PinchGestureBegin(); |
1508 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 1513 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
1509 host_impl_->PinchGestureEnd(); | 1514 host_impl_->PinchGestureEnd(); |
1510 host_impl_->ScrollEnd(EndState().get()); | 1515 host_impl_->ScrollEnd(EndState().get()); |
1511 EXPECT_FALSE(did_request_next_frame_); | 1516 EXPECT_FALSE(did_request_next_frame_); |
1512 EXPECT_TRUE(did_request_redraw_); | 1517 EXPECT_TRUE(did_request_redraw_); |
1513 EXPECT_TRUE(did_request_commit_); | 1518 EXPECT_TRUE(did_request_commit_); |
1514 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 1519 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
1515 | 1520 |
1516 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1521 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
1517 host_impl_->ProcessScrollDeltas(); | 1522 host_impl_->ProcessScrollDeltas(); |
1518 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1523 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
1519 | 1524 |
1520 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), | 1525 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), |
1521 scroll_layer->MaxScrollOffset().ToString()); | 1526 scroll_layer->MaxScrollOffset().ToString()); |
1522 } | 1527 } |
1523 | 1528 |
1524 // Scrolling after a pinch gesture should always be in local space. The | 1529 // Scrolling after a pinch gesture should always be in local space. The |
1525 // scroll deltas have the page scale factor applied. | 1530 // scroll deltas have the page scale factor applied. |
1526 { | 1531 { |
(...skipping 11 matching lines...) Expand all Loading... |
1538 host_impl_->ScrollEnd(EndState().get()); | 1543 host_impl_->ScrollEnd(EndState().get()); |
1539 | 1544 |
1540 gfx::Vector2d scroll_delta(0, 10); | 1545 gfx::Vector2d scroll_delta(0, 10); |
1541 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1546 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
1542 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 1547 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
1543 InputHandler::WHEEL) | 1548 InputHandler::WHEEL) |
1544 .thread); | 1549 .thread); |
1545 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 1550 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
1546 host_impl_->ScrollEnd(EndState().get()); | 1551 host_impl_->ScrollEnd(EndState().get()); |
1547 | 1552 |
1548 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1553 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
1549 host_impl_->ProcessScrollDeltas(); | 1554 host_impl_->ProcessScrollDeltas(); |
1550 EXPECT_TRUE(ScrollInfoContains( | 1555 EXPECT_TRUE(ScrollInfoContains( |
1551 *scroll_info.get(), scroll_layer->id(), | 1556 *scroll_info.get(), scroll_layer->id(), |
1552 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); | 1557 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); |
1553 } | 1558 } |
1554 } | 1559 } |
1555 | 1560 |
1556 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { | 1561 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { |
1557 LayerTreeSettings settings = DefaultSettings(); | 1562 LayerTreeSettings settings = DefaultSettings(); |
1558 CreateHostImpl(settings, | 1563 CreateHostImpl(settings, |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 outer_scroll_layer->CurrentScrollOffset()); | 1884 outer_scroll_layer->CurrentScrollOffset()); |
1880 EXPECT_VECTOR_EQ( | 1885 EXPECT_VECTOR_EQ( |
1881 gfx::Vector2dF(50, 50), | 1886 gfx::Vector2dF(50, 50), |
1882 inner_scroll_layer->CurrentScrollOffset()); | 1887 inner_scroll_layer->CurrentScrollOffset()); |
1883 } | 1888 } |
1884 | 1889 |
1885 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { | 1890 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { |
1886 ui::LatencyInfo latency_info; | 1891 ui::LatencyInfo latency_info; |
1887 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, | 1892 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, |
1888 1234); | 1893 1234); |
1889 scoped_ptr<SwapPromise> swap_promise( | 1894 std::unique_ptr<SwapPromise> swap_promise( |
1890 new LatencyInfoSwapPromise(latency_info)); | 1895 new LatencyInfoSwapPromise(latency_info)); |
1891 | 1896 |
1892 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1897 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1893 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1898 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
1894 host_impl_ | 1899 host_impl_ |
1895 ->ScrollBegin(BeginState(gfx::Point()).get(), | 1900 ->ScrollBegin(BeginState(gfx::Point()).get(), |
1896 InputHandler::TOUCHSCREEN) | 1901 InputHandler::TOUCHSCREEN) |
1897 .thread); | 1902 .thread); |
1898 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 1903 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
1899 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( | 1904 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( |
1900 std::move(swap_promise)); | 1905 std::move(swap_promise)); |
1901 host_impl_->ScrollEnd(EndState().get()); | 1906 host_impl_->ScrollEnd(EndState().get()); |
1902 | 1907 |
1903 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 1908 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 1909 host_impl_->ProcessScrollDeltas(); |
1904 EXPECT_EQ(1u, scroll_info->swap_promises.size()); | 1910 EXPECT_EQ(1u, scroll_info->swap_promises.size()); |
1905 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); | 1911 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); |
1906 } | 1912 } |
1907 | 1913 |
1908 // Test that scrolls targeting a layer with a non-null scroll_parent() don't | 1914 // Test that scrolls targeting a layer with a non-null scroll_parent() don't |
1909 // bubble up. | 1915 // bubble up. |
1910 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { | 1916 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { |
1911 LayerImpl* viewport_scroll = | 1917 LayerImpl* viewport_scroll = |
1912 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1918 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1913 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1919 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1914 | 1920 |
1915 // Set up two scrolling children of the root, one of which is a scroll parent | 1921 // Set up two scrolling children of the root, one of which is a scroll parent |
1916 // to the other. Scrolls shouldn't bubbling from the child. | 1922 // to the other. Scrolls shouldn't bubbling from the child. |
1917 LayerImpl *parent; | 1923 LayerImpl *parent; |
1918 LayerImpl *child; | 1924 LayerImpl *child; |
1919 LayerImpl *child_clip; | 1925 LayerImpl *child_clip; |
1920 | 1926 |
1921 scoped_ptr<LayerImpl> scroll_parent_clip = | 1927 std::unique_ptr<LayerImpl> scroll_parent_clip = |
1922 LayerImpl::Create(host_impl_->active_tree(), 6); | 1928 LayerImpl::Create(host_impl_->active_tree(), 6); |
1923 scoped_ptr<LayerImpl> scroll_parent = CreateScrollableLayer( | 1929 std::unique_ptr<LayerImpl> scroll_parent = |
1924 7, gfx::Size(10, 10), scroll_parent_clip.get()); | 1930 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get()); |
1925 parent = scroll_parent.get(); | 1931 parent = scroll_parent.get(); |
1926 scroll_parent_clip->AddChild(std::move(scroll_parent)); | 1932 scroll_parent_clip->AddChild(std::move(scroll_parent)); |
1927 | 1933 |
1928 viewport_scroll->AddChild(std::move(scroll_parent_clip)); | 1934 viewport_scroll->AddChild(std::move(scroll_parent_clip)); |
1929 | 1935 |
1930 scoped_ptr<LayerImpl> scroll_child_clip = | 1936 std::unique_ptr<LayerImpl> scroll_child_clip = |
1931 LayerImpl::Create(host_impl_->active_tree(), 8); | 1937 LayerImpl::Create(host_impl_->active_tree(), 8); |
1932 scoped_ptr<LayerImpl> scroll_child = CreateScrollableLayer( | 1938 std::unique_ptr<LayerImpl> scroll_child = |
1933 9, gfx::Size(10, 10), scroll_child_clip.get()); | 1939 CreateScrollableLayer(9, gfx::Size(10, 10), scroll_child_clip.get()); |
1934 child = scroll_child.get(); | 1940 child = scroll_child.get(); |
1935 scroll_child->SetPosition(gfx::PointF(20.f, 20.f)); | 1941 scroll_child->SetPosition(gfx::PointF(20.f, 20.f)); |
1936 scroll_child_clip->AddChild(std::move(scroll_child)); | 1942 scroll_child_clip->AddChild(std::move(scroll_child)); |
1937 | 1943 |
1938 child_clip = scroll_child_clip.get(); | 1944 child_clip = scroll_child_clip.get(); |
1939 viewport_scroll->AddChild(std::move(scroll_child_clip)); | 1945 viewport_scroll->AddChild(std::move(scroll_child_clip)); |
1940 | 1946 |
1941 child_clip->SetScrollParent(parent); | 1947 child_clip->SetScrollParent(parent); |
1942 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); | 1948 std::unique_ptr<std::set<LayerImpl*>> scroll_children( |
| 1949 new std::set<LayerImpl*>); |
1943 scroll_children->insert(child_clip); | 1950 scroll_children->insert(child_clip); |
1944 parent->SetScrollChildren(scroll_children.release()); | 1951 parent->SetScrollChildren(scroll_children.release()); |
1945 | 1952 |
1946 SetNeedsRebuildPropertyTrees(); | 1953 SetNeedsRebuildPropertyTrees(); |
1947 DrawFrame(); | 1954 DrawFrame(); |
1948 | 1955 |
1949 { | 1956 { |
1950 host_impl_->ScrollBegin(BeginState(gfx::Point(21, 21)).get(), | 1957 host_impl_->ScrollBegin(BeginState(gfx::Point(21, 21)).get(), |
1951 InputHandler::TOUCHSCREEN); | 1958 InputHandler::TOUCHSCREEN); |
1952 host_impl_->ScrollBy( | 1959 host_impl_->ScrollBy( |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), | 2025 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), |
2019 InputHandler::TOUCHSCREEN); | 2026 InputHandler::TOUCHSCREEN); |
2020 host_impl_->PinchGestureBegin(); | 2027 host_impl_->PinchGestureBegin(); |
2021 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 2028 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
2022 host_impl_->PinchGestureEnd(); | 2029 host_impl_->PinchGestureEnd(); |
2023 host_impl_->ScrollEnd(EndState().get()); | 2030 host_impl_->ScrollEnd(EndState().get()); |
2024 EXPECT_FALSE(did_request_next_frame_); | 2031 EXPECT_FALSE(did_request_next_frame_); |
2025 EXPECT_TRUE(did_request_redraw_); | 2032 EXPECT_TRUE(did_request_redraw_); |
2026 EXPECT_TRUE(did_request_commit_); | 2033 EXPECT_TRUE(did_request_commit_); |
2027 | 2034 |
2028 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2035 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2029 host_impl_->ProcessScrollDeltas(); | 2036 host_impl_->ProcessScrollDeltas(); |
2030 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 2037 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
2031 } | 2038 } |
2032 | 2039 |
2033 // Zoom-in clamping | 2040 // Zoom-in clamping |
2034 { | 2041 { |
2035 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2042 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2036 max_page_scale); | 2043 max_page_scale); |
2037 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); | 2044 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); |
2038 float page_scale_delta = 10.f; | 2045 float page_scale_delta = 10.f; |
2039 | 2046 |
2040 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), | 2047 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), |
2041 InputHandler::TOUCHSCREEN); | 2048 InputHandler::TOUCHSCREEN); |
2042 host_impl_->PinchGestureBegin(); | 2049 host_impl_->PinchGestureBegin(); |
2043 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 2050 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
2044 host_impl_->PinchGestureEnd(); | 2051 host_impl_->PinchGestureEnd(); |
2045 host_impl_->ScrollEnd(EndState().get()); | 2052 host_impl_->ScrollEnd(EndState().get()); |
2046 | 2053 |
2047 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2054 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2048 host_impl_->ProcessScrollDeltas(); | 2055 host_impl_->ProcessScrollDeltas(); |
2049 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); | 2056 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); |
2050 } | 2057 } |
2051 | 2058 |
2052 // Zoom-out clamping | 2059 // Zoom-out clamping |
2053 { | 2060 { |
2054 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2061 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2055 max_page_scale); | 2062 max_page_scale); |
2056 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); | 2063 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); |
2057 scroll_layer->layer_tree_impl() | 2064 scroll_layer->layer_tree_impl() |
2058 ->property_trees() | 2065 ->property_trees() |
2059 ->scroll_tree.CollectScrollDeltasForTesting(); | 2066 ->scroll_tree.CollectScrollDeltasForTesting(); |
2060 scroll_layer->layer_tree_impl() | 2067 scroll_layer->layer_tree_impl() |
2061 ->property_trees() | 2068 ->property_trees() |
2062 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2069 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2063 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2070 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
2064 | 2071 |
2065 float page_scale_delta = 0.1f; | 2072 float page_scale_delta = 0.1f; |
2066 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2073 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
2067 InputHandler::TOUCHSCREEN); | 2074 InputHandler::TOUCHSCREEN); |
2068 host_impl_->PinchGestureBegin(); | 2075 host_impl_->PinchGestureBegin(); |
2069 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 2076 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
2070 host_impl_->PinchGestureEnd(); | 2077 host_impl_->PinchGestureEnd(); |
2071 host_impl_->ScrollEnd(EndState().get()); | 2078 host_impl_->ScrollEnd(EndState().get()); |
2072 | 2079 |
2073 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2080 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2074 host_impl_->ProcessScrollDeltas(); | 2081 host_impl_->ProcessScrollDeltas(); |
2075 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 2082 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
2076 | 2083 |
2077 EXPECT_TRUE(scroll_info->scrolls.empty()); | 2084 EXPECT_TRUE(scroll_info->scrolls.empty()); |
2078 } | 2085 } |
2079 | 2086 |
2080 // Two-finger panning should not happen based on pinch events only | 2087 // Two-finger panning should not happen based on pinch events only |
2081 { | 2088 { |
2082 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2089 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2083 max_page_scale); | 2090 max_page_scale); |
2084 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); | 2091 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); |
2085 scroll_layer->layer_tree_impl() | 2092 scroll_layer->layer_tree_impl() |
2086 ->property_trees() | 2093 ->property_trees() |
2087 ->scroll_tree.CollectScrollDeltasForTesting(); | 2094 ->scroll_tree.CollectScrollDeltasForTesting(); |
2088 scroll_layer->layer_tree_impl() | 2095 scroll_layer->layer_tree_impl() |
2089 ->property_trees() | 2096 ->property_trees() |
2090 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2097 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2091 scroll_layer->id(), gfx::ScrollOffset(20, 20)); | 2098 scroll_layer->id(), gfx::ScrollOffset(20, 20)); |
2092 | 2099 |
2093 float page_scale_delta = 1.f; | 2100 float page_scale_delta = 1.f; |
2094 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), | 2101 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), |
2095 InputHandler::TOUCHSCREEN); | 2102 InputHandler::TOUCHSCREEN); |
2096 host_impl_->PinchGestureBegin(); | 2103 host_impl_->PinchGestureBegin(); |
2097 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 2104 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
2098 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 2105 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
2099 host_impl_->PinchGestureEnd(); | 2106 host_impl_->PinchGestureEnd(); |
2100 host_impl_->ScrollEnd(EndState().get()); | 2107 host_impl_->ScrollEnd(EndState().get()); |
2101 | 2108 |
2102 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2109 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2103 host_impl_->ProcessScrollDeltas(); | 2110 host_impl_->ProcessScrollDeltas(); |
2104 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 2111 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
2105 EXPECT_TRUE(scroll_info->scrolls.empty()); | 2112 EXPECT_TRUE(scroll_info->scrolls.empty()); |
2106 } | 2113 } |
2107 | 2114 |
2108 // Two-finger panning should work with interleaved scroll events | 2115 // Two-finger panning should work with interleaved scroll events |
2109 { | 2116 { |
2110 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2117 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2111 max_page_scale); | 2118 max_page_scale); |
2112 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); | 2119 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); |
2113 scroll_layer->layer_tree_impl() | 2120 scroll_layer->layer_tree_impl() |
2114 ->property_trees() | 2121 ->property_trees() |
2115 ->scroll_tree.CollectScrollDeltasForTesting(); | 2122 ->scroll_tree.CollectScrollDeltasForTesting(); |
2116 scroll_layer->layer_tree_impl() | 2123 scroll_layer->layer_tree_impl() |
2117 ->property_trees() | 2124 ->property_trees() |
2118 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2125 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2119 scroll_layer->id(), gfx::ScrollOffset(20, 20)); | 2126 scroll_layer->id(), gfx::ScrollOffset(20, 20)); |
2120 | 2127 |
2121 float page_scale_delta = 1.f; | 2128 float page_scale_delta = 1.f; |
2122 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), | 2129 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), |
2123 InputHandler::TOUCHSCREEN); | 2130 InputHandler::TOUCHSCREEN); |
2124 host_impl_->PinchGestureBegin(); | 2131 host_impl_->PinchGestureBegin(); |
2125 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 2132 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
2126 host_impl_->ScrollBy( | 2133 host_impl_->ScrollBy( |
2127 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get()); | 2134 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get()); |
2128 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 2135 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
2129 host_impl_->PinchGestureEnd(); | 2136 host_impl_->PinchGestureEnd(); |
2130 host_impl_->ScrollEnd(EndState().get()); | 2137 host_impl_->ScrollEnd(EndState().get()); |
2131 | 2138 |
2132 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2139 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2133 host_impl_->ProcessScrollDeltas(); | 2140 host_impl_->ProcessScrollDeltas(); |
2134 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 2141 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
2135 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2142 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
2136 gfx::Vector2d(-10, -10))); | 2143 gfx::Vector2d(-10, -10))); |
2137 } | 2144 } |
2138 | 2145 |
2139 // Two-finger panning should work when starting fully zoomed out. | 2146 // Two-finger panning should work when starting fully zoomed out. |
2140 { | 2147 { |
2141 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); | 2148 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); |
2142 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); | 2149 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); |
(...skipping 13 matching lines...) Expand all Loading... |
2156 | 2163 |
2157 // Needed so layer transform includes page scale. | 2164 // Needed so layer transform includes page scale. |
2158 DrawFrame(); | 2165 DrawFrame(); |
2159 | 2166 |
2160 host_impl_->ScrollBy( | 2167 host_impl_->ScrollBy( |
2161 UpdateState(gfx::Point(0, 0), gfx::Vector2d(10, 10)).get()); | 2168 UpdateState(gfx::Point(0, 0), gfx::Vector2d(10, 10)).get()); |
2162 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); | 2169 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); |
2163 host_impl_->PinchGestureEnd(); | 2170 host_impl_->PinchGestureEnd(); |
2164 host_impl_->ScrollEnd(EndState().get()); | 2171 host_impl_->ScrollEnd(EndState().get()); |
2165 | 2172 |
2166 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2173 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2167 host_impl_->ProcessScrollDeltas(); | 2174 host_impl_->ProcessScrollDeltas(); |
2168 EXPECT_EQ(scroll_info->page_scale_delta, 2.f); | 2175 EXPECT_EQ(scroll_info->page_scale_delta, 2.f); |
2169 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2176 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
2170 gfx::Vector2d(10, 10))); | 2177 gfx::Vector2d(10, 10))); |
2171 } | 2178 } |
2172 } | 2179 } |
2173 | 2180 |
2174 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { | 2181 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { |
2175 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2182 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2176 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2183 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
(...skipping 18 matching lines...) Expand all Loading... |
2195 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2202 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2196 max_page_scale); | 2203 max_page_scale); |
2197 scroll_layer->layer_tree_impl() | 2204 scroll_layer->layer_tree_impl() |
2198 ->property_trees() | 2205 ->property_trees() |
2199 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2206 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2200 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2207 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
2201 | 2208 |
2202 did_request_redraw_ = false; | 2209 did_request_redraw_ = false; |
2203 did_request_next_frame_ = false; | 2210 did_request_next_frame_ = false; |
2204 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2211 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2205 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2212 std::unique_ptr<PendingPageScaleAnimation>( |
2206 gfx::Vector2d(), | 2213 new PendingPageScaleAnimation(gfx::Vector2d(), false, 2.f, |
2207 false, | 2214 duration))); |
2208 2.f, | |
2209 duration))); | |
2210 host_impl_->ActivateSyncTree(); | 2215 host_impl_->ActivateSyncTree(); |
2211 EXPECT_FALSE(did_request_redraw_); | 2216 EXPECT_FALSE(did_request_redraw_); |
2212 EXPECT_TRUE(did_request_next_frame_); | 2217 EXPECT_TRUE(did_request_next_frame_); |
2213 | 2218 |
2214 did_request_redraw_ = false; | 2219 did_request_redraw_ = false; |
2215 did_request_next_frame_ = false; | 2220 did_request_next_frame_ = false; |
2216 begin_frame_args.frame_time = start_time; | 2221 begin_frame_args.frame_time = start_time; |
2217 host_impl_->WillBeginImplFrame(begin_frame_args); | 2222 host_impl_->WillBeginImplFrame(begin_frame_args); |
2218 host_impl_->Animate(); | 2223 host_impl_->Animate(); |
2219 EXPECT_TRUE(did_request_redraw_); | 2224 EXPECT_TRUE(did_request_redraw_); |
(...skipping 12 matching lines...) Expand all Loading... |
2232 did_request_redraw_ = false; | 2237 did_request_redraw_ = false; |
2233 did_request_next_frame_ = false; | 2238 did_request_next_frame_ = false; |
2234 did_request_commit_ = false; | 2239 did_request_commit_ = false; |
2235 begin_frame_args.frame_time = end_time; | 2240 begin_frame_args.frame_time = end_time; |
2236 host_impl_->WillBeginImplFrame(begin_frame_args); | 2241 host_impl_->WillBeginImplFrame(begin_frame_args); |
2237 host_impl_->Animate(); | 2242 host_impl_->Animate(); |
2238 EXPECT_TRUE(did_request_commit_); | 2243 EXPECT_TRUE(did_request_commit_); |
2239 EXPECT_FALSE(did_request_next_frame_); | 2244 EXPECT_FALSE(did_request_next_frame_); |
2240 host_impl_->DidFinishImplFrame(); | 2245 host_impl_->DidFinishImplFrame(); |
2241 | 2246 |
2242 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2247 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2243 host_impl_->ProcessScrollDeltas(); | 2248 host_impl_->ProcessScrollDeltas(); |
2244 EXPECT_EQ(scroll_info->page_scale_delta, 2); | 2249 EXPECT_EQ(scroll_info->page_scale_delta, 2); |
2245 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2250 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
2246 gfx::Vector2d(-50, -50))); | 2251 gfx::Vector2d(-50, -50))); |
2247 } | 2252 } |
2248 | 2253 |
2249 start_time += base::TimeDelta::FromSeconds(10); | 2254 start_time += base::TimeDelta::FromSeconds(10); |
2250 halfway_through_animation += base::TimeDelta::FromSeconds(10); | 2255 halfway_through_animation += base::TimeDelta::FromSeconds(10); |
2251 end_time += base::TimeDelta::FromSeconds(10); | 2256 end_time += base::TimeDelta::FromSeconds(10); |
2252 | 2257 |
2253 // Anchor zoom-out | 2258 // Anchor zoom-out |
2254 { | 2259 { |
2255 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2260 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2256 max_page_scale); | 2261 max_page_scale); |
2257 scroll_layer->layer_tree_impl() | 2262 scroll_layer->layer_tree_impl() |
2258 ->property_trees() | 2263 ->property_trees() |
2259 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2264 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2260 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2265 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
2261 | 2266 |
2262 did_request_redraw_ = false; | 2267 did_request_redraw_ = false; |
2263 did_request_next_frame_ = false; | 2268 did_request_next_frame_ = false; |
2264 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2269 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2265 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation( | 2270 std::unique_ptr<PendingPageScaleAnimation>( |
2266 gfx::Vector2d(25, 25), | 2271 new PendingPageScaleAnimation(gfx::Vector2d(25, 25), true, |
2267 true, | 2272 min_page_scale, duration))); |
2268 min_page_scale, | |
2269 duration))); | |
2270 host_impl_->ActivateSyncTree(); | 2273 host_impl_->ActivateSyncTree(); |
2271 EXPECT_FALSE(did_request_redraw_); | 2274 EXPECT_FALSE(did_request_redraw_); |
2272 EXPECT_TRUE(did_request_next_frame_); | 2275 EXPECT_TRUE(did_request_next_frame_); |
2273 | 2276 |
2274 did_request_redraw_ = false; | 2277 did_request_redraw_ = false; |
2275 did_request_next_frame_ = false; | 2278 did_request_next_frame_ = false; |
2276 begin_frame_args.frame_time = start_time; | 2279 begin_frame_args.frame_time = start_time; |
2277 host_impl_->WillBeginImplFrame(begin_frame_args); | 2280 host_impl_->WillBeginImplFrame(begin_frame_args); |
2278 host_impl_->Animate(); | 2281 host_impl_->Animate(); |
2279 EXPECT_TRUE(did_request_redraw_); | 2282 EXPECT_TRUE(did_request_redraw_); |
2280 EXPECT_TRUE(did_request_next_frame_); | 2283 EXPECT_TRUE(did_request_next_frame_); |
2281 host_impl_->DidFinishImplFrame(); | 2284 host_impl_->DidFinishImplFrame(); |
2282 | 2285 |
2283 did_request_redraw_ = false; | 2286 did_request_redraw_ = false; |
2284 did_request_commit_ = false; | 2287 did_request_commit_ = false; |
2285 did_request_next_frame_ = false; | 2288 did_request_next_frame_ = false; |
2286 begin_frame_args.frame_time = end_time; | 2289 begin_frame_args.frame_time = end_time; |
2287 host_impl_->WillBeginImplFrame(begin_frame_args); | 2290 host_impl_->WillBeginImplFrame(begin_frame_args); |
2288 host_impl_->Animate(); | 2291 host_impl_->Animate(); |
2289 EXPECT_TRUE(did_request_redraw_); | 2292 EXPECT_TRUE(did_request_redraw_); |
2290 EXPECT_FALSE(did_request_next_frame_); | 2293 EXPECT_FALSE(did_request_next_frame_); |
2291 EXPECT_TRUE(did_request_commit_); | 2294 EXPECT_TRUE(did_request_commit_); |
2292 host_impl_->DidFinishImplFrame(); | 2295 host_impl_->DidFinishImplFrame(); |
2293 | 2296 |
2294 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2297 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2295 host_impl_->ProcessScrollDeltas(); | 2298 host_impl_->ProcessScrollDeltas(); |
2296 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 2299 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
2297 // Pushed to (0,0) via clamping against contents layer size. | 2300 // Pushed to (0,0) via clamping against contents layer size. |
2298 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2301 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
2299 gfx::Vector2d(-50, -50))); | 2302 gfx::Vector2d(-50, -50))); |
2300 } | 2303 } |
2301 } | 2304 } |
2302 | 2305 |
2303 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { | 2306 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { |
2304 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2307 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
(...skipping 17 matching lines...) Expand all Loading... |
2322 // Anchor zoom with unchanged page scale should not change scroll or scale. | 2325 // Anchor zoom with unchanged page scale should not change scroll or scale. |
2323 { | 2326 { |
2324 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2327 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2325 max_page_scale); | 2328 max_page_scale); |
2326 scroll_layer->layer_tree_impl() | 2329 scroll_layer->layer_tree_impl() |
2327 ->property_trees() | 2330 ->property_trees() |
2328 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2331 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2329 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2332 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
2330 | 2333 |
2331 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2334 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2332 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2335 std::unique_ptr<PendingPageScaleAnimation>( |
2333 gfx::Vector2d(), | 2336 new PendingPageScaleAnimation(gfx::Vector2d(), true, 1.f, |
2334 true, | 2337 duration))); |
2335 1.f, | |
2336 duration))); | |
2337 host_impl_->ActivateSyncTree(); | 2338 host_impl_->ActivateSyncTree(); |
2338 begin_frame_args.frame_time = start_time; | 2339 begin_frame_args.frame_time = start_time; |
2339 host_impl_->WillBeginImplFrame(begin_frame_args); | 2340 host_impl_->WillBeginImplFrame(begin_frame_args); |
2340 host_impl_->Animate(); | 2341 host_impl_->Animate(); |
2341 host_impl_->DidFinishImplFrame(); | 2342 host_impl_->DidFinishImplFrame(); |
2342 | 2343 |
2343 begin_frame_args.frame_time = halfway_through_animation; | 2344 begin_frame_args.frame_time = halfway_through_animation; |
2344 host_impl_->WillBeginImplFrame(begin_frame_args); | 2345 host_impl_->WillBeginImplFrame(begin_frame_args); |
2345 host_impl_->Animate(); | 2346 host_impl_->Animate(); |
2346 EXPECT_TRUE(did_request_redraw_); | 2347 EXPECT_TRUE(did_request_redraw_); |
2347 host_impl_->DidFinishImplFrame(); | 2348 host_impl_->DidFinishImplFrame(); |
2348 | 2349 |
2349 begin_frame_args.frame_time = end_time; | 2350 begin_frame_args.frame_time = end_time; |
2350 host_impl_->WillBeginImplFrame(begin_frame_args); | 2351 host_impl_->WillBeginImplFrame(begin_frame_args); |
2351 host_impl_->Animate(); | 2352 host_impl_->Animate(); |
2352 EXPECT_TRUE(did_request_commit_); | 2353 EXPECT_TRUE(did_request_commit_); |
2353 host_impl_->DidFinishImplFrame(); | 2354 host_impl_->DidFinishImplFrame(); |
2354 | 2355 |
2355 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2356 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2356 host_impl_->ProcessScrollDeltas(); | 2357 host_impl_->ProcessScrollDeltas(); |
2357 EXPECT_EQ(scroll_info->page_scale_delta, 1); | 2358 EXPECT_EQ(scroll_info->page_scale_delta, 1); |
2358 ExpectNone(*scroll_info, scroll_layer->id()); | 2359 ExpectNone(*scroll_info, scroll_layer->id()); |
2359 } | 2360 } |
2360 } | 2361 } |
2361 | 2362 |
2362 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { | 2363 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { |
2363 host_impl_->CreatePendingTree(); | 2364 host_impl_->CreatePendingTree(); |
2364 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 2365 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
2365 CreateScrollAndContentsLayers( | 2366 CreateScrollAndContentsLayers( |
(...skipping 24 matching lines...) Expand all Loading... |
2390 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2391 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
2391 | 2392 |
2392 scroll_layer->layer_tree_impl() | 2393 scroll_layer->layer_tree_impl() |
2393 ->property_trees() | 2394 ->property_trees() |
2394 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 2395 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
2395 gfx::ScrollOffset(50, 50)); | 2396 gfx::ScrollOffset(50, 50)); |
2396 | 2397 |
2397 // Make sure TakePageScaleAnimation works properly. | 2398 // Make sure TakePageScaleAnimation works properly. |
2398 | 2399 |
2399 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 2400 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
2400 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2401 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
2401 gfx::Vector2d(), | 2402 gfx::Vector2d(), false, target_scale, duration))); |
2402 false, | 2403 std::unique_ptr<PendingPageScaleAnimation> psa = |
2403 target_scale, | |
2404 duration))); | |
2405 scoped_ptr<PendingPageScaleAnimation> psa = | |
2406 host_impl_->sync_tree()->TakePendingPageScaleAnimation(); | 2404 host_impl_->sync_tree()->TakePendingPageScaleAnimation(); |
2407 EXPECT_EQ(target_scale, psa->scale); | 2405 EXPECT_EQ(target_scale, psa->scale); |
2408 EXPECT_EQ(duration, psa->duration); | 2406 EXPECT_EQ(duration, psa->duration); |
2409 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); | 2407 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); |
2410 | 2408 |
2411 // Recreate the PSA. Nothing should happen here since the tree containing the | 2409 // Recreate the PSA. Nothing should happen here since the tree containing the |
2412 // PSA hasn't been activated yet. | 2410 // PSA hasn't been activated yet. |
2413 did_request_redraw_ = false; | 2411 did_request_redraw_ = false; |
2414 did_request_next_frame_ = false; | 2412 did_request_next_frame_ = false; |
2415 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 2413 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
2416 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2414 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
2417 gfx::Vector2d(), | 2415 gfx::Vector2d(), false, target_scale, duration))); |
2418 false, | |
2419 target_scale, | |
2420 duration))); | |
2421 begin_frame_args.frame_time = halfway_through_animation; | 2416 begin_frame_args.frame_time = halfway_through_animation; |
2422 host_impl_->WillBeginImplFrame(begin_frame_args); | 2417 host_impl_->WillBeginImplFrame(begin_frame_args); |
2423 host_impl_->Animate(); | 2418 host_impl_->Animate(); |
2424 EXPECT_FALSE(did_request_next_frame_); | 2419 EXPECT_FALSE(did_request_next_frame_); |
2425 EXPECT_FALSE(did_request_redraw_); | 2420 EXPECT_FALSE(did_request_redraw_); |
2426 host_impl_->DidFinishImplFrame(); | 2421 host_impl_->DidFinishImplFrame(); |
2427 | 2422 |
2428 // Activate the sync tree. This should cause the animation to become enabled. | 2423 // Activate the sync tree. This should cause the animation to become enabled. |
2429 // It should also clear the pointer on the sync tree. | 2424 // It should also clear the pointer on the sync tree. |
2430 host_impl_->ActivateSyncTree(); | 2425 host_impl_->ActivateSyncTree(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2472 did_request_redraw_ = false; | 2467 did_request_redraw_ = false; |
2473 did_request_next_frame_ = false; | 2468 did_request_next_frame_ = false; |
2474 did_request_commit_ = false; | 2469 did_request_commit_ = false; |
2475 begin_frame_args.frame_time = end_time; | 2470 begin_frame_args.frame_time = end_time; |
2476 host_impl_->WillBeginImplFrame(begin_frame_args); | 2471 host_impl_->WillBeginImplFrame(begin_frame_args); |
2477 host_impl_->Animate(); | 2472 host_impl_->Animate(); |
2478 EXPECT_TRUE(did_request_commit_); | 2473 EXPECT_TRUE(did_request_commit_); |
2479 EXPECT_FALSE(did_request_next_frame_); | 2474 EXPECT_FALSE(did_request_next_frame_); |
2480 host_impl_->DidFinishImplFrame(); | 2475 host_impl_->DidFinishImplFrame(); |
2481 | 2476 |
2482 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2477 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2483 host_impl_->ProcessScrollDeltas(); | 2478 host_impl_->ProcessScrollDeltas(); |
2484 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); | 2479 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); |
2485 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2480 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
2486 gfx::Vector2d(-50, -50))); | 2481 gfx::Vector2d(-50, -50))); |
2487 } | 2482 } |
2488 | 2483 |
2489 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { | 2484 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { |
2490 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2485 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2491 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2486 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2492 DrawFrame(); | 2487 DrawFrame(); |
(...skipping 11 matching lines...) Expand all Loading... |
2504 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2499 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
2505 | 2500 |
2506 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 2501 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
2507 scroll_layer->layer_tree_impl() | 2502 scroll_layer->layer_tree_impl() |
2508 ->property_trees() | 2503 ->property_trees() |
2509 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 2504 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
2510 gfx::ScrollOffset(50, 50)); | 2505 gfx::ScrollOffset(50, 50)); |
2511 | 2506 |
2512 did_complete_page_scale_animation_ = false; | 2507 did_complete_page_scale_animation_ = false; |
2513 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2508 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2514 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2509 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
2515 gfx::Vector2d(), false, 2.f, duration))); | 2510 gfx::Vector2d(), false, 2.f, duration))); |
2516 host_impl_->ActivateSyncTree(); | 2511 host_impl_->ActivateSyncTree(); |
2517 begin_frame_args.frame_time = start_time; | 2512 begin_frame_args.frame_time = start_time; |
2518 host_impl_->WillBeginImplFrame(begin_frame_args); | 2513 host_impl_->WillBeginImplFrame(begin_frame_args); |
2519 host_impl_->Animate(); | 2514 host_impl_->Animate(); |
2520 EXPECT_FALSE(did_complete_page_scale_animation_); | 2515 EXPECT_FALSE(did_complete_page_scale_animation_); |
2521 host_impl_->DidFinishImplFrame(); | 2516 host_impl_->DidFinishImplFrame(); |
2522 | 2517 |
2523 begin_frame_args.frame_time = halfway_through_animation; | 2518 begin_frame_args.frame_time = halfway_through_animation; |
2524 host_impl_->WillBeginImplFrame(begin_frame_args); | 2519 host_impl_->WillBeginImplFrame(begin_frame_args); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2593 | 2588 |
2594 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { | 2589 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { |
2595 protected: | 2590 protected: |
2596 void SetupLayers(LayerTreeSettings settings) { | 2591 void SetupLayers(LayerTreeSettings settings) { |
2597 gfx::Size content_size(100, 100); | 2592 gfx::Size content_size(100, 100); |
2598 | 2593 |
2599 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = | 2594 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = |
2600 new LayerTreeHostImplOverridePhysicalTime( | 2595 new LayerTreeHostImplOverridePhysicalTime( |
2601 settings, this, &task_runner_provider_, &shared_bitmap_manager_, | 2596 settings, this, &task_runner_provider_, &shared_bitmap_manager_, |
2602 &task_graph_runner_, &stats_instrumentation_); | 2597 &task_graph_runner_, &stats_instrumentation_); |
2603 host_impl_ = make_scoped_ptr(host_impl_override_time); | 2598 host_impl_ = base::WrapUnique(host_impl_override_time); |
2604 output_surface_ = CreateOutputSurface(); | 2599 output_surface_ = CreateOutputSurface(); |
2605 host_impl_->SetVisible(true); | 2600 host_impl_->SetVisible(true); |
2606 host_impl_->InitializeRenderer(output_surface_.get()); | 2601 host_impl_->InitializeRenderer(output_surface_.get()); |
2607 | 2602 |
2608 SetupScrollAndContentsLayers(content_size); | 2603 SetupScrollAndContentsLayers(content_size); |
2609 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); | 2604 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
2610 host_impl_->SetViewportSize( | 2605 host_impl_->SetViewportSize( |
2611 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 2606 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
2612 | 2607 |
2613 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2608 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
2614 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, | 2609 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, |
2615 VERTICAL, 10, 0, false, true); | 2610 VERTICAL, 10, 0, false, true); |
2616 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); | 2611 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); |
2617 | 2612 |
2618 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); | 2613 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); |
2619 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); | 2614 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); |
2620 scrollbar->SetScrollLayerId(scroll->id()); | 2615 scrollbar->SetScrollLayerId(scroll->id()); |
2621 root->AddChild(std::move(scrollbar)); | 2616 root->AddChild(std::move(scrollbar)); |
2622 | 2617 |
2623 host_impl_->active_tree()->DidBecomeActive(); | 2618 host_impl_->active_tree()->DidBecomeActive(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2787 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2782 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
2788 LayerTreeSettings settings = DefaultSettings(); | 2783 LayerTreeSettings settings = DefaultSettings(); |
2789 settings.scrollbar_animator = animator; | 2784 settings.scrollbar_animator = animator; |
2790 settings.scrollbar_fade_delay_ms = 20; | 2785 settings.scrollbar_fade_delay_ms = 20; |
2791 settings.scrollbar_fade_duration_ms = 20; | 2786 settings.scrollbar_fade_duration_ms = 20; |
2792 gfx::Size content_size(100, 100); | 2787 gfx::Size content_size(100, 100); |
2793 | 2788 |
2794 CreateHostImpl(settings, CreateOutputSurface()); | 2789 CreateHostImpl(settings, CreateOutputSurface()); |
2795 host_impl_->CreatePendingTree(); | 2790 host_impl_->CreatePendingTree(); |
2796 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); | 2791 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); |
2797 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2792 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
2798 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, | 2793 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, |
2799 VERTICAL, 10, 0, false, true); | 2794 VERTICAL, 10, 0, false, true); |
2800 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); | 2795 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); |
2801 LayerImpl* root = host_impl_->pending_tree()->InnerViewportContainerLayer(); | 2796 LayerImpl* root = host_impl_->pending_tree()->InnerViewportContainerLayer(); |
2802 scrollbar->SetScrollLayerId(scroll->id()); | 2797 scrollbar->SetScrollLayerId(scroll->id()); |
2803 root->AddChild(std::move(scrollbar)); | 2798 root->AddChild(std::move(scrollbar)); |
2804 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 2799 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
2805 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 2800 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
2806 host_impl_->ActivateSyncTree(); | 2801 host_impl_->ActivateSyncTree(); |
2807 | 2802 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2854 const int child_clip_id = 14; | 2849 const int child_clip_id = 14; |
2855 const int child_scroll_id = 15; | 2850 const int child_scroll_id = 15; |
2856 | 2851 |
2857 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); | 2852 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
2858 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( | 2853 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( |
2859 inner_viewport_size); | 2854 inner_viewport_size); |
2860 host_impl_->active_tree()->OuterViewportContainerLayer()->SetBounds( | 2855 host_impl_->active_tree()->OuterViewportContainerLayer()->SetBounds( |
2861 outer_viewport_size); | 2856 outer_viewport_size); |
2862 LayerImpl* root_scroll = | 2857 LayerImpl* root_scroll = |
2863 host_impl_->active_tree()->OuterViewportScrollLayer(); | 2858 host_impl_->active_tree()->OuterViewportScrollLayer(); |
2864 scoped_ptr<SolidColorScrollbarLayerImpl> horiz_scrollbar = | 2859 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_scrollbar = |
2865 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), horiz_id, | 2860 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), horiz_id, |
2866 HORIZONTAL, 5, 5, true, true); | 2861 HORIZONTAL, 5, 5, true, true); |
2867 scoped_ptr<LayerImpl> child = | 2862 std::unique_ptr<LayerImpl> child = |
2868 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); | 2863 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); |
2869 child->SetBounds(content_size); | 2864 child->SetBounds(content_size); |
2870 scoped_ptr<LayerImpl> child_clip = | 2865 std::unique_ptr<LayerImpl> child_clip = |
2871 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); | 2866 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); |
2872 child->SetBounds(inner_viewport_size); | 2867 child->SetBounds(inner_viewport_size); |
2873 | 2868 |
2874 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); | 2869 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); |
2875 | 2870 |
2876 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); | 2871 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); |
2877 } | 2872 } |
2878 | 2873 |
2879 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { | 2874 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { |
2880 LayerTreeSettings settings = DefaultSettings(); | 2875 LayerTreeSettings settings = DefaultSettings(); |
(...skipping 10 matching lines...) Expand all Loading... |
2891 const int vert_2_id = 12; | 2886 const int vert_2_id = 12; |
2892 const int horiz_2_id = 13; | 2887 const int horiz_2_id = 13; |
2893 const int child_clip_id = 14; | 2888 const int child_clip_id = 14; |
2894 const int child_scroll_id = 15; | 2889 const int child_scroll_id = 15; |
2895 | 2890 |
2896 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); | 2891 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
2897 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( | 2892 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( |
2898 viewport_size); | 2893 viewport_size); |
2899 LayerImpl* root_scroll = | 2894 LayerImpl* root_scroll = |
2900 host_impl_->active_tree()->OuterViewportScrollLayer(); | 2895 host_impl_->active_tree()->OuterViewportScrollLayer(); |
2901 scoped_ptr<SolidColorScrollbarLayerImpl> vert_1_scrollbar = | 2896 std::unique_ptr<SolidColorScrollbarLayerImpl> vert_1_scrollbar = |
2902 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), vert_1_id, | 2897 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), vert_1_id, |
2903 VERTICAL, 5, 5, true, true); | 2898 VERTICAL, 5, 5, true, true); |
2904 scoped_ptr<SolidColorScrollbarLayerImpl> horiz_1_scrollbar = | 2899 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_1_scrollbar = |
2905 SolidColorScrollbarLayerImpl::Create( | 2900 SolidColorScrollbarLayerImpl::Create( |
2906 host_impl_->active_tree(), horiz_1_id, HORIZONTAL, 5, 5, true, true); | 2901 host_impl_->active_tree(), horiz_1_id, HORIZONTAL, 5, 5, true, true); |
2907 scoped_ptr<SolidColorScrollbarLayerImpl> vert_2_scrollbar = | 2902 std::unique_ptr<SolidColorScrollbarLayerImpl> vert_2_scrollbar = |
2908 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), vert_2_id, | 2903 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), vert_2_id, |
2909 VERTICAL, 5, 5, true, true); | 2904 VERTICAL, 5, 5, true, true); |
2910 scoped_ptr<SolidColorScrollbarLayerImpl> horiz_2_scrollbar = | 2905 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_2_scrollbar = |
2911 SolidColorScrollbarLayerImpl::Create( | 2906 SolidColorScrollbarLayerImpl::Create( |
2912 host_impl_->active_tree(), horiz_2_id, HORIZONTAL, 5, 5, true, true); | 2907 host_impl_->active_tree(), horiz_2_id, HORIZONTAL, 5, 5, true, true); |
2913 scoped_ptr<LayerImpl> child = | 2908 std::unique_ptr<LayerImpl> child = |
2914 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); | 2909 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); |
2915 child->SetBounds(content_size); | 2910 child->SetBounds(content_size); |
2916 scoped_ptr<LayerImpl> child_clip = | 2911 std::unique_ptr<LayerImpl> child_clip = |
2917 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); | 2912 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); |
2918 child->SetBounds(viewport_size); | 2913 child->SetBounds(viewport_size); |
2919 LayerImpl* child_ptr = child.get(); | 2914 LayerImpl* child_ptr = child.get(); |
2920 LayerImpl* child_clip_ptr = child_clip.get(); | 2915 LayerImpl* child_clip_ptr = child_clip.get(); |
2921 | 2916 |
2922 // Check scrollbar registration on the viewport layers. | 2917 // Check scrollbar registration on the viewport layers. |
2923 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); | 2918 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); |
2924 EXPECT_EQ(nullptr, | 2919 EXPECT_EQ(nullptr, |
2925 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); | 2920 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); |
2926 vert_1_scrollbar->SetScrollLayerId(root_scroll->id()); | 2921 vert_1_scrollbar->SetScrollLayerId(root_scroll->id()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3012 CreateHostImpl(settings, CreateOutputSurface()); | 3007 CreateHostImpl(settings, CreateOutputSurface()); |
3013 host_impl_->active_tree()->SetDeviceScaleFactor(device_scale_factor); | 3008 host_impl_->active_tree()->SetDeviceScaleFactor(device_scale_factor); |
3014 host_impl_->SetViewportSize(device_viewport_size); | 3009 host_impl_->SetViewportSize(device_viewport_size); |
3015 | 3010 |
3016 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); | 3011 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
3017 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( | 3012 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( |
3018 viewport_size); | 3013 viewport_size); |
3019 LayerImpl* root_scroll = | 3014 LayerImpl* root_scroll = |
3020 host_impl_->active_tree()->OuterViewportScrollLayer(); | 3015 host_impl_->active_tree()->OuterViewportScrollLayer(); |
3021 // The scrollbar is on the left side. | 3016 // The scrollbar is on the left side. |
3022 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 3017 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
3023 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, | 3018 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, |
3024 VERTICAL, 5, 5, true, true); | 3019 VERTICAL, 5, 5, true, true); |
3025 scrollbar->SetScrollLayerId(root_scroll->id()); | 3020 scrollbar->SetScrollLayerId(root_scroll->id()); |
3026 scrollbar->SetDrawsContent(true); | 3021 scrollbar->SetDrawsContent(true); |
3027 scrollbar->SetBounds(scrollbar_size); | 3022 scrollbar->SetBounds(scrollbar_size); |
3028 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); | 3023 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); |
3029 host_impl_->active_tree()->InnerViewportContainerLayer()->AddChild( | 3024 host_impl_->active_tree()->InnerViewportContainerLayer()->AddChild( |
3030 std::move(scrollbar)); | 3025 std::move(scrollbar)); |
3031 host_impl_->active_tree()->DidBecomeActive(); | 3026 host_impl_->active_tree()->DidBecomeActive(); |
3032 | 3027 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3188 EXPECT_EQ(4.f, metadata.page_scale_factor); | 3183 EXPECT_EQ(4.f, metadata.page_scale_factor); |
3189 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.scrollable_viewport_size); | 3184 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.scrollable_viewport_size); |
3190 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); | 3185 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); |
3191 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 3186 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
3192 EXPECT_EQ(4.f, metadata.max_page_scale_factor); | 3187 EXPECT_EQ(4.f, metadata.max_page_scale_factor); |
3193 } | 3188 } |
3194 } | 3189 } |
3195 | 3190 |
3196 class DidDrawCheckLayer : public LayerImpl { | 3191 class DidDrawCheckLayer : public LayerImpl { |
3197 public: | 3192 public: |
3198 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 3193 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
3199 return make_scoped_ptr(new DidDrawCheckLayer(tree_impl, id)); | 3194 return base::WrapUnique(new DidDrawCheckLayer(tree_impl, id)); |
3200 } | 3195 } |
3201 | 3196 |
3202 bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) override { | 3197 bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) override { |
3203 will_draw_called_ = true; | 3198 will_draw_called_ = true; |
3204 if (will_draw_returns_false_) | 3199 if (will_draw_returns_false_) |
3205 return false; | 3200 return false; |
3206 return LayerImpl::WillDraw(draw_mode, provider); | 3201 return LayerImpl::WillDraw(draw_mode, provider); |
3207 } | 3202 } |
3208 | 3203 |
3209 void AppendQuads(RenderPass* render_pass, | 3204 void AppendQuads(RenderPass* render_pass, |
(...skipping 12 matching lines...) Expand all Loading... |
3222 bool did_draw_called() const { return did_draw_called_; } | 3217 bool did_draw_called() const { return did_draw_called_; } |
3223 | 3218 |
3224 void set_will_draw_returns_false() { will_draw_returns_false_ = true; } | 3219 void set_will_draw_returns_false() { will_draw_returns_false_ = true; } |
3225 | 3220 |
3226 void ClearDidDrawCheck() { | 3221 void ClearDidDrawCheck() { |
3227 will_draw_called_ = false; | 3222 will_draw_called_ = false; |
3228 append_quads_called_ = false; | 3223 append_quads_called_ = false; |
3229 did_draw_called_ = false; | 3224 did_draw_called_ = false; |
3230 } | 3225 } |
3231 | 3226 |
3232 static void IgnoreResult(scoped_ptr<CopyOutputResult> result) {} | 3227 static void IgnoreResult(std::unique_ptr<CopyOutputResult> result) {} |
3233 | 3228 |
3234 void AddCopyRequest() { | 3229 void AddCopyRequest() { |
3235 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 3230 std::vector<std::unique_ptr<CopyOutputRequest>> requests; |
3236 requests.push_back( | 3231 requests.push_back( |
3237 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreResult))); | 3232 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreResult))); |
3238 SetForceRenderSurface(true); | 3233 SetForceRenderSurface(true); |
3239 PassCopyRequests(&requests); | 3234 PassCopyRequests(&requests); |
3240 } | 3235 } |
3241 | 3236 |
3242 protected: | 3237 protected: |
3243 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) | 3238 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) |
3244 : LayerImpl(tree_impl, id), | 3239 : LayerImpl(tree_impl, id), |
3245 will_draw_returns_false_(false), | 3240 will_draw_returns_false_(false), |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3420 EXPECT_TRUE(root->did_draw_called()); | 3415 EXPECT_TRUE(root->did_draw_called()); |
3421 EXPECT_TRUE(layer1->did_draw_called()); | 3416 EXPECT_TRUE(layer1->did_draw_called()); |
3422 EXPECT_TRUE(layer2->did_draw_called()); | 3417 EXPECT_TRUE(layer2->did_draw_called()); |
3423 | 3418 |
3424 EXPECT_NE(root->render_surface(), layer1->render_surface()); | 3419 EXPECT_NE(root->render_surface(), layer1->render_surface()); |
3425 EXPECT_TRUE(layer1->render_surface()); | 3420 EXPECT_TRUE(layer1->render_surface()); |
3426 } | 3421 } |
3427 | 3422 |
3428 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { | 3423 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { |
3429 public: | 3424 public: |
3430 static scoped_ptr<LayerImpl> Create( | 3425 static std::unique_ptr<LayerImpl> Create( |
3431 LayerTreeImpl* tree_impl, | 3426 LayerTreeImpl* tree_impl, |
3432 int id, | 3427 int id, |
3433 bool tile_missing, | 3428 bool tile_missing, |
3434 bool had_incomplete_tile, | 3429 bool had_incomplete_tile, |
3435 bool animating, | 3430 bool animating, |
3436 ResourceProvider* resource_provider, | 3431 ResourceProvider* resource_provider, |
3437 scoped_refptr<AnimationTimeline> timeline) { | 3432 scoped_refptr<AnimationTimeline> timeline) { |
3438 return make_scoped_ptr(new MissingTextureAnimatingLayer( | 3433 return base::WrapUnique(new MissingTextureAnimatingLayer( |
3439 tree_impl, id, tile_missing, had_incomplete_tile, animating, | 3434 tree_impl, id, tile_missing, had_incomplete_tile, animating, |
3440 resource_provider, timeline)); | 3435 resource_provider, timeline)); |
3441 } | 3436 } |
3442 | 3437 |
3443 void AppendQuads(RenderPass* render_pass, | 3438 void AppendQuads(RenderPass* render_pass, |
3444 AppendQuadsData* append_quads_data) override { | 3439 AppendQuadsData* append_quads_data) override { |
3445 LayerImpl::AppendQuads(render_pass, append_quads_data); | 3440 LayerImpl::AppendQuads(render_pass, append_quads_data); |
3446 if (had_incomplete_tile_) | 3441 if (had_incomplete_tile_) |
3447 append_quads_data->num_incomplete_tiles++; | 3442 append_quads_data->num_incomplete_tiles++; |
3448 if (tile_missing_) | 3443 if (tile_missing_) |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3622 host_impl_->DrawLayers(&frame); | 3617 host_impl_->DrawLayers(&frame); |
3623 host_impl_->DidDrawAllLayers(frame); | 3618 host_impl_->DidDrawAllLayers(frame); |
3624 host_impl_->SwapBuffers(frame); | 3619 host_impl_->SwapBuffers(frame); |
3625 } | 3620 } |
3626 } | 3621 } |
3627 | 3622 |
3628 TEST_F(LayerTreeHostImplTest, | 3623 TEST_F(LayerTreeHostImplTest, |
3629 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { | 3624 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { |
3630 CreateHostImpl(DefaultSettings(), | 3625 CreateHostImpl(DefaultSettings(), |
3631 FakeOutputSurface::CreateSoftware( | 3626 FakeOutputSurface::CreateSoftware( |
3632 make_scoped_ptr(new SoftwareOutputDevice()))); | 3627 base::WrapUnique(new SoftwareOutputDevice()))); |
3633 | 3628 |
3634 const gfx::Transform external_transform; | 3629 const gfx::Transform external_transform; |
3635 const gfx::Rect external_viewport; | 3630 const gfx::Rect external_viewport; |
3636 const gfx::Rect external_clip; | 3631 const gfx::Rect external_clip; |
3637 const bool resourceless_software_draw = true; | 3632 const bool resourceless_software_draw = true; |
3638 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 3633 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
3639 external_transform); | 3634 external_transform); |
3640 | 3635 |
3641 std::vector<PrepareToDrawSuccessTestCase> cases; | 3636 std::vector<PrepareToDrawSuccessTestCase> cases; |
3642 | 3637 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3710 if (testcase.high_res_required) | 3705 if (testcase.high_res_required) |
3711 host_impl_->SetRequiresHighResToDraw(); | 3706 host_impl_->SetRequiresHighResToDraw(); |
3712 | 3707 |
3713 SetNeedsRebuildPropertyTrees(); | 3708 SetNeedsRebuildPropertyTrees(); |
3714 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3709 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
3715 resourceless_software_draw); | 3710 resourceless_software_draw); |
3716 } | 3711 } |
3717 } | 3712 } |
3718 | 3713 |
3719 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 3714 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
3720 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3715 std::unique_ptr<LayerImpl> root = |
| 3716 LayerImpl::Create(host_impl_->active_tree(), 1); |
3721 root->SetScrollClipLayer(Layer::INVALID_ID); | 3717 root->SetScrollClipLayer(Layer::INVALID_ID); |
3722 root->SetForceRenderSurface(true); | 3718 root->SetForceRenderSurface(true); |
3723 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 3719 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
3724 SetNeedsRebuildPropertyTrees(); | 3720 SetNeedsRebuildPropertyTrees(); |
3725 DrawFrame(); | 3721 DrawFrame(); |
3726 | 3722 |
3727 // Scroll event is ignored because layer is not scrollable. | 3723 // Scroll event is ignored because layer is not scrollable. |
3728 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 3724 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
3729 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 3725 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
3730 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 3726 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3764 // Make the clip size the same as the layer (content) size so the layer is | 3760 // Make the clip size the same as the layer (content) size so the layer is |
3765 // non-scrollable. | 3761 // non-scrollable. |
3766 : layer_size_(10, 10), | 3762 : layer_size_(10, 10), |
3767 clip_size_(layer_size_), | 3763 clip_size_(layer_size_), |
3768 top_controls_height_(50) { | 3764 top_controls_height_(50) { |
3769 viewport_size_ = gfx::Size(clip_size_.width(), | 3765 viewport_size_ = gfx::Size(clip_size_.width(), |
3770 clip_size_.height() + top_controls_height_); | 3766 clip_size_.height() + top_controls_height_); |
3771 } | 3767 } |
3772 | 3768 |
3773 bool CreateHostImpl(const LayerTreeSettings& settings, | 3769 bool CreateHostImpl(const LayerTreeSettings& settings, |
3774 scoped_ptr<OutputSurface> output_surface) override { | 3770 std::unique_ptr<OutputSurface> output_surface) override { |
3775 bool init = LayerTreeHostImplTest::CreateHostImpl( | 3771 bool init = LayerTreeHostImplTest::CreateHostImpl( |
3776 settings, std::move(output_surface)); | 3772 settings, std::move(output_surface)); |
3777 if (init) { | 3773 if (init) { |
3778 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 3774 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
3779 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 3775 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
3780 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3776 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
3781 } | 3777 } |
3782 return init; | 3778 return init; |
3783 } | 3779 } |
3784 | 3780 |
(...skipping 12 matching lines...) Expand all Loading... |
3797 LayerTreeImpl* tree_impl, | 3793 LayerTreeImpl* tree_impl, |
3798 const gfx::Size& inner_viewport_size, | 3794 const gfx::Size& inner_viewport_size, |
3799 const gfx::Size& outer_viewport_size, | 3795 const gfx::Size& outer_viewport_size, |
3800 const gfx::Size& scroll_layer_size) { | 3796 const gfx::Size& scroll_layer_size) { |
3801 tree_impl->set_top_controls_shrink_blink_size(true); | 3797 tree_impl->set_top_controls_shrink_blink_size(true); |
3802 tree_impl->set_top_controls_height(top_controls_height_); | 3798 tree_impl->set_top_controls_height(top_controls_height_); |
3803 tree_impl->SetCurrentTopControlsShownRatio(1.f); | 3799 tree_impl->SetCurrentTopControlsShownRatio(1.f); |
3804 tree_impl->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3800 tree_impl->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
3805 host_impl_->DidChangeTopControlsPosition(); | 3801 host_impl_->DidChangeTopControlsPosition(); |
3806 | 3802 |
3807 scoped_ptr<LayerImpl> root = LayerImpl::Create(tree_impl, 1); | 3803 std::unique_ptr<LayerImpl> root = LayerImpl::Create(tree_impl, 1); |
3808 scoped_ptr<LayerImpl> root_clip = LayerImpl::Create(tree_impl, 2); | 3804 std::unique_ptr<LayerImpl> root_clip = LayerImpl::Create(tree_impl, 2); |
3809 scoped_ptr<LayerImpl> page_scale = LayerImpl::Create(tree_impl, 3); | 3805 std::unique_ptr<LayerImpl> page_scale = LayerImpl::Create(tree_impl, 3); |
3810 | 3806 |
3811 scoped_ptr<LayerImpl> outer_scroll = LayerImpl::Create(tree_impl, 4); | 3807 std::unique_ptr<LayerImpl> outer_scroll = LayerImpl::Create(tree_impl, 4); |
3812 scoped_ptr<LayerImpl> outer_clip = LayerImpl::Create(tree_impl, 5); | 3808 std::unique_ptr<LayerImpl> outer_clip = LayerImpl::Create(tree_impl, 5); |
3813 | 3809 |
3814 root_clip->SetBounds(inner_viewport_size); | 3810 root_clip->SetBounds(inner_viewport_size); |
3815 root->SetScrollClipLayer(root_clip->id()); | 3811 root->SetScrollClipLayer(root_clip->id()); |
3816 root->SetBounds(outer_viewport_size); | 3812 root->SetBounds(outer_viewport_size); |
3817 root->SetPosition(gfx::PointF()); | 3813 root->SetPosition(gfx::PointF()); |
3818 root->SetDrawsContent(false); | 3814 root->SetDrawsContent(false); |
3819 root->SetIsContainerForFixedPositionLayers(true); | 3815 root->SetIsContainerForFixedPositionLayers(true); |
3820 root_clip->SetForceRenderSurface(true); | 3816 root_clip->SetForceRenderSurface(true); |
3821 outer_clip->SetBounds(outer_viewport_size); | 3817 outer_clip->SetBounds(outer_viewport_size); |
3822 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 3818 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4124 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); | 4120 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); |
4125 DrawFrame(); | 4121 DrawFrame(); |
4126 | 4122 |
4127 // Show top controls | 4123 // Show top controls |
4128 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4124 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
4129 | 4125 |
4130 LayerImpl* outer_viewport_scroll_layer = | 4126 LayerImpl* outer_viewport_scroll_layer = |
4131 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4127 host_impl_->active_tree()->OuterViewportScrollLayer(); |
4132 int id = outer_viewport_scroll_layer->id(); | 4128 int id = outer_viewport_scroll_layer->id(); |
4133 | 4129 |
4134 scoped_ptr<LayerImpl> child = | 4130 std::unique_ptr<LayerImpl> child = |
4135 LayerImpl::Create(host_impl_->active_tree(), id + 2); | 4131 LayerImpl::Create(host_impl_->active_tree(), id + 2); |
4136 scoped_ptr<LayerImpl> child_clip = | 4132 std::unique_ptr<LayerImpl> child_clip = |
4137 LayerImpl::Create(host_impl_->active_tree(), id + 3); | 4133 LayerImpl::Create(host_impl_->active_tree(), id + 3); |
4138 | 4134 |
4139 child_clip->SetBounds(sub_content_layer_size); | 4135 child_clip->SetBounds(sub_content_layer_size); |
4140 child->SetScrollClipLayer(child_clip->id()); | 4136 child->SetScrollClipLayer(child_clip->id()); |
4141 child->SetBounds(sub_content_size); | 4137 child->SetBounds(sub_content_size); |
4142 child->SetPosition(gfx::PointF()); | 4138 child->SetPosition(gfx::PointF()); |
4143 child->SetDrawsContent(true); | 4139 child->SetDrawsContent(true); |
4144 child->SetIsContainerForFixedPositionLayers(true); | 4140 child->SetIsContainerForFixedPositionLayers(true); |
4145 | 4141 |
4146 // scroll child to limit | 4142 // scroll child to limit |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4602 EXPECT_EQ(925, inner_scroll->CurrentScrollOffset().y()); | 4598 EXPECT_EQ(925, inner_scroll->CurrentScrollOffset().y()); |
4603 EXPECT_EQ(800, outer_scroll->CurrentScrollOffset().y()); | 4599 EXPECT_EQ(800, outer_scroll->CurrentScrollOffset().y()); |
4604 } | 4600 } |
4605 | 4601 |
4606 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { | 4602 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { |
4607 // Test the configuration where a non-composited root layer is embedded in a | 4603 // Test the configuration where a non-composited root layer is embedded in a |
4608 // scrollable outer layer. | 4604 // scrollable outer layer. |
4609 gfx::Size surface_size(10, 10); | 4605 gfx::Size surface_size(10, 10); |
4610 gfx::Size contents_size(20, 20); | 4606 gfx::Size contents_size(20, 20); |
4611 | 4607 |
4612 scoped_ptr<LayerImpl> content_layer = | 4608 std::unique_ptr<LayerImpl> content_layer = |
4613 LayerImpl::Create(host_impl_->active_tree(), 1); | 4609 LayerImpl::Create(host_impl_->active_tree(), 1); |
4614 content_layer->SetDrawsContent(true); | 4610 content_layer->SetDrawsContent(true); |
4615 content_layer->SetPosition(gfx::PointF()); | 4611 content_layer->SetPosition(gfx::PointF()); |
4616 content_layer->SetBounds(contents_size); | 4612 content_layer->SetBounds(contents_size); |
4617 | 4613 |
4618 scoped_ptr<LayerImpl> scroll_clip_layer = | 4614 std::unique_ptr<LayerImpl> scroll_clip_layer = |
4619 LayerImpl::Create(host_impl_->active_tree(), 3); | 4615 LayerImpl::Create(host_impl_->active_tree(), 3); |
4620 scroll_clip_layer->SetBounds(surface_size); | 4616 scroll_clip_layer->SetBounds(surface_size); |
4621 | 4617 |
4622 scoped_ptr<LayerImpl> scroll_layer = | 4618 std::unique_ptr<LayerImpl> scroll_layer = |
4623 LayerImpl::Create(host_impl_->active_tree(), 2); | 4619 LayerImpl::Create(host_impl_->active_tree(), 2); |
4624 scroll_layer->SetScrollClipLayer(3); | 4620 scroll_layer->SetScrollClipLayer(3); |
4625 scroll_layer->SetBounds(contents_size); | 4621 scroll_layer->SetBounds(contents_size); |
4626 scroll_layer->SetPosition(gfx::PointF()); | 4622 scroll_layer->SetPosition(gfx::PointF()); |
4627 scroll_layer->AddChild(std::move(content_layer)); | 4623 scroll_layer->AddChild(std::move(content_layer)); |
4628 scroll_clip_layer->AddChild(std::move(scroll_layer)); | 4624 scroll_clip_layer->AddChild(std::move(scroll_layer)); |
4629 | 4625 |
4630 scroll_clip_layer->SetForceRenderSurface(true); | 4626 scroll_clip_layer->SetForceRenderSurface(true); |
4631 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); | 4627 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); |
4632 host_impl_->SetViewportSize(surface_size); | 4628 host_impl_->SetViewportSize(surface_size); |
4633 SetNeedsRebuildPropertyTrees(); | 4629 SetNeedsRebuildPropertyTrees(); |
4634 DrawFrame(); | 4630 DrawFrame(); |
4635 | 4631 |
4636 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4632 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4637 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4633 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
4638 InputHandler::WHEEL) | 4634 InputHandler::WHEEL) |
4639 .thread); | 4635 .thread); |
4640 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4636 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4641 host_impl_->ScrollEnd(EndState().get()); | 4637 host_impl_->ScrollEnd(EndState().get()); |
4642 EXPECT_TRUE(did_request_redraw_); | 4638 EXPECT_TRUE(did_request_redraw_); |
4643 EXPECT_TRUE(did_request_commit_); | 4639 EXPECT_TRUE(did_request_commit_); |
4644 } | 4640 } |
4645 | 4641 |
4646 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4642 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
4647 gfx::Size surface_size(10, 10); | 4643 gfx::Size surface_size(10, 10); |
4648 gfx::Size contents_size(20, 20); | 4644 gfx::Size contents_size(20, 20); |
4649 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4645 std::unique_ptr<LayerImpl> root = |
| 4646 LayerImpl::Create(host_impl_->active_tree(), 1); |
4650 root->SetBounds(surface_size); | 4647 root->SetBounds(surface_size); |
4651 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 4648 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
4652 root->SetForceRenderSurface(true); | 4649 root->SetForceRenderSurface(true); |
4653 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4650 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4654 host_impl_->SetViewportSize(surface_size); | 4651 host_impl_->SetViewportSize(surface_size); |
4655 SetNeedsRebuildPropertyTrees(); | 4652 SetNeedsRebuildPropertyTrees(); |
4656 DrawFrame(); | 4653 DrawFrame(); |
4657 | 4654 |
4658 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4655 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4659 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4656 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
4660 InputHandler::WHEEL) | 4657 InputHandler::WHEEL) |
4661 .thread); | 4658 .thread); |
4662 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4659 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4663 host_impl_->ScrollEnd(EndState().get()); | 4660 host_impl_->ScrollEnd(EndState().get()); |
4664 EXPECT_TRUE(did_request_redraw_); | 4661 EXPECT_TRUE(did_request_redraw_); |
4665 EXPECT_TRUE(did_request_commit_); | 4662 EXPECT_TRUE(did_request_commit_); |
4666 } | 4663 } |
4667 | 4664 |
4668 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4665 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
4669 gfx::Size surface_size(10, 10); | 4666 gfx::Size surface_size(10, 10); |
4670 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4667 std::unique_ptr<LayerImpl> root = |
| 4668 LayerImpl::Create(host_impl_->active_tree(), 1); |
4671 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 4669 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
4672 root->SetForceRenderSurface(true); | 4670 root->SetForceRenderSurface(true); |
4673 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4671 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4674 host_impl_->SetViewportSize(surface_size); | 4672 host_impl_->SetViewportSize(surface_size); |
4675 SetNeedsRebuildPropertyTrees(); | 4673 SetNeedsRebuildPropertyTrees(); |
4676 DrawFrame(); | 4674 DrawFrame(); |
4677 | 4675 |
4678 // Scroll event is ignored because the input coordinate is outside the layer | 4676 // Scroll event is ignored because the input coordinate is outside the layer |
4679 // boundaries. | 4677 // boundaries. |
4680 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4678 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4681 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); | 4679 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); |
4682 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4680 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
4683 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4681 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
4684 status.main_thread_scrolling_reasons); | 4682 status.main_thread_scrolling_reasons); |
4685 | 4683 |
4686 EXPECT_FALSE(did_request_redraw_); | 4684 EXPECT_FALSE(did_request_redraw_); |
4687 EXPECT_FALSE(did_request_commit_); | 4685 EXPECT_FALSE(did_request_commit_); |
4688 } | 4686 } |
4689 | 4687 |
4690 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 4688 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
4691 gfx::Size surface_size(10, 10); | 4689 gfx::Size surface_size(10, 10); |
4692 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4690 std::unique_ptr<LayerImpl> root = |
| 4691 LayerImpl::Create(host_impl_->active_tree(), 1); |
4693 root->SetForceRenderSurface(true); | 4692 root->SetForceRenderSurface(true); |
4694 scoped_ptr<LayerImpl> child = | 4693 std::unique_ptr<LayerImpl> child = |
4695 CreateScrollableLayer(2, surface_size, root.get()); | 4694 CreateScrollableLayer(2, surface_size, root.get()); |
4696 host_impl_->SetViewportSize(surface_size); | 4695 host_impl_->SetViewportSize(surface_size); |
4697 | 4696 |
4698 gfx::Transform matrix; | 4697 gfx::Transform matrix; |
4699 matrix.RotateAboutXAxis(180.0); | 4698 matrix.RotateAboutXAxis(180.0); |
4700 child->SetTransform(matrix); | 4699 child->SetTransform(matrix); |
4701 child->SetDoubleSided(false); | 4700 child->SetDoubleSided(false); |
4702 | 4701 |
4703 root->AddChild(std::move(child)); | 4702 root->AddChild(std::move(child)); |
4704 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4703 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4705 SetNeedsRebuildPropertyTrees(); | 4704 SetNeedsRebuildPropertyTrees(); |
4706 DrawFrame(); | 4705 DrawFrame(); |
4707 | 4706 |
4708 // Scroll event is ignored because the scrollable layer is not facing the | 4707 // Scroll event is ignored because the scrollable layer is not facing the |
4709 // viewer and there is nothing scrollable behind it. | 4708 // viewer and there is nothing scrollable behind it. |
4710 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4709 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4711 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); | 4710 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); |
4712 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4711 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
4713 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4712 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
4714 status.main_thread_scrolling_reasons); | 4713 status.main_thread_scrolling_reasons); |
4715 | 4714 |
4716 EXPECT_FALSE(did_request_redraw_); | 4715 EXPECT_FALSE(did_request_redraw_); |
4717 EXPECT_FALSE(did_request_commit_); | 4716 EXPECT_FALSE(did_request_commit_); |
4718 } | 4717 } |
4719 | 4718 |
4720 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { | 4719 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { |
4721 gfx::Size surface_size(10, 10); | 4720 gfx::Size surface_size(10, 10); |
4722 scoped_ptr<LayerImpl> clip_layer = | 4721 std::unique_ptr<LayerImpl> clip_layer = |
4723 LayerImpl::Create(host_impl_->active_tree(), 3); | 4722 LayerImpl::Create(host_impl_->active_tree(), 3); |
4724 scoped_ptr<LayerImpl> content_layer = | 4723 std::unique_ptr<LayerImpl> content_layer = |
4725 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 4724 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
4726 content_layer->set_main_thread_scrolling_reasons( | 4725 content_layer->set_main_thread_scrolling_reasons( |
4727 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 4726 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
4728 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 4727 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
4729 | 4728 |
4730 // Note: we can use the same clip layer for both since both calls to | 4729 // Note: we can use the same clip layer for both since both calls to |
4731 // CreateScrollableLayer() use the same surface size. | 4730 // CreateScrollableLayer() use the same surface size. |
4732 scoped_ptr<LayerImpl> scroll_layer = | 4731 std::unique_ptr<LayerImpl> scroll_layer = |
4733 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 4732 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
4734 scroll_layer->AddChild(std::move(content_layer)); | 4733 scroll_layer->AddChild(std::move(content_layer)); |
4735 clip_layer->AddChild(std::move(scroll_layer)); | 4734 clip_layer->AddChild(std::move(scroll_layer)); |
4736 clip_layer->SetForceRenderSurface(true); | 4735 clip_layer->SetForceRenderSurface(true); |
4737 | 4736 |
4738 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); | 4737 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); |
4739 host_impl_->SetViewportSize(surface_size); | 4738 host_impl_->SetViewportSize(surface_size); |
4740 SetNeedsRebuildPropertyTrees(); | 4739 SetNeedsRebuildPropertyTrees(); |
4741 DrawFrame(); | 4740 DrawFrame(); |
4742 | 4741 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4775 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4774 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4776 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4775 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
4777 InputHandler::WHEEL) | 4776 InputHandler::WHEEL) |
4778 .thread); | 4777 .thread); |
4779 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4778 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
4780 host_impl_->ScrollEnd(EndState().get()); | 4779 host_impl_->ScrollEnd(EndState().get()); |
4781 | 4780 |
4782 // Set new page scale from main thread. | 4781 // Set new page scale from main thread. |
4783 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); | 4782 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); |
4784 | 4783 |
4785 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 4784 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 4785 host_impl_->ProcessScrollDeltas(); |
4786 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 4786 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
4787 expected_scroll_delta)); | 4787 expected_scroll_delta)); |
4788 | 4788 |
4789 // The scroll range should also have been updated. | 4789 // The scroll range should also have been updated. |
4790 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); | 4790 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); |
4791 | 4791 |
4792 // The page scale delta remains constant because the impl thread did not | 4792 // The page scale delta remains constant because the impl thread did not |
4793 // scale. | 4793 // scale. |
4794 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); | 4794 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); |
4795 } | 4795 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4827 // Set new page scale on impl thread by pinching. | 4827 // Set new page scale on impl thread by pinching. |
4828 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4828 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
4829 InputHandler::TOUCHSCREEN); | 4829 InputHandler::TOUCHSCREEN); |
4830 host_impl_->PinchGestureBegin(); | 4830 host_impl_->PinchGestureBegin(); |
4831 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); | 4831 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); |
4832 host_impl_->PinchGestureEnd(); | 4832 host_impl_->PinchGestureEnd(); |
4833 host_impl_->ScrollEnd(EndState().get()); | 4833 host_impl_->ScrollEnd(EndState().get()); |
4834 DrawOneFrame(); | 4834 DrawOneFrame(); |
4835 | 4835 |
4836 // The scroll delta is not scaled because the main thread did not scale. | 4836 // The scroll delta is not scaled because the main thread did not scale. |
4837 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 4837 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 4838 host_impl_->ProcessScrollDeltas(); |
4838 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 4839 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
4839 expected_scroll_delta)); | 4840 expected_scroll_delta)); |
4840 | 4841 |
4841 // The scroll range should also have been updated. | 4842 // The scroll range should also have been updated. |
4842 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); | 4843 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); |
4843 | 4844 |
4844 // The page scale delta should match the new scale on the impl side. | 4845 // The page scale delta should match the new scale on the impl side. |
4845 EXPECT_EQ(page_scale, host_impl_->active_tree()->current_page_scale_factor()); | 4846 EXPECT_EQ(page_scale, host_impl_->active_tree()->current_page_scale_factor()); |
4846 } | 4847 } |
4847 | 4848 |
4848 TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) { | 4849 TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) { |
4849 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 4850 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
4850 gfx::Size surface_size(10, 10); | 4851 gfx::Size surface_size(10, 10); |
4851 float default_page_scale = 1.f; | 4852 float default_page_scale = 1.f; |
4852 gfx::Transform default_page_scale_matrix; | 4853 gfx::Transform default_page_scale_matrix; |
4853 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); | 4854 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); |
4854 | 4855 |
4855 float new_page_scale = 2.f; | 4856 float new_page_scale = 2.f; |
4856 gfx::Transform new_page_scale_matrix; | 4857 gfx::Transform new_page_scale_matrix; |
4857 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); | 4858 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); |
4858 | 4859 |
4859 // Create a normal scrollable root layer and another scrollable child layer. | 4860 // Create a normal scrollable root layer and another scrollable child layer. |
4860 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); | 4861 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); |
4861 scroll->SetDrawsContent(true); | 4862 scroll->SetDrawsContent(true); |
4862 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4863 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
4863 LayerImpl* child = scroll->children()[0]; | 4864 LayerImpl* child = scroll->children()[0]; |
4864 child->SetDrawsContent(true); | 4865 child->SetDrawsContent(true); |
4865 | 4866 |
4866 scoped_ptr<LayerImpl> scrollable_child_clip = | 4867 std::unique_ptr<LayerImpl> scrollable_child_clip = |
4867 LayerImpl::Create(host_impl_->active_tree(), 6); | 4868 LayerImpl::Create(host_impl_->active_tree(), 6); |
4868 scoped_ptr<LayerImpl> scrollable_child = | 4869 std::unique_ptr<LayerImpl> scrollable_child = |
4869 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 4870 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
4870 scrollable_child_clip->AddChild(std::move(scrollable_child)); | 4871 scrollable_child_clip->AddChild(std::move(scrollable_child)); |
4871 child->AddChild(std::move(scrollable_child_clip)); | 4872 child->AddChild(std::move(scrollable_child_clip)); |
4872 LayerImpl* grand_child = child->children()[0]; | 4873 LayerImpl* grand_child = child->children()[0]; |
4873 grand_child->SetDrawsContent(true); | 4874 grand_child->SetDrawsContent(true); |
4874 | 4875 |
4875 // Set new page scale on impl thread by pinching. | 4876 // Set new page scale on impl thread by pinching. |
4876 SetNeedsRebuildPropertyTrees(); | 4877 SetNeedsRebuildPropertyTrees(); |
4877 RebuildPropertyTrees(); | 4878 RebuildPropertyTrees(); |
4878 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4879 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4922 .thread); | 4923 .thread); |
4923 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4924 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
4924 host_impl_->ScrollEnd(EndState().get()); | 4925 host_impl_->ScrollEnd(EndState().get()); |
4925 | 4926 |
4926 float page_scale = 2.f; | 4927 float page_scale = 2.f; |
4927 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, | 4928 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, |
4928 page_scale); | 4929 page_scale); |
4929 | 4930 |
4930 DrawOneFrame(); | 4931 DrawOneFrame(); |
4931 | 4932 |
4932 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 4933 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 4934 host_impl_->ProcessScrollDeltas(); |
4933 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 4935 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
4934 expected_scroll_delta)); | 4936 expected_scroll_delta)); |
4935 | 4937 |
4936 // The scroll range should not have changed. | 4938 // The scroll range should not have changed. |
4937 EXPECT_EQ(outer_scroll->MaxScrollOffset(), expected_max_scroll); | 4939 EXPECT_EQ(outer_scroll->MaxScrollOffset(), expected_max_scroll); |
4938 | 4940 |
4939 // The page scale delta remains constant because the impl thread did not | 4941 // The page scale delta remains constant because the impl thread did not |
4940 // scale. | 4942 // scale. |
4941 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); | 4943 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); |
4942 } | 4944 } |
4943 | 4945 |
4944 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 4946 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
4945 // Scroll a child layer beyond its maximum scroll range and make sure the | 4947 // Scroll a child layer beyond its maximum scroll range and make sure the |
4946 // parent layer isn't scrolled. | 4948 // parent layer isn't scrolled. |
4947 gfx::Size surface_size(10, 10); | 4949 gfx::Size surface_size(10, 10); |
4948 gfx::Size content_size(20, 20); | 4950 gfx::Size content_size(20, 20); |
4949 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4951 std::unique_ptr<LayerImpl> root = |
| 4952 LayerImpl::Create(host_impl_->active_tree(), 1); |
4950 root->SetBounds(surface_size); | 4953 root->SetBounds(surface_size); |
4951 root->SetForceRenderSurface(true); | 4954 root->SetForceRenderSurface(true); |
4952 scoped_ptr<LayerImpl> grand_child = | 4955 std::unique_ptr<LayerImpl> grand_child = |
4953 CreateScrollableLayer(3, content_size, root.get()); | 4956 CreateScrollableLayer(3, content_size, root.get()); |
4954 | 4957 |
4955 scoped_ptr<LayerImpl> child = | 4958 std::unique_ptr<LayerImpl> child = |
4956 CreateScrollableLayer(2, content_size, root.get()); | 4959 CreateScrollableLayer(2, content_size, root.get()); |
4957 LayerImpl* grand_child_layer = grand_child.get(); | 4960 LayerImpl* grand_child_layer = grand_child.get(); |
4958 child->AddChild(std::move(grand_child)); | 4961 child->AddChild(std::move(grand_child)); |
4959 | 4962 |
4960 LayerImpl* child_layer = child.get(); | 4963 LayerImpl* child_layer = child.get(); |
4961 root->AddChild(std::move(child)); | 4964 root->AddChild(std::move(child)); |
4962 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4965 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4963 host_impl_->active_tree()->DidBecomeActive(); | 4966 host_impl_->active_tree()->DidBecomeActive(); |
4964 host_impl_->SetViewportSize(surface_size); | 4967 host_impl_->SetViewportSize(surface_size); |
4965 grand_child_layer->layer_tree_impl() | 4968 grand_child_layer->layer_tree_impl() |
4966 ->property_trees() | 4969 ->property_trees() |
4967 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 4970 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
4968 gfx::ScrollOffset(0, 5)); | 4971 gfx::ScrollOffset(0, 5)); |
4969 child_layer->layer_tree_impl() | 4972 child_layer->layer_tree_impl() |
4970 ->property_trees() | 4973 ->property_trees() |
4971 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 4974 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
4972 gfx::ScrollOffset(3, 0)); | 4975 gfx::ScrollOffset(3, 0)); |
4973 | 4976 |
4974 SetNeedsRebuildPropertyTrees(); | 4977 SetNeedsRebuildPropertyTrees(); |
4975 DrawFrame(); | 4978 DrawFrame(); |
4976 { | 4979 { |
4977 gfx::Vector2d scroll_delta(-8, -7); | 4980 gfx::Vector2d scroll_delta(-8, -7); |
4978 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4981 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4979 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4982 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
4980 InputHandler::WHEEL) | 4983 InputHandler::WHEEL) |
4981 .thread); | 4984 .thread); |
4982 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4985 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
4983 host_impl_->ScrollEnd(EndState().get()); | 4986 host_impl_->ScrollEnd(EndState().get()); |
4984 | 4987 |
4985 scoped_ptr<ScrollAndScaleSet> scroll_info = | 4988 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
4986 host_impl_->ProcessScrollDeltas(); | 4989 host_impl_->ProcessScrollDeltas(); |
4987 | 4990 |
4988 // The grand child should have scrolled up to its limit. | 4991 // The grand child should have scrolled up to its limit. |
4989 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; | 4992 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; |
4990 LayerImpl* grand_child = child->children()[0]; | 4993 LayerImpl* grand_child = child->children()[0]; |
4991 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 4994 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
4992 gfx::Vector2d(0, -5))); | 4995 gfx::Vector2d(0, -5))); |
4993 | 4996 |
4994 // The child should not have scrolled. | 4997 // The child should not have scrolled. |
4995 ExpectNone(*scroll_info.get(), child->id()); | 4998 ExpectNone(*scroll_info.get(), child->id()); |
4996 } | 4999 } |
4997 } | 5000 } |
4998 | 5001 |
4999 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 5002 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
5000 // Scroll a child layer beyond its maximum scroll range and make sure the | 5003 // Scroll a child layer beyond its maximum scroll range and make sure the |
5001 // the scroll doesn't bubble up to the parent layer. | 5004 // the scroll doesn't bubble up to the parent layer. |
5002 gfx::Size surface_size(20, 20); | 5005 gfx::Size surface_size(20, 20); |
5003 gfx::Size viewport_size(10, 10); | 5006 gfx::Size viewport_size(10, 10); |
5004 scoped_ptr<LayerImpl> root_ptr = | 5007 std::unique_ptr<LayerImpl> root_ptr = |
5005 LayerImpl::Create(host_impl_->active_tree(), 1); | 5008 LayerImpl::Create(host_impl_->active_tree(), 1); |
5006 scoped_ptr<LayerImpl> root_clip = | 5009 std::unique_ptr<LayerImpl> root_clip = |
5007 LayerImpl::Create(host_impl_->active_tree(), 2); | 5010 LayerImpl::Create(host_impl_->active_tree(), 2); |
5008 root_clip->SetForceRenderSurface(true); | 5011 root_clip->SetForceRenderSurface(true); |
5009 scoped_ptr<LayerImpl> root_scrolling = | 5012 std::unique_ptr<LayerImpl> root_scrolling = |
5010 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5013 CreateScrollableLayer(3, surface_size, root_clip.get()); |
5011 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 5014 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
5012 | 5015 |
5013 scoped_ptr<LayerImpl> grand_child = | 5016 std::unique_ptr<LayerImpl> grand_child = |
5014 CreateScrollableLayer(5, surface_size, root_clip.get()); | 5017 CreateScrollableLayer(5, surface_size, root_clip.get()); |
5015 | 5018 |
5016 scoped_ptr<LayerImpl> child = | 5019 std::unique_ptr<LayerImpl> child = |
5017 CreateScrollableLayer(4, surface_size, root_clip.get()); | 5020 CreateScrollableLayer(4, surface_size, root_clip.get()); |
5018 LayerImpl* grand_child_layer = grand_child.get(); | 5021 LayerImpl* grand_child_layer = grand_child.get(); |
5019 child->AddChild(std::move(grand_child)); | 5022 child->AddChild(std::move(grand_child)); |
5020 | 5023 |
5021 LayerImpl* child_layer = child.get(); | 5024 LayerImpl* child_layer = child.get(); |
5022 root_scrolling->AddChild(std::move(child)); | 5025 root_scrolling->AddChild(std::move(child)); |
5023 root_clip->AddChild(std::move(root_scrolling)); | 5026 root_clip->AddChild(std::move(root_scrolling)); |
5024 EXPECT_EQ(viewport_size, root_clip->bounds()); | 5027 EXPECT_EQ(viewport_size, root_clip->bounds()); |
5025 root_ptr->AddChild(std::move(root_clip)); | 5028 root_ptr->AddChild(std::move(root_clip)); |
5026 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5029 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); |
(...skipping 15 matching lines...) Expand all Loading... |
5042 DrawFrame(); | 5045 DrawFrame(); |
5043 { | 5046 { |
5044 gfx::Vector2d scroll_delta(0, -10); | 5047 gfx::Vector2d scroll_delta(0, -10); |
5045 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5048 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5046 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5049 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5047 InputHandler::NON_BUBBLING_GESTURE) | 5050 InputHandler::NON_BUBBLING_GESTURE) |
5048 .thread); | 5051 .thread); |
5049 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5052 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5050 host_impl_->ScrollEnd(EndState().get()); | 5053 host_impl_->ScrollEnd(EndState().get()); |
5051 | 5054 |
5052 scoped_ptr<ScrollAndScaleSet> scroll_info = | 5055 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5053 host_impl_->ProcessScrollDeltas(); | 5056 host_impl_->ProcessScrollDeltas(); |
5054 | 5057 |
5055 // The grand child should have scrolled up to its limit. | 5058 // The grand child should have scrolled up to its limit. |
5056 LayerImpl* child = host_impl_->active_tree() | 5059 LayerImpl* child = host_impl_->active_tree() |
5057 ->root_layer() | 5060 ->root_layer() |
5058 ->children()[0] | 5061 ->children()[0] |
5059 ->children()[0] | 5062 ->children()[0] |
5060 ->children()[0]; | 5063 ->children()[0]; |
5061 LayerImpl* grand_child = child->children()[0]; | 5064 LayerImpl* grand_child = child->children()[0]; |
5062 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5065 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5126 // Should have scrolled by half the amount in layer space (5 - 2/2) | 5129 // Should have scrolled by half the amount in layer space (5 - 2/2) |
5127 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5130 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
5128 gfx::Vector2d(0, 4))); | 5131 gfx::Vector2d(0, 4))); |
5129 } | 5132 } |
5130 } | 5133 } |
5131 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 5134 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
5132 // When we try to scroll a non-scrollable child layer, the scroll delta | 5135 // When we try to scroll a non-scrollable child layer, the scroll delta |
5133 // should be applied to one of its ancestors if possible. | 5136 // should be applied to one of its ancestors if possible. |
5134 gfx::Size surface_size(10, 10); | 5137 gfx::Size surface_size(10, 10); |
5135 gfx::Size content_size(20, 20); | 5138 gfx::Size content_size(20, 20); |
5136 scoped_ptr<LayerImpl> root_ptr = | 5139 std::unique_ptr<LayerImpl> root_ptr = |
5137 LayerImpl::Create(host_impl_->active_tree(), 4); | 5140 LayerImpl::Create(host_impl_->active_tree(), 4); |
5138 scoped_ptr<LayerImpl> root_clip = | 5141 std::unique_ptr<LayerImpl> root_clip = |
5139 LayerImpl::Create(host_impl_->active_tree(), 3); | 5142 LayerImpl::Create(host_impl_->active_tree(), 3); |
5140 root_clip->SetForceRenderSurface(true); | 5143 root_clip->SetForceRenderSurface(true); |
5141 scoped_ptr<LayerImpl> root_scroll = | 5144 std::unique_ptr<LayerImpl> root_scroll = |
5142 CreateScrollableLayer(1, content_size, root_clip.get()); | 5145 CreateScrollableLayer(1, content_size, root_clip.get()); |
5143 // Make 'root' the clip layer for child: since they have the same sizes the | 5146 // Make 'root' the clip layer for child: since they have the same sizes the |
5144 // child will have zero max_scroll_offset and scrolls will bubble. | 5147 // child will have zero max_scroll_offset and scrolls will bubble. |
5145 scoped_ptr<LayerImpl> child = | 5148 std::unique_ptr<LayerImpl> child = |
5146 CreateScrollableLayer(2, content_size, root_scroll.get()); | 5149 CreateScrollableLayer(2, content_size, root_scroll.get()); |
5147 child->SetIsContainerForFixedPositionLayers(true); | 5150 child->SetIsContainerForFixedPositionLayers(true); |
5148 root_scroll->SetBounds(content_size); | 5151 root_scroll->SetBounds(content_size); |
5149 | 5152 |
5150 int root_scroll_id = root_scroll->id(); | 5153 int root_scroll_id = root_scroll->id(); |
5151 root_scroll->AddChild(std::move(child)); | 5154 root_scroll->AddChild(std::move(child)); |
5152 root_clip->AddChild(std::move(root_scroll)); | 5155 root_clip->AddChild(std::move(root_scroll)); |
5153 root_ptr->AddChild(std::move(root_clip)); | 5156 root_ptr->AddChild(std::move(root_clip)); |
5154 | 5157 |
5155 host_impl_->SetViewportSize(surface_size); | 5158 host_impl_->SetViewportSize(surface_size); |
5156 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5159 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); |
5157 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, | 5160 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, |
5158 Layer::INVALID_ID); | 5161 Layer::INVALID_ID); |
5159 host_impl_->active_tree()->DidBecomeActive(); | 5162 host_impl_->active_tree()->DidBecomeActive(); |
5160 SetNeedsRebuildPropertyTrees(); | 5163 SetNeedsRebuildPropertyTrees(); |
5161 DrawFrame(); | 5164 DrawFrame(); |
5162 { | 5165 { |
5163 gfx::Vector2d scroll_delta(0, 4); | 5166 gfx::Vector2d scroll_delta(0, 4); |
5164 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5167 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5165 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5168 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5166 InputHandler::WHEEL) | 5169 InputHandler::WHEEL) |
5167 .thread); | 5170 .thread); |
5168 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5171 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5169 host_impl_->ScrollEnd(EndState().get()); | 5172 host_impl_->ScrollEnd(EndState().get()); |
5170 | 5173 |
5171 scoped_ptr<ScrollAndScaleSet> scroll_info = | 5174 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5172 host_impl_->ProcessScrollDeltas(); | 5175 host_impl_->ProcessScrollDeltas(); |
5173 | 5176 |
5174 // Only the root scroll should have scrolled. | 5177 // Only the root scroll should have scrolled. |
5175 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 5178 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
5176 EXPECT_TRUE( | 5179 EXPECT_TRUE( |
5177 ScrollInfoContains(*scroll_info.get(), root_scroll_id, scroll_delta)); | 5180 ScrollInfoContains(*scroll_info.get(), root_scroll_id, scroll_delta)); |
5178 } | 5181 } |
5179 } | 5182 } |
5180 | 5183 |
5181 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 5184 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
5182 gfx::Size surface_size(10, 10); | 5185 gfx::Size surface_size(10, 10); |
5183 scoped_ptr<LayerImpl> root_ptr = | 5186 std::unique_ptr<LayerImpl> root_ptr = |
5184 LayerImpl::Create(host_impl_->active_tree(), 1); | 5187 LayerImpl::Create(host_impl_->active_tree(), 1); |
5185 scoped_ptr<LayerImpl> root_clip = | 5188 std::unique_ptr<LayerImpl> root_clip = |
5186 LayerImpl::Create(host_impl_->active_tree(), 2); | 5189 LayerImpl::Create(host_impl_->active_tree(), 2); |
5187 scoped_ptr<LayerImpl> root_scroll = | 5190 std::unique_ptr<LayerImpl> root_scroll = |
5188 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5191 CreateScrollableLayer(3, surface_size, root_clip.get()); |
5189 root_scroll->SetIsContainerForFixedPositionLayers(true); | 5192 root_scroll->SetIsContainerForFixedPositionLayers(true); |
5190 root_clip->SetForceRenderSurface(true); | 5193 root_clip->SetForceRenderSurface(true); |
5191 root_clip->AddChild(std::move(root_scroll)); | 5194 root_clip->AddChild(std::move(root_scroll)); |
5192 root_ptr->AddChild(std::move(root_clip)); | 5195 root_ptr->AddChild(std::move(root_clip)); |
5193 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5196 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); |
5194 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5197 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
5195 Layer::INVALID_ID); | 5198 Layer::INVALID_ID); |
5196 host_impl_->active_tree()->DidBecomeActive(); | 5199 host_impl_->active_tree()->DidBecomeActive(); |
5197 host_impl_->SetViewportSize(surface_size); | 5200 host_impl_->SetViewportSize(surface_size); |
5198 | 5201 |
5199 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 5202 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
5200 // synchronization. | 5203 // synchronization. |
5201 SetNeedsRebuildPropertyTrees(); | 5204 SetNeedsRebuildPropertyTrees(); |
5202 DrawFrame(); | 5205 DrawFrame(); |
5203 host_impl_->active_tree()->ClearLayers(); | 5206 host_impl_->active_tree()->ClearLayers(); |
5204 scoped_ptr<LayerImpl> root_ptr2 = | 5207 std::unique_ptr<LayerImpl> root_ptr2 = |
5205 LayerImpl::Create(host_impl_->active_tree(), 4); | 5208 LayerImpl::Create(host_impl_->active_tree(), 4); |
5206 scoped_ptr<LayerImpl> root_clip2 = | 5209 std::unique_ptr<LayerImpl> root_clip2 = |
5207 LayerImpl::Create(host_impl_->active_tree(), 5); | 5210 LayerImpl::Create(host_impl_->active_tree(), 5); |
5208 scoped_ptr<LayerImpl> root_scroll2 = | 5211 std::unique_ptr<LayerImpl> root_scroll2 = |
5209 CreateScrollableLayer(6, surface_size, root_clip2.get()); | 5212 CreateScrollableLayer(6, surface_size, root_clip2.get()); |
5210 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 5213 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
5211 root_clip2->AddChild(std::move(root_scroll2)); | 5214 root_clip2->AddChild(std::move(root_scroll2)); |
5212 root_clip2->SetForceRenderSurface(true); | 5215 root_clip2->SetForceRenderSurface(true); |
5213 root_ptr2->AddChild(std::move(root_clip2)); | 5216 root_ptr2->AddChild(std::move(root_clip2)); |
5214 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr2)); | 5217 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr2)); |
5215 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, | 5218 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, |
5216 Layer::INVALID_ID); | 5219 Layer::INVALID_ID); |
5217 host_impl_->active_tree()->DidBecomeActive(); | 5220 host_impl_->active_tree()->DidBecomeActive(); |
5218 | 5221 |
(...skipping 24 matching lines...) Expand all Loading... |
5243 gfx::Vector2d gesture_scroll_delta(10, 0); | 5246 gfx::Vector2d gesture_scroll_delta(10, 0); |
5244 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5247 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5245 host_impl_ | 5248 host_impl_ |
5246 ->ScrollBegin(BeginState(gfx::Point()).get(), | 5249 ->ScrollBegin(BeginState(gfx::Point()).get(), |
5247 InputHandler::TOUCHSCREEN) | 5250 InputHandler::TOUCHSCREEN) |
5248 .thread); | 5251 .thread); |
5249 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5252 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
5250 host_impl_->ScrollEnd(EndState().get()); | 5253 host_impl_->ScrollEnd(EndState().get()); |
5251 | 5254 |
5252 // The layer should have scrolled down in its local coordinates. | 5255 // The layer should have scrolled down in its local coordinates. |
5253 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 5256 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5257 host_impl_->ProcessScrollDeltas(); |
5254 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5258 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
5255 gfx::Vector2d(0, gesture_scroll_delta.x()))); | 5259 gfx::Vector2d(0, gesture_scroll_delta.x()))); |
5256 | 5260 |
5257 // Reset and scroll down with the wheel. | 5261 // Reset and scroll down with the wheel. |
5258 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); | 5262 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); |
5259 gfx::Vector2d wheel_scroll_delta(0, 10); | 5263 gfx::Vector2d wheel_scroll_delta(0, 10); |
5260 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5264 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5261 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5265 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5262 InputHandler::WHEEL) | 5266 InputHandler::WHEEL) |
5263 .thread); | 5267 .thread); |
5264 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); | 5268 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); |
5265 host_impl_->ScrollEnd(EndState().get()); | 5269 host_impl_->ScrollEnd(EndState().get()); |
5266 | 5270 |
5267 // The layer should have scrolled down in its local coordinates. | 5271 // The layer should have scrolled down in its local coordinates. |
5268 scroll_info = host_impl_->ProcessScrollDeltas(); | 5272 scroll_info = host_impl_->ProcessScrollDeltas(); |
5269 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5273 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
5270 wheel_scroll_delta)); | 5274 wheel_scroll_delta)); |
5271 } | 5275 } |
5272 | 5276 |
5273 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { | 5277 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { |
5274 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5278 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5275 int child_clip_layer_id = 6; | 5279 int child_clip_layer_id = 6; |
5276 int child_layer_id = 7; | 5280 int child_layer_id = 7; |
5277 float child_layer_angle = -20.f; | 5281 float child_layer_angle = -20.f; |
5278 | 5282 |
5279 // Create a child layer that is rotated to a non-axis-aligned angle. | 5283 // Create a child layer that is rotated to a non-axis-aligned angle. |
5280 scoped_ptr<LayerImpl> clip_layer = | 5284 std::unique_ptr<LayerImpl> clip_layer = |
5281 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); | 5285 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); |
5282 scoped_ptr<LayerImpl> child = CreateScrollableLayer( | 5286 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( |
5283 child_layer_id, scroll_layer->bounds(), clip_layer.get()); | 5287 child_layer_id, scroll_layer->bounds(), clip_layer.get()); |
5284 gfx::Transform rotate_transform; | 5288 gfx::Transform rotate_transform; |
5285 rotate_transform.Translate(-50.0, -50.0); | 5289 rotate_transform.Translate(-50.0, -50.0); |
5286 rotate_transform.Rotate(child_layer_angle); | 5290 rotate_transform.Rotate(child_layer_angle); |
5287 rotate_transform.Translate(50.0, 50.0); | 5291 rotate_transform.Translate(50.0, 50.0); |
5288 clip_layer->SetTransform(rotate_transform); | 5292 clip_layer->SetTransform(rotate_transform); |
5289 | 5293 |
5290 // Only allow vertical scrolling. | 5294 // Only allow vertical scrolling. |
5291 clip_layer->SetBounds( | 5295 clip_layer->SetBounds( |
5292 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); | 5296 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); |
(...skipping 19 matching lines...) Expand all Loading... |
5312 InputHandler::TOUCHSCREEN) | 5316 InputHandler::TOUCHSCREEN) |
5313 .thread); | 5317 .thread); |
5314 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5318 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
5315 host_impl_->ScrollEnd(EndState().get()); | 5319 host_impl_->ScrollEnd(EndState().get()); |
5316 | 5320 |
5317 // The child layer should have scrolled down in its local coordinates an | 5321 // The child layer should have scrolled down in its local coordinates an |
5318 // amount proportional to the angle between it and the input scroll delta. | 5322 // amount proportional to the angle between it and the input scroll delta. |
5319 gfx::Vector2d expected_scroll_delta( | 5323 gfx::Vector2d expected_scroll_delta( |
5320 0, gesture_scroll_delta.y() * | 5324 0, gesture_scroll_delta.y() * |
5321 std::cos(MathUtil::Deg2Rad(child_layer_angle))); | 5325 std::cos(MathUtil::Deg2Rad(child_layer_angle))); |
5322 scoped_ptr<ScrollAndScaleSet> scroll_info = | 5326 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5323 host_impl_->ProcessScrollDeltas(); | 5327 host_impl_->ProcessScrollDeltas(); |
5324 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, | 5328 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, |
5325 expected_scroll_delta)); | 5329 expected_scroll_delta)); |
5326 | 5330 |
5327 // The root scroll layer should not have scrolled, because the input delta | 5331 // The root scroll layer should not have scrolled, because the input delta |
5328 // was close to the layer's axis of movement. | 5332 // was close to the layer's axis of movement. |
5329 EXPECT_EQ(scroll_info->scrolls.size(), 1u); | 5333 EXPECT_EQ(scroll_info->scrolls.size(), 1u); |
5330 } | 5334 } |
5331 { | 5335 { |
5332 // Now reset and scroll the same amount horizontally. | 5336 // Now reset and scroll the same amount horizontally. |
5333 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF()); | 5337 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF()); |
5334 gfx::Vector2d gesture_scroll_delta(10, 0); | 5338 gfx::Vector2d gesture_scroll_delta(10, 0); |
5335 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5339 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5336 host_impl_ | 5340 host_impl_ |
5337 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), | 5341 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), |
5338 InputHandler::TOUCHSCREEN) | 5342 InputHandler::TOUCHSCREEN) |
5339 .thread); | 5343 .thread); |
5340 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5344 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
5341 host_impl_->ScrollEnd(EndState().get()); | 5345 host_impl_->ScrollEnd(EndState().get()); |
5342 | 5346 |
5343 // The child layer shouldn't have scrolled. | 5347 // The child layer shouldn't have scrolled. |
5344 gfx::Vector2d expected_scroll_delta( | 5348 gfx::Vector2d expected_scroll_delta( |
5345 0, -gesture_scroll_delta.x() * | 5349 0, -gesture_scroll_delta.x() * |
5346 std::sin(MathUtil::Deg2Rad(child_layer_angle))); | 5350 std::sin(MathUtil::Deg2Rad(child_layer_angle))); |
5347 scoped_ptr<ScrollAndScaleSet> scroll_info = | 5351 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5348 host_impl_->ProcessScrollDeltas(); | 5352 host_impl_->ProcessScrollDeltas(); |
5349 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, | 5353 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, |
5350 expected_scroll_delta)); | 5354 expected_scroll_delta)); |
5351 | 5355 |
5352 // The root scroll layer shouldn't have scrolled. | 5356 // The root scroll layer shouldn't have scrolled. |
5353 ExpectNone(*scroll_info.get(), scroll_layer->id()); | 5357 ExpectNone(*scroll_info.get(), scroll_layer->id()); |
5354 } | 5358 } |
5355 } | 5359 } |
5356 | 5360 |
5357 TEST_F(LayerTreeHostImplTest, ScrollPerspectiveTransformedLayer) { | 5361 TEST_F(LayerTreeHostImplTest, ScrollPerspectiveTransformedLayer) { |
5358 // When scrolling an element with perspective, the distance scrolled | 5362 // When scrolling an element with perspective, the distance scrolled |
5359 // depends on the point at which the scroll begins. | 5363 // depends on the point at which the scroll begins. |
5360 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5364 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5361 int child_clip_layer_id = 6; | 5365 int child_clip_layer_id = 6; |
5362 int child_layer_id = 7; | 5366 int child_layer_id = 7; |
5363 | 5367 |
5364 // Create a child layer that is rotated on its x axis, with perspective. | 5368 // Create a child layer that is rotated on its x axis, with perspective. |
5365 scoped_ptr<LayerImpl> clip_layer = | 5369 std::unique_ptr<LayerImpl> clip_layer = |
5366 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); | 5370 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); |
5367 scoped_ptr<LayerImpl> child = CreateScrollableLayer( | 5371 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( |
5368 child_layer_id, scroll_layer->bounds(), clip_layer.get()); | 5372 child_layer_id, scroll_layer->bounds(), clip_layer.get()); |
5369 LayerImpl* child_ptr = child.get(); | 5373 LayerImpl* child_ptr = child.get(); |
5370 gfx::Transform perspective_transform; | 5374 gfx::Transform perspective_transform; |
5371 perspective_transform.Translate(-50.0, -50.0); | 5375 perspective_transform.Translate(-50.0, -50.0); |
5372 perspective_transform.ApplyPerspectiveDepth(20); | 5376 perspective_transform.ApplyPerspectiveDepth(20); |
5373 perspective_transform.RotateAboutXAxis(45); | 5377 perspective_transform.RotateAboutXAxis(45); |
5374 perspective_transform.Translate(50.0, 50.0); | 5378 perspective_transform.Translate(50.0, 50.0); |
5375 clip_layer->SetTransform(perspective_transform); | 5379 clip_layer->SetTransform(perspective_transform); |
5376 | 5380 |
5377 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, | 5381 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, |
5378 child_ptr->bounds().height() / 2)); | 5382 child_ptr->bounds().height() / 2)); |
5379 // The transform depends on the layer's transform origin, and the child layer | 5383 // The transform depends on the layer's transform origin, and the child layer |
5380 // is a different size than the clip, so make sure the clip layer's origin | 5384 // is a different size than the clip, so make sure the clip layer's origin |
5381 // lines up over the child. | 5385 // lines up over the child. |
5382 clip_layer->SetTransformOrigin(gfx::Point3F( | 5386 clip_layer->SetTransformOrigin(gfx::Point3F( |
5383 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f)); | 5387 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f)); |
5384 clip_layer->AddChild(std::move(child)); | 5388 clip_layer->AddChild(std::move(child)); |
5385 scroll_layer->AddChild(std::move(clip_layer)); | 5389 scroll_layer->AddChild(std::move(clip_layer)); |
5386 | 5390 |
5387 gfx::Size surface_size(50, 50); | 5391 gfx::Size surface_size(50, 50); |
5388 host_impl_->SetViewportSize(surface_size); | 5392 host_impl_->SetViewportSize(surface_size); |
5389 | 5393 |
5390 scoped_ptr<ScrollAndScaleSet> scroll_info; | 5394 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
5391 | 5395 |
5392 gfx::Vector2d gesture_scroll_deltas[4]; | 5396 gfx::Vector2d gesture_scroll_deltas[4]; |
5393 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10); | 5397 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10); |
5394 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10); | 5398 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10); |
5395 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0); | 5399 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0); |
5396 gesture_scroll_deltas[3] = gfx::Vector2d(10, 0); | 5400 gesture_scroll_deltas[3] = gfx::Vector2d(10, 0); |
5397 | 5401 |
5398 gfx::Vector2d expected_scroll_deltas[4]; | 5402 gfx::Vector2d expected_scroll_deltas[4]; |
5399 // Perspective affects the vertical delta by a different | 5403 // Perspective affects the vertical delta by a different |
5400 // amount depending on the vertical position of the |viewport_point|. | 5404 // amount depending on the vertical position of the |viewport_point|. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5454 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5458 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5455 host_impl_ | 5459 host_impl_ |
5456 ->ScrollBegin(BeginState(gfx::Point()).get(), | 5460 ->ScrollBegin(BeginState(gfx::Point()).get(), |
5457 InputHandler::TOUCHSCREEN) | 5461 InputHandler::TOUCHSCREEN) |
5458 .thread); | 5462 .thread); |
5459 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5463 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5460 host_impl_->ScrollEnd(EndState().get()); | 5464 host_impl_->ScrollEnd(EndState().get()); |
5461 | 5465 |
5462 // The layer should have scrolled down in its local coordinates, but half the | 5466 // The layer should have scrolled down in its local coordinates, but half the |
5463 // amount. | 5467 // amount. |
5464 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 5468 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5469 host_impl_->ProcessScrollDeltas(); |
5465 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5470 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
5466 gfx::Vector2d(0, scroll_delta.y() / scale))); | 5471 gfx::Vector2d(0, scroll_delta.y() / scale))); |
5467 | 5472 |
5468 // Reset and scroll down with the wheel. | 5473 // Reset and scroll down with the wheel. |
5469 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); | 5474 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); |
5470 gfx::Vector2d wheel_scroll_delta(0, 10); | 5475 gfx::Vector2d wheel_scroll_delta(0, 10); |
5471 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5476 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5472 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5477 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5473 InputHandler::WHEEL) | 5478 InputHandler::WHEEL) |
5474 .thread); | 5479 .thread); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5825 | 5830 |
5826 host_impl_->ScrollEnd(EndState().get()); | 5831 host_impl_->ScrollEnd(EndState().get()); |
5827 } | 5832 } |
5828 | 5833 |
5829 | 5834 |
5830 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 5835 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
5831 // Scroll child layers beyond their maximum scroll range and make sure root | 5836 // Scroll child layers beyond their maximum scroll range and make sure root |
5832 // overscroll does not accumulate. | 5837 // overscroll does not accumulate. |
5833 InputHandlerScrollResult scroll_result; | 5838 InputHandlerScrollResult scroll_result; |
5834 gfx::Size surface_size(10, 10); | 5839 gfx::Size surface_size(10, 10); |
5835 scoped_ptr<LayerImpl> root_clip = | 5840 std::unique_ptr<LayerImpl> root_clip = |
5836 LayerImpl::Create(host_impl_->active_tree(), 4); | 5841 LayerImpl::Create(host_impl_->active_tree(), 4); |
5837 root_clip->SetForceRenderSurface(true); | 5842 root_clip->SetForceRenderSurface(true); |
5838 | 5843 |
5839 scoped_ptr<LayerImpl> root = | 5844 std::unique_ptr<LayerImpl> root = |
5840 CreateScrollableLayer(1, surface_size, root_clip.get()); | 5845 CreateScrollableLayer(1, surface_size, root_clip.get()); |
5841 | 5846 |
5842 scoped_ptr<LayerImpl> grand_child = | 5847 std::unique_ptr<LayerImpl> grand_child = |
5843 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5848 CreateScrollableLayer(3, surface_size, root_clip.get()); |
5844 | 5849 |
5845 scoped_ptr<LayerImpl> child = | 5850 std::unique_ptr<LayerImpl> child = |
5846 CreateScrollableLayer(2, surface_size, root_clip.get()); | 5851 CreateScrollableLayer(2, surface_size, root_clip.get()); |
5847 LayerImpl* grand_child_layer = grand_child.get(); | 5852 LayerImpl* grand_child_layer = grand_child.get(); |
5848 child->AddChild(std::move(grand_child)); | 5853 child->AddChild(std::move(grand_child)); |
5849 | 5854 |
5850 LayerImpl* child_layer = child.get(); | 5855 LayerImpl* child_layer = child.get(); |
5851 root->AddChild(std::move(child)); | 5856 root->AddChild(std::move(child)); |
5852 root_clip->AddChild(std::move(root)); | 5857 root_clip->AddChild(std::move(root)); |
5853 child_layer->layer_tree_impl() | 5858 child_layer->layer_tree_impl() |
5854 ->property_trees() | 5859 ->property_trees() |
5855 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5860 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6029 EXPECT_FALSE(scroll_result.did_scroll); | 6034 EXPECT_FALSE(scroll_result.did_scroll); |
6030 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6035 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6031 EXPECT_EQ(gfx::Vector2dF().ToString(), | 6036 EXPECT_EQ(gfx::Vector2dF().ToString(), |
6032 host_impl_->accumulated_root_overscroll().ToString()); | 6037 host_impl_->accumulated_root_overscroll().ToString()); |
6033 host_impl_->ScrollEnd(EndState().get()); | 6038 host_impl_->ScrollEnd(EndState().get()); |
6034 } | 6039 } |
6035 } | 6040 } |
6036 | 6041 |
6037 class BlendStateCheckLayer : public LayerImpl { | 6042 class BlendStateCheckLayer : public LayerImpl { |
6038 public: | 6043 public: |
6039 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, | 6044 static std::unique_ptr<LayerImpl> Create( |
6040 int id, | 6045 LayerTreeImpl* tree_impl, |
6041 ResourceProvider* resource_provider) { | 6046 int id, |
6042 return make_scoped_ptr( | 6047 ResourceProvider* resource_provider) { |
| 6048 return base::WrapUnique( |
6043 new BlendStateCheckLayer(tree_impl, id, resource_provider)); | 6049 new BlendStateCheckLayer(tree_impl, id, resource_provider)); |
6044 } | 6050 } |
6045 | 6051 |
6046 void AppendQuads(RenderPass* render_pass, | 6052 void AppendQuads(RenderPass* render_pass, |
6047 AppendQuadsData* append_quads_data) override { | 6053 AppendQuadsData* append_quads_data) override { |
6048 quads_appended_ = true; | 6054 quads_appended_ = true; |
6049 | 6055 |
6050 gfx::Rect opaque_rect; | 6056 gfx::Rect opaque_rect; |
6051 if (contents_opaque()) | 6057 if (contents_opaque()) |
6052 opaque_rect = quad_rect_; | 6058 opaque_rect = quad_rect_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6111 bool has_render_surface_; | 6117 bool has_render_surface_; |
6112 bool quads_appended_; | 6118 bool quads_appended_; |
6113 gfx::Rect quad_rect_; | 6119 gfx::Rect quad_rect_; |
6114 gfx::Rect opaque_content_rect_; | 6120 gfx::Rect opaque_content_rect_; |
6115 gfx::Rect quad_visible_rect_; | 6121 gfx::Rect quad_visible_rect_; |
6116 ResourceId resource_id_; | 6122 ResourceId resource_id_; |
6117 }; | 6123 }; |
6118 | 6124 |
6119 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 6125 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
6120 { | 6126 { |
6121 scoped_ptr<LayerImpl> root = | 6127 std::unique_ptr<LayerImpl> root = |
6122 LayerImpl::Create(host_impl_->active_tree(), 1); | 6128 LayerImpl::Create(host_impl_->active_tree(), 1); |
6123 root->SetBounds(gfx::Size(10, 10)); | 6129 root->SetBounds(gfx::Size(10, 10)); |
6124 root->SetDrawsContent(false); | 6130 root->SetDrawsContent(false); |
6125 root->SetForceRenderSurface(true); | 6131 root->SetForceRenderSurface(true); |
6126 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6132 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
6127 } | 6133 } |
6128 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 6134 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
6129 | 6135 |
6130 root->AddChild( | 6136 root->AddChild( |
6131 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 6137 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6369 host_impl_->DidDrawAllLayers(frame); | 6375 host_impl_->DidDrawAllLayers(frame); |
6370 } | 6376 } |
6371 | 6377 |
6372 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 6378 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
6373 protected: | 6379 protected: |
6374 LayerTreeHostImplViewportCoveredTest() : | 6380 LayerTreeHostImplViewportCoveredTest() : |
6375 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 6381 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
6376 child_(NULL), | 6382 child_(NULL), |
6377 did_activate_pending_tree_(false) {} | 6383 did_activate_pending_tree_(false) {} |
6378 | 6384 |
6379 scoped_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { | 6385 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { |
6380 if (software) { | 6386 if (software) { |
6381 return FakeOutputSurface::CreateSoftware( | 6387 return FakeOutputSurface::CreateSoftware( |
6382 make_scoped_ptr(new SoftwareOutputDevice())); | 6388 base::WrapUnique(new SoftwareOutputDevice())); |
6383 } | 6389 } |
6384 return FakeOutputSurface::Create3d(); | 6390 return FakeOutputSurface::Create3d(); |
6385 } | 6391 } |
6386 | 6392 |
6387 void SetupActiveTreeLayers() { | 6393 void SetupActiveTreeLayers() { |
6388 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 6394 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
6389 host_impl_->active_tree()->SetRootLayer( | 6395 host_impl_->active_tree()->SetRootLayer( |
6390 LayerImpl::Create(host_impl_->active_tree(), 1)); | 6396 LayerImpl::Create(host_impl_->active_tree(), 1)); |
6391 host_impl_->active_tree()->root_layer()->SetForceRenderSurface(true); | 6397 host_impl_->active_tree()->root_layer()->SetForceRenderSurface(true); |
6392 host_impl_->active_tree()->root_layer()->AddChild( | 6398 host_impl_->active_tree()->root_layer()->AddChild( |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6663 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); | 6669 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); |
6664 | 6670 |
6665 SetupActiveTreeLayers(); | 6671 SetupActiveTreeLayers(); |
6666 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); | 6672 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); |
6667 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); | 6673 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); |
6668 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); | 6674 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); |
6669 } | 6675 } |
6670 | 6676 |
6671 class FakeDrawableLayerImpl: public LayerImpl { | 6677 class FakeDrawableLayerImpl: public LayerImpl { |
6672 public: | 6678 public: |
6673 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 6679 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
6674 return make_scoped_ptr(new FakeDrawableLayerImpl(tree_impl, id)); | 6680 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); |
6675 } | 6681 } |
6676 protected: | 6682 protected: |
6677 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) | 6683 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) |
6678 : LayerImpl(tree_impl, id) {} | 6684 : LayerImpl(tree_impl, id) {} |
6679 }; | 6685 }; |
6680 | 6686 |
6681 // Only reshape when we know we are going to draw. Otherwise, the reshape | 6687 // Only reshape when we know we are going to draw. Otherwise, the reshape |
6682 // can leave the window at the wrong size if we never draw and the proper | 6688 // can leave the window at the wrong size if we never draw and the proper |
6683 // viewport size is never set. | 6689 // viewport size is never set. |
6684 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { | 6690 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { |
6685 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 6691 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
6686 scoped_ptr<OutputSurface> output_surface( | 6692 std::unique_ptr<OutputSurface> output_surface( |
6687 FakeOutputSurface::Create3d(provider)); | 6693 FakeOutputSurface::Create3d(provider)); |
6688 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 6694 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
6689 | 6695 |
6690 scoped_ptr<LayerImpl> root = | 6696 std::unique_ptr<LayerImpl> root = |
6691 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 6697 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
6692 root->SetBounds(gfx::Size(10, 10)); | 6698 root->SetBounds(gfx::Size(10, 10)); |
6693 root->SetDrawsContent(true); | 6699 root->SetDrawsContent(true); |
6694 root->SetForceRenderSurface(true); | 6700 root->SetForceRenderSurface(true); |
6695 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6701 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
6696 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 6702 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
6697 provider->TestContext3d()->clear_reshape_called(); | 6703 provider->TestContext3d()->clear_reshape_called(); |
6698 | 6704 |
6699 LayerTreeHostImpl::FrameData frame; | 6705 LayerTreeHostImpl::FrameData frame; |
6700 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 6706 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
(...skipping 29 matching lines...) Expand all Loading... |
6730 } | 6736 } |
6731 | 6737 |
6732 // Make sure damage tracking propagates all the way to the graphics context, | 6738 // Make sure damage tracking propagates all the way to the graphics context, |
6733 // where it should request to swap only the sub-buffer that is damaged. | 6739 // where it should request to swap only the sub-buffer that is damaged. |
6734 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { | 6740 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { |
6735 scoped_refptr<TestContextProvider> context_provider( | 6741 scoped_refptr<TestContextProvider> context_provider( |
6736 TestContextProvider::Create()); | 6742 TestContextProvider::Create()); |
6737 context_provider->BindToCurrentThread(); | 6743 context_provider->BindToCurrentThread(); |
6738 context_provider->TestContext3d()->set_have_post_sub_buffer(true); | 6744 context_provider->TestContext3d()->set_have_post_sub_buffer(true); |
6739 | 6745 |
6740 scoped_ptr<FakeOutputSurface> output_surface( | 6746 std::unique_ptr<FakeOutputSurface> output_surface( |
6741 FakeOutputSurface::Create3d(context_provider)); | 6747 FakeOutputSurface::Create3d(context_provider)); |
6742 FakeOutputSurface* fake_output_surface = output_surface.get(); | 6748 FakeOutputSurface* fake_output_surface = output_surface.get(); |
6743 | 6749 |
6744 // This test creates its own LayerTreeHostImpl, so | 6750 // This test creates its own LayerTreeHostImpl, so |
6745 // that we can force partial swap enabled. | 6751 // that we can force partial swap enabled. |
6746 LayerTreeSettings settings = DefaultSettings(); | 6752 LayerTreeSettings settings = DefaultSettings(); |
6747 settings.renderer_settings.partial_swap_enabled = true; | 6753 settings.renderer_settings.partial_swap_enabled = true; |
6748 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 6754 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
6749 LayerTreeHostImpl::Create( | 6755 LayerTreeHostImpl::Create( |
6750 settings, this, &task_runner_provider_, &stats_instrumentation_, | 6756 settings, this, &task_runner_provider_, &stats_instrumentation_, |
6751 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0); | 6757 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0); |
6752 layer_tree_host_impl->SetVisible(true); | 6758 layer_tree_host_impl->SetVisible(true); |
6753 layer_tree_host_impl->InitializeRenderer(output_surface.get()); | 6759 layer_tree_host_impl->InitializeRenderer(output_surface.get()); |
6754 layer_tree_host_impl->WillBeginImplFrame( | 6760 layer_tree_host_impl->WillBeginImplFrame( |
6755 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 6761 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
6756 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 6762 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
6757 | 6763 |
6758 scoped_ptr<LayerImpl> root = | 6764 std::unique_ptr<LayerImpl> root = |
6759 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 6765 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
6760 root->SetForceRenderSurface(true); | 6766 root->SetForceRenderSurface(true); |
6761 scoped_ptr<LayerImpl> child = | 6767 std::unique_ptr<LayerImpl> child = |
6762 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 6768 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
6763 child->SetPosition(gfx::PointF(12.f, 13.f)); | 6769 child->SetPosition(gfx::PointF(12.f, 13.f)); |
6764 child->SetBounds(gfx::Size(14, 15)); | 6770 child->SetBounds(gfx::Size(14, 15)); |
6765 child->SetDrawsContent(true); | 6771 child->SetDrawsContent(true); |
6766 root->SetBounds(gfx::Size(500, 500)); | 6772 root->SetBounds(gfx::Size(500, 500)); |
6767 root->SetDrawsContent(true); | 6773 root->SetDrawsContent(true); |
6768 root->AddChild(std::move(child)); | 6774 root->AddChild(std::move(child)); |
6769 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root)); | 6775 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root)); |
6770 | 6776 |
6771 LayerTreeHostImpl::FrameData frame; | 6777 LayerTreeHostImpl::FrameData frame; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6812 layer_tree_host_impl->DrawLayers(&frame); | 6818 layer_tree_host_impl->DrawLayers(&frame); |
6813 host_impl_->DidDrawAllLayers(frame); | 6819 host_impl_->DidDrawAllLayers(frame); |
6814 layer_tree_host_impl->SwapBuffers(frame); | 6820 layer_tree_host_impl->SwapBuffers(frame); |
6815 | 6821 |
6816 expected_swap_rect = gfx::Rect(0, 0, 10, 10); | 6822 expected_swap_rect = gfx::Rect(0, 0, 10, 10); |
6817 EXPECT_EQ(expected_swap_rect.ToString(), | 6823 EXPECT_EQ(expected_swap_rect.ToString(), |
6818 fake_output_surface->last_swap_rect().ToString()); | 6824 fake_output_surface->last_swap_rect().ToString()); |
6819 } | 6825 } |
6820 | 6826 |
6821 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 6827 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
6822 scoped_ptr<LayerImpl> root = | 6828 std::unique_ptr<LayerImpl> root = |
6823 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 6829 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
6824 scoped_ptr<LayerImpl> child = | 6830 std::unique_ptr<LayerImpl> child = |
6825 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 6831 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
6826 child->SetBounds(gfx::Size(10, 10)); | 6832 child->SetBounds(gfx::Size(10, 10)); |
6827 child->SetDrawsContent(true); | 6833 child->SetDrawsContent(true); |
6828 root->SetBounds(gfx::Size(10, 10)); | 6834 root->SetBounds(gfx::Size(10, 10)); |
6829 root->SetDrawsContent(true); | 6835 root->SetDrawsContent(true); |
6830 root->SetForceRenderSurface(true); | 6836 root->SetForceRenderSurface(true); |
6831 root->AddChild(std::move(child)); | 6837 root->AddChild(std::move(child)); |
6832 | 6838 |
6833 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6839 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
6834 | 6840 |
6835 LayerTreeHostImpl::FrameData frame; | 6841 LayerTreeHostImpl::FrameData frame; |
6836 | 6842 |
6837 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6843 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6838 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 6844 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
6839 EXPECT_EQ(1u, frame.render_passes.size()); | 6845 EXPECT_EQ(1u, frame.render_passes.size()); |
6840 host_impl_->DidDrawAllLayers(frame); | 6846 host_impl_->DidDrawAllLayers(frame); |
6841 } | 6847 } |
6842 | 6848 |
6843 class FakeLayerWithQuads : public LayerImpl { | 6849 class FakeLayerWithQuads : public LayerImpl { |
6844 public: | 6850 public: |
6845 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 6851 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
6846 return make_scoped_ptr(new FakeLayerWithQuads(tree_impl, id)); | 6852 return base::WrapUnique(new FakeLayerWithQuads(tree_impl, id)); |
6847 } | 6853 } |
6848 | 6854 |
6849 void AppendQuads(RenderPass* render_pass, | 6855 void AppendQuads(RenderPass* render_pass, |
6850 AppendQuadsData* append_quads_data) override { | 6856 AppendQuadsData* append_quads_data) override { |
6851 SharedQuadState* shared_quad_state = | 6857 SharedQuadState* shared_quad_state = |
6852 render_pass->CreateAndAppendSharedQuadState(); | 6858 render_pass->CreateAndAppendSharedQuadState(); |
6853 PopulateSharedQuadState(shared_quad_state); | 6859 PopulateSharedQuadState(shared_quad_state); |
6854 | 6860 |
6855 SkColor gray = SkColorSetRGB(100, 100, 100); | 6861 SkColor gray = SkColorSetRGB(100, 100, 100); |
6856 gfx::Rect quad_rect(bounds()); | 6862 gfx::Rect quad_rect(bounds()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6947 | 6953 |
6948 EXPECT_CALL(*context_, enable(GL_SCISSOR_TEST)) | 6954 EXPECT_CALL(*context_, enable(GL_SCISSOR_TEST)) |
6949 .Times(0); | 6955 .Times(0); |
6950 | 6956 |
6951 EXPECT_CALL(*context_, scissor(_, _, _, _)) | 6957 EXPECT_CALL(*context_, scissor(_, _, _, _)) |
6952 .Times(0); | 6958 .Times(0); |
6953 } | 6959 } |
6954 }; | 6960 }; |
6955 | 6961 |
6956 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { | 6962 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { |
6957 scoped_ptr<MockContext> mock_context_owned(new MockContext); | 6963 std::unique_ptr<MockContext> mock_context_owned(new MockContext); |
6958 MockContext* mock_context = mock_context_owned.get(); | 6964 MockContext* mock_context = mock_context_owned.get(); |
6959 MockContextHarness harness(mock_context); | 6965 MockContextHarness harness(mock_context); |
6960 | 6966 |
6961 // Run test case | 6967 // Run test case |
6962 LayerTreeSettings settings = DefaultSettings(); | 6968 LayerTreeSettings settings = DefaultSettings(); |
6963 settings.renderer_settings.partial_swap_enabled = false; | 6969 settings.renderer_settings.partial_swap_enabled = false; |
6964 CreateHostImpl(settings, | 6970 CreateHostImpl(settings, |
6965 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | 6971 FakeOutputSurface::Create3d(std::move(mock_context_owned))); |
6966 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 6972 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
6967 | 6973 |
(...skipping 19 matching lines...) Expand all Loading... |
6987 LayerTreeHostImpl::FrameData frame; | 6993 LayerTreeHostImpl::FrameData frame; |
6988 SetNeedsRebuildPropertyTrees(); | 6994 SetNeedsRebuildPropertyTrees(); |
6989 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6995 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6990 host_impl_->DrawLayers(&frame); | 6996 host_impl_->DrawLayers(&frame); |
6991 host_impl_->DidDrawAllLayers(frame); | 6997 host_impl_->DidDrawAllLayers(frame); |
6992 } | 6998 } |
6993 Mock::VerifyAndClearExpectations(&mock_context); | 6999 Mock::VerifyAndClearExpectations(&mock_context); |
6994 } | 7000 } |
6995 | 7001 |
6996 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 7002 TEST_F(LayerTreeHostImplTest, PartialSwap) { |
6997 scoped_ptr<MockContext> context_owned(new MockContext); | 7003 std::unique_ptr<MockContext> context_owned(new MockContext); |
6998 MockContext* mock_context = context_owned.get(); | 7004 MockContext* mock_context = context_owned.get(); |
6999 MockContextHarness harness(mock_context); | 7005 MockContextHarness harness(mock_context); |
7000 | 7006 |
7001 LayerTreeSettings settings = DefaultSettings(); | 7007 LayerTreeSettings settings = DefaultSettings(); |
7002 settings.renderer_settings.partial_swap_enabled = true; | 7008 settings.renderer_settings.partial_swap_enabled = true; |
7003 CreateHostImpl(settings, | 7009 CreateHostImpl(settings, |
7004 FakeOutputSurface::Create3d(std::move(context_owned))); | 7010 FakeOutputSurface::Create3d(std::move(context_owned))); |
7005 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 7011 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
7006 | 7012 |
7007 // The first frame is not a partially-swapped one. No scissor should be set. | 7013 // The first frame is not a partially-swapped one. No scissor should be set. |
(...skipping 16 matching lines...) Expand all Loading... |
7024 harness.MustDrawSolidQuad(); | 7030 harness.MustDrawSolidQuad(); |
7025 { | 7031 { |
7026 LayerTreeHostImpl::FrameData frame; | 7032 LayerTreeHostImpl::FrameData frame; |
7027 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7033 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7028 host_impl_->DrawLayers(&frame); | 7034 host_impl_->DrawLayers(&frame); |
7029 host_impl_->DidDrawAllLayers(frame); | 7035 host_impl_->DidDrawAllLayers(frame); |
7030 } | 7036 } |
7031 Mock::VerifyAndClearExpectations(&mock_context); | 7037 Mock::VerifyAndClearExpectations(&mock_context); |
7032 } | 7038 } |
7033 | 7039 |
7034 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 7040 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
7035 LayerTreeSettings settings, | 7041 LayerTreeSettings settings, |
7036 bool partial_swap, | 7042 bool partial_swap, |
7037 LayerTreeHostImplClient* client, | 7043 LayerTreeHostImplClient* client, |
7038 TaskRunnerProvider* task_runner_provider, | 7044 TaskRunnerProvider* task_runner_provider, |
7039 SharedBitmapManager* manager, | 7045 SharedBitmapManager* manager, |
7040 TaskGraphRunner* task_graph_runner, | 7046 TaskGraphRunner* task_graph_runner, |
7041 RenderingStatsInstrumentation* stats_instrumentation, | 7047 RenderingStatsInstrumentation* stats_instrumentation, |
7042 OutputSurface* output_surface) { | 7048 OutputSurface* output_surface) { |
7043 settings.renderer_settings.partial_swap_enabled = partial_swap; | 7049 settings.renderer_settings.partial_swap_enabled = partial_swap; |
7044 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 7050 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
7045 settings, client, task_runner_provider, stats_instrumentation, manager, | 7051 settings, client, task_runner_provider, stats_instrumentation, manager, |
7046 nullptr, task_graph_runner, 0); | 7052 nullptr, task_graph_runner, 0); |
7047 my_host_impl->SetVisible(true); | 7053 my_host_impl->SetVisible(true); |
7048 my_host_impl->InitializeRenderer(output_surface); | 7054 my_host_impl->InitializeRenderer(output_surface); |
7049 my_host_impl->WillBeginImplFrame( | 7055 my_host_impl->WillBeginImplFrame( |
7050 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7056 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
7051 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 7057 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
7052 | 7058 |
7053 /* | 7059 /* |
7054 Layers are created as follows: | 7060 Layers are created as follows: |
7055 | 7061 |
7056 +--------------------+ | 7062 +--------------------+ |
7057 | 1 | | 7063 | 1 | |
7058 | +-----------+ | | 7064 | +-----------+ | |
7059 | | 2 | | | 7065 | | 2 | | |
7060 | | +-------------------+ | 7066 | | +-------------------+ |
7061 | | | 3 | | 7067 | | | 3 | |
7062 | | +-------------------+ | 7068 | | +-------------------+ |
7063 | | | | | 7069 | | | | |
7064 | +-----------+ | | 7070 | +-----------+ | |
7065 | | | 7071 | | |
7066 | | | 7072 | | |
7067 +--------------------+ | 7073 +--------------------+ |
7068 | 7074 |
7069 Layers 1, 2 have render surfaces | 7075 Layers 1, 2 have render surfaces |
7070 */ | 7076 */ |
7071 scoped_ptr<LayerImpl> root = | 7077 std::unique_ptr<LayerImpl> root = |
7072 LayerImpl::Create(my_host_impl->active_tree(), 1); | 7078 LayerImpl::Create(my_host_impl->active_tree(), 1); |
7073 scoped_ptr<LayerImpl> child = | 7079 std::unique_ptr<LayerImpl> child = |
7074 LayerImpl::Create(my_host_impl->active_tree(), 2); | 7080 LayerImpl::Create(my_host_impl->active_tree(), 2); |
7075 scoped_ptr<LayerImpl> grand_child = | 7081 std::unique_ptr<LayerImpl> grand_child = |
7076 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 7082 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
7077 | 7083 |
7078 gfx::Rect root_rect(0, 0, 100, 100); | 7084 gfx::Rect root_rect(0, 0, 100, 100); |
7079 gfx::Rect child_rect(10, 10, 50, 50); | 7085 gfx::Rect child_rect(10, 10, 50, 50); |
7080 gfx::Rect grand_child_rect(5, 5, 150, 150); | 7086 gfx::Rect grand_child_rect(5, 5, 150, 150); |
7081 | 7087 |
7082 root->SetForceRenderSurface(true); | 7088 root->SetForceRenderSurface(true); |
7083 root->SetPosition(gfx::PointF(root_rect.origin())); | 7089 root->SetPosition(gfx::PointF(root_rect.origin())); |
7084 root->SetBounds(root_rect.size()); | 7090 root->SetBounds(root_rect.size()); |
7085 root->draw_properties().visible_layer_rect = root_rect; | 7091 root->draw_properties().visible_layer_rect = root_rect; |
(...skipping 18 matching lines...) Expand all Loading... |
7104 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 7110 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
7105 return my_host_impl; | 7111 return my_host_impl; |
7106 } | 7112 } |
7107 | 7113 |
7108 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 7114 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
7109 TestSharedBitmapManager shared_bitmap_manager; | 7115 TestSharedBitmapManager shared_bitmap_manager; |
7110 TestTaskGraphRunner task_graph_runner; | 7116 TestTaskGraphRunner task_graph_runner; |
7111 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7117 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
7112 provider->BindToCurrentThread(); | 7118 provider->BindToCurrentThread(); |
7113 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7119 provider->TestContext3d()->set_have_post_sub_buffer(true); |
7114 scoped_ptr<OutputSurface> output_surface( | 7120 std::unique_ptr<OutputSurface> output_surface( |
7115 FakeOutputSurface::Create3d(provider)); | 7121 FakeOutputSurface::Create3d(provider)); |
7116 scoped_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7122 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
7117 DefaultSettings(), true, this, &task_runner_provider_, | 7123 DefaultSettings(), true, this, &task_runner_provider_, |
7118 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7124 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, |
7119 output_surface.get()); | 7125 output_surface.get()); |
7120 { | 7126 { |
7121 LayerTreeHostImpl::FrameData frame; | 7127 LayerTreeHostImpl::FrameData frame; |
7122 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7128 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
7123 | 7129 |
7124 // Verify all quads have been computed | 7130 // Verify all quads have been computed |
7125 ASSERT_EQ(2U, frame.render_passes.size()); | 7131 ASSERT_EQ(2U, frame.render_passes.size()); |
7126 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 7132 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
7127 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 7133 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
7128 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 7134 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
7129 frame.render_passes[0]->quad_list.front()->material); | 7135 frame.render_passes[0]->quad_list.front()->material); |
7130 EXPECT_EQ(DrawQuad::RENDER_PASS, | 7136 EXPECT_EQ(DrawQuad::RENDER_PASS, |
7131 frame.render_passes[1]->quad_list.front()->material); | 7137 frame.render_passes[1]->quad_list.front()->material); |
7132 | 7138 |
7133 my_host_impl->DrawLayers(&frame); | 7139 my_host_impl->DrawLayers(&frame); |
7134 my_host_impl->DidDrawAllLayers(frame); | 7140 my_host_impl->DidDrawAllLayers(frame); |
7135 } | 7141 } |
7136 } | 7142 } |
7137 | 7143 |
7138 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 7144 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
7139 TestSharedBitmapManager shared_bitmap_manager; | 7145 TestSharedBitmapManager shared_bitmap_manager; |
7140 TestTaskGraphRunner task_graph_runner; | 7146 TestTaskGraphRunner task_graph_runner; |
7141 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7147 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
7142 provider->BindToCurrentThread(); | 7148 provider->BindToCurrentThread(); |
7143 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7149 provider->TestContext3d()->set_have_post_sub_buffer(true); |
7144 scoped_ptr<OutputSurface> output_surface( | 7150 std::unique_ptr<OutputSurface> output_surface( |
7145 FakeOutputSurface::Create3d(provider)); | 7151 FakeOutputSurface::Create3d(provider)); |
7146 scoped_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7152 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
7147 DefaultSettings(), false, this, &task_runner_provider_, | 7153 DefaultSettings(), false, this, &task_runner_provider_, |
7148 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7154 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, |
7149 output_surface.get()); | 7155 output_surface.get()); |
7150 { | 7156 { |
7151 LayerTreeHostImpl::FrameData frame; | 7157 LayerTreeHostImpl::FrameData frame; |
7152 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7158 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
7153 | 7159 |
7154 // Verify all quads have been computed | 7160 // Verify all quads have been computed |
7155 ASSERT_EQ(2U, frame.render_passes.size()); | 7161 ASSERT_EQ(2U, frame.render_passes.size()); |
7156 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 7162 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
7157 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 7163 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
7158 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 7164 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
7159 frame.render_passes[0]->quad_list.front()->material); | 7165 frame.render_passes[0]->quad_list.front()->material); |
7160 EXPECT_EQ(DrawQuad::RENDER_PASS, | 7166 EXPECT_EQ(DrawQuad::RENDER_PASS, |
7161 frame.render_passes[1]->quad_list.front()->material); | 7167 frame.render_passes[1]->quad_list.front()->material); |
7162 | 7168 |
7163 my_host_impl->DrawLayers(&frame); | 7169 my_host_impl->DrawLayers(&frame); |
7164 my_host_impl->DidDrawAllLayers(frame); | 7170 my_host_impl->DidDrawAllLayers(frame); |
7165 } | 7171 } |
7166 } | 7172 } |
7167 | 7173 |
7168 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { | 7174 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
7169 scoped_ptr<TestWebGraphicsContext3D> context = | 7175 std::unique_ptr<TestWebGraphicsContext3D> context = |
7170 TestWebGraphicsContext3D::Create(); | 7176 TestWebGraphicsContext3D::Create(); |
7171 TestWebGraphicsContext3D* context3d = context.get(); | 7177 TestWebGraphicsContext3D* context3d = context.get(); |
7172 scoped_ptr<OutputSurface> output_surface( | 7178 std::unique_ptr<OutputSurface> output_surface( |
7173 FakeOutputSurface::Create3d(std::move(context))); | 7179 FakeOutputSurface::Create3d(std::move(context))); |
7174 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 7180 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
7175 | 7181 |
7176 scoped_ptr<LayerImpl> root_layer = | 7182 std::unique_ptr<LayerImpl> root_layer = |
7177 LayerImpl::Create(host_impl_->active_tree(), 1); | 7183 LayerImpl::Create(host_impl_->active_tree(), 1); |
7178 root_layer->SetBounds(gfx::Size(10, 10)); | 7184 root_layer->SetBounds(gfx::Size(10, 10)); |
7179 root_layer->SetForceRenderSurface(true); | 7185 root_layer->SetForceRenderSurface(true); |
7180 | 7186 |
7181 scoped_refptr<VideoFrame> softwareFrame = | 7187 scoped_refptr<VideoFrame> softwareFrame = |
7182 media::VideoFrame::CreateColorFrame( | 7188 media::VideoFrame::CreateColorFrame( |
7183 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 7189 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
7184 FakeVideoFrameProvider provider; | 7190 FakeVideoFrameProvider provider; |
7185 provider.set_frame(softwareFrame); | 7191 provider.set_frame(softwareFrame); |
7186 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7192 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
7187 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 7193 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
7188 video_layer->SetBounds(gfx::Size(10, 10)); | 7194 video_layer->SetBounds(gfx::Size(10, 10)); |
7189 video_layer->SetDrawsContent(true); | 7195 video_layer->SetDrawsContent(true); |
7190 root_layer->AddChild(std::move(video_layer)); | 7196 root_layer->AddChild(std::move(video_layer)); |
7191 | 7197 |
7192 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = | 7198 std::unique_ptr<IOSurfaceLayerImpl> io_surface_layer = |
7193 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); | 7199 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); |
7194 io_surface_layer->SetBounds(gfx::Size(10, 10)); | 7200 io_surface_layer->SetBounds(gfx::Size(10, 10)); |
7195 io_surface_layer->SetDrawsContent(true); | 7201 io_surface_layer->SetDrawsContent(true); |
7196 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); | 7202 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); |
7197 root_layer->AddChild(std::move(io_surface_layer)); | 7203 root_layer->AddChild(std::move(io_surface_layer)); |
7198 | 7204 |
7199 host_impl_->active_tree()->SetRootLayer(std::move(root_layer)); | 7205 host_impl_->active_tree()->SetRootLayer(std::move(root_layer)); |
7200 | 7206 |
7201 EXPECT_EQ(0u, context3d->NumTextures()); | 7207 EXPECT_EQ(0u, context3d->NumTextures()); |
7202 | 7208 |
(...skipping 15 matching lines...) Expand all Loading... |
7218 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { | 7224 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { |
7219 public: | 7225 public: |
7220 MOCK_METHOD1(useProgram, void(GLuint program)); | 7226 MOCK_METHOD1(useProgram, void(GLuint program)); |
7221 MOCK_METHOD4(drawElements, void(GLenum mode, | 7227 MOCK_METHOD4(drawElements, void(GLenum mode, |
7222 GLsizei count, | 7228 GLsizei count, |
7223 GLenum type, | 7229 GLenum type, |
7224 GLintptr offset)); | 7230 GLintptr offset)); |
7225 }; | 7231 }; |
7226 | 7232 |
7227 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { | 7233 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { |
7228 scoped_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( | 7234 std::unique_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( |
7229 new MockDrawQuadsToFillScreenContext); | 7235 new MockDrawQuadsToFillScreenContext); |
7230 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); | 7236 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); |
7231 | 7237 |
7232 // Run test case | 7238 // Run test case |
7233 LayerTreeSettings settings = DefaultSettings(); | 7239 LayerTreeSettings settings = DefaultSettings(); |
7234 settings.renderer_settings.partial_swap_enabled = false; | 7240 settings.renderer_settings.partial_swap_enabled = false; |
7235 CreateHostImpl(settings, | 7241 CreateHostImpl(settings, |
7236 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | 7242 FakeOutputSurface::Create3d(std::move(mock_context_owned))); |
7237 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7243 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
7238 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 7244 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
(...skipping 15 matching lines...) Expand all Loading... |
7254 host_impl_->SetFullRootLayerDamage(); | 7260 host_impl_->SetFullRootLayerDamage(); |
7255 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7261 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7256 host_impl_->DrawLayers(&frame); | 7262 host_impl_->DrawLayers(&frame); |
7257 host_impl_->DidDrawAllLayers(frame); | 7263 host_impl_->DidDrawAllLayers(frame); |
7258 Mock::VerifyAndClearExpectations(&mock_context); | 7264 Mock::VerifyAndClearExpectations(&mock_context); |
7259 } | 7265 } |
7260 | 7266 |
7261 class LayerTreeHostImplTestWithDelegatingRenderer | 7267 class LayerTreeHostImplTestWithDelegatingRenderer |
7262 : public LayerTreeHostImplTest { | 7268 : public LayerTreeHostImplTest { |
7263 protected: | 7269 protected: |
7264 scoped_ptr<OutputSurface> CreateOutputSurface() override { | 7270 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
7265 return FakeOutputSurface::CreateDelegating3d(); | 7271 return FakeOutputSurface::CreateDelegating3d(); |
7266 } | 7272 } |
7267 | 7273 |
7268 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { | 7274 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { |
7269 bool expect_to_draw = !expected_damage.IsEmpty(); | 7275 bool expect_to_draw = !expected_damage.IsEmpty(); |
7270 | 7276 |
7271 LayerTreeHostImpl::FrameData frame; | 7277 LayerTreeHostImpl::FrameData frame; |
7272 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7278 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7273 | 7279 |
7274 if (!expect_to_draw) { | 7280 if (!expect_to_draw) { |
(...skipping 21 matching lines...) Expand all Loading... |
7296 root_render_pass->quad_list.ElementAt(1)->visible_rect); | 7302 root_render_pass->quad_list.ElementAt(1)->visible_rect); |
7297 } | 7303 } |
7298 | 7304 |
7299 host_impl_->DrawLayers(&frame); | 7305 host_impl_->DrawLayers(&frame); |
7300 host_impl_->DidDrawAllLayers(frame); | 7306 host_impl_->DidDrawAllLayers(frame); |
7301 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); | 7307 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); |
7302 } | 7308 } |
7303 }; | 7309 }; |
7304 | 7310 |
7305 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 7311 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
7306 scoped_ptr<SolidColorLayerImpl> root = | 7312 std::unique_ptr<SolidColorLayerImpl> root = |
7307 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7313 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
7308 root->SetPosition(gfx::PointF()); | 7314 root->SetPosition(gfx::PointF()); |
7309 root->SetBounds(gfx::Size(10, 10)); | 7315 root->SetBounds(gfx::Size(10, 10)); |
7310 root->SetDrawsContent(true); | 7316 root->SetDrawsContent(true); |
7311 root->SetForceRenderSurface(true); | 7317 root->SetForceRenderSurface(true); |
7312 | 7318 |
7313 // Child layer is in the bottom right corner. | 7319 // Child layer is in the bottom right corner. |
7314 scoped_ptr<SolidColorLayerImpl> child = | 7320 std::unique_ptr<SolidColorLayerImpl> child = |
7315 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 7321 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
7316 child->SetPosition(gfx::PointF(9.f, 9.f)); | 7322 child->SetPosition(gfx::PointF(9.f, 9.f)); |
7317 child->SetBounds(gfx::Size(1, 1)); | 7323 child->SetBounds(gfx::Size(1, 1)); |
7318 child->SetDrawsContent(true); | 7324 child->SetDrawsContent(true); |
7319 root->AddChild(std::move(child)); | 7325 root->AddChild(std::move(child)); |
7320 | 7326 |
7321 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 7327 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
7322 | 7328 |
7323 // Draw a frame. In the first frame, the entire viewport should be damaged. | 7329 // Draw a frame. In the first frame, the entire viewport should be damaged. |
7324 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 7330 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
(...skipping 30 matching lines...) Expand all Loading... |
7355 gfx::Size root_size(2000, 1000); | 7361 gfx::Size root_size(2000, 1000); |
7356 gfx::Size device_viewport_size = | 7362 gfx::Size device_viewport_size = |
7357 gfx::ScaleToCeiledSize(root_size, device_scale_factor); | 7363 gfx::ScaleToCeiledSize(root_size, device_scale_factor); |
7358 host_impl_->SetViewportSize(device_viewport_size); | 7364 host_impl_->SetViewportSize(device_viewport_size); |
7359 | 7365 |
7360 host_impl_->CreatePendingTree(); | 7366 host_impl_->CreatePendingTree(); |
7361 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); | 7367 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); |
7362 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, | 7368 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, |
7363 16.f); | 7369 16.f); |
7364 | 7370 |
7365 scoped_ptr<LayerImpl> scoped_root = | 7371 std::unique_ptr<LayerImpl> scoped_root = |
7366 LayerImpl::Create(host_impl_->pending_tree(), 1); | 7372 LayerImpl::Create(host_impl_->pending_tree(), 1); |
7367 LayerImpl* root = scoped_root.get(); | 7373 LayerImpl* root = scoped_root.get(); |
7368 root->SetForceRenderSurface(true); | 7374 root->SetForceRenderSurface(true); |
7369 | 7375 |
7370 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); | 7376 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); |
7371 | 7377 |
7372 scoped_ptr<LayerImpl> scoped_scrolling_layer = | 7378 std::unique_ptr<LayerImpl> scoped_scrolling_layer = |
7373 LayerImpl::Create(host_impl_->pending_tree(), 2); | 7379 LayerImpl::Create(host_impl_->pending_tree(), 2); |
7374 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 7380 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
7375 root->AddChild(std::move(scoped_scrolling_layer)); | 7381 root->AddChild(std::move(scoped_scrolling_layer)); |
7376 | 7382 |
7377 gfx::Size content_layer_bounds(100000, 100); | 7383 gfx::Size content_layer_bounds(100000, 100); |
7378 scoped_refptr<FakeRasterSource> raster_source( | 7384 scoped_refptr<FakeRasterSource> raster_source( |
7379 FakeRasterSource::CreateFilled(content_layer_bounds)); | 7385 FakeRasterSource::CreateFilled(content_layer_bounds)); |
7380 | 7386 |
7381 scoped_ptr<FakePictureLayerImpl> scoped_content_layer = | 7387 std::unique_ptr<FakePictureLayerImpl> scoped_content_layer = |
7382 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), | 7388 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
7383 3, raster_source); | 7389 3, raster_source); |
7384 LayerImpl* content_layer = scoped_content_layer.get(); | 7390 LayerImpl* content_layer = scoped_content_layer.get(); |
7385 scrolling_layer->AddChild(std::move(scoped_content_layer)); | 7391 scrolling_layer->AddChild(std::move(scoped_content_layer)); |
7386 content_layer->SetBounds(content_layer_bounds); | 7392 content_layer->SetBounds(content_layer_bounds); |
7387 content_layer->SetDrawsContent(true); | 7393 content_layer->SetDrawsContent(true); |
7388 | 7394 |
7389 root->SetBounds(root_size); | 7395 root->SetBounds(root_size); |
7390 | 7396 |
7391 gfx::ScrollOffset scroll_offset(100000, 0); | 7397 gfx::ScrollOffset scroll_offset(100000, 0); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7466 | 7472 |
7467 int frames_began_, frames_ended_; | 7473 int frames_began_, frames_ended_; |
7468 }; | 7474 }; |
7469 | 7475 |
7470 TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) { | 7476 TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) { |
7471 // No main thread evictions in resourceless software mode. | 7477 // No main thread evictions in resourceless software mode. |
7472 set_reduce_memory_result(false); | 7478 set_reduce_memory_result(false); |
7473 CountingSoftwareDevice* software_device = new CountingSoftwareDevice(); | 7479 CountingSoftwareDevice* software_device = new CountingSoftwareDevice(); |
7474 EXPECT_TRUE(CreateHostImpl( | 7480 EXPECT_TRUE(CreateHostImpl( |
7475 DefaultSettings(), | 7481 DefaultSettings(), |
7476 FakeOutputSurface::CreateSoftware(make_scoped_ptr(software_device)))); | 7482 FakeOutputSurface::CreateSoftware(base::WrapUnique(software_device)))); |
7477 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 7483 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
7478 | 7484 |
7479 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 7485 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
7480 | 7486 |
7481 const gfx::Transform external_transform; | 7487 const gfx::Transform external_transform; |
7482 const gfx::Rect external_viewport; | 7488 const gfx::Rect external_viewport; |
7483 const gfx::Rect external_clip; | 7489 const gfx::Rect external_clip; |
7484 const bool resourceless_software_draw = true; | 7490 const bool resourceless_software_draw = true; |
7485 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 7491 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
7486 external_transform); | 7492 external_transform); |
7487 | 7493 |
7488 EXPECT_EQ(0, software_device->frames_began_); | 7494 EXPECT_EQ(0, software_device->frames_began_); |
7489 EXPECT_EQ(0, software_device->frames_ended_); | 7495 EXPECT_EQ(0, software_device->frames_ended_); |
7490 | 7496 |
7491 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 7497 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
7492 resourceless_software_draw); | 7498 resourceless_software_draw); |
7493 | 7499 |
7494 EXPECT_EQ(1, software_device->frames_began_); | 7500 EXPECT_EQ(1, software_device->frames_began_); |
7495 EXPECT_EQ(1, software_device->frames_ended_); | 7501 EXPECT_EQ(1, software_device->frames_ended_); |
7496 | 7502 |
7497 // Call another API method that is likely to hit nullptr in this mode. | 7503 // Call another API method that is likely to hit nullptr in this mode. |
7498 scoped_ptr<base::trace_event::TracedValue> state( | 7504 std::unique_ptr<base::trace_event::TracedValue> state( |
7499 new base::trace_event::TracedValue()); | 7505 new base::trace_event::TracedValue()); |
7500 host_impl_->ActivationStateAsValueInto(state.get()); | 7506 host_impl_->ActivationStateAsValueInto(state.get()); |
7501 } | 7507 } |
7502 | 7508 |
7503 TEST_F(LayerTreeHostImplTest, | 7509 TEST_F(LayerTreeHostImplTest, |
7504 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { | 7510 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { |
7505 set_reduce_memory_result(false); | 7511 set_reduce_memory_result(false); |
7506 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), | 7512 EXPECT_TRUE(CreateHostImpl( |
7507 FakeOutputSurface::CreateSoftware( | 7513 DefaultSettings(), FakeOutputSurface::CreateSoftware( |
7508 make_scoped_ptr(new CountingSoftwareDevice)))); | 7514 base::WrapUnique(new CountingSoftwareDevice)))); |
7509 | 7515 |
7510 const gfx::Transform external_transform; | 7516 const gfx::Transform external_transform; |
7511 const gfx::Rect external_viewport; | 7517 const gfx::Rect external_viewport; |
7512 const gfx::Rect external_clip; | 7518 const gfx::Rect external_clip; |
7513 const bool resourceless_software_draw = true; | 7519 const bool resourceless_software_draw = true; |
7514 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 7520 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
7515 external_transform); | 7521 external_transform); |
7516 | 7522 |
7517 // SolidColorLayerImpl will be drawn. | 7523 // SolidColorLayerImpl will be drawn. |
7518 scoped_ptr<SolidColorLayerImpl> root_layer = | 7524 std::unique_ptr<SolidColorLayerImpl> root_layer = |
7519 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7525 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
7520 | 7526 |
7521 // VideoLayerImpl will not be drawn. | 7527 // VideoLayerImpl will not be drawn. |
7522 FakeVideoFrameProvider provider; | 7528 FakeVideoFrameProvider provider; |
7523 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7529 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
7524 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); | 7530 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); |
7525 video_layer->SetBounds(gfx::Size(10, 10)); | 7531 video_layer->SetBounds(gfx::Size(10, 10)); |
7526 video_layer->SetDrawsContent(true); | 7532 video_layer->SetDrawsContent(true); |
7527 root_layer->AddChild(std::move(video_layer)); | 7533 root_layer->AddChild(std::move(video_layer)); |
7528 SetupRootLayerImpl(std::move(root_layer)); | 7534 SetupRootLayerImpl(std::move(root_layer)); |
7529 | 7535 |
7530 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 7536 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
7531 resourceless_software_draw); | 7537 resourceless_software_draw); |
7532 | 7538 |
7533 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); | 7539 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7619 | 7625 |
7620 TEST_F(LayerTreeHostImplTestPrepareTiles, PrepareTilesWhenInvisible) { | 7626 TEST_F(LayerTreeHostImplTestPrepareTiles, PrepareTilesWhenInvisible) { |
7621 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); | 7627 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); |
7622 host_impl_->SetVisible(false); | 7628 host_impl_->SetVisible(false); |
7623 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); | 7629 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); |
7624 host_impl_->SetVisible(true); | 7630 host_impl_->SetVisible(true); |
7625 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); | 7631 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); |
7626 } | 7632 } |
7627 | 7633 |
7628 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { | 7634 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
7629 scoped_ptr<TestWebGraphicsContext3D> context = | 7635 std::unique_ptr<TestWebGraphicsContext3D> context = |
7630 TestWebGraphicsContext3D::Create(); | 7636 TestWebGraphicsContext3D::Create(); |
7631 TestWebGraphicsContext3D* context3d = context.get(); | 7637 TestWebGraphicsContext3D* context3d = context.get(); |
7632 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); | 7638 std::unique_ptr<FakeOutputSurface> output_surface = |
| 7639 FakeOutputSurface::Create3d(); |
7633 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 7640 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
7634 | 7641 |
7635 EXPECT_EQ(0u, context3d->NumTextures()); | 7642 EXPECT_EQ(0u, context3d->NumTextures()); |
7636 | 7643 |
7637 UIResourceId ui_resource_id = 1; | 7644 UIResourceId ui_resource_id = 1; |
7638 bool is_opaque = false; | 7645 bool is_opaque = false; |
7639 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); | 7646 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); |
7640 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 7647 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
7641 EXPECT_EQ(1u, context3d->NumTextures()); | 7648 EXPECT_EQ(1u, context3d->NumTextures()); |
7642 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); | 7649 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
(...skipping 19 matching lines...) Expand all Loading... |
7662 host_impl_->DeleteUIResource(ui_resource_id); | 7669 host_impl_->DeleteUIResource(ui_resource_id); |
7663 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); | 7670 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); |
7664 EXPECT_EQ(0u, context3d->NumTextures()); | 7671 EXPECT_EQ(0u, context3d->NumTextures()); |
7665 | 7672 |
7666 // Should not change state for multiple deletion on one UIResourceId | 7673 // Should not change state for multiple deletion on one UIResourceId |
7667 host_impl_->DeleteUIResource(ui_resource_id); | 7674 host_impl_->DeleteUIResource(ui_resource_id); |
7668 EXPECT_EQ(0u, context3d->NumTextures()); | 7675 EXPECT_EQ(0u, context3d->NumTextures()); |
7669 } | 7676 } |
7670 | 7677 |
7671 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { | 7678 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { |
7672 scoped_ptr<TestWebGraphicsContext3D> context = | 7679 std::unique_ptr<TestWebGraphicsContext3D> context = |
7673 TestWebGraphicsContext3D::Create(); | 7680 TestWebGraphicsContext3D::Create(); |
7674 TestWebGraphicsContext3D* context3d = context.get(); | 7681 TestWebGraphicsContext3D* context3d = context.get(); |
7675 CreateHostImpl(DefaultSettings(), FakeOutputSurface::Create3d()); | 7682 CreateHostImpl(DefaultSettings(), FakeOutputSurface::Create3d()); |
7676 | 7683 |
7677 EXPECT_EQ(0u, context3d->NumTextures()); | 7684 EXPECT_EQ(0u, context3d->NumTextures()); |
7678 | 7685 |
7679 gfx::Size size(4, 4); | 7686 gfx::Size size(4, 4); |
7680 // SkImageInfo has no support for ETC1. The |info| below contains the right | 7687 // SkImageInfo has no support for ETC1. The |info| below contains the right |
7681 // total pixel size for the bitmap but not the right height and width. The | 7688 // total pixel size for the bitmap but not the right height and width. The |
7682 // correct width/height are passed directly to UIResourceBitmap. | 7689 // correct width/height are passed directly to UIResourceBitmap. |
7683 SkImageInfo info = | 7690 SkImageInfo info = |
7684 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); | 7691 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); |
7685 skia::RefPtr<SkPixelRef> pixel_ref = | 7692 skia::RefPtr<SkPixelRef> pixel_ref = |
7686 skia::AdoptRef(SkMallocPixelRef::NewAllocate(info, 0, 0)); | 7693 skia::AdoptRef(SkMallocPixelRef::NewAllocate(info, 0, 0)); |
7687 pixel_ref->setImmutable(); | 7694 pixel_ref->setImmutable(); |
7688 UIResourceBitmap bitmap(pixel_ref, size); | 7695 UIResourceBitmap bitmap(pixel_ref, size); |
7689 UIResourceId ui_resource_id = 1; | 7696 UIResourceId ui_resource_id = 1; |
7690 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 7697 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
7691 EXPECT_EQ(1u, context3d->NumTextures()); | 7698 EXPECT_EQ(1u, context3d->NumTextures()); |
7692 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); | 7699 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
7693 EXPECT_NE(0u, id1); | 7700 EXPECT_NE(0u, id1); |
7694 } | 7701 } |
7695 | 7702 |
7696 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { | 7703 void ShutdownReleasesContext_Callback( |
7697 } | 7704 std::unique_ptr<CopyOutputResult> result) {} |
7698 | 7705 |
7699 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 7706 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
7700 scoped_refptr<TestContextProvider> context_provider = | 7707 scoped_refptr<TestContextProvider> context_provider = |
7701 TestContextProvider::Create(); | 7708 TestContextProvider::Create(); |
7702 | 7709 |
7703 CreateHostImpl(DefaultSettings(), | 7710 CreateHostImpl(DefaultSettings(), |
7704 FakeOutputSurface::Create3d(context_provider)); | 7711 FakeOutputSurface::Create3d(context_provider)); |
7705 | 7712 |
7706 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7713 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
7707 | 7714 |
7708 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 7715 std::vector<std::unique_ptr<CopyOutputRequest>> requests; |
7709 requests.push_back(CopyOutputRequest::CreateRequest( | 7716 requests.push_back(CopyOutputRequest::CreateRequest( |
7710 base::Bind(&ShutdownReleasesContext_Callback))); | 7717 base::Bind(&ShutdownReleasesContext_Callback))); |
7711 | 7718 |
7712 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 7719 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
7713 root->PassCopyRequests(&requests); | 7720 root->PassCopyRequests(&requests); |
7714 | 7721 |
7715 LayerTreeHostImpl::FrameData frame; | 7722 LayerTreeHostImpl::FrameData frame; |
7716 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7723 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7717 host_impl_->DrawLayers(&frame); | 7724 host_impl_->DrawLayers(&frame); |
7718 host_impl_->DidDrawAllLayers(frame); | 7725 host_impl_->DidDrawAllLayers(frame); |
7719 | 7726 |
7720 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 7727 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
7721 // texture in a texture mailbox. | 7728 // texture in a texture mailbox. |
7722 EXPECT_FALSE(context_provider->HasOneRef()); | 7729 EXPECT_FALSE(context_provider->HasOneRef()); |
7723 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 7730 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
7724 | 7731 |
7725 host_impl_ = nullptr; | 7732 host_impl_ = nullptr; |
7726 | 7733 |
7727 // The CopyOutputResult's callback was cancelled, the CopyOutputResult | 7734 // The CopyOutputResult's callback was cancelled, the CopyOutputResult |
7728 // released, and the texture deleted. | 7735 // released, and the texture deleted. |
7729 EXPECT_TRUE(context_provider->HasOneRef()); | 7736 EXPECT_TRUE(context_provider->HasOneRef()); |
7730 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 7737 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
7731 } | 7738 } |
7732 | 7739 |
7733 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 7740 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
7734 // When flinging via touch, only the child should scroll (we should not | 7741 // When flinging via touch, only the child should scroll (we should not |
7735 // bubble). | 7742 // bubble). |
7736 gfx::Size surface_size(10, 10); | 7743 gfx::Size surface_size(10, 10); |
7737 gfx::Size content_size(20, 20); | 7744 gfx::Size content_size(20, 20); |
7738 scoped_ptr<LayerImpl> root_ptr = | 7745 std::unique_ptr<LayerImpl> root_ptr = |
7739 LayerImpl::Create(host_impl_->active_tree(), 4); | 7746 LayerImpl::Create(host_impl_->active_tree(), 4); |
7740 scoped_ptr<LayerImpl> root_clip = | 7747 std::unique_ptr<LayerImpl> root_clip = |
7741 LayerImpl::Create(host_impl_->active_tree(), 3); | 7748 LayerImpl::Create(host_impl_->active_tree(), 3); |
7742 root_clip->SetForceRenderSurface(true); | 7749 root_clip->SetForceRenderSurface(true); |
7743 | 7750 |
7744 scoped_ptr<LayerImpl> root_scroll = | 7751 std::unique_ptr<LayerImpl> root_scroll = |
7745 CreateScrollableLayer(1, content_size, root_clip.get()); | 7752 CreateScrollableLayer(1, content_size, root_clip.get()); |
7746 root_scroll->SetIsContainerForFixedPositionLayers(true); | 7753 root_scroll->SetIsContainerForFixedPositionLayers(true); |
7747 scoped_ptr<LayerImpl> child = | 7754 std::unique_ptr<LayerImpl> child = |
7748 CreateScrollableLayer(2, content_size, root_clip.get()); | 7755 CreateScrollableLayer(2, content_size, root_clip.get()); |
7749 | 7756 |
7750 root_scroll->AddChild(std::move(child)); | 7757 root_scroll->AddChild(std::move(child)); |
7751 int root_id = root_scroll->id(); | 7758 int root_id = root_scroll->id(); |
7752 root_clip->AddChild(std::move(root_scroll)); | 7759 root_clip->AddChild(std::move(root_scroll)); |
7753 root_ptr->AddChild(std::move(root_clip)); | 7760 root_ptr->AddChild(std::move(root_clip)); |
7754 | 7761 |
7755 host_impl_->SetViewportSize(surface_size); | 7762 host_impl_->SetViewportSize(surface_size); |
7756 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 7763 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); |
7757 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, | 7764 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, |
(...skipping 10 matching lines...) Expand all Loading... |
7768 | 7775 |
7769 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 7776 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
7770 host_impl_->FlingScrollBegin().thread); | 7777 host_impl_->FlingScrollBegin().thread); |
7771 | 7778 |
7772 gfx::Vector2d scroll_delta(0, 100); | 7779 gfx::Vector2d scroll_delta(0, 100); |
7773 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 7780 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
7774 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 7781 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
7775 | 7782 |
7776 host_impl_->ScrollEnd(EndState().get()); | 7783 host_impl_->ScrollEnd(EndState().get()); |
7777 | 7784 |
7778 scoped_ptr<ScrollAndScaleSet> scroll_info = | 7785 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
7779 host_impl_->ProcessScrollDeltas(); | 7786 host_impl_->ProcessScrollDeltas(); |
7780 | 7787 |
7781 // Only the child should have scrolled. | 7788 // Only the child should have scrolled. |
7782 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 7789 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
7783 ExpectNone(*scroll_info.get(), root_id); | 7790 ExpectNone(*scroll_info.get(), root_id); |
7784 } | 7791 } |
7785 } | 7792 } |
7786 | 7793 |
7787 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { | 7794 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { |
7788 // Scroll a child layer beyond its maximum scroll range and make sure the | 7795 // Scroll a child layer beyond its maximum scroll range and make sure the |
7789 // the scroll doesn't bubble up to the parent layer. | 7796 // the scroll doesn't bubble up to the parent layer. |
7790 gfx::Size surface_size(10, 10); | 7797 gfx::Size surface_size(10, 10); |
7791 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 7798 std::unique_ptr<LayerImpl> root = |
| 7799 LayerImpl::Create(host_impl_->active_tree(), 1); |
7792 root->SetForceRenderSurface(true); | 7800 root->SetForceRenderSurface(true); |
7793 scoped_ptr<LayerImpl> root_scrolling = | 7801 std::unique_ptr<LayerImpl> root_scrolling = |
7794 CreateScrollableLayer(2, surface_size, root.get()); | 7802 CreateScrollableLayer(2, surface_size, root.get()); |
7795 | 7803 |
7796 scoped_ptr<LayerImpl> grand_child = | 7804 std::unique_ptr<LayerImpl> grand_child = |
7797 CreateScrollableLayer(4, surface_size, root.get()); | 7805 CreateScrollableLayer(4, surface_size, root.get()); |
7798 grand_child->layer_tree_impl() | 7806 grand_child->layer_tree_impl() |
7799 ->property_trees() | 7807 ->property_trees() |
7800 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), | 7808 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), |
7801 gfx::ScrollOffset(0, 2)); | 7809 gfx::ScrollOffset(0, 2)); |
7802 | 7810 |
7803 scoped_ptr<LayerImpl> child = | 7811 std::unique_ptr<LayerImpl> child = |
7804 CreateScrollableLayer(3, surface_size, root.get()); | 7812 CreateScrollableLayer(3, surface_size, root.get()); |
7805 child->layer_tree_impl() | 7813 child->layer_tree_impl() |
7806 ->property_trees() | 7814 ->property_trees() |
7807 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(), | 7815 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(), |
7808 gfx::ScrollOffset(0, 4)); | 7816 gfx::ScrollOffset(0, 4)); |
7809 child->AddChild(std::move(grand_child)); | 7817 child->AddChild(std::move(grand_child)); |
7810 | 7818 |
7811 root_scrolling->AddChild(std::move(child)); | 7819 root_scrolling->AddChild(std::move(child)); |
7812 root->AddChild(std::move(root_scrolling)); | 7820 root->AddChild(std::move(root_scrolling)); |
7813 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 7821 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
7814 host_impl_->active_tree()->DidBecomeActive(); | 7822 host_impl_->active_tree()->DidBecomeActive(); |
7815 host_impl_->SetViewportSize(surface_size); | 7823 host_impl_->SetViewportSize(surface_size); |
7816 SetNeedsRebuildPropertyTrees(); | 7824 SetNeedsRebuildPropertyTrees(); |
7817 DrawFrame(); | 7825 DrawFrame(); |
7818 { | 7826 { |
7819 scoped_ptr<ScrollAndScaleSet> scroll_info; | 7827 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
7820 LayerImpl* child = | 7828 LayerImpl* child = |
7821 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; | 7829 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; |
7822 LayerImpl* grand_child = child->children()[0]; | 7830 LayerImpl* grand_child = child->children()[0]; |
7823 | 7831 |
7824 gfx::Vector2d scroll_delta(0, -2); | 7832 gfx::Vector2d scroll_delta(0, -2); |
7825 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 7833 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
7826 host_impl_ | 7834 host_impl_ |
7827 ->ScrollBegin(BeginState(gfx::Point()).get(), | 7835 ->ScrollBegin(BeginState(gfx::Point()).get(), |
7828 InputHandler::TOUCHSCREEN) | 7836 InputHandler::TOUCHSCREEN) |
7829 .thread); | 7837 .thread); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7869 .did_scroll); | 7877 .did_scroll); |
7870 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 7878 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
7871 host_impl_->ScrollEnd(EndState().get()); | 7879 host_impl_->ScrollEnd(EndState().get()); |
7872 } | 7880 } |
7873 } | 7881 } |
7874 | 7882 |
7875 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { | 7883 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { |
7876 // When flinging via wheel, we shouldn't bubble. | 7884 // When flinging via wheel, we shouldn't bubble. |
7877 gfx::Size surface_size(10, 10); | 7885 gfx::Size surface_size(10, 10); |
7878 gfx::Size content_size(20, 20); | 7886 gfx::Size content_size(20, 20); |
7879 scoped_ptr<LayerImpl> root_clip = | 7887 std::unique_ptr<LayerImpl> root_clip = |
7880 LayerImpl::Create(host_impl_->active_tree(), 3); | 7888 LayerImpl::Create(host_impl_->active_tree(), 3); |
7881 root_clip->SetForceRenderSurface(true); | 7889 root_clip->SetForceRenderSurface(true); |
7882 scoped_ptr<LayerImpl> root_scroll = | 7890 std::unique_ptr<LayerImpl> root_scroll = |
7883 CreateScrollableLayer(1, content_size, root_clip.get()); | 7891 CreateScrollableLayer(1, content_size, root_clip.get()); |
7884 int root_scroll_id = root_scroll->id(); | 7892 int root_scroll_id = root_scroll->id(); |
7885 scoped_ptr<LayerImpl> child = | 7893 std::unique_ptr<LayerImpl> child = |
7886 CreateScrollableLayer(2, content_size, root_clip.get()); | 7894 CreateScrollableLayer(2, content_size, root_clip.get()); |
7887 | 7895 |
7888 root_scroll->AddChild(std::move(child)); | 7896 root_scroll->AddChild(std::move(child)); |
7889 root_clip->AddChild(std::move(root_scroll)); | 7897 root_clip->AddChild(std::move(root_scroll)); |
7890 | 7898 |
7891 host_impl_->SetViewportSize(surface_size); | 7899 host_impl_->SetViewportSize(surface_size); |
7892 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); | 7900 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
7893 host_impl_->active_tree()->DidBecomeActive(); | 7901 host_impl_->active_tree()->DidBecomeActive(); |
7894 SetNeedsRebuildPropertyTrees(); | 7902 SetNeedsRebuildPropertyTrees(); |
7895 DrawFrame(); | 7903 DrawFrame(); |
7896 { | 7904 { |
7897 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 7905 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
7898 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 7906 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
7899 InputHandler::WHEEL) | 7907 InputHandler::WHEEL) |
7900 .thread); | 7908 .thread); |
7901 | 7909 |
7902 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 7910 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
7903 host_impl_->FlingScrollBegin().thread); | 7911 host_impl_->FlingScrollBegin().thread); |
7904 | 7912 |
7905 gfx::Vector2d scroll_delta(0, 100); | 7913 gfx::Vector2d scroll_delta(0, 100); |
7906 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 7914 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
7907 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 7915 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
7908 | 7916 |
7909 host_impl_->ScrollEnd(EndState().get()); | 7917 host_impl_->ScrollEnd(EndState().get()); |
7910 | 7918 |
7911 scoped_ptr<ScrollAndScaleSet> scroll_info = | 7919 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
7912 host_impl_->ProcessScrollDeltas(); | 7920 host_impl_->ProcessScrollDeltas(); |
7913 | 7921 |
7914 // The root shouldn't have scrolled. | 7922 // The root shouldn't have scrolled. |
7915 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 7923 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
7916 ExpectNone(*scroll_info.get(), root_scroll_id); | 7924 ExpectNone(*scroll_info.get(), root_scroll_id); |
7917 } | 7925 } |
7918 } | 7926 } |
7919 | 7927 |
7920 TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) { | 7928 TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) { |
7921 // If we ray cast a scroller that is not on the first layer's ancestor chain, | 7929 // If we ray cast a scroller that is not on the first layer's ancestor chain, |
7922 // we should return SCROLL_UNKNOWN. | 7930 // we should return SCROLL_UNKNOWN. |
7923 gfx::Size content_size(100, 100); | 7931 gfx::Size content_size(100, 100); |
7924 SetupScrollAndContentsLayers(content_size); | 7932 SetupScrollAndContentsLayers(content_size); |
7925 | 7933 |
7926 int scroll_layer_id = 2; | 7934 int scroll_layer_id = 2; |
7927 LayerImpl* scroll_layer = | 7935 LayerImpl* scroll_layer = |
7928 host_impl_->active_tree()->LayerById(scroll_layer_id); | 7936 host_impl_->active_tree()->LayerById(scroll_layer_id); |
7929 scroll_layer->SetDrawsContent(true); | 7937 scroll_layer->SetDrawsContent(true); |
7930 | 7938 |
7931 int page_scale_layer_id = 5; | 7939 int page_scale_layer_id = 5; |
7932 LayerImpl* page_scale_layer = | 7940 LayerImpl* page_scale_layer = |
7933 host_impl_->active_tree()->LayerById(page_scale_layer_id); | 7941 host_impl_->active_tree()->LayerById(page_scale_layer_id); |
7934 | 7942 |
7935 int occluder_layer_id = 6; | 7943 int occluder_layer_id = 6; |
7936 scoped_ptr<LayerImpl> occluder_layer = | 7944 std::unique_ptr<LayerImpl> occluder_layer = |
7937 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 7945 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
7938 occluder_layer->SetDrawsContent(true); | 7946 occluder_layer->SetDrawsContent(true); |
7939 occluder_layer->SetBounds(content_size); | 7947 occluder_layer->SetBounds(content_size); |
7940 occluder_layer->SetPosition(gfx::PointF()); | 7948 occluder_layer->SetPosition(gfx::PointF()); |
7941 | 7949 |
7942 // The parent of the occluder is *above* the scroller. | 7950 // The parent of the occluder is *above* the scroller. |
7943 page_scale_layer->AddChild(std::move(occluder_layer)); | 7951 page_scale_layer->AddChild(std::move(occluder_layer)); |
7944 | 7952 |
7945 SetNeedsRebuildPropertyTrees(); | 7953 SetNeedsRebuildPropertyTrees(); |
7946 DrawFrame(); | 7954 DrawFrame(); |
(...skipping 11 matching lines...) Expand all Loading... |
7958 // should also return SCROLL_UNKNOWN. | 7966 // should also return SCROLL_UNKNOWN. |
7959 gfx::Size content_size(100, 100); | 7967 gfx::Size content_size(100, 100); |
7960 SetupScrollAndContentsLayers(content_size); | 7968 SetupScrollAndContentsLayers(content_size); |
7961 | 7969 |
7962 int scroll_layer_id = 2; | 7970 int scroll_layer_id = 2; |
7963 LayerImpl* scroll_layer = | 7971 LayerImpl* scroll_layer = |
7964 host_impl_->active_tree()->LayerById(scroll_layer_id); | 7972 host_impl_->active_tree()->LayerById(scroll_layer_id); |
7965 scroll_layer->SetDrawsContent(true); | 7973 scroll_layer->SetDrawsContent(true); |
7966 | 7974 |
7967 int occluder_layer_id = 6; | 7975 int occluder_layer_id = 6; |
7968 scoped_ptr<LayerImpl> occluder_layer = | 7976 std::unique_ptr<LayerImpl> occluder_layer = |
7969 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 7977 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
7970 occluder_layer->SetDrawsContent(true); | 7978 occluder_layer->SetDrawsContent(true); |
7971 occluder_layer->SetBounds(content_size); | 7979 occluder_layer->SetBounds(content_size); |
7972 occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f)); | 7980 occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f)); |
7973 | 7981 |
7974 int child_scroll_clip_layer_id = 7; | 7982 int child_scroll_clip_layer_id = 7; |
7975 scoped_ptr<LayerImpl> child_scroll_clip = | 7983 std::unique_ptr<LayerImpl> child_scroll_clip = |
7976 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); | 7984 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); |
7977 | 7985 |
7978 int child_scroll_layer_id = 8; | 7986 int child_scroll_layer_id = 8; |
7979 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( | 7987 std::unique_ptr<LayerImpl> child_scroll = CreateScrollableLayer( |
7980 child_scroll_layer_id, content_size, child_scroll_clip.get()); | 7988 child_scroll_layer_id, content_size, child_scroll_clip.get()); |
7981 | 7989 |
7982 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); | 7990 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); |
7983 | 7991 |
7984 child_scroll->AddChild(std::move(occluder_layer)); | 7992 child_scroll->AddChild(std::move(occluder_layer)); |
7985 child_scroll_clip->AddChild(std::move(child_scroll)); | 7993 child_scroll_clip->AddChild(std::move(child_scroll)); |
7986 scroll_layer->AddChild(std::move(child_scroll_clip)); | 7994 scroll_layer->AddChild(std::move(child_scroll_clip)); |
7987 | 7995 |
7988 SetNeedsRebuildPropertyTrees(); | 7996 SetNeedsRebuildPropertyTrees(); |
7989 DrawFrame(); | 7997 DrawFrame(); |
7990 | 7998 |
7991 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 7999 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
7992 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 8000 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
7993 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); | 8001 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
7994 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | 8002 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
7995 status.main_thread_scrolling_reasons); | 8003 status.main_thread_scrolling_reasons); |
7996 } | 8004 } |
7997 | 8005 |
7998 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { | 8006 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { |
7999 gfx::Size content_size(100, 100); | 8007 gfx::Size content_size(100, 100); |
8000 SetupScrollAndContentsLayers(content_size); | 8008 SetupScrollAndContentsLayers(content_size); |
8001 | 8009 |
8002 LayerImpl* root = host_impl_->active_tree()->LayerById(1); | 8010 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
8003 | 8011 |
8004 int scroll_layer_id = 2; | 8012 int scroll_layer_id = 2; |
8005 LayerImpl* scroll_layer = | 8013 LayerImpl* scroll_layer = |
8006 host_impl_->active_tree()->LayerById(scroll_layer_id); | 8014 host_impl_->active_tree()->LayerById(scroll_layer_id); |
8007 | 8015 |
8008 int child_scroll_layer_id = 7; | 8016 int child_scroll_layer_id = 7; |
8009 scoped_ptr<LayerImpl> child_scroll = | 8017 std::unique_ptr<LayerImpl> child_scroll = |
8010 CreateScrollableLayer(child_scroll_layer_id, content_size, root); | 8018 CreateScrollableLayer(child_scroll_layer_id, content_size, root); |
8011 child_scroll->SetDrawsContent(false); | 8019 child_scroll->SetDrawsContent(false); |
8012 | 8020 |
8013 scroll_layer->AddChild(std::move(child_scroll)); | 8021 scroll_layer->AddChild(std::move(child_scroll)); |
8014 | 8022 |
8015 SetNeedsRebuildPropertyTrees(); | 8023 SetNeedsRebuildPropertyTrees(); |
8016 DrawFrame(); | 8024 DrawFrame(); |
8017 | 8025 |
8018 // We should not have scrolled |child_scroll| even though we technically "hit" | 8026 // We should not have scrolled |child_scroll| even though we technically "hit" |
8019 // it. The reason for this is that if the scrolling the scroll would not move | 8027 // it. The reason for this is that if the scrolling the scroll would not move |
8020 // any layer that is a drawn RSLL member, then we can ignore the hit. | 8028 // any layer that is a drawn RSLL member, then we can ignore the hit. |
8021 // | 8029 // |
8022 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and | 8030 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and |
8023 // started scrolling the inner viewport. | 8031 // started scrolling the inner viewport. |
8024 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8032 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8025 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8033 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
8026 InputHandler::WHEEL) | 8034 InputHandler::WHEEL) |
8027 .thread); | 8035 .thread); |
8028 | 8036 |
8029 EXPECT_EQ(2, host_impl_->CurrentlyScrollingLayer()->id()); | 8037 EXPECT_EQ(2, host_impl_->CurrentlyScrollingLayer()->id()); |
8030 } | 8038 } |
8031 | 8039 |
8032 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleDescendent) { | 8040 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleDescendent) { |
8033 gfx::Size content_size(100, 100); | 8041 gfx::Size content_size(100, 100); |
8034 SetupScrollAndContentsLayers(content_size); | 8042 SetupScrollAndContentsLayers(content_size); |
8035 | 8043 |
8036 LayerImpl* root = host_impl_->active_tree()->LayerById(1); | 8044 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
8037 LayerImpl* root_scroll_layer = host_impl_->active_tree()->LayerById(2); | 8045 LayerImpl* root_scroll_layer = host_impl_->active_tree()->LayerById(2); |
8038 | 8046 |
8039 scoped_ptr<LayerImpl> invisible_scroll_layer = | 8047 std::unique_ptr<LayerImpl> invisible_scroll_layer = |
8040 CreateScrollableLayer(7, content_size, root); | 8048 CreateScrollableLayer(7, content_size, root); |
8041 invisible_scroll_layer->SetDrawsContent(false); | 8049 invisible_scroll_layer->SetDrawsContent(false); |
8042 | 8050 |
8043 scoped_ptr<LayerImpl> child_layer = | 8051 std::unique_ptr<LayerImpl> child_layer = |
8044 LayerImpl::Create(host_impl_->active_tree(), 8); | 8052 LayerImpl::Create(host_impl_->active_tree(), 8); |
8045 child_layer->SetDrawsContent(false); | 8053 child_layer->SetDrawsContent(false); |
8046 | 8054 |
8047 scoped_ptr<LayerImpl> grand_child_layer = | 8055 std::unique_ptr<LayerImpl> grand_child_layer = |
8048 LayerImpl::Create(host_impl_->active_tree(), 9); | 8056 LayerImpl::Create(host_impl_->active_tree(), 9); |
8049 grand_child_layer->SetDrawsContent(true); | 8057 grand_child_layer->SetDrawsContent(true); |
8050 grand_child_layer->SetBounds(content_size); | 8058 grand_child_layer->SetBounds(content_size); |
8051 // Move the grand child so it's not hit by our test point. | 8059 // Move the grand child so it's not hit by our test point. |
8052 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); | 8060 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
8053 | 8061 |
8054 child_layer->AddChild(std::move(grand_child_layer)); | 8062 child_layer->AddChild(std::move(grand_child_layer)); |
8055 invisible_scroll_layer->AddChild(std::move(child_layer)); | 8063 invisible_scroll_layer->AddChild(std::move(child_layer)); |
8056 root_scroll_layer->AddChild(std::move(invisible_scroll_layer)); | 8064 root_scroll_layer->AddChild(std::move(invisible_scroll_layer)); |
8057 | 8065 |
(...skipping 18 matching lines...) Expand all Loading... |
8076 gfx::Size content_size(100, 100); | 8084 gfx::Size content_size(100, 100); |
8077 SetupScrollAndContentsLayers(content_size); | 8085 SetupScrollAndContentsLayers(content_size); |
8078 | 8086 |
8079 LayerImpl* root = host_impl_->active_tree()->LayerById(1); | 8087 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
8080 | 8088 |
8081 int scroll_layer_id = 2; | 8089 int scroll_layer_id = 2; |
8082 LayerImpl* scroll_layer = | 8090 LayerImpl* scroll_layer = |
8083 host_impl_->active_tree()->LayerById(scroll_layer_id); | 8091 host_impl_->active_tree()->LayerById(scroll_layer_id); |
8084 | 8092 |
8085 int scroll_child_id = 6; | 8093 int scroll_child_id = 6; |
8086 scoped_ptr<LayerImpl> scroll_child = | 8094 std::unique_ptr<LayerImpl> scroll_child = |
8087 LayerImpl::Create(host_impl_->active_tree(), scroll_child_id); | 8095 LayerImpl::Create(host_impl_->active_tree(), scroll_child_id); |
8088 scroll_child->SetDrawsContent(true); | 8096 scroll_child->SetDrawsContent(true); |
8089 scroll_child->SetBounds(content_size); | 8097 scroll_child->SetBounds(content_size); |
8090 // Move the scroll child so it's not hit by our test point. | 8098 // Move the scroll child so it's not hit by our test point. |
8091 scroll_child->SetPosition(gfx::PointF(10.f, 10.f)); | 8099 scroll_child->SetPosition(gfx::PointF(10.f, 10.f)); |
8092 | 8100 |
8093 int invisible_scroll_layer_id = 7; | 8101 int invisible_scroll_layer_id = 7; |
8094 scoped_ptr<LayerImpl> invisible_scroll = | 8102 std::unique_ptr<LayerImpl> invisible_scroll = |
8095 CreateScrollableLayer(invisible_scroll_layer_id, content_size, root); | 8103 CreateScrollableLayer(invisible_scroll_layer_id, content_size, root); |
8096 invisible_scroll->SetDrawsContent(false); | 8104 invisible_scroll->SetDrawsContent(false); |
8097 | 8105 |
8098 int container_id = 8; | 8106 int container_id = 8; |
8099 scoped_ptr<LayerImpl> container = | 8107 std::unique_ptr<LayerImpl> container = |
8100 LayerImpl::Create(host_impl_->active_tree(), container_id); | 8108 LayerImpl::Create(host_impl_->active_tree(), container_id); |
8101 | 8109 |
8102 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); | 8110 std::unique_ptr<std::set<LayerImpl*>> scroll_children( |
| 8111 new std::set<LayerImpl*>); |
8103 scroll_children->insert(scroll_child.get()); | 8112 scroll_children->insert(scroll_child.get()); |
8104 invisible_scroll->SetScrollChildren(scroll_children.release()); | 8113 invisible_scroll->SetScrollChildren(scroll_children.release()); |
8105 | 8114 |
8106 scroll_child->SetScrollParent(invisible_scroll.get()); | 8115 scroll_child->SetScrollParent(invisible_scroll.get()); |
8107 | 8116 |
8108 container->AddChild(std::move(invisible_scroll)); | 8117 container->AddChild(std::move(invisible_scroll)); |
8109 container->AddChild(std::move(scroll_child)); | 8118 container->AddChild(std::move(scroll_child)); |
8110 | 8119 |
8111 scroll_layer->AddChild(std::move(container)); | 8120 scroll_layer->AddChild(std::move(container)); |
8112 | 8121 |
8113 SetNeedsRebuildPropertyTrees(); | 8122 SetNeedsRebuildPropertyTrees(); |
8114 DrawFrame(); | 8123 DrawFrame(); |
8115 | 8124 |
8116 // We should have scrolled |child_scroll| even though it is invisible. | 8125 // We should have scrolled |child_scroll| even though it is invisible. |
8117 // The reason for this is that if the scrolling the scroll would move a layer | 8126 // The reason for this is that if the scrolling the scroll would move a layer |
8118 // that is a drawn RSLL member, then we should accept this hit. | 8127 // that is a drawn RSLL member, then we should accept this hit. |
8119 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8128 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8120 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8129 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
8121 InputHandler::WHEEL) | 8130 InputHandler::WHEEL) |
8122 .thread); | 8131 .thread); |
8123 | 8132 |
8124 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 8133 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
8125 } | 8134 } |
8126 | 8135 |
8127 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 8136 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
8128 // to CompositorFrameMetadata after SwapBuffers(); | 8137 // to CompositorFrameMetadata after SwapBuffers(); |
8129 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 8138 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
8130 scoped_ptr<SolidColorLayerImpl> root = | 8139 std::unique_ptr<SolidColorLayerImpl> root = |
8131 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8140 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
8132 root->SetPosition(gfx::PointF()); | 8141 root->SetPosition(gfx::PointF()); |
8133 root->SetBounds(gfx::Size(10, 10)); | 8142 root->SetBounds(gfx::Size(10, 10)); |
8134 root->SetDrawsContent(true); | 8143 root->SetDrawsContent(true); |
8135 root->SetForceRenderSurface(true); | 8144 root->SetForceRenderSurface(true); |
8136 | 8145 |
8137 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8146 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
8138 | 8147 |
8139 FakeOutputSurface* fake_output_surface = | 8148 FakeOutputSurface* fake_output_surface = |
8140 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8149 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
8141 | 8150 |
8142 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 8151 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
8143 fake_output_surface->last_sent_frame().metadata.latency_info; | 8152 fake_output_surface->last_sent_frame().metadata.latency_info; |
8144 EXPECT_TRUE(metadata_latency_before.empty()); | 8153 EXPECT_TRUE(metadata_latency_before.empty()); |
8145 | 8154 |
8146 ui::LatencyInfo latency_info; | 8155 ui::LatencyInfo latency_info; |
8147 latency_info.AddLatencyNumber( | 8156 latency_info.AddLatencyNumber( |
8148 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 8157 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
8149 scoped_ptr<SwapPromise> swap_promise( | 8158 std::unique_ptr<SwapPromise> swap_promise( |
8150 new LatencyInfoSwapPromise(latency_info)); | 8159 new LatencyInfoSwapPromise(latency_info)); |
8151 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); | 8160 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); |
8152 host_impl_->SetNeedsRedraw(); | 8161 host_impl_->SetNeedsRedraw(); |
8153 | 8162 |
8154 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8163 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
8155 LayerTreeHostImpl::FrameData frame; | 8164 LayerTreeHostImpl::FrameData frame; |
8156 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 8165 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
8157 host_impl_->DrawLayers(&frame); | 8166 host_impl_->DrawLayers(&frame); |
8158 host_impl_->DidDrawAllLayers(frame); | 8167 host_impl_->DidDrawAllLayers(frame); |
8159 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 8168 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
8160 | 8169 |
8161 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 8170 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
8162 fake_output_surface->last_sent_frame().metadata.latency_info; | 8171 fake_output_surface->last_sent_frame().metadata.latency_info; |
8163 EXPECT_EQ(1u, metadata_latency_after.size()); | 8172 EXPECT_EQ(1u, metadata_latency_after.size()); |
8164 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 8173 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
8165 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 8174 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
8166 } | 8175 } |
8167 | 8176 |
8168 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 8177 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
8169 int root_layer_id = 1; | 8178 int root_layer_id = 1; |
8170 scoped_ptr<SolidColorLayerImpl> root = | 8179 std::unique_ptr<SolidColorLayerImpl> root = |
8171 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 8180 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
8172 root->SetPosition(gfx::PointF()); | 8181 root->SetPosition(gfx::PointF()); |
8173 root->SetBounds(gfx::Size(10, 10)); | 8182 root->SetBounds(gfx::Size(10, 10)); |
8174 root->SetDrawsContent(true); | 8183 root->SetDrawsContent(true); |
8175 root->SetForceRenderSurface(true); | 8184 root->SetForceRenderSurface(true); |
8176 | 8185 |
8177 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8186 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
8178 | 8187 |
8179 // Ensure the default frame selection bounds are empty. | 8188 // Ensure the default frame selection bounds are empty. |
8180 FakeOutputSurface* fake_output_surface = | 8189 FakeOutputSurface* fake_output_surface = |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8243 int* set_needs_redraw_count_; | 8252 int* set_needs_redraw_count_; |
8244 int* forward_to_main_count_; | 8253 int* forward_to_main_count_; |
8245 }; | 8254 }; |
8246 | 8255 |
8247 TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) { | 8256 TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) { |
8248 int set_needs_commit_count = 0; | 8257 int set_needs_commit_count = 0; |
8249 int set_needs_redraw_count = 0; | 8258 int set_needs_redraw_count = 0; |
8250 int forward_to_main_count = 0; | 8259 int forward_to_main_count = 0; |
8251 | 8260 |
8252 { | 8261 { |
8253 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 8262 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
8254 new SimpleSwapPromiseMonitor(NULL, | 8263 new SimpleSwapPromiseMonitor( |
8255 host_impl_.get(), | 8264 NULL, host_impl_.get(), &set_needs_commit_count, |
8256 &set_needs_commit_count, | 8265 &set_needs_redraw_count, &forward_to_main_count)); |
8257 &set_needs_redraw_count, | |
8258 &forward_to_main_count)); | |
8259 host_impl_->SetNeedsRedraw(); | 8266 host_impl_->SetNeedsRedraw(); |
8260 EXPECT_EQ(0, set_needs_commit_count); | 8267 EXPECT_EQ(0, set_needs_commit_count); |
8261 EXPECT_EQ(1, set_needs_redraw_count); | 8268 EXPECT_EQ(1, set_needs_redraw_count); |
8262 EXPECT_EQ(0, forward_to_main_count); | 8269 EXPECT_EQ(0, forward_to_main_count); |
8263 } | 8270 } |
8264 | 8271 |
8265 // Now the monitor is destroyed, SetNeedsRedraw() is no longer being | 8272 // Now the monitor is destroyed, SetNeedsRedraw() is no longer being |
8266 // monitored. | 8273 // monitored. |
8267 host_impl_->SetNeedsRedraw(); | 8274 host_impl_->SetNeedsRedraw(); |
8268 EXPECT_EQ(0, set_needs_commit_count); | 8275 EXPECT_EQ(0, set_needs_commit_count); |
8269 EXPECT_EQ(1, set_needs_redraw_count); | 8276 EXPECT_EQ(1, set_needs_redraw_count); |
8270 EXPECT_EQ(0, forward_to_main_count); | 8277 EXPECT_EQ(0, forward_to_main_count); |
8271 | 8278 |
8272 { | 8279 { |
8273 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 8280 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
8274 new SimpleSwapPromiseMonitor(NULL, | 8281 new SimpleSwapPromiseMonitor( |
8275 host_impl_.get(), | 8282 NULL, host_impl_.get(), &set_needs_commit_count, |
8276 &set_needs_commit_count, | 8283 &set_needs_redraw_count, &forward_to_main_count)); |
8277 &set_needs_redraw_count, | |
8278 &forward_to_main_count)); | |
8279 host_impl_->SetNeedsRedrawRect(gfx::Rect(10, 10)); | 8284 host_impl_->SetNeedsRedrawRect(gfx::Rect(10, 10)); |
8280 EXPECT_EQ(0, set_needs_commit_count); | 8285 EXPECT_EQ(0, set_needs_commit_count); |
8281 EXPECT_EQ(2, set_needs_redraw_count); | 8286 EXPECT_EQ(2, set_needs_redraw_count); |
8282 EXPECT_EQ(0, forward_to_main_count); | 8287 EXPECT_EQ(0, forward_to_main_count); |
8283 } | 8288 } |
8284 | 8289 |
8285 { | 8290 { |
8286 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 8291 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
8287 new SimpleSwapPromiseMonitor(NULL, | 8292 new SimpleSwapPromiseMonitor( |
8288 host_impl_.get(), | 8293 NULL, host_impl_.get(), &set_needs_commit_count, |
8289 &set_needs_commit_count, | 8294 &set_needs_redraw_count, &forward_to_main_count)); |
8290 &set_needs_redraw_count, | |
8291 &forward_to_main_count)); | |
8292 // Empty damage rect won't signal the monitor. | 8295 // Empty damage rect won't signal the monitor. |
8293 host_impl_->SetNeedsRedrawRect(gfx::Rect()); | 8296 host_impl_->SetNeedsRedrawRect(gfx::Rect()); |
8294 EXPECT_EQ(0, set_needs_commit_count); | 8297 EXPECT_EQ(0, set_needs_commit_count); |
8295 EXPECT_EQ(2, set_needs_redraw_count); | 8298 EXPECT_EQ(2, set_needs_redraw_count); |
8296 EXPECT_EQ(0, forward_to_main_count); | 8299 EXPECT_EQ(0, forward_to_main_count); |
8297 } | 8300 } |
8298 | 8301 |
8299 { | 8302 { |
8300 set_needs_commit_count = 0; | 8303 set_needs_commit_count = 0; |
8301 set_needs_redraw_count = 0; | 8304 set_needs_redraw_count = 0; |
8302 forward_to_main_count = 0; | 8305 forward_to_main_count = 0; |
8303 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 8306 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
8304 new SimpleSwapPromiseMonitor(NULL, | 8307 new SimpleSwapPromiseMonitor( |
8305 host_impl_.get(), | 8308 NULL, host_impl_.get(), &set_needs_commit_count, |
8306 &set_needs_commit_count, | 8309 &set_needs_redraw_count, &forward_to_main_count)); |
8307 &set_needs_redraw_count, | |
8308 &forward_to_main_count)); | |
8309 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8310 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
8310 | 8311 |
8311 // Scrolling normally should not trigger any forwarding. | 8312 // Scrolling normally should not trigger any forwarding. |
8312 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8313 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8313 host_impl_ | 8314 host_impl_ |
8314 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8315 ->ScrollBegin(BeginState(gfx::Point()).get(), |
8315 InputHandler::TOUCHSCREEN) | 8316 InputHandler::TOUCHSCREEN) |
8316 .thread); | 8317 .thread); |
8317 EXPECT_TRUE( | 8318 EXPECT_TRUE( |
8318 host_impl_->ScrollBy( | 8319 host_impl_->ScrollBy( |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8824 void SetupVirtualViewportLayers(const gfx::Size& content_size, | 8825 void SetupVirtualViewportLayers(const gfx::Size& content_size, |
8825 const gfx::Size& outer_viewport, | 8826 const gfx::Size& outer_viewport, |
8826 const gfx::Size& inner_viewport) { | 8827 const gfx::Size& inner_viewport) { |
8827 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); | 8828 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
8828 const int kOuterViewportClipLayerId = 6; | 8829 const int kOuterViewportClipLayerId = 6; |
8829 const int kOuterViewportScrollLayerId = 7; | 8830 const int kOuterViewportScrollLayerId = 7; |
8830 const int kInnerViewportScrollLayerId = 2; | 8831 const int kInnerViewportScrollLayerId = 2; |
8831 const int kInnerViewportClipLayerId = 4; | 8832 const int kInnerViewportClipLayerId = 4; |
8832 const int kPageScaleLayerId = 5; | 8833 const int kPageScaleLayerId = 5; |
8833 | 8834 |
8834 scoped_ptr<LayerImpl> inner_scroll = | 8835 std::unique_ptr<LayerImpl> inner_scroll = |
8835 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 8836 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
8836 inner_scroll->SetIsContainerForFixedPositionLayers(true); | 8837 inner_scroll->SetIsContainerForFixedPositionLayers(true); |
8837 inner_scroll->layer_tree_impl() | 8838 inner_scroll->layer_tree_impl() |
8838 ->property_trees() | 8839 ->property_trees() |
8839 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), | 8840 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), |
8840 gfx::ScrollOffset()); | 8841 gfx::ScrollOffset()); |
8841 | 8842 |
8842 scoped_ptr<LayerImpl> inner_clip = | 8843 std::unique_ptr<LayerImpl> inner_clip = |
8843 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 8844 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
8844 inner_clip->SetBounds(inner_viewport); | 8845 inner_clip->SetBounds(inner_viewport); |
8845 | 8846 |
8846 scoped_ptr<LayerImpl> page_scale = | 8847 std::unique_ptr<LayerImpl> page_scale = |
8847 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 8848 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); |
8848 | 8849 |
8849 inner_scroll->SetScrollClipLayer(inner_clip->id()); | 8850 inner_scroll->SetScrollClipLayer(inner_clip->id()); |
8850 inner_scroll->SetBounds(outer_viewport); | 8851 inner_scroll->SetBounds(outer_viewport); |
8851 inner_scroll->SetPosition(gfx::PointF()); | 8852 inner_scroll->SetPosition(gfx::PointF()); |
8852 | 8853 |
8853 scoped_ptr<LayerImpl> outer_clip = | 8854 std::unique_ptr<LayerImpl> outer_clip = |
8854 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); | 8855 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); |
8855 outer_clip->SetBounds(outer_viewport); | 8856 outer_clip->SetBounds(outer_viewport); |
8856 outer_clip->SetIsContainerForFixedPositionLayers(true); | 8857 outer_clip->SetIsContainerForFixedPositionLayers(true); |
8857 | 8858 |
8858 scoped_ptr<LayerImpl> outer_scroll = | 8859 std::unique_ptr<LayerImpl> outer_scroll = |
8859 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); | 8860 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); |
8860 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 8861 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
8861 outer_scroll->layer_tree_impl() | 8862 outer_scroll->layer_tree_impl() |
8862 ->property_trees() | 8863 ->property_trees() |
8863 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(), | 8864 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(), |
8864 gfx::ScrollOffset()); | 8865 gfx::ScrollOffset()); |
8865 outer_scroll->SetBounds(content_size); | 8866 outer_scroll->SetBounds(content_size); |
8866 outer_scroll->SetPosition(gfx::PointF()); | 8867 outer_scroll->SetPosition(gfx::PointF()); |
8867 | 8868 |
8868 scoped_ptr<LayerImpl> contents = | 8869 std::unique_ptr<LayerImpl> contents = LayerImpl::Create(layer_tree_impl, 8); |
8869 LayerImpl::Create(layer_tree_impl, 8); | |
8870 contents->SetDrawsContent(true); | 8870 contents->SetDrawsContent(true); |
8871 contents->SetBounds(content_size); | 8871 contents->SetBounds(content_size); |
8872 contents->SetPosition(gfx::PointF()); | 8872 contents->SetPosition(gfx::PointF()); |
8873 | 8873 |
8874 outer_scroll->AddChild(std::move(contents)); | 8874 outer_scroll->AddChild(std::move(contents)); |
8875 outer_clip->AddChild(std::move(outer_scroll)); | 8875 outer_clip->AddChild(std::move(outer_scroll)); |
8876 inner_scroll->AddChild(std::move(outer_clip)); | 8876 inner_scroll->AddChild(std::move(outer_clip)); |
8877 page_scale->AddChild(std::move(inner_scroll)); | 8877 page_scale->AddChild(std::move(inner_scroll)); |
8878 inner_clip->AddChild(std::move(page_scale)); | 8878 inner_clip->AddChild(std::move(page_scale)); |
8879 | 8879 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9049 TouchFlingDoesntSwitchScrollingLayer) { | 9049 TouchFlingDoesntSwitchScrollingLayer) { |
9050 gfx::Size content_size = gfx::Size(100, 160); | 9050 gfx::Size content_size = gfx::Size(100, 160); |
9051 gfx::Size outer_viewport = gfx::Size(50, 80); | 9051 gfx::Size outer_viewport = gfx::Size(50, 80); |
9052 gfx::Size inner_viewport = gfx::Size(25, 40); | 9052 gfx::Size inner_viewport = gfx::Size(25, 40); |
9053 | 9053 |
9054 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9054 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
9055 | 9055 |
9056 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9056 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
9057 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9057 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
9058 | 9058 |
9059 scoped_ptr<LayerImpl> child = | 9059 std::unique_ptr<LayerImpl> child = |
9060 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 9060 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
9061 LayerImpl* child_scroll = child.get(); | 9061 LayerImpl* child_scroll = child.get(); |
9062 outer_scroll->children()[0]->AddChild(std::move(child)); | 9062 outer_scroll->children()[0]->AddChild(std::move(child)); |
9063 | 9063 |
9064 SetNeedsRebuildPropertyTrees(); | 9064 SetNeedsRebuildPropertyTrees(); |
9065 DrawFrame(); | 9065 DrawFrame(); |
9066 { | 9066 { |
9067 scoped_ptr<ScrollAndScaleSet> scroll_info; | 9067 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
9068 | 9068 |
9069 gfx::Vector2d scroll_delta(0, inner_viewport.height()); | 9069 gfx::Vector2d scroll_delta(0, inner_viewport.height()); |
9070 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9070 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9071 host_impl_ | 9071 host_impl_ |
9072 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9072 ->ScrollBegin(BeginState(gfx::Point()).get(), |
9073 InputHandler::TOUCHSCREEN) | 9073 InputHandler::TOUCHSCREEN) |
9074 .thread); | 9074 .thread); |
9075 EXPECT_TRUE( | 9075 EXPECT_TRUE( |
9076 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 9076 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
9077 .did_scroll); | 9077 .did_scroll); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9117 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { | 9117 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { |
9118 gfx::Size content_size = gfx::Size(100, 160); | 9118 gfx::Size content_size = gfx::Size(100, 160); |
9119 gfx::Size outer_viewport = gfx::Size(50, 80); | 9119 gfx::Size outer_viewport = gfx::Size(50, 80); |
9120 gfx::Size inner_viewport = gfx::Size(25, 40); | 9120 gfx::Size inner_viewport = gfx::Size(25, 40); |
9121 | 9121 |
9122 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9122 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
9123 | 9123 |
9124 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9124 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
9125 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9125 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
9126 | 9126 |
9127 scoped_ptr<LayerImpl> child = | 9127 std::unique_ptr<LayerImpl> child = |
9128 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 9128 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
9129 LayerImpl* child_scroll = child.get(); | 9129 LayerImpl* child_scroll = child.get(); |
9130 outer_scroll->children()[0]->AddChild(std::move(child)); | 9130 outer_scroll->children()[0]->AddChild(std::move(child)); |
9131 | 9131 |
9132 SetNeedsRebuildPropertyTrees(); | 9132 SetNeedsRebuildPropertyTrees(); |
9133 DrawFrame(); | 9133 DrawFrame(); |
9134 | 9134 |
9135 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9135 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9136 host_impl_ | 9136 host_impl_ |
9137 ->RootScrollBegin(BeginState(gfx::Point()).get(), | 9137 ->RootScrollBegin(BeginState(gfx::Point()).get(), |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9284 // Different draw params does swap. | 9284 // Different draw params does swap. |
9285 did_request_redraw_ = false; | 9285 did_request_redraw_ = false; |
9286 host_impl_->OnDraw(draw_transform, draw_viewport2, clip, | 9286 host_impl_->OnDraw(draw_transform, draw_viewport2, clip, |
9287 resourceless_software_draw); | 9287 resourceless_software_draw); |
9288 EXPECT_TRUE(did_request_redraw_); | 9288 EXPECT_TRUE(did_request_redraw_); |
9289 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); | 9289 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); |
9290 } | 9290 } |
9291 | 9291 |
9292 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { | 9292 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { |
9293 protected: | 9293 protected: |
9294 scoped_ptr<OutputSurface> CreateOutputSurface() override { | 9294 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
9295 return FakeOutputSurface::Create3dWithResourcelessSoftwareSupport(); | 9295 return FakeOutputSurface::Create3dWithResourcelessSoftwareSupport(); |
9296 } | 9296 } |
9297 }; | 9297 }; |
9298 | 9298 |
9299 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, | 9299 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, |
9300 ResourcelessSoftwareSetNeedsRedraw) { | 9300 ResourcelessSoftwareSetNeedsRedraw) { |
9301 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9301 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
9302 | 9302 |
9303 const gfx::Size viewport_size(100, 100); | 9303 const gfx::Size viewport_size(100, 100); |
9304 host_impl_->SetViewportSize(viewport_size); | 9304 host_impl_->SetViewportSize(viewport_size); |
(...skipping 23 matching lines...) Expand all Loading... |
9328 } | 9328 } |
9329 | 9329 |
9330 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, | 9330 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, |
9331 ResourcelessSoftwareDrawSkipsUpdateTiles) { | 9331 ResourcelessSoftwareDrawSkipsUpdateTiles) { |
9332 const gfx::Size viewport_size(100, 100); | 9332 const gfx::Size viewport_size(100, 100); |
9333 host_impl_->SetViewportSize(viewport_size); | 9333 host_impl_->SetViewportSize(viewport_size); |
9334 | 9334 |
9335 host_impl_->CreatePendingTree(); | 9335 host_impl_->CreatePendingTree(); |
9336 scoped_refptr<FakeRasterSource> raster_source( | 9336 scoped_refptr<FakeRasterSource> raster_source( |
9337 FakeRasterSource::CreateFilled(viewport_size)); | 9337 FakeRasterSource::CreateFilled(viewport_size)); |
9338 scoped_ptr<FakePictureLayerImpl> layer( | 9338 std::unique_ptr<FakePictureLayerImpl> layer( |
9339 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), | 9339 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
9340 11, raster_source)); | 9340 11, raster_source)); |
9341 layer->SetBounds(viewport_size); | 9341 layer->SetBounds(viewport_size); |
9342 layer->SetDrawsContent(true); | 9342 layer->SetDrawsContent(true); |
9343 host_impl_->pending_tree()->SetRootLayer(std::move(layer)); | 9343 host_impl_->pending_tree()->SetRootLayer(std::move(layer)); |
9344 | 9344 |
9345 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 9345 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
9346 host_impl_->ActivateSyncTree(); | 9346 host_impl_->ActivateSyncTree(); |
9347 | 9347 |
9348 const gfx::Transform draw_transform; | 9348 const gfx::Transform draw_transform; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9639 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9639 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9640 host_impl_->ScrollBegin(BeginState(gfx::Point(0, y)).get(), | 9640 host_impl_->ScrollBegin(BeginState(gfx::Point(0, y)).get(), |
9641 InputHandler::WHEEL) | 9641 InputHandler::WHEEL) |
9642 .thread); | 9642 .thread); |
9643 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), | 9643 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), |
9644 InputHandler::WHEEL)); | 9644 InputHandler::WHEEL)); |
9645 host_impl_->ScrollBy( | 9645 host_impl_->ScrollBy( |
9646 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); | 9646 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); |
9647 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 9647 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
9648 InputHandler::WHEEL)); | 9648 InputHandler::WHEEL)); |
9649 scoped_ptr<ScrollState> scroll_state_end = EndState(); | 9649 std::unique_ptr<ScrollState> scroll_state_end = EndState(); |
9650 host_impl_->ScrollEnd(scroll_state_end.get()); | 9650 host_impl_->ScrollEnd(scroll_state_end.get()); |
9651 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 9651 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
9652 InputHandler::WHEEL)); | 9652 InputHandler::WHEEL)); |
9653 | 9653 |
9654 // The instant scroll should have marked the smooth scroll animation as | 9654 // The instant scroll should have marked the smooth scroll animation as |
9655 // aborted. | 9655 // aborted. |
9656 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 9656 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
9657 scrolling_layer->id())); | 9657 scrolling_layer->id())); |
9658 | 9658 |
9659 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 9659 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10005 host_impl_->DidFinishImplFrame(); | 10005 host_impl_->DidFinishImplFrame(); |
10006 } | 10006 } |
10007 | 10007 |
10008 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { | 10008 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { |
10009 host_impl_->CreatePendingTree(); | 10009 host_impl_->CreatePendingTree(); |
10010 | 10010 |
10011 Region empty_invalidation; | 10011 Region empty_invalidation; |
10012 scoped_refptr<RasterSource> raster_source_with_tiles( | 10012 scoped_refptr<RasterSource> raster_source_with_tiles( |
10013 FakeRasterSource::CreateFilled(gfx::Size(10, 10))); | 10013 FakeRasterSource::CreateFilled(gfx::Size(10, 10))); |
10014 | 10014 |
10015 scoped_ptr<FakePictureLayerImpl> layer = | 10015 std::unique_ptr<FakePictureLayerImpl> layer = |
10016 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11); | 10016 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11); |
10017 layer->SetBounds(gfx::Size(10, 10)); | 10017 layer->SetBounds(gfx::Size(10, 10)); |
10018 layer->set_gpu_raster_max_texture_size(host_impl_->device_viewport_size()); | 10018 layer->set_gpu_raster_max_texture_size(host_impl_->device_viewport_size()); |
10019 layer->SetDrawsContent(true); | 10019 layer->SetDrawsContent(true); |
10020 layer->tilings()->AddTiling(1.0f, raster_source_with_tiles); | 10020 layer->tilings()->AddTiling(1.0f, raster_source_with_tiles); |
10021 layer->UpdateRasterSource(raster_source_with_tiles, &empty_invalidation, | 10021 layer->UpdateRasterSource(raster_source_with_tiles, &empty_invalidation, |
10022 nullptr); | 10022 nullptr); |
10023 layer->tilings()->tiling_at(0)->set_resolution( | 10023 layer->tilings()->tiling_at(0)->set_resolution( |
10024 TileResolution::HIGH_RESOLUTION); | 10024 TileResolution::HIGH_RESOLUTION); |
10025 layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 10025 layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
10026 layer->tilings()->tiling_at(0)->ComputeTilePriorityRects( | 10026 layer->tilings()->tiling_at(0)->ComputeTilePriorityRects( |
10027 gfx::Rect(gfx::Size(10, 10)), 1.f, 1.0, Occlusion()); | 10027 gfx::Rect(gfx::Size(10, 10)), 1.f, 1.0, Occlusion()); |
10028 host_impl_->pending_tree()->SetRootLayer(std::move(layer)); | 10028 host_impl_->pending_tree()->SetRootLayer(std::move(layer)); |
10029 | 10029 |
10030 FakePictureLayerImpl* root_layer = static_cast<FakePictureLayerImpl*>( | 10030 FakePictureLayerImpl* root_layer = static_cast<FakePictureLayerImpl*>( |
10031 host_impl_->pending_tree()->root_layer()); | 10031 host_impl_->pending_tree()->root_layer()); |
10032 | 10032 |
10033 root_layer->set_has_valid_tile_priorities(true); | 10033 root_layer->set_has_valid_tile_priorities(true); |
10034 scoped_ptr<RasterTilePriorityQueue> non_empty_raster_priority_queue_all = | 10034 std::unique_ptr<RasterTilePriorityQueue> non_empty_raster_priority_queue_all = |
10035 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, | 10035 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, |
10036 RasterTilePriorityQueue::Type::ALL); | 10036 RasterTilePriorityQueue::Type::ALL); |
10037 EXPECT_FALSE(non_empty_raster_priority_queue_all->IsEmpty()); | 10037 EXPECT_FALSE(non_empty_raster_priority_queue_all->IsEmpty()); |
10038 | 10038 |
10039 root_layer->set_has_valid_tile_priorities(false); | 10039 root_layer->set_has_valid_tile_priorities(false); |
10040 scoped_ptr<RasterTilePriorityQueue> empty_raster_priority_queue_all = | 10040 std::unique_ptr<RasterTilePriorityQueue> empty_raster_priority_queue_all = |
10041 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, | 10041 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, |
10042 RasterTilePriorityQueue::Type::ALL); | 10042 RasterTilePriorityQueue::Type::ALL); |
10043 EXPECT_TRUE(empty_raster_priority_queue_all->IsEmpty()); | 10043 EXPECT_TRUE(empty_raster_priority_queue_all->IsEmpty()); |
10044 } | 10044 } |
10045 | 10045 |
10046 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { | 10046 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { |
10047 host_impl_->CreatePendingTree(); | 10047 host_impl_->CreatePendingTree(); |
10048 host_impl_->ActivateSyncTree(); | 10048 host_impl_->ActivateSyncTree(); |
10049 host_impl_->CreatePendingTree(); | 10049 host_impl_->CreatePendingTree(); |
10050 | 10050 |
10051 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 10051 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
10052 | 10052 |
10053 scoped_ptr<FakePictureLayerImpl> pending_layer = | 10053 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
10054 FakePictureLayerImpl::Create(pending_tree, 10); | 10054 FakePictureLayerImpl::Create(pending_tree, 10); |
10055 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); | 10055 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); |
10056 pending_tree->SetRootLayer(std::move(pending_layer)); | 10056 pending_tree->SetRootLayer(std::move(pending_layer)); |
10057 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer()); | 10057 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer()); |
10058 | 10058 |
10059 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); | 10059 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); |
10060 pending_tree->DidBecomeActive(); | 10060 pending_tree->DidBecomeActive(); |
10061 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); | 10061 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); |
10062 | 10062 |
10063 scoped_ptr<FakePictureLayerImpl> mask_layer = | 10063 std::unique_ptr<FakePictureLayerImpl> mask_layer = |
10064 FakePictureLayerImpl::Create(pending_tree, 11); | 10064 FakePictureLayerImpl::Create(pending_tree, 11); |
10065 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); | 10065 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); |
10066 raw_pending_layer->SetMaskLayer(std::move(mask_layer)); | 10066 raw_pending_layer->SetMaskLayer(std::move(mask_layer)); |
10067 ASSERT_EQ(raw_mask_layer, raw_pending_layer->mask_layer()); | 10067 ASSERT_EQ(raw_mask_layer, raw_pending_layer->mask_layer()); |
10068 | 10068 |
10069 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); | 10069 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); |
10070 EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count()); | 10070 EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count()); |
10071 pending_tree->DidBecomeActive(); | 10071 pending_tree->DidBecomeActive(); |
10072 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); | 10072 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); |
10073 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); | 10073 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); |
10074 | 10074 |
10075 scoped_ptr<FakePictureLayerImpl> replica_layer = | 10075 std::unique_ptr<FakePictureLayerImpl> replica_layer = |
10076 FakePictureLayerImpl::Create(pending_tree, 12); | 10076 FakePictureLayerImpl::Create(pending_tree, 12); |
10077 scoped_ptr<FakePictureLayerImpl> replica_mask_layer = | 10077 std::unique_ptr<FakePictureLayerImpl> replica_mask_layer = |
10078 FakePictureLayerImpl::Create(pending_tree, 13); | 10078 FakePictureLayerImpl::Create(pending_tree, 13); |
10079 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); | 10079 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); |
10080 replica_layer->SetMaskLayer(std::move(replica_mask_layer)); | 10080 replica_layer->SetMaskLayer(std::move(replica_mask_layer)); |
10081 raw_pending_layer->SetReplicaLayer(std::move(replica_layer)); | 10081 raw_pending_layer->SetReplicaLayer(std::move(replica_layer)); |
10082 ASSERT_EQ(raw_replica_mask_layer, | 10082 ASSERT_EQ(raw_replica_mask_layer, |
10083 raw_pending_layer->replica_layer()->mask_layer()); | 10083 raw_pending_layer->replica_layer()->mask_layer()); |
10084 | 10084 |
10085 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); | 10085 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); |
10086 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); | 10086 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); |
10087 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); | 10087 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10146 EXPECT_EQ(0, num_lost_surfaces_); | 10146 EXPECT_EQ(0, num_lost_surfaces_); |
10147 host_impl_->DidLoseOutputSurface(); | 10147 host_impl_->DidLoseOutputSurface(); |
10148 EXPECT_EQ(1, num_lost_surfaces_); | 10148 EXPECT_EQ(1, num_lost_surfaces_); |
10149 host_impl_->DidLoseOutputSurface(); | 10149 host_impl_->DidLoseOutputSurface(); |
10150 EXPECT_LE(1, num_lost_surfaces_); | 10150 EXPECT_LE(1, num_lost_surfaces_); |
10151 } | 10151 } |
10152 | 10152 |
10153 size_t CountRenderPassesWithId(const RenderPassList& list, RenderPassId id) { | 10153 size_t CountRenderPassesWithId(const RenderPassList& list, RenderPassId id) { |
10154 return std::count_if( | 10154 return std::count_if( |
10155 list.begin(), list.end(), | 10155 list.begin(), list.end(), |
10156 [id](const scoped_ptr<RenderPass>& p) { return p->id == id; }); | 10156 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; }); |
10157 } | 10157 } |
10158 | 10158 |
10159 TEST_F(LayerTreeHostImplTest, RemoveUnreferencedRenderPass) { | 10159 TEST_F(LayerTreeHostImplTest, RemoveUnreferencedRenderPass) { |
10160 LayerTreeHostImpl::FrameData frame; | 10160 LayerTreeHostImpl::FrameData frame; |
10161 frame.render_passes.push_back(RenderPass::Create()); | 10161 frame.render_passes.push_back(RenderPass::Create()); |
10162 RenderPass* pass3 = frame.render_passes.back().get(); | 10162 RenderPass* pass3 = frame.render_passes.back().get(); |
10163 frame.render_passes.push_back(RenderPass::Create()); | 10163 frame.render_passes.push_back(RenderPass::Create()); |
10164 RenderPass* pass2 = frame.render_passes.back().get(); | 10164 RenderPass* pass2 = frame.render_passes.back().get(); |
10165 frame.render_passes.push_back(RenderPass::Create()); | 10165 frame.render_passes.push_back(RenderPass::Create()); |
10166 RenderPass* pass1 = frame.render_passes.back().get(); | 10166 RenderPass* pass1 = frame.render_passes.back().get(); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10365 host_impl_->gpu_rasterization_status()); | 10365 host_impl_->gpu_rasterization_status()); |
10366 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10366 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10367 | 10367 |
10368 host_impl_->SetHasGpuRasterizationTrigger(true); | 10368 host_impl_->SetHasGpuRasterizationTrigger(true); |
10369 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 10369 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
10370 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 10370 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
10371 host_impl_->gpu_rasterization_status()); | 10371 host_impl_->gpu_rasterization_status()); |
10372 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10372 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10373 EXPECT_FALSE(host_impl_->use_msaa()); | 10373 EXPECT_FALSE(host_impl_->use_msaa()); |
10374 | 10374 |
10375 scoped_ptr<TestWebGraphicsContext3D> context_with_msaa = | 10375 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = |
10376 TestWebGraphicsContext3D::Create(); | 10376 TestWebGraphicsContext3D::Create(); |
10377 context_with_msaa->SetMaxSamples(8); | 10377 context_with_msaa->SetMaxSamples(8); |
10378 | 10378 |
10379 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); | 10379 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); |
10380 msaaSettings.gpu_rasterization_msaa_sample_count = 4; | 10380 msaaSettings.gpu_rasterization_msaa_sample_count = 4; |
10381 EXPECT_TRUE(CreateHostImpl( | 10381 EXPECT_TRUE(CreateHostImpl( |
10382 msaaSettings, FakeOutputSurface::Create3d(std::move(context_with_msaa)))); | 10382 msaaSettings, FakeOutputSurface::Create3d(std::move(context_with_msaa)))); |
10383 host_impl_->SetHasGpuRasterizationTrigger(true); | 10383 host_impl_->SetHasGpuRasterizationTrigger(true); |
10384 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 10384 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
10385 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 10385 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10438 host_impl_->SetHasGpuRasterizationTrigger(true); | 10438 host_impl_->SetHasGpuRasterizationTrigger(true); |
10439 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 10439 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
10440 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 10440 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
10441 host_impl_->gpu_rasterization_status()); | 10441 host_impl_->gpu_rasterization_status()); |
10442 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10442 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10443 } | 10443 } |
10444 | 10444 |
10445 // A mock output surface which lets us detect calls to ForceReclaimResources. | 10445 // A mock output surface which lets us detect calls to ForceReclaimResources. |
10446 class MockReclaimResourcesOutputSurface : public FakeOutputSurface { | 10446 class MockReclaimResourcesOutputSurface : public FakeOutputSurface { |
10447 public: | 10447 public: |
10448 static scoped_ptr<MockReclaimResourcesOutputSurface> Create3d() { | 10448 static std::unique_ptr<MockReclaimResourcesOutputSurface> Create3d() { |
10449 return make_scoped_ptr(new MockReclaimResourcesOutputSurface( | 10449 return base::WrapUnique(new MockReclaimResourcesOutputSurface( |
10450 TestContextProvider::Create(), TestContextProvider::CreateWorker(), | 10450 TestContextProvider::Create(), TestContextProvider::CreateWorker(), |
10451 false)); | 10451 false)); |
10452 } | 10452 } |
10453 | 10453 |
10454 MOCK_METHOD0(ForceReclaimResources, void()); | 10454 MOCK_METHOD0(ForceReclaimResources, void()); |
10455 | 10455 |
10456 protected: | 10456 protected: |
10457 MockReclaimResourcesOutputSurface( | 10457 MockReclaimResourcesOutputSurface( |
10458 scoped_refptr<ContextProvider> context_provider, | 10458 scoped_refptr<ContextProvider> context_provider, |
10459 scoped_refptr<ContextProvider> worker_context_provider, | 10459 scoped_refptr<ContextProvider> worker_context_provider, |
10460 bool delegated_rendering) | 10460 bool delegated_rendering) |
10461 : FakeOutputSurface(context_provider, | 10461 : FakeOutputSurface(context_provider, |
10462 worker_context_provider, | 10462 worker_context_provider, |
10463 delegated_rendering) {} | 10463 delegated_rendering) {} |
10464 }; | 10464 }; |
10465 | 10465 |
10466 // Display::Draw (and the planned Display Scheduler) currently rely on resources | 10466 // Display::Draw (and the planned Display Scheduler) currently rely on resources |
10467 // being reclaimed to block drawing between BeginCommit / Swap. This test | 10467 // being reclaimed to block drawing between BeginCommit / Swap. This test |
10468 // ensures that BeginCommit triggers ForceReclaimResources. See | 10468 // ensures that BeginCommit triggers ForceReclaimResources. See |
10469 // crbug.com/489515. | 10469 // crbug.com/489515. |
10470 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { | 10470 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { |
10471 scoped_ptr<MockReclaimResourcesOutputSurface> output_surface( | 10471 std::unique_ptr<MockReclaimResourcesOutputSurface> output_surface( |
10472 MockReclaimResourcesOutputSurface::Create3d()); | 10472 MockReclaimResourcesOutputSurface::Create3d()); |
10473 // Hold an unowned pointer to the output surface to use for mock expectations. | 10473 // Hold an unowned pointer to the output surface to use for mock expectations. |
10474 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); | 10474 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); |
10475 | 10475 |
10476 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 10476 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
10477 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); | 10477 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); |
10478 host_impl_->BeginCommit(); | 10478 host_impl_->BeginCommit(); |
10479 } | 10479 } |
10480 | 10480 |
10481 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 10481 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10608 // There should not be any jitter measured till we hit the fixed point hits | 10608 // There should not be any jitter measured till we hit the fixed point hits |
10609 // threshold. | 10609 // threshold. |
10610 float expected_jitter = | 10610 float expected_jitter = |
10611 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 10611 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
10612 EXPECT_EQ(jitter, expected_jitter); | 10612 EXPECT_EQ(jitter, expected_jitter); |
10613 } | 10613 } |
10614 } | 10614 } |
10615 | 10615 |
10616 } // namespace | 10616 } // namespace |
10617 } // namespace cc | 10617 } // namespace cc |
OLD | NEW |