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

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

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

Powered by Google App Engine
This is Rietveld 408576698