OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/android/synchronous_compositor_output_surface.h" | 5 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void SetSurfaceSize(const gfx::Size surface_size) { | 89 void SetSurfaceSize(const gfx::Size surface_size) { |
90 surface_size_ = surface_size; | 90 surface_size_ = surface_size; |
91 } | 91 } |
92 }; | 92 }; |
93 | 93 |
94 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( | 94 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( |
95 scoped_refptr<cc::ContextProvider> context_provider, | 95 scoped_refptr<cc::ContextProvider> context_provider, |
96 scoped_refptr<cc::ContextProvider> worker_context_provider, | 96 scoped_refptr<cc::ContextProvider> worker_context_provider, |
97 int routing_id, | 97 int routing_id, |
98 uint32_t output_surface_id, | 98 uint32_t output_surface_id, |
| 99 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, |
99 SynchronousCompositorRegistry* registry, | 100 SynchronousCompositorRegistry* registry, |
100 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) | 101 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) |
101 : cc::OutputSurface(std::move(context_provider), | 102 : cc::OutputSurface(std::move(context_provider), |
102 std::move(worker_context_provider), | 103 std::move(worker_context_provider), |
103 nullptr), | 104 nullptr), |
104 routing_id_(routing_id), | 105 routing_id_(routing_id), |
105 output_surface_id_(output_surface_id), | 106 output_surface_id_(output_surface_id), |
106 registry_(registry), | 107 registry_(registry), |
107 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()), | 108 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()), |
108 memory_policy_(0u), | 109 memory_policy_(0u), |
109 frame_swap_message_queue_(frame_swap_message_queue), | 110 frame_swap_message_queue_(frame_swap_message_queue), |
110 surface_manager_(new cc::SurfaceManager), | 111 surface_manager_(new cc::SurfaceManager), |
111 surface_id_allocator_(new cc::SurfaceIdAllocator(kCompositorClientId)), | 112 surface_id_allocator_(new cc::SurfaceIdAllocator(kCompositorClientId)), |
112 surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)) { | 113 surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)), |
| 114 begin_frame_source_(std::move(begin_frame_source)) { |
113 DCHECK(registry_); | 115 DCHECK(registry_); |
114 DCHECK(sender_); | 116 DCHECK(sender_); |
| 117 DCHECK(begin_frame_source_); |
115 thread_checker_.DetachFromThread(); | 118 thread_checker_.DetachFromThread(); |
116 capabilities_.adjust_deadline_for_parent = false; | 119 capabilities_.adjust_deadline_for_parent = false; |
117 capabilities_.delegated_rendering = true; | 120 capabilities_.delegated_rendering = true; |
118 memory_policy_.priority_cutoff_when_visible = | 121 memory_policy_.priority_cutoff_when_visible = |
119 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 122 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
120 } | 123 } |
121 | 124 |
122 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() = | 125 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() = |
123 default; | 126 default; |
124 | 127 |
(...skipping 15 matching lines...) Expand all Loading... |
140 IPC_END_MESSAGE_MAP() | 143 IPC_END_MESSAGE_MAP() |
141 return handled; | 144 return handled; |
142 } | 145 } |
143 | 146 |
144 bool SynchronousCompositorOutputSurface::BindToClient( | 147 bool SynchronousCompositorOutputSurface::BindToClient( |
145 cc::OutputSurfaceClient* surface_client) { | 148 cc::OutputSurfaceClient* surface_client) { |
146 DCHECK(CalledOnValidThread()); | 149 DCHECK(CalledOnValidThread()); |
147 if (!cc::OutputSurface::BindToClient(surface_client)) | 150 if (!cc::OutputSurface::BindToClient(surface_client)) |
148 return false; | 151 return false; |
149 | 152 |
| 153 DCHECK(begin_frame_source_); |
| 154 client_->SetBeginFrameSource(begin_frame_source_.get()); |
150 client_->SetMemoryPolicy(memory_policy_); | 155 client_->SetMemoryPolicy(memory_policy_); |
151 client_->SetTreeActivationCallback( | 156 client_->SetTreeActivationCallback( |
152 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree, | 157 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree, |
153 base::Unretained(this))); | 158 base::Unretained(this))); |
154 registry_->RegisterOutputSurface(routing_id_, this); | 159 registry_->RegisterOutputSurface(routing_id_, this); |
155 registered_ = true; | 160 registered_ = true; |
156 | 161 |
157 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); | 162 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); |
158 surface_manager_->RegisterSurfaceFactoryClient( | 163 surface_manager_->RegisterSurfaceFactoryClient( |
159 surface_id_allocator_->client_id(), this); | 164 surface_id_allocator_->client_id(), this); |
(...skipping 15 matching lines...) Expand all Loading... |
175 nullptr /* begin_frame_source */, std::move(output_surface), | 180 nullptr /* begin_frame_source */, std::move(output_surface), |
176 nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */)); | 181 nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */)); |
177 display_->Initialize(&display_client_, surface_manager_.get(), | 182 display_->Initialize(&display_client_, surface_manager_.get(), |
178 surface_id_allocator_->client_id()); | 183 surface_id_allocator_->client_id()); |
179 display_->SetVisible(true); | 184 display_->SetVisible(true); |
180 return true; | 185 return true; |
181 } | 186 } |
182 | 187 |
183 void SynchronousCompositorOutputSurface::DetachFromClient() { | 188 void SynchronousCompositorOutputSurface::DetachFromClient() { |
184 DCHECK(CalledOnValidThread()); | 189 DCHECK(CalledOnValidThread()); |
185 if (registered_) { | 190 client_->SetBeginFrameSource(nullptr); |
| 191 // Destroy the begin frame source on the same thread it was bound on. |
| 192 begin_frame_source_ = nullptr; |
| 193 if (registered_) |
186 registry_->UnregisterOutputSurface(routing_id_, this); | 194 registry_->UnregisterOutputSurface(routing_id_, this); |
187 } | |
188 client_->SetTreeActivationCallback(base::Closure()); | 195 client_->SetTreeActivationCallback(base::Closure()); |
189 if (!delegated_surface_id_.is_null()) | 196 if (!delegated_surface_id_.is_null()) |
190 surface_factory_->Destroy(delegated_surface_id_); | 197 surface_factory_->Destroy(delegated_surface_id_); |
191 surface_manager_->UnregisterSurfaceFactoryClient( | 198 surface_manager_->UnregisterSurfaceFactoryClient( |
192 surface_id_allocator_->client_id()); | 199 surface_id_allocator_->client_id()); |
193 surface_manager_->InvalidateSurfaceClientId( | 200 surface_manager_->InvalidateSurfaceClientId( |
194 surface_id_allocator_->client_id()); | 201 surface_id_allocator_->client_id()); |
195 software_output_surface_ = nullptr; | 202 software_output_surface_ = nullptr; |
196 display_ = nullptr; | 203 display_ = nullptr; |
197 surface_factory_ = nullptr; | 204 surface_factory_ = nullptr; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 client_->ReclaimResources(resources); | 426 client_->ReclaimResources(resources); |
420 } | 427 } |
421 | 428 |
422 void SynchronousCompositorOutputSurface::SetBeginFrameSource( | 429 void SynchronousCompositorOutputSurface::SetBeginFrameSource( |
423 cc::BeginFrameSource* begin_frame_source) { | 430 cc::BeginFrameSource* begin_frame_source) { |
424 // Software output is synchronous and doesn't use a BeginFrameSource. | 431 // Software output is synchronous and doesn't use a BeginFrameSource. |
425 NOTREACHED(); | 432 NOTREACHED(); |
426 } | 433 } |
427 | 434 |
428 } // namespace content | 435 } // namespace content |
OLD | NEW |