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

Side by Side Diff: services/ui/surfaces/mus_display_provider.cc

Issue 2778863002: Introduce DisplayProvider for DisplayCompositor. (Closed)
Patch Set: Delete extra task runner ref. 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 | « services/ui/surfaces/mus_display_provider.h ('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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "services/ui/surfaces/mus_display_provider.h"
6
7 #include <utility>
8
9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h"
11 #include "base/threading/thread_task_runner_handle.h"
12 #include "cc/base/switches.h"
13 #include "cc/output/in_process_context_provider.h"
14 #include "cc/output/texture_mailbox_deleter.h"
15 #include "cc/scheduler/begin_frame_source.h"
16 #include "cc/surfaces/display.h"
17 #include "cc/surfaces/display_scheduler.h"
18 #include "components/display_compositor/gpu_root_compositor_frame_sink.h"
19 #include "gpu/command_buffer/client/shared_memory_limits.h"
20 #include "gpu/command_buffer/service/image_factory.h"
21 #include "services/ui/surfaces/display_output_surface.h"
22
23 #if defined(USE_OZONE)
24 #include "gpu/command_buffer/client/gles2_interface.h"
25 #include "services/ui/surfaces/display_output_surface_ozone.h"
26 #endif
27
28 namespace ui {
29
30 MusDisplayProvider::MusDisplayProvider(
31 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service,
32 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager,
33 gpu::ImageFactory* image_factory)
34 : gpu_service_(std::move(gpu_service)),
35 gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)),
36 image_factory_(image_factory),
37 task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
38
39 MusDisplayProvider::~MusDisplayProvider() {}
40
41 std::unique_ptr<cc::Display> MusDisplayProvider::CreateDisplay(
42 const cc::FrameSinkId& frame_sink_id,
43 gpu::SurfaceHandle surface_handle,
44 std::unique_ptr<cc::BeginFrameSource>* begin_frame_source) {
45 auto synthetic_begin_frame_source =
46 base::MakeUnique<cc::DelayBasedBeginFrameSource>(
47 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()));
48
49 scoped_refptr<cc::InProcessContextProvider> context_provider =
50 new cc::InProcessContextProvider(
51 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(),
52 image_factory_, gpu::SharedMemoryLimits(),
53 nullptr /* shared_context */);
54
55 // TODO(rjkroege): If there is something better to do than CHECK, add it.
56 CHECK(context_provider->BindToCurrentThread());
57
58 std::unique_ptr<cc::OutputSurface> display_output_surface;
59 if (context_provider->ContextCapabilities().surfaceless) {
60 #if defined(USE_OZONE)
61 display_output_surface = base::MakeUnique<DisplayOutputSurfaceOzone>(
62 std::move(context_provider), surface_handle,
63 synthetic_begin_frame_source.get(), gpu_memory_buffer_manager_.get(),
64 GL_TEXTURE_2D, GL_RGB);
65 #else
66 NOTREACHED();
67 #endif
68 } else {
69 display_output_surface = base::MakeUnique<DisplayOutputSurface>(
70 std::move(context_provider), synthetic_begin_frame_source.get());
71 }
72
73 int max_frames_pending =
74 display_output_surface->capabilities().max_frames_pending;
75 DCHECK_GT(max_frames_pending, 0);
76
77 auto scheduler = base::MakeUnique<cc::DisplayScheduler>(task_runner_.get(),
78 max_frames_pending);
79
80 cc::RendererSettings settings;
81 settings.show_overdraw_feedback =
82 base::CommandLine::ForCurrentProcess()->HasSwitch(
83 cc::switches::kShowOverdrawFeedback);
84
85 // The ownership of the BeginFrameSource is transfered to the caller.
86 *begin_frame_source = std::move(synthetic_begin_frame_source);
87
88 return base::MakeUnique<cc::Display>(
89 nullptr /* bitmap_manager */, gpu_memory_buffer_manager_.get(), settings,
90 frame_sink_id, begin_frame_source->get(),
91 std::move(display_output_surface), std::move(scheduler),
92 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()));
93 }
94
95 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/mus_display_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698