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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2096493002: Make cc::CompositorFrames movable [Part 1 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix reflector Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #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
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 7726 matching lines...) Expand 10 before | Expand all | Expand 10 after
8323 root->SetPosition(gfx::PointF()); 8323 root->SetPosition(gfx::PointF());
8324 root->SetBounds(gfx::Size(10, 10)); 8324 root->SetBounds(gfx::Size(10, 10));
8325 root->SetDrawsContent(true); 8325 root->SetDrawsContent(true);
8326 root->test_properties()->force_render_surface = true; 8326 root->test_properties()->force_render_surface = true;
8327 8327
8328 host_impl_->active_tree()->SetRootLayer(std::move(root)); 8328 host_impl_->active_tree()->SetRootLayer(std::move(root));
8329 8329
8330 FakeOutputSurface* fake_output_surface = 8330 FakeOutputSurface* fake_output_surface =
8331 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); 8331 static_cast<FakeOutputSurface*>(host_impl_->output_surface());
8332 8332
8333 const std::vector<ui::LatencyInfo>& metadata_latency_before = 8333 EXPECT_FALSE(fake_output_surface->last_sent_frame());
8334 fake_output_surface->last_sent_frame().metadata.latency_info;
8335 EXPECT_TRUE(metadata_latency_before.empty());
8336 8334
8337 ui::LatencyInfo latency_info; 8335 ui::LatencyInfo latency_info;
8338 latency_info.AddLatencyNumber( 8336 latency_info.AddLatencyNumber(
8339 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); 8337 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0);
8340 std::unique_ptr<SwapPromise> swap_promise( 8338 std::unique_ptr<SwapPromise> swap_promise(
8341 new LatencyInfoSwapPromise(latency_info)); 8339 new LatencyInfoSwapPromise(latency_info));
8342 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); 8340 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise));
8343 host_impl_->SetNeedsRedraw(); 8341 host_impl_->SetNeedsRedraw();
8344 8342
8345 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 8343 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
8346 LayerTreeHostImpl::FrameData frame; 8344 LayerTreeHostImpl::FrameData frame;
8347 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 8345 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
8348 host_impl_->DrawLayers(&frame); 8346 host_impl_->DrawLayers(&frame);
8349 host_impl_->DidDrawAllLayers(frame); 8347 host_impl_->DidDrawAllLayers(frame);
8350 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); 8348 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
8351 8349
8352 const std::vector<ui::LatencyInfo>& metadata_latency_after = 8350 const std::vector<ui::LatencyInfo>& metadata_latency_after =
8353 fake_output_surface->last_sent_frame().metadata.latency_info; 8351 fake_output_surface->last_sent_frame()->metadata.latency_info;
8354 EXPECT_EQ(1u, metadata_latency_after.size()); 8352 EXPECT_EQ(1u, metadata_latency_after.size());
8355 EXPECT_TRUE(metadata_latency_after[0].FindLatency( 8353 EXPECT_TRUE(metadata_latency_after[0].FindLatency(
8356 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); 8354 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL));
8357 } 8355 }
8358 8356
8359 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { 8357 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) {
8360 int root_layer_id = 1; 8358 int root_layer_id = 1;
8361 std::unique_ptr<SolidColorLayerImpl> root = 8359 std::unique_ptr<SolidColorLayerImpl> root =
8362 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); 8360 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id);
8363 root->SetPosition(gfx::PointF()); 8361 root->SetPosition(gfx::PointF());
8364 root->SetBounds(gfx::Size(10, 10)); 8362 root->SetBounds(gfx::Size(10, 10));
8365 root->SetDrawsContent(true); 8363 root->SetDrawsContent(true);
8366 root->test_properties()->force_render_surface = true; 8364 root->test_properties()->force_render_surface = true;
8367 8365
8368 host_impl_->active_tree()->SetRootLayer(std::move(root)); 8366 host_impl_->active_tree()->SetRootLayer(std::move(root));
8369 8367
8370 // Ensure the default frame selection bounds are empty.
8371 FakeOutputSurface* fake_output_surface = 8368 FakeOutputSurface* fake_output_surface =
8372 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); 8369 static_cast<FakeOutputSurface*>(host_impl_->output_surface());
8373 const Selection<gfx::SelectionBound>& selection_before = 8370 EXPECT_FALSE(fake_output_surface->last_sent_frame());
8374 fake_output_surface->last_sent_frame().metadata.selection;
8375 EXPECT_EQ(gfx::SelectionBound(), selection_before.start);
8376 EXPECT_EQ(gfx::SelectionBound(), selection_before.end);
8377 8371
8378 // Plumb the layer-local selection bounds. 8372 // Plumb the layer-local selection bounds.
8379 gfx::Point selection_top(5, 0); 8373 gfx::Point selection_top(5, 0);
8380 gfx::Point selection_bottom(5, 5); 8374 gfx::Point selection_bottom(5, 5);
8381 LayerSelection selection; 8375 LayerSelection selection;
8382 selection.start.type = gfx::SelectionBound::CENTER; 8376 selection.start.type = gfx::SelectionBound::CENTER;
8383 selection.start.layer_id = root_layer_id; 8377 selection.start.layer_id = root_layer_id;
8384 selection.start.edge_bottom = selection_bottom; 8378 selection.start.edge_bottom = selection_bottom;
8385 selection.start.edge_top = selection_top; 8379 selection.start.edge_top = selection_top;
8386 selection.end = selection.start; 8380 selection.end = selection.start;
8387 host_impl_->active_tree()->RegisterSelection(selection); 8381 host_impl_->active_tree()->RegisterSelection(selection);
8388 8382
8389 // Trigger a draw-swap sequence. 8383 // Trigger a draw-swap sequence.
8390 host_impl_->SetNeedsRedraw(); 8384 host_impl_->SetNeedsRedraw();
8391 8385
8392 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 8386 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
8393 LayerTreeHostImpl::FrameData frame; 8387 LayerTreeHostImpl::FrameData frame;
8394 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 8388 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
8395 host_impl_->DrawLayers(&frame); 8389 host_impl_->DrawLayers(&frame);
8396 host_impl_->DidDrawAllLayers(frame); 8390 host_impl_->DidDrawAllLayers(frame);
8397 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); 8391 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
8398 8392
8399 // Ensure the selection bounds have propagated to the frame metadata. 8393 // Ensure the selection bounds have propagated to the frame metadata.
8400 const Selection<gfx::SelectionBound>& selection_after = 8394 const Selection<gfx::SelectionBound>& selection_after =
8401 fake_output_surface->last_sent_frame().metadata.selection; 8395 fake_output_surface->last_sent_frame()->metadata.selection;
8402 EXPECT_EQ(selection.start.type, selection_after.start.type()); 8396 EXPECT_EQ(selection.start.type, selection_after.start.type());
8403 EXPECT_EQ(selection.end.type, selection_after.end.type()); 8397 EXPECT_EQ(selection.end.type, selection_after.end.type());
8404 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); 8398 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom());
8405 EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top()); 8399 EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top());
8406 EXPECT_TRUE(selection_after.start.visible()); 8400 EXPECT_TRUE(selection_after.start.visible());
8407 EXPECT_TRUE(selection_after.start.visible()); 8401 EXPECT_TRUE(selection_after.start.visible());
8408 } 8402 }
8409 8403
8410 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { 8404 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor {
8411 public: 8405 public:
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after
10877 10871
10878 // Re-initialize with a software output surface. 10872 // Re-initialize with a software output surface.
10879 output_surface_ = FakeOutputSurface::CreateSoftware( 10873 output_surface_ = FakeOutputSurface::CreateSoftware(
10880 base::WrapUnique(new SoftwareOutputDevice)); 10874 base::WrapUnique(new SoftwareOutputDevice));
10881 host_impl_->InitializeRenderer(output_surface_.get()); 10875 host_impl_->InitializeRenderer(output_surface_.get());
10882 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10876 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10883 } 10877 }
10884 10878
10885 } // namespace 10879 } // namespace
10886 } // namespace cc 10880 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698