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/surfaces/display_compositor.h" | 5 #include "services/ui/surfaces/display_compositor.h" |
6 | 6 |
7 #include "cc/output/copy_output_request.h" | 7 #include "cc/output/copy_output_request.h" |
8 #include "cc/output/output_surface.h" | 8 #include "cc/output/output_surface.h" |
9 #include "cc/output/renderer_settings.h" | 9 #include "cc/output/renderer_settings.h" |
10 #include "cc/output/texture_mailbox_deleter.h" | 10 #include "cc/output/texture_mailbox_deleter.h" |
11 #include "cc/scheduler/begin_frame_source.h" | 11 #include "cc/scheduler/begin_frame_source.h" |
12 #include "cc/scheduler/delay_based_time_source.h" | 12 #include "cc/scheduler/delay_based_time_source.h" |
13 #include "cc/surfaces/display.h" | 13 #include "cc/surfaces/display.h" |
14 #include "cc/surfaces/display_scheduler.h" | 14 #include "cc/surfaces/display_scheduler.h" |
| 15 #include "cc/surfaces/frame_sink_id.h" |
15 #include "gpu/ipc/client/gpu_channel_host.h" | 16 #include "gpu/ipc/client/gpu_channel_host.h" |
16 #include "services/ui/surfaces/direct_output_surface.h" | 17 #include "services/ui/surfaces/direct_output_surface.h" |
17 #include "services/ui/surfaces/surfaces_context_provider.h" | 18 #include "services/ui/surfaces/surfaces_context_provider.h" |
18 | 19 |
19 #if defined(USE_OZONE) | 20 #if defined(USE_OZONE) |
20 #include "gpu/command_buffer/client/gles2_interface.h" | 21 #include "gpu/command_buffer/client/gles2_interface.h" |
21 #include "services/ui/surfaces/direct_output_surface_ozone.h" | 22 #include "services/ui/surfaces/direct_output_surface_ozone.h" |
22 #endif | 23 #endif |
23 | 24 |
24 namespace ui { | 25 namespace ui { |
25 | 26 |
26 DisplayCompositor::DisplayCompositor( | 27 DisplayCompositor::DisplayCompositor( |
27 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
28 gfx::AcceleratedWidget widget, | 29 gfx::AcceleratedWidget widget, |
29 scoped_refptr<gpu::GpuChannelHost> gpu_channel, | 30 scoped_refptr<gpu::GpuChannelHost> gpu_channel, |
30 const scoped_refptr<SurfacesState>& surfaces_state) | 31 const scoped_refptr<SurfacesState>& surfaces_state) |
31 : task_runner_(task_runner), | 32 : task_runner_(task_runner), |
32 surfaces_state_(surfaces_state), | 33 surfaces_state_(surfaces_state), |
33 factory_(surfaces_state->manager(), this), | 34 factory_(surfaces_state->manager(), this), |
34 allocator_(surfaces_state->next_client_id()) { | 35 allocator_(cc::FrameSinkId(surfaces_state->next_client_id(), 0)) { |
35 surfaces_state_->manager()->RegisterSurfaceClientId(allocator_.client_id()); | 36 surfaces_state_->manager()->RegisterFrameSinkId(allocator_.frame_sink_id()); |
36 surfaces_state_->manager()->RegisterSurfaceFactoryClient( | 37 surfaces_state_->manager()->RegisterSurfaceFactoryClient( |
37 allocator_.client_id(), this); | 38 allocator_.frame_sink_id(), this); |
38 | 39 |
39 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = | 40 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = |
40 gpu_channel->gpu_memory_buffer_manager(); | 41 gpu_channel->gpu_memory_buffer_manager(); |
41 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( | 42 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( |
42 new SurfacesContextProvider(widget, std::move(gpu_channel))); | 43 new SurfacesContextProvider(widget, std::move(gpu_channel))); |
43 // TODO(rjkroege): If there is something better to do than CHECK, add it. | 44 // TODO(rjkroege): If there is something better to do than CHECK, add it. |
44 CHECK(surfaces_context_provider->BindToCurrentThread()); | 45 CHECK(surfaces_context_provider->BindToCurrentThread()); |
45 | 46 |
46 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( | 47 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( |
47 new cc::DelayBasedBeginFrameSource( | 48 new cc::DelayBasedBeginFrameSource( |
(...skipping 20 matching lines...) Expand all Loading... |
68 std::unique_ptr<cc::DisplayScheduler> scheduler( | 69 std::unique_ptr<cc::DisplayScheduler> scheduler( |
69 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), | 70 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), |
70 task_runner_.get(), max_frames_pending)); | 71 task_runner_.get(), max_frames_pending)); |
71 | 72 |
72 display_.reset(new cc::Display( | 73 display_.reset(new cc::Display( |
73 nullptr /* bitmap_manager */, gpu_memory_buffer_manager, | 74 nullptr /* bitmap_manager */, gpu_memory_buffer_manager, |
74 cc::RendererSettings(), std::move(synthetic_begin_frame_source), | 75 cc::RendererSettings(), std::move(synthetic_begin_frame_source), |
75 std::move(display_output_surface), std::move(scheduler), | 76 std::move(display_output_surface), std::move(scheduler), |
76 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); | 77 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); |
77 display_->Initialize(this, surfaces_state_->manager(), | 78 display_->Initialize(this, surfaces_state_->manager(), |
78 allocator_.client_id()); | 79 allocator_.frame_sink_id()); |
79 display_->SetVisible(true); | 80 display_->SetVisible(true); |
80 } | 81 } |
81 | 82 |
82 DisplayCompositor::~DisplayCompositor() { | 83 DisplayCompositor::~DisplayCompositor() { |
83 surfaces_state_->manager()->UnregisterSurfaceFactoryClient( | 84 surfaces_state_->manager()->UnregisterSurfaceFactoryClient( |
84 allocator_.client_id()); | 85 allocator_.frame_sink_id()); |
85 surfaces_state_->manager()->InvalidateSurfaceClientId(allocator_.client_id()); | 86 surfaces_state_->manager()->InvalidateFrameSinkId(allocator_.frame_sink_id()); |
86 } | 87 } |
87 | 88 |
88 void DisplayCompositor::SubmitCompositorFrame( | 89 void DisplayCompositor::SubmitCompositorFrame( |
89 cc::CompositorFrame frame, | 90 cc::CompositorFrame frame, |
90 const base::Callback<void()>& callback) { | 91 const base::Callback<void()>& callback) { |
91 gfx::Size frame_size = | 92 gfx::Size frame_size = |
92 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); | 93 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); |
93 if (frame_size.IsEmpty() || frame_size != display_size_) { | 94 if (frame_size.IsEmpty() || frame_size != display_size_) { |
94 if (!surface_id_.is_null()) | 95 if (!surface_id_.is_null()) |
95 factory_.Destroy(surface_id_); | 96 factory_.Destroy(surface_id_); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // This notification is not relevant to our client outside of tests. | 130 // This notification is not relevant to our client outside of tests. |
130 } | 131 } |
131 | 132 |
132 void DisplayCompositor::DisplayDidDrawAndSwap() { | 133 void DisplayCompositor::DisplayDidDrawAndSwap() { |
133 // This notification is not relevant to our client outside of tests. We | 134 // This notification is not relevant to our client outside of tests. We |
134 // unblock the client from the DrawCallback when the surface is going to | 135 // unblock the client from the DrawCallback when the surface is going to |
135 // be drawn. | 136 // be drawn. |
136 } | 137 } |
137 | 138 |
138 } // namespace ui | 139 } // namespace ui |
OLD | NEW |