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_frame_sink.h" | 5 #include "content/renderer/android/synchronous_compositor_frame_sink.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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 if (!cc::CompositorFrameSink::BindToClient(sink_client)) | 156 if (!cc::CompositorFrameSink::BindToClient(sink_client)) |
157 return false; | 157 return false; |
158 | 158 |
159 DCHECK(begin_frame_source_); | 159 DCHECK(begin_frame_source_); |
160 client_->SetBeginFrameSource(begin_frame_source_.get()); | 160 client_->SetBeginFrameSource(begin_frame_source_.get()); |
161 client_->SetMemoryPolicy(memory_policy_); | 161 client_->SetMemoryPolicy(memory_policy_); |
162 client_->SetTreeActivationCallback( | 162 client_->SetTreeActivationCallback( |
163 base::Bind(&SynchronousCompositorFrameSink::DidActivatePendingTree, | 163 base::Bind(&SynchronousCompositorFrameSink::DidActivatePendingTree, |
164 base::Unretained(this))); | 164 base::Unretained(this))); |
165 registry_->RegisterCompositorFrameSink(routing_id_, this); | 165 registry_->RegisterCompositorFrameSink(routing_id_, this); |
166 registered_ = true; | |
167 | 166 |
168 surface_manager_->RegisterFrameSinkId(kFrameSinkId); | 167 surface_manager_->RegisterFrameSinkId(kFrameSinkId); |
169 surface_manager_->RegisterSurfaceFactoryClient(kFrameSinkId, this); | 168 surface_manager_->RegisterSurfaceFactoryClient(kFrameSinkId, this); |
170 | 169 |
171 cc::RendererSettings software_renderer_settings; | 170 cc::RendererSettings software_renderer_settings; |
172 | 171 |
173 auto output_surface = base::MakeUnique<SoftwareOutputSurface>( | 172 auto output_surface = base::MakeUnique<SoftwareOutputSurface>( |
174 base::MakeUnique<SoftwareDevice>(¤t_sw_canvas_)); | 173 base::MakeUnique<SoftwareDevice>(¤t_sw_canvas_)); |
175 software_output_surface_ = output_surface.get(); | 174 software_output_surface_ = output_surface.get(); |
176 | 175 |
177 // The shared_bitmap_manager and gpu_memory_buffer_manager here are null as | 176 // The shared_bitmap_manager and gpu_memory_buffer_manager here are null as |
178 // this Display is only used for resourcesless software draws, where no | 177 // this Display is only used for resourcesless software draws, where no |
179 // resources are included in the frame swapped from the compositor. So there | 178 // resources are included in the frame swapped from the compositor. So there |
180 // is no need for these. | 179 // is no need for these. |
181 display_.reset(new cc::Display( | 180 display_.reset(new cc::Display( |
182 nullptr /* shared_bitmap_manager */, | 181 nullptr /* shared_bitmap_manager */, |
183 nullptr /* gpu_memory_buffer_manager */, software_renderer_settings, | 182 nullptr /* gpu_memory_buffer_manager */, software_renderer_settings, |
184 nullptr /* begin_frame_source */, std::move(output_surface), | 183 nullptr /* begin_frame_source */, std::move(output_surface), |
185 nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */)); | 184 nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */)); |
186 display_->Initialize(&display_client_, surface_manager_.get(), kFrameSinkId); | 185 display_->Initialize(&display_client_, surface_manager_.get(), kFrameSinkId); |
187 display_->SetVisible(true); | 186 display_->SetVisible(true); |
188 return true; | 187 return true; |
189 } | 188 } |
190 | 189 |
191 void SynchronousCompositorFrameSink::DetachFromClient() { | 190 void SynchronousCompositorFrameSink::DetachFromClient() { |
192 DCHECK(CalledOnValidThread()); | 191 DCHECK(CalledOnValidThread()); |
193 client_->SetBeginFrameSource(nullptr); | 192 client_->SetBeginFrameSource(nullptr); |
194 // Destroy the begin frame source on the same thread it was bound on. | 193 // Destroy the begin frame source on the same thread it was bound on. |
195 begin_frame_source_ = nullptr; | 194 begin_frame_source_ = nullptr; |
196 if (registered_) | 195 registry_->UnregisterCompositorFrameSink(routing_id_, this); |
197 registry_->UnregisterCompositorFrameSink(routing_id_, this); | |
198 client_->SetTreeActivationCallback(base::Closure()); | 196 client_->SetTreeActivationCallback(base::Closure()); |
199 if (!root_local_frame_id_.is_null()) { | 197 if (!root_local_frame_id_.is_null()) { |
200 surface_factory_->Destroy(root_local_frame_id_); | 198 surface_factory_->Destroy(root_local_frame_id_); |
201 surface_factory_->Destroy(child_local_frame_id_); | 199 surface_factory_->Destroy(child_local_frame_id_); |
202 } | 200 } |
203 surface_manager_->UnregisterSurfaceFactoryClient(kFrameSinkId); | 201 surface_manager_->UnregisterSurfaceFactoryClient(kFrameSinkId); |
204 surface_manager_->InvalidateFrameSinkId(kFrameSinkId); | 202 surface_manager_->InvalidateFrameSinkId(kFrameSinkId); |
205 software_output_surface_ = nullptr; | 203 software_output_surface_ = nullptr; |
206 display_ = nullptr; | 204 display_ = nullptr; |
207 surface_factory_ = nullptr; | 205 surface_factory_ = nullptr; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 client_->ReclaimResources(resources); | 461 client_->ReclaimResources(resources); |
464 } | 462 } |
465 | 463 |
466 void SynchronousCompositorFrameSink::SetBeginFrameSource( | 464 void SynchronousCompositorFrameSink::SetBeginFrameSource( |
467 cc::BeginFrameSource* begin_frame_source) { | 465 cc::BeginFrameSource* begin_frame_source) { |
468 // Software output is synchronous and doesn't use a BeginFrameSource. | 466 // Software output is synchronous and doesn't use a BeginFrameSource. |
469 NOTREACHED(); | 467 NOTREACHED(); |
470 } | 468 } |
471 | 469 |
472 } // namespace content | 470 } // namespace content |
OLD | NEW |