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

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

Issue 2383373002: Reduce SurfaceIdAllocator usage and tie SurfaceFactory to a single FrameSinkId (Closed)
Patch Set: Fix TestRenderViewHost + Mac 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
OLDNEW
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"
(...skipping 11 matching lines...) Expand all
22 #include "services/ui/surfaces/direct_output_surface_ozone.h" 22 #include "services/ui/surfaces/direct_output_surface_ozone.h"
23 #endif 23 #endif
24 24
25 namespace ui { 25 namespace ui {
26 26
27 DisplayCompositor::DisplayCompositor( 27 DisplayCompositor::DisplayCompositor(
28 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
29 gfx::AcceleratedWidget widget, 29 gfx::AcceleratedWidget widget,
30 scoped_refptr<gpu::GpuChannelHost> gpu_channel, 30 scoped_refptr<gpu::GpuChannelHost> gpu_channel,
31 const scoped_refptr<SurfacesState>& surfaces_state) 31 const scoped_refptr<SurfacesState>& surfaces_state)
32 : task_runner_(task_runner), 32 : frame_sink_id_(surfaces_state->next_client_id(), 0),
33 task_runner_(task_runner),
33 surfaces_state_(surfaces_state), 34 surfaces_state_(surfaces_state),
34 factory_(surfaces_state->manager(), this), 35 allocator_(frame_sink_id_),
35 allocator_(cc::FrameSinkId(surfaces_state->next_client_id(), 0)) { 36 factory_(frame_sink_id_, surfaces_state->manager(), this) {
36 surfaces_state_->manager()->RegisterFrameSinkId(allocator_.frame_sink_id()); 37 surfaces_state_->manager()->RegisterFrameSinkId(frame_sink_id_);
37 surfaces_state_->manager()->RegisterSurfaceFactoryClient( 38 surfaces_state_->manager()->RegisterSurfaceFactoryClient(frame_sink_id_,
38 allocator_.frame_sink_id(), this); 39 this);
39 40
40 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = 41 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager =
41 gpu_channel->gpu_memory_buffer_manager(); 42 gpu_channel->gpu_memory_buffer_manager();
42 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( 43 scoped_refptr<SurfacesContextProvider> surfaces_context_provider(
43 new SurfacesContextProvider(widget, std::move(gpu_channel))); 44 new SurfacesContextProvider(widget, std::move(gpu_channel)));
44 // TODO(rjkroege): If there is something better to do than CHECK, add it. 45 // TODO(rjkroege): If there is something better to do than CHECK, add it.
45 CHECK(surfaces_context_provider->BindToCurrentThread()); 46 CHECK(surfaces_context_provider->BindToCurrentThread());
46 47
47 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( 48 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source(
48 new cc::DelayBasedBeginFrameSource( 49 new cc::DelayBasedBeginFrameSource(
(...skipping 19 matching lines...) Expand all
68 69
69 std::unique_ptr<cc::DisplayScheduler> scheduler( 70 std::unique_ptr<cc::DisplayScheduler> scheduler(
70 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), 71 new cc::DisplayScheduler(synthetic_begin_frame_source.get(),
71 task_runner_.get(), max_frames_pending)); 72 task_runner_.get(), max_frames_pending));
72 73
73 display_.reset(new cc::Display( 74 display_.reset(new cc::Display(
74 nullptr /* bitmap_manager */, gpu_memory_buffer_manager, 75 nullptr /* bitmap_manager */, gpu_memory_buffer_manager,
75 cc::RendererSettings(), std::move(synthetic_begin_frame_source), 76 cc::RendererSettings(), std::move(synthetic_begin_frame_source),
76 std::move(display_output_surface), std::move(scheduler), 77 std::move(display_output_surface), std::move(scheduler),
77 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); 78 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get())));
78 display_->Initialize(this, surfaces_state_->manager(), 79 display_->Initialize(this, surfaces_state_->manager(), frame_sink_id_);
79 allocator_.frame_sink_id());
80 display_->SetVisible(true); 80 display_->SetVisible(true);
81 } 81 }
82 82
83 DisplayCompositor::~DisplayCompositor() { 83 DisplayCompositor::~DisplayCompositor() {
84 surfaces_state_->manager()->UnregisterSurfaceFactoryClient( 84 surfaces_state_->manager()->UnregisterSurfaceFactoryClient(frame_sink_id_);
85 allocator_.frame_sink_id()); 85 surfaces_state_->manager()->InvalidateFrameSinkId(frame_sink_id_);
86 surfaces_state_->manager()->InvalidateFrameSinkId(allocator_.frame_sink_id());
87 } 86 }
88 87
89 void DisplayCompositor::SubmitCompositorFrame( 88 void DisplayCompositor::SubmitCompositorFrame(
90 cc::CompositorFrame frame, 89 cc::CompositorFrame frame,
91 const base::Callback<void()>& callback) { 90 const base::Callback<void()>& callback) {
92 gfx::Size frame_size = 91 gfx::Size frame_size =
93 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); 92 frame.delegated_frame_data->render_pass_list.back()->output_rect.size();
94 if (frame_size.IsEmpty() || frame_size != display_size_) { 93 if (frame_size.IsEmpty() || frame_size != display_size_) {
95 if (!surface_id_.is_null()) 94 if (!surface_id_.is_null())
96 factory_.Destroy(surface_id_); 95 factory_.Destroy(surface_id_);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // This notification is not relevant to our client outside of tests. 129 // This notification is not relevant to our client outside of tests.
131 } 130 }
132 131
133 void DisplayCompositor::DisplayDidDrawAndSwap() { 132 void DisplayCompositor::DisplayDidDrawAndSwap() {
134 // This notification is not relevant to our client outside of tests. We 133 // 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 134 // unblock the client from the DrawCallback when the surface is going to
136 // be drawn. 135 // be drawn.
137 } 136 }
138 137
139 } // namespace ui 138 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698