| 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/ids.h" | 13 #include "services/ui/ws/ids.h" |
| 14 #include "services/ui/ws/platform_display_init_params.h" | 14 #include "services/ui/ws/platform_display_init_params.h" |
| 15 #include "services/ui/ws/server_window.h" | 15 #include "services/ui/ws/server_window.h" |
| 16 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" | 16 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" |
| 17 #include "services/ui/ws/test_server_window_delegate.h" | 17 #include "services/ui/ws/test_server_window_delegate.h" |
| 18 #include "services/ui/ws/test_utils.h" | 18 #include "services/ui/ws/test_utils.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace ui { | 21 namespace ui { |
| 22 namespace ws { | 22 namespace ws { |
| 23 namespace test { | 23 namespace test { |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Typical id for the display root ServerWindow. | 26 // Typical id for the display root ServerWindow. |
| 27 constexpr WindowId kRootDisplayId(0, 2); | 27 constexpr WindowId kRootDisplayId(0, 2); |
| 28 const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create(); |
| 28 | 29 |
| 29 // Makes the window visible and creates the default surface for it. | 30 // Makes the window visible and creates the default surface for it. |
| 30 void InitWindow(ServerWindow* window) { | 31 void InitWindow(ServerWindow* window) { |
| 31 window->SetVisible(true); | 32 window->SetVisible(true); |
| 32 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = | 33 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = |
| 33 window->GetOrCreateCompositorFrameSinkManager(); | 34 window->GetOrCreateCompositorFrameSinkManager(); |
| 34 compositor_frame_sink_manager->SetLatestSurfaceInfo( | 35 compositor_frame_sink_manager->SetLatestSurfaceInfo( |
| 35 mojom::CompositorFrameSinkType::DEFAULT, | 36 mojom::CompositorFrameSinkType::DEFAULT, |
| 36 cc::SurfaceId( | 37 cc::SurfaceId( |
| 37 cc::FrameSinkId( | 38 cc::FrameSinkId( |
| 38 WindowIdToTransportId(window->id()), | 39 WindowIdToTransportId(window->id()), |
| 39 static_cast<uint32_t>(mojom::CompositorFrameSinkType::DEFAULT)), | 40 static_cast<uint32_t>(mojom::CompositorFrameSinkType::DEFAULT)), |
| 40 cc::LocalFrameId(1u, 1u)), | 41 cc::LocalFrameId(1u, kArbitraryToken)), |
| 41 gfx::Size(100, 100)); | 42 gfx::Size(100, 100)); |
| 42 } | 43 } |
| 43 | 44 |
| 44 } // namespace | 45 } // namespace |
| 45 | 46 |
| 46 class FrameGeneratorTest : public testing::Test { | 47 class FrameGeneratorTest : public testing::Test { |
| 47 public: | 48 public: |
| 48 FrameGeneratorTest() | 49 FrameGeneratorTest() |
| 49 : display_compositor_(new DisplayCompositor(nullptr)), | 50 : display_compositor_(new DisplayCompositor(nullptr)), |
| 50 root_window_(base::MakeUnique<ServerWindow>(&window_delegate_, | 51 root_window_(base::MakeUnique<ServerWindow>(&window_delegate_, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); | 125 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); |
| 125 | 126 |
| 126 // Pretend to create the UNDERLAY Surface for the child window, and confirm | 127 // Pretend to create the UNDERLAY Surface for the child window, and confirm |
| 127 // that this creates an extra SharedQuadState in the CompositorFrame. | 128 // that this creates an extra SharedQuadState in the CompositorFrame. |
| 128 child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo( | 129 child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo( |
| 129 mojom::CompositorFrameSinkType::UNDERLAY, | 130 mojom::CompositorFrameSinkType::UNDERLAY, |
| 130 cc::SurfaceId( | 131 cc::SurfaceId( |
| 131 cc::FrameSinkId( | 132 cc::FrameSinkId( |
| 132 WindowIdToTransportId(child_window.id()), | 133 WindowIdToTransportId(child_window.id()), |
| 133 static_cast<uint32_t>(mojom::CompositorFrameSinkType::UNDERLAY)), | 134 static_cast<uint32_t>(mojom::CompositorFrameSinkType::UNDERLAY)), |
| 134 cc::LocalFrameId(1u, 1u)), | 135 cc::LocalFrameId(1u, kArbitraryToken)), |
| 135 gfx::Size(100, 100)); | 136 gfx::Size(100, 100)); |
| 136 | 137 |
| 137 render_pass = cc::RenderPass::Create(); | 138 render_pass = cc::RenderPass::Create(); |
| 138 DrawWindowTree(render_pass.get()); | 139 DrawWindowTree(render_pass.get()); |
| 139 quad_state_list = &render_pass->shared_quad_state_list; | 140 quad_state_list = &render_pass->shared_quad_state_list; |
| 140 EXPECT_EQ(3u, quad_state_list->size()); | 141 EXPECT_EQ(3u, quad_state_list->size()); |
| 141 auto it = quad_state_list->begin(); | 142 auto it = quad_state_list->begin(); |
| 142 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); | 143 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); |
| 143 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); | 144 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); |
| 144 EXPECT_EQ(root_opacity, (*++it)->opacity); | 145 EXPECT_EQ(root_opacity, (*++it)->opacity); |
| 145 } | 146 } |
| 146 | 147 |
| 147 } // namespace test | 148 } // namespace test |
| 148 } // namespace ws | 149 } // namespace ws |
| 149 } // namespace ui | 150 } // namespace ui |
| OLD | NEW |