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

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

Issue 2803913004: cc: Introduce embedded_surfaces in metadata for surface Ids in draw quads (Closed)
Patch Set: Addressed Dana's comments Created 3 years, 8 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 12 matching lines...) Expand all
23 #include "cc/input/browser_controls_offset_manager.h" 23 #include "cc/input/browser_controls_offset_manager.h"
24 #include "cc/input/main_thread_scrolling_reason.h" 24 #include "cc/input/main_thread_scrolling_reason.h"
25 #include "cc/input/page_scale_animation.h" 25 #include "cc/input/page_scale_animation.h"
26 #include "cc/layers/append_quads_data.h" 26 #include "cc/layers/append_quads_data.h"
27 #include "cc/layers/heads_up_display_layer_impl.h" 27 #include "cc/layers/heads_up_display_layer_impl.h"
28 #include "cc/layers/layer_impl.h" 28 #include "cc/layers/layer_impl.h"
29 #include "cc/layers/painted_scrollbar_layer_impl.h" 29 #include "cc/layers/painted_scrollbar_layer_impl.h"
30 #include "cc/layers/render_surface_impl.h" 30 #include "cc/layers/render_surface_impl.h"
31 #include "cc/layers/solid_color_layer_impl.h" 31 #include "cc/layers/solid_color_layer_impl.h"
32 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 32 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
33 #include "cc/layers/surface_layer_impl.h"
33 #include "cc/layers/texture_layer_impl.h" 34 #include "cc/layers/texture_layer_impl.h"
34 #include "cc/layers/video_layer_impl.h" 35 #include "cc/layers/video_layer_impl.h"
35 #include "cc/layers/viewport.h" 36 #include "cc/layers/viewport.h"
36 #include "cc/output/begin_frame_args.h" 37 #include "cc/output/begin_frame_args.h"
37 #include "cc/output/compositor_frame_metadata.h" 38 #include "cc/output/compositor_frame_metadata.h"
38 #include "cc/output/copy_output_request.h" 39 #include "cc/output/copy_output_request.h"
39 #include "cc/output/copy_output_result.h" 40 #include "cc/output/copy_output_result.h"
40 #include "cc/output/gl_renderer.h" 41 #include "cc/output/gl_renderer.h"
41 #include "cc/output/latency_info_swap_promise.h" 42 #include "cc/output/latency_info_swap_promise.h"
42 #include "cc/quads/render_pass_draw_quad.h" 43 #include "cc/quads/render_pass_draw_quad.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 using ::testing::Mock; 87 using ::testing::Mock;
87 using ::testing::Return; 88 using ::testing::Return;
88 using ::testing::AnyNumber; 89 using ::testing::AnyNumber;
89 using ::testing::AtLeast; 90 using ::testing::AtLeast;
90 using ::testing::_; 91 using ::testing::_;
91 using media::VideoFrame; 92 using media::VideoFrame;
92 93
93 namespace cc { 94 namespace cc {
94 namespace { 95 namespace {
95 96
97 SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) {
98 return SurfaceId(
99 frame_sink_id,
100 LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u)));
101 }
102
96 struct TestFrameData : public LayerTreeHostImpl::FrameData { 103 struct TestFrameData : public LayerTreeHostImpl::FrameData {
97 TestFrameData() { 104 TestFrameData() {
98 // Set ack to something valid, so DCHECKs don't complain. 105 // Set ack to something valid, so DCHECKs don't complain.
99 begin_frame_ack = BeginFrameAck(0, 1, 1, true); 106 begin_frame_ack = BeginFrameAck(0, 1, 1, true);
100 } 107 }
101 }; 108 };
102 109
103 class LayerTreeHostImplTest : public testing::Test, 110 class LayerTreeHostImplTest : public testing::Test,
104 public LayerTreeHostImplClient { 111 public LayerTreeHostImplClient {
105 public: 112 public:
(...skipping 3368 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 } 3481 }
3475 3482
3476 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { 3483 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) {
3477 SetupMouseMoveAtWithDeviceScale(1.f); 3484 SetupMouseMoveAtWithDeviceScale(1.f);
3478 } 3485 }
3479 3486
3480 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { 3487 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) {
3481 SetupMouseMoveAtWithDeviceScale(2.f); 3488 SetupMouseMoveAtWithDeviceScale(2.f);
3482 } 3489 }
3483 3490
3491 // This test verifies that only SurfaceLayers in the viewport are included
3492 // in CompositorFrameMetadata's |embedded_surfaces|.
3493 TEST_F(LayerTreeHostImplTest, EmbeddedSurfacesInMetadata) {
3494 SetupScrollAndContentsLayers(gfx::Size(100, 100));
3495 host_impl_->SetViewportSize(gfx::Size(50, 50));
3496 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
3497
3498 std::vector<SurfaceId> children = {MakeSurfaceId(FrameSinkId(1, 1), 1),
3499 MakeSurfaceId(FrameSinkId(2, 2), 2),
3500 MakeSurfaceId(FrameSinkId(3, 3), 3)};
3501 for (size_t i = 0; i < children.size(); ++i) {
3502 std::unique_ptr<SurfaceLayerImpl> child =
3503 SurfaceLayerImpl::Create(host_impl_->active_tree(), i + 6);
3504 child->SetPosition(gfx::PointF(25.f * i, 0.f));
3505 child->SetBounds(gfx::Size(1, 1));
3506 child->SetDrawsContent(true);
3507 child->SetPrimarySurfaceInfo(
3508 SurfaceInfo(children[i], 1.f /* device_scale_factor */,
3509 gfx::Size(10, 10) /* size_in_pixels */));
3510 root->test_properties()->AddChild(std::move(child));
3511 }
3512
3513 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3514 DrawFrame();
3515
3516 FakeCompositorFrameSink* fake_compositor_frame_sink =
3517 static_cast<FakeCompositorFrameSink*>(
3518 host_impl_->compositor_frame_sink());
3519 const CompositorFrameMetadata& metadata =
3520 fake_compositor_frame_sink->last_sent_frame()->metadata;
3521 EXPECT_THAT(metadata.embedded_surfaces,
3522 testing::UnorderedElementsAre(children[0], children[1]));
3523 EXPECT_THAT(
3524 metadata.referenced_surfaces,
3525 testing::UnorderedElementsAre(children[0], children[1], children[2]));
3526 }
3527
3484 TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) { 3528 TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) {
3485 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 3529 SetupScrollAndContentsLayers(gfx::Size(100, 100));
3486 host_impl_->SetViewportSize(gfx::Size(50, 50)); 3530 host_impl_->SetViewportSize(gfx::Size(50, 50));
3487 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 3531 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
3488 DrawFrame(); 3532 DrawFrame();
3489 { 3533 {
3490 CompositorFrameMetadata metadata = 3534 CompositorFrameMetadata metadata =
3491 host_impl_->MakeCompositorFrameMetadata(); 3535 host_impl_->MakeCompositorFrameMetadata();
3492 EXPECT_EQ(gfx::Vector2dF(), metadata.root_scroll_offset); 3536 EXPECT_EQ(gfx::Vector2dF(), metadata.root_scroll_offset);
3493 EXPECT_EQ(1.f, metadata.page_scale_factor); 3537 EXPECT_EQ(1.f, metadata.page_scale_factor);
(...skipping 8758 matching lines...) Expand 10 before | Expand all | Expand 10 after
12252 else 12296 else
12253 EXPECT_FALSE(tile->HasRasterTask()); 12297 EXPECT_FALSE(tile->HasRasterTask());
12254 } 12298 }
12255 Region expected_invalidation( 12299 Region expected_invalidation(
12256 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12300 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12257 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12301 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12258 } 12302 }
12259 12303
12260 } // namespace 12304 } // namespace
12261 } // namespace cc 12305 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698