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/test/test_message_loop.h" | 9 #include "base/test/test_message_loop.h" |
10 #include "cc/quads/render_pass.h" | 10 #include "cc/quads/render_pass.h" |
11 #include "cc/quads/shared_quad_state.h" | 11 #include "cc/quads/shared_quad_state.h" |
12 #include "services/ui/surfaces/display_compositor.h" | 12 #include "services/ui/surfaces/display_compositor.h" |
13 #include "services/ui/ws/platform_display_init_params.h" | 13 #include "services/ui/ws/platform_display_init_params.h" |
14 #include "services/ui/ws/server_window.h" | 14 #include "services/ui/ws/server_window.h" |
15 #include "services/ui/ws/server_window_surface_manager.h" | 15 #include "services/ui/ws/server_window_surface_manager.h" |
16 #include "services/ui/ws/test_server_window_delegate.h" | 16 #include "services/ui/ws/test_server_window_delegate.h" |
17 #include "services/ui/ws/test_utils.h" | 17 #include "services/ui/ws/test_utils.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace ui { | 20 namespace ui { |
21 namespace ws { | 21 namespace ws { |
22 namespace test { | 22 namespace test { |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Makes the window visible and creates the default surface for it. | 25 // Makes the window visible and creates the default surface for it. |
26 void InitWindow(ServerWindow* window) { | 26 void InitWindow(ServerWindow* window) { |
27 window->SetVisible(true); | 27 window->SetVisible(true); |
28 ServerWindowSurfaceManager* surface_manager = | 28 ServerWindowSurfaceManager* surface_manager = |
29 window->GetOrCreateSurfaceManager(); | 29 window->GetOrCreateCompositorFrameSinkManager(); |
30 surface_manager->CreateSurface( | 30 surface_manager->CreateCompositorFrameSink( |
31 mojom::SurfaceType::DEFAULT, | 31 mojom::CompositorFrameSinkType::DEFAULT, |
32 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink>(), | 32 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink>(), |
33 cc::mojom::MojoCompositorFrameSinkClientPtr()); | 33 cc::mojom::MojoCompositorFrameSinkClientPtr()); |
34 } | 34 } |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 class FrameGeneratorTest : public testing::Test { | 38 class FrameGeneratorTest : public testing::Test { |
39 public: | 39 public: |
40 FrameGeneratorTest() : display_compositor_(new DisplayCompositor(nullptr)) {} | 40 FrameGeneratorTest() : display_compositor_(new DisplayCompositor(nullptr)) {} |
41 ~FrameGeneratorTest() override {} | 41 ~FrameGeneratorTest() override {} |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 EXPECT_EQ(2u, quad_state_list->size()); | 107 EXPECT_EQ(2u, quad_state_list->size()); |
108 cc::SharedQuadState* root_sqs = quad_state_list->back(); | 108 cc::SharedQuadState* root_sqs = quad_state_list->back(); |
109 cc::SharedQuadState* child_sqs = quad_state_list->front(); | 109 cc::SharedQuadState* child_sqs = quad_state_list->front(); |
110 EXPECT_EQ(root_opacity, root_sqs->opacity); | 110 EXPECT_EQ(root_opacity, root_sqs->opacity); |
111 // Child's SharedQuadState contains the effective opacity of the child layer, | 111 // Child's SharedQuadState contains the effective opacity of the child layer, |
112 // which should be a product of the child and the parent opacity. | 112 // which should be a product of the child and the parent opacity. |
113 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); | 113 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); |
114 | 114 |
115 // Create the UNDERLAY Surface for the child window, and confirm that this | 115 // Create the UNDERLAY Surface for the child window, and confirm that this |
116 // creates an extra SharedQuadState in the CompositorFrame. | 116 // creates an extra SharedQuadState in the CompositorFrame. |
117 child_window.GetOrCreateSurfaceManager()->CreateSurface( | 117 child_window.GetOrCreateCompositorFrameSinkManager() |
118 mojom::SurfaceType::UNDERLAY, | 118 ->CreateCompositorFrameSink( |
119 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink>(), | 119 mojom::CompositorFrameSinkType::UNDERLAY, |
120 cc::mojom::MojoCompositorFrameSinkClientPtr()); | 120 cc::mojom::MojoCompositorFrameSinkRequest(), |
| 121 cc::mojom::MojoCompositorFrameSinkClientPtr()); |
121 | 122 |
122 render_pass = cc::RenderPass::Create(); | 123 render_pass = cc::RenderPass::Create(); |
123 DrawWindowTree(render_pass.get()); | 124 DrawWindowTree(render_pass.get()); |
124 quad_state_list = &render_pass->shared_quad_state_list; | 125 quad_state_list = &render_pass->shared_quad_state_list; |
125 EXPECT_EQ(3u, quad_state_list->size()); | 126 EXPECT_EQ(3u, quad_state_list->size()); |
126 auto it = quad_state_list->begin(); | 127 auto it = quad_state_list->begin(); |
127 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); | 128 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); |
128 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); | 129 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); |
129 EXPECT_EQ(root_opacity, (*++it)->opacity); | 130 EXPECT_EQ(root_opacity, (*++it)->opacity); |
130 } | 131 } |
131 | 132 |
132 } // namespace test | 133 } // namespace test |
133 } // namespace ws | 134 } // namespace ws |
134 } // namespace ui | 135 } // namespace ui |
OLD | NEW |