OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/ws/frame_generator.h" | 5 #include "services/ui/ws/frame_generator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/test/test_message_loop.h" | 10 #include "base/test/test_message_loop.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 constexpr WindowId kRootDisplayId(0, 2); | 27 constexpr WindowId kRootDisplayId(0, 2); |
28 const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create(); | 28 const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create(); |
29 | 29 |
30 // Makes the window visible and creates the default surface for it. | 30 // Makes the window visible and creates the default surface for it. |
31 void InitWindow(ServerWindow* window) { | 31 void InitWindow(ServerWindow* window) { |
32 window->SetVisible(true); | 32 window->SetVisible(true); |
33 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = | 33 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = |
34 window->GetOrCreateCompositorFrameSinkManager(); | 34 window->GetOrCreateCompositorFrameSinkManager(); |
35 compositor_frame_sink_manager->SetLatestSurfaceInfo( | 35 compositor_frame_sink_manager->SetLatestSurfaceInfo( |
36 mojom::CompositorFrameSinkType::DEFAULT, | 36 mojom::CompositorFrameSinkType::DEFAULT, |
37 cc::SurfaceId( | 37 cc::SurfaceInfo( |
38 cc::FrameSinkId( | 38 cc::SurfaceId( |
39 WindowIdToTransportId(window->id()), | 39 cc::FrameSinkId(WindowIdToTransportId(window->id()), |
40 static_cast<uint32_t>(mojom::CompositorFrameSinkType::DEFAULT)), | 40 static_cast<uint32_t>( |
41 cc::LocalFrameId(1u, kArbitraryToken)), | 41 mojom::CompositorFrameSinkType::DEFAULT)), |
42 gfx::Size(100, 100)); | 42 cc::LocalFrameId(1u, kArbitraryToken)), |
| 43 1.0f, gfx::Size(100, 100))); |
43 } | 44 } |
44 | 45 |
45 } // namespace | 46 } // namespace |
46 | 47 |
47 class FrameGeneratorTest : public testing::Test { | 48 class FrameGeneratorTest : public testing::Test { |
48 public: | 49 public: |
49 FrameGeneratorTest() | 50 FrameGeneratorTest() |
50 : root_window_(base::MakeUnique<ServerWindow>(&window_delegate_, | 51 : root_window_(base::MakeUnique<ServerWindow>(&window_delegate_, |
51 kRootDisplayId)) {} | 52 kRootDisplayId)) {} |
52 ~FrameGeneratorTest() override {} | 53 ~FrameGeneratorTest() override {} |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 cc::SharedQuadState* child_sqs = quad_state_list->front(); | 119 cc::SharedQuadState* child_sqs = quad_state_list->front(); |
119 EXPECT_EQ(root_opacity, root_sqs->opacity); | 120 EXPECT_EQ(root_opacity, root_sqs->opacity); |
120 // Child's SharedQuadState contains the effective opacity of the child layer, | 121 // Child's SharedQuadState contains the effective opacity of the child layer, |
121 // which should be a product of the child and the parent opacity. | 122 // which should be a product of the child and the parent opacity. |
122 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); | 123 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); |
123 | 124 |
124 // Pretend to create the UNDERLAY Surface for the child window, and confirm | 125 // Pretend to create the UNDERLAY Surface for the child window, and confirm |
125 // that this creates an extra SharedQuadState in the CompositorFrame. | 126 // that this creates an extra SharedQuadState in the CompositorFrame. |
126 child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo( | 127 child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo( |
127 mojom::CompositorFrameSinkType::UNDERLAY, | 128 mojom::CompositorFrameSinkType::UNDERLAY, |
128 cc::SurfaceId( | 129 cc::SurfaceInfo( |
129 cc::FrameSinkId( | 130 cc::SurfaceId( |
130 WindowIdToTransportId(child_window.id()), | 131 cc::FrameSinkId(WindowIdToTransportId(child_window.id()), |
131 static_cast<uint32_t>(mojom::CompositorFrameSinkType::UNDERLAY)), | 132 static_cast<uint32_t>( |
132 cc::LocalFrameId(1u, kArbitraryToken)), | 133 mojom::CompositorFrameSinkType::UNDERLAY)), |
133 gfx::Size(100, 100)); | 134 cc::LocalFrameId(1u, kArbitraryToken)), |
| 135 1.0f, gfx::Size(100, 100))); |
134 | 136 |
135 render_pass = cc::RenderPass::Create(); | 137 render_pass = cc::RenderPass::Create(); |
136 DrawWindowTree(render_pass.get()); | 138 DrawWindowTree(render_pass.get()); |
137 quad_state_list = &render_pass->shared_quad_state_list; | 139 quad_state_list = &render_pass->shared_quad_state_list; |
138 EXPECT_EQ(3u, quad_state_list->size()); | 140 EXPECT_EQ(3u, quad_state_list->size()); |
139 auto it = quad_state_list->begin(); | 141 auto it = quad_state_list->begin(); |
140 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); | 142 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); |
141 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); | 143 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); |
142 EXPECT_EQ(root_opacity, (*++it)->opacity); | 144 EXPECT_EQ(root_opacity, (*++it)->opacity); |
143 } | 145 } |
144 | 146 |
145 } // namespace test | 147 } // namespace test |
146 } // namespace ws | 148 } // namespace ws |
147 } // namespace ui | 149 } // namespace ui |
OLD | NEW |