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

Side by Side Diff: services/ui/ws/server_window_compositor_frame_sink.cc

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: rebase Created 4 years, 1 month 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 2015 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/ws/server_window_compositor_frame_sink.h" 5 #include "services/ui/ws/server_window_compositor_frame_sink.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 this); 45 this);
46 46
47 if (widget != gfx::kNullAcceleratedWidget) 47 if (widget != gfx::kNullAcceleratedWidget)
48 InitDisplay(widget, gpu_memory_buffer_manager, std::move(context_provider)); 48 InitDisplay(widget, gpu_memory_buffer_manager, std::move(context_provider));
49 } 49 }
50 50
51 ServerWindowCompositorFrameSink::~ServerWindowCompositorFrameSink() { 51 ServerWindowCompositorFrameSink::~ServerWindowCompositorFrameSink() {
52 // SurfaceFactory's destructor will attempt to return resources which will 52 // SurfaceFactory's destructor will attempt to return resources which will
53 // call back into here and access |client_| so we should destroy 53 // call back into here and access |client_| so we should destroy
54 // |surface_factory_|'s resources early on. 54 // |surface_factory_|'s resources early on.
55 surface_factory_.DestroyAll(); 55 surface_factory_.Reset();
56 display_compositor_->manager()->UnregisterSurfaceFactoryClient( 56 display_compositor_->manager()->UnregisterSurfaceFactoryClient(
57 frame_sink_id_); 57 frame_sink_id_);
58 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_); 58 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_);
59 } 59 }
60 60
61 void ServerWindowCompositorFrameSink::SetNeedsBeginFrame( 61 void ServerWindowCompositorFrameSink::SetNeedsBeginFrame(
62 bool needs_begin_frame) { 62 bool needs_begin_frame) {
63 needs_begin_frame_ = needs_begin_frame; 63 needs_begin_frame_ = needs_begin_frame;
64 UpdateNeedsBeginFramesInternal(); 64 UpdateNeedsBeginFramesInternal();
65 } 65 }
66 66
67 void ServerWindowCompositorFrameSink::SubmitCompositorFrame( 67 void ServerWindowCompositorFrameSink::SubmitCompositorFrame(
68 cc::CompositorFrame frame) { 68 cc::CompositorFrame frame) {
69 gfx::Size frame_size = frame.render_pass_list[0]->output_rect.size(); 69 gfx::Size frame_size = frame.render_pass_list[0]->output_rect.size();
70 // If the size of the CompostiorFrame has changed then destroy the existing 70 // If the size of the CompostiorFrame has changed then destroy the existing
71 // Surface and create a new one of the appropriate size. 71 // Surface and create a new one of the appropriate size.
72 if (!local_frame_id_.is_valid() || frame_size != last_submitted_frame_size_) { 72 if (!local_frame_id_.is_valid() || frame_size != last_submitted_frame_size_) {
73 if (local_frame_id_.is_valid())
74 surface_factory_.Destroy(local_frame_id_);
75 local_frame_id_ = surface_id_allocator_.GenerateId(); 73 local_frame_id_ = surface_id_allocator_.GenerateId();
76 surface_factory_.Create(local_frame_id_);
77 if (display_) 74 if (display_)
78 display_->Resize(frame_size); 75 display_->Resize(frame_size);
79 } 76 }
80 ++ack_pending_count_; 77 ++ack_pending_count_;
81 surface_factory_.SubmitCompositorFrame( 78 surface_factory_.SubmitCompositorFrame(
82 local_frame_id_, std::move(frame), 79 local_frame_id_, std::move(frame),
83 base::Bind(&ServerWindowCompositorFrameSink::DidReceiveCompositorFrameAck, 80 base::Bind(&ServerWindowCompositorFrameSink::DidReceiveCompositorFrameAck,
84 base::Unretained(this))); 81 base::Unretained(this)));
85 if (display_) { 82 if (display_) {
86 display_->SetLocalFrameId(local_frame_id_, 83 display_->SetLocalFrameId(local_frame_id_,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 213
217 added_frame_observer_ = needs_begin_frame_; 214 added_frame_observer_ = needs_begin_frame_;
218 if (needs_begin_frame_) 215 if (needs_begin_frame_)
219 begin_frame_source_->AddObserver(this); 216 begin_frame_source_->AddObserver(this);
220 else 217 else
221 begin_frame_source_->RemoveObserver(this); 218 begin_frame_source_->RemoveObserver(this);
222 } 219 }
223 220
224 } // namespace ws 221 } // namespace ws
225 } // namespace ui 222 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698