OLD | NEW |
---|---|
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/gpu_compositor_frame_sink.h" | 5 #include "services/ui/ws/gpu_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 Loading... | |
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 GpuCompositorFrameSink::~GpuCompositorFrameSink() { | 51 GpuCompositorFrameSink::~GpuCompositorFrameSink() { |
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(); |
Fady Samuel
2016/11/11 19:47:57
EvictFrame()
| |
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 GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { | 61 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { |
62 needs_begin_frame_ = needs_begin_frame; | 62 needs_begin_frame_ = needs_begin_frame; |
63 UpdateNeedsBeginFramesInternal(); | 63 UpdateNeedsBeginFramesInternal(); |
64 } | 64 } |
65 | 65 |
66 void GpuCompositorFrameSink::SubmitCompositorFrame(cc::CompositorFrame frame) { | 66 void GpuCompositorFrameSink::SubmitCompositorFrame(cc::CompositorFrame frame) { |
67 gfx::Size frame_size = frame.render_pass_list[0]->output_rect.size(); | 67 gfx::Size frame_size = frame.render_pass_list[0]->output_rect.size(); |
68 // If the size of the CompostiorFrame has changed then destroy the existing | 68 // If the size of the CompostiorFrame has changed then destroy the existing |
69 // Surface and create a new one of the appropriate size. | 69 // Surface and create a new one of the appropriate size. |
70 if (!local_frame_id_.is_valid() || frame_size != last_submitted_frame_size_) { | 70 if (!local_frame_id_.is_valid() || frame_size != last_submitted_frame_size_) { |
71 if (local_frame_id_.is_valid()) | |
72 surface_factory_.Destroy(local_frame_id_); | |
73 local_frame_id_ = surface_id_allocator_.GenerateId(); | 71 local_frame_id_ = surface_id_allocator_.GenerateId(); |
74 surface_factory_.Create(local_frame_id_); | |
75 if (display_) | 72 if (display_) |
76 display_->Resize(frame_size); | 73 display_->Resize(frame_size); |
77 } | 74 } |
78 ++ack_pending_count_; | 75 ++ack_pending_count_; |
79 surface_factory_.SubmitCompositorFrame( | 76 surface_factory_.SubmitCompositorFrame( |
80 local_frame_id_, std::move(frame), | 77 local_frame_id_, std::move(frame), |
81 base::Bind(&GpuCompositorFrameSink::DidReceiveCompositorFrameAck, | 78 base::Bind(&GpuCompositorFrameSink::DidReceiveCompositorFrameAck, |
82 base::Unretained(this))); | 79 base::Unretained(this))); |
83 if (display_) { | 80 if (display_) { |
84 display_->SetLocalFrameId(local_frame_id_, | 81 display_->SetLocalFrameId(local_frame_id_, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 | 209 |
213 added_frame_observer_ = needs_begin_frame_; | 210 added_frame_observer_ = needs_begin_frame_; |
214 if (needs_begin_frame_) | 211 if (needs_begin_frame_) |
215 begin_frame_source_->AddObserver(this); | 212 begin_frame_source_->AddObserver(this); |
216 else | 213 else |
217 begin_frame_source_->RemoveObserver(this); | 214 begin_frame_source_->RemoveObserver(this); |
218 } | 215 } |
219 | 216 |
220 } // namespace ws | 217 } // namespace ws |
221 } // namespace ui | 218 } // namespace ui |
OLD | NEW |