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> |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 576 |
577 FakeOutputSurface* fake_output_surface = | 577 FakeOutputSurface* fake_output_surface = |
578 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 578 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
579 EXPECT_EQ(fake_output_surface->num_sent_frames(), 0u); | 579 EXPECT_EQ(fake_output_surface->num_sent_frames(), 0u); |
580 gfx::Transform identity; | 580 gfx::Transform identity; |
581 gfx::Rect viewport(100, 100); | 581 gfx::Rect viewport(100, 100); |
582 const bool resourceless_software_draw = true; | 582 const bool resourceless_software_draw = true; |
583 host_impl_->OnDraw(identity, viewport, viewport, resourceless_software_draw); | 583 host_impl_->OnDraw(identity, viewport, viewport, resourceless_software_draw); |
584 ASSERT_EQ(fake_output_surface->num_sent_frames(), 1u); | 584 ASSERT_EQ(fake_output_surface->num_sent_frames(), 1u); |
585 EXPECT_EQ(gfx::SizeF(100.f, 100.f), | 585 EXPECT_EQ(gfx::SizeF(100.f, 100.f), |
586 fake_output_surface->last_sent_frame().metadata.root_layer_size); | 586 fake_output_surface->last_sent_frame()->metadata.root_layer_size); |
587 } | 587 } |
588 | 588 |
589 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { | 589 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { |
590 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); | 590 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); |
591 | 591 |
592 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 592 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
593 host_impl_->ProcessScrollDeltas(); | 593 host_impl_->ProcessScrollDeltas(); |
594 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 594 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
595 } | 595 } |
596 | 596 |
(...skipping 7752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8349 root->SetPosition(gfx::PointF()); | 8349 root->SetPosition(gfx::PointF()); |
8350 root->SetBounds(gfx::Size(10, 10)); | 8350 root->SetBounds(gfx::Size(10, 10)); |
8351 root->SetDrawsContent(true); | 8351 root->SetDrawsContent(true); |
8352 root->test_properties()->force_render_surface = true; | 8352 root->test_properties()->force_render_surface = true; |
8353 | 8353 |
8354 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8354 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
8355 | 8355 |
8356 FakeOutputSurface* fake_output_surface = | 8356 FakeOutputSurface* fake_output_surface = |
8357 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8357 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
8358 | 8358 |
8359 const std::vector<ui::LatencyInfo>& metadata_latency_before = | |
8360 fake_output_surface->last_sent_frame().metadata.latency_info; | |
8361 EXPECT_TRUE(metadata_latency_before.empty()); | |
8362 | |
8363 ui::LatencyInfo latency_info; | 8359 ui::LatencyInfo latency_info; |
8364 latency_info.AddLatencyNumber( | 8360 latency_info.AddLatencyNumber( |
8365 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 8361 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
8366 std::unique_ptr<SwapPromise> swap_promise( | 8362 std::unique_ptr<SwapPromise> swap_promise( |
8367 new LatencyInfoSwapPromise(latency_info)); | 8363 new LatencyInfoSwapPromise(latency_info)); |
8368 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); | 8364 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); |
8369 host_impl_->SetNeedsRedraw(); | 8365 host_impl_->SetNeedsRedraw(); |
8370 | 8366 |
8371 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8367 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
8372 LayerTreeHostImpl::FrameData frame; | 8368 LayerTreeHostImpl::FrameData frame; |
8373 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 8369 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
8374 host_impl_->DrawLayers(&frame); | 8370 host_impl_->DrawLayers(&frame); |
8375 host_impl_->DidDrawAllLayers(frame); | 8371 host_impl_->DidDrawAllLayers(frame); |
8376 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 8372 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
8377 | 8373 |
8378 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 8374 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
8379 fake_output_surface->last_sent_frame().metadata.latency_info; | 8375 fake_output_surface->last_sent_frame()->metadata.latency_info; |
8380 EXPECT_EQ(1u, metadata_latency_after.size()); | 8376 EXPECT_EQ(1u, metadata_latency_after.size()); |
8381 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 8377 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
8382 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 8378 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
8383 } | 8379 } |
8384 | 8380 |
8385 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 8381 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
8386 int root_layer_id = 1; | 8382 int root_layer_id = 1; |
8387 std::unique_ptr<SolidColorLayerImpl> root = | 8383 std::unique_ptr<SolidColorLayerImpl> root = |
8388 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 8384 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
8389 root->SetPosition(gfx::PointF()); | 8385 root->SetPosition(gfx::PointF()); |
8390 root->SetBounds(gfx::Size(10, 10)); | 8386 root->SetBounds(gfx::Size(10, 10)); |
8391 root->SetDrawsContent(true); | 8387 root->SetDrawsContent(true); |
8392 root->test_properties()->force_render_surface = true; | 8388 root->test_properties()->force_render_surface = true; |
8393 | 8389 |
8394 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8390 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
8395 | 8391 |
8396 // Ensure the default frame selection bounds are empty. | 8392 // Ensure the default frame selection bounds are empty. |
8397 FakeOutputSurface* fake_output_surface = | 8393 FakeOutputSurface* fake_output_surface = |
8398 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8394 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
8399 const Selection<gfx::SelectionBound>& selection_before = | |
8400 fake_output_surface->last_sent_frame().metadata.selection; | |
8401 EXPECT_EQ(gfx::SelectionBound(), selection_before.start); | |
8402 EXPECT_EQ(gfx::SelectionBound(), selection_before.end); | |
8403 | 8395 |
8404 // Plumb the layer-local selection bounds. | 8396 // Plumb the layer-local selection bounds. |
8405 gfx::Point selection_top(5, 0); | 8397 gfx::Point selection_top(5, 0); |
8406 gfx::Point selection_bottom(5, 5); | 8398 gfx::Point selection_bottom(5, 5); |
8407 LayerSelection selection; | 8399 LayerSelection selection; |
8408 selection.start.type = gfx::SelectionBound::CENTER; | 8400 selection.start.type = gfx::SelectionBound::CENTER; |
8409 selection.start.layer_id = root_layer_id; | 8401 selection.start.layer_id = root_layer_id; |
8410 selection.start.edge_bottom = selection_bottom; | 8402 selection.start.edge_bottom = selection_bottom; |
8411 selection.start.edge_top = selection_top; | 8403 selection.start.edge_top = selection_top; |
8412 selection.end = selection.start; | 8404 selection.end = selection.start; |
8413 host_impl_->active_tree()->RegisterSelection(selection); | 8405 host_impl_->active_tree()->RegisterSelection(selection); |
8414 | 8406 |
8415 // Trigger a draw-swap sequence. | 8407 // Trigger a draw-swap sequence. |
8416 host_impl_->SetNeedsRedraw(); | 8408 host_impl_->SetNeedsRedraw(); |
8417 | 8409 |
8418 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8410 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
8419 LayerTreeHostImpl::FrameData frame; | 8411 LayerTreeHostImpl::FrameData frame; |
8420 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 8412 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
8421 host_impl_->DrawLayers(&frame); | 8413 host_impl_->DrawLayers(&frame); |
8422 host_impl_->DidDrawAllLayers(frame); | 8414 host_impl_->DidDrawAllLayers(frame); |
8423 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 8415 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
8424 | 8416 |
8425 // Ensure the selection bounds have propagated to the frame metadata. | 8417 // Ensure the selection bounds have propagated to the frame metadata. |
8426 const Selection<gfx::SelectionBound>& selection_after = | 8418 const Selection<gfx::SelectionBound>& selection_after = |
8427 fake_output_surface->last_sent_frame().metadata.selection; | 8419 fake_output_surface->last_sent_frame()->metadata.selection; |
8428 EXPECT_EQ(selection.start.type, selection_after.start.type()); | 8420 EXPECT_EQ(selection.start.type, selection_after.start.type()); |
8429 EXPECT_EQ(selection.end.type, selection_after.end.type()); | 8421 EXPECT_EQ(selection.end.type, selection_after.end.type()); |
8430 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); | 8422 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); |
8431 EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top()); | 8423 EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top()); |
8432 EXPECT_TRUE(selection_after.start.visible()); | 8424 EXPECT_TRUE(selection_after.start.visible()); |
8433 EXPECT_TRUE(selection_after.start.visible()); | 8425 EXPECT_TRUE(selection_after.start.visible()); |
8434 } | 8426 } |
8435 | 8427 |
8436 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { | 8428 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { |
8437 public: | 8429 public: |
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10903 | 10895 |
10904 // Re-initialize with a software output surface. | 10896 // Re-initialize with a software output surface. |
10905 output_surface_ = FakeOutputSurface::CreateSoftware( | 10897 output_surface_ = FakeOutputSurface::CreateSoftware( |
10906 base::WrapUnique(new SoftwareOutputDevice)); | 10898 base::WrapUnique(new SoftwareOutputDevice)); |
10907 host_impl_->InitializeRenderer(output_surface_.get()); | 10899 host_impl_->InitializeRenderer(output_surface_.get()); |
10908 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10900 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10909 } | 10901 } |
10910 | 10902 |
10911 } // namespace | 10903 } // namespace |
10912 } // namespace cc | 10904 } // namespace cc |
OLD | NEW |