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

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

Issue 2386763002: services/ui: Match naming in cc (and jellyfish branch) (Closed)
Patch Set: Removed bad change Created 4 years, 2 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/display_compositor.h ('k') | services/ui/surfaces/surfaces_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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"
8 #include "cc/output/output_surface.h"
9 #include "cc/output/renderer_settings.h"
10 #include "cc/output/texture_mailbox_deleter.h"
11 #include "cc/scheduler/begin_frame_source.h"
12 #include "cc/scheduler/delay_based_time_source.h"
13 #include "cc/surfaces/display.h"
14 #include "cc/surfaces/display_scheduler.h"
15 #include "cc/surfaces/frame_sink_id.h"
16 #include "gpu/ipc/client/gpu_channel_host.h"
17 #include "services/ui/surfaces/direct_output_surface.h"
18 #include "services/ui/surfaces/surfaces_context_provider.h"
19
20 #if defined(USE_OZONE)
21 #include "gpu/command_buffer/client/gles2_interface.h"
22 #include "services/ui/surfaces/direct_output_surface_ozone.h"
23 #endif
24
25 namespace ui { 7 namespace ui {
26 8
27 DisplayCompositor::DisplayCompositor( 9 DisplayCompositor::DisplayCompositor() : next_client_id_(1u) {}
28 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
29 gfx::AcceleratedWidget widget,
30 scoped_refptr<gpu::GpuChannelHost> gpu_channel,
31 const scoped_refptr<SurfacesState>& surfaces_state)
32 : task_runner_(task_runner),
33 surfaces_state_(surfaces_state),
34 factory_(surfaces_state->manager(), this),
35 allocator_(cc::FrameSinkId(surfaces_state->next_client_id(), 0)) {
36 surfaces_state_->manager()->RegisterFrameSinkId(allocator_.frame_sink_id());
37 surfaces_state_->manager()->RegisterSurfaceFactoryClient(
38 allocator_.frame_sink_id(), this);
39 10
40 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = 11 DisplayCompositor::~DisplayCompositor() {}
41 gpu_channel->gpu_memory_buffer_manager();
42 scoped_refptr<SurfacesContextProvider> surfaces_context_provider(
43 new SurfacesContextProvider(widget, std::move(gpu_channel)));
44 // TODO(rjkroege): If there is something better to do than CHECK, add it.
45 CHECK(surfaces_context_provider->BindToCurrentThread());
46 12
47 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( 13 uint32_t DisplayCompositor::GenerateNextClientId() {
48 new cc::DelayBasedBeginFrameSource( 14 return next_client_id_++;
49 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get())));
50
51 std::unique_ptr<cc::OutputSurface> display_output_surface;
52 if (surfaces_context_provider->ContextCapabilities().surfaceless) {
53 #if defined(USE_OZONE)
54 display_output_surface = base::MakeUnique<DirectOutputSurfaceOzone>(
55 surfaces_context_provider, widget, synthetic_begin_frame_source.get(),
56 gpu_memory_buffer_manager, GL_TEXTURE_2D, GL_RGB);
57 #else
58 NOTREACHED();
59 #endif
60 } else {
61 display_output_surface = base::MakeUnique<DirectOutputSurface>(
62 surfaces_context_provider, synthetic_begin_frame_source.get());
63 }
64
65 int max_frames_pending =
66 display_output_surface->capabilities().max_frames_pending;
67 DCHECK_GT(max_frames_pending, 0);
68
69 std::unique_ptr<cc::DisplayScheduler> scheduler(
70 new cc::DisplayScheduler(synthetic_begin_frame_source.get(),
71 task_runner_.get(), max_frames_pending));
72
73 display_.reset(new cc::Display(
74 nullptr /* bitmap_manager */, gpu_memory_buffer_manager,
75 cc::RendererSettings(), std::move(synthetic_begin_frame_source),
76 std::move(display_output_surface), std::move(scheduler),
77 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get())));
78 display_->Initialize(this, surfaces_state_->manager(),
79 allocator_.frame_sink_id());
80 display_->SetVisible(true);
81 }
82
83 DisplayCompositor::~DisplayCompositor() {
84 surfaces_state_->manager()->UnregisterSurfaceFactoryClient(
85 allocator_.frame_sink_id());
86 surfaces_state_->manager()->InvalidateFrameSinkId(allocator_.frame_sink_id());
87 }
88
89 void DisplayCompositor::SubmitCompositorFrame(
90 cc::CompositorFrame frame,
91 const base::Callback<void()>& callback) {
92 gfx::Size frame_size =
93 frame.delegated_frame_data->render_pass_list.back()->output_rect.size();
94 if (frame_size.IsEmpty() || frame_size != display_size_) {
95 if (!surface_id_.is_null())
96 factory_.Destroy(surface_id_);
97 surface_id_ = allocator_.GenerateId();
98 factory_.Create(surface_id_);
99 display_size_ = frame_size;
100 display_->Resize(display_size_);
101 }
102 display_->SetSurfaceId(surface_id_, frame.metadata.device_scale_factor);
103 factory_.SubmitCompositorFrame(surface_id_, std::move(frame), callback);
104 }
105
106 void DisplayCompositor::RequestCopyOfOutput(
107 std::unique_ptr<cc::CopyOutputRequest> output_request) {
108 factory_.RequestCopyOfSurface(surface_id_, std::move(output_request));
109 }
110
111 void DisplayCompositor::ReturnResources(
112 const cc::ReturnedResourceArray& resources) {
113 // TODO(fsamuel): Implement this.
114 }
115
116 void DisplayCompositor::SetBeginFrameSource(
117 cc::BeginFrameSource* begin_frame_source) {
118 // TODO(fsamuel): Implement this.
119 }
120
121 void DisplayCompositor::DisplayOutputSurfaceLost() {
122 // TODO(fsamuel): This looks like it would crash if a frame was in flight and
123 // will be submitted.
124 display_.reset();
125 }
126
127 void DisplayCompositor::DisplayWillDrawAndSwap(
128 bool will_draw_and_swap,
129 const cc::RenderPassList& render_passes) {
130 // This notification is not relevant to our client outside of tests.
131 }
132
133 void DisplayCompositor::DisplayDidDrawAndSwap() {
134 // This notification is not relevant to our client outside of tests. We
135 // unblock the client from the DrawCallback when the surface is going to
136 // be drawn.
137 } 15 }
138 16
139 } // namespace ui 17 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/display_compositor.h ('k') | services/ui/surfaces/surfaces_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698