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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 surface_manager_(new cc::SurfaceManager), | 99 surface_manager_(new cc::SurfaceManager), |
100 surface_id_allocator_(new cc::SurfaceIdAllocator(kCompositorClientId)), | 100 surface_id_allocator_(new cc::SurfaceIdAllocator(kCompositorClientId)), |
101 surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)) { | 101 surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)) { |
102 DCHECK(registry_); | 102 DCHECK(registry_); |
103 DCHECK(sender_); | 103 DCHECK(sender_); |
104 thread_checker_.DetachFromThread(); | 104 thread_checker_.DetachFromThread(); |
105 capabilities_.adjust_deadline_for_parent = false; | 105 capabilities_.adjust_deadline_for_parent = false; |
106 capabilities_.delegated_rendering = true; | 106 capabilities_.delegated_rendering = true; |
107 memory_policy_.priority_cutoff_when_visible = | 107 memory_policy_.priority_cutoff_when_visible = |
108 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 108 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
109 surface_id_allocator_->RegisterSurfaceClientId(surface_manager_.get()); | |
110 } | 109 } |
111 | 110 |
112 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {} | 111 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() = |
| 112 default; |
113 | 113 |
114 void SynchronousCompositorOutputSurface::SetSyncClient( | 114 void SynchronousCompositorOutputSurface::SetSyncClient( |
115 SynchronousCompositorOutputSurfaceClient* compositor) { | 115 SynchronousCompositorOutputSurfaceClient* compositor) { |
116 DCHECK(CalledOnValidThread()); | 116 DCHECK(CalledOnValidThread()); |
117 sync_client_ = compositor; | 117 sync_client_ = compositor; |
118 if (sync_client_) | 118 if (sync_client_) |
119 Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_)); | 119 Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_)); |
120 } | 120 } |
121 | 121 |
122 bool SynchronousCompositorOutputSurface::OnMessageReceived( | 122 bool SynchronousCompositorOutputSurface::OnMessageReceived( |
(...skipping 13 matching lines...) Expand all Loading... |
136 if (!cc::OutputSurface::BindToClient(surface_client)) | 136 if (!cc::OutputSurface::BindToClient(surface_client)) |
137 return false; | 137 return false; |
138 | 138 |
139 client_->SetMemoryPolicy(memory_policy_); | 139 client_->SetMemoryPolicy(memory_policy_); |
140 client_->SetTreeActivationCallback( | 140 client_->SetTreeActivationCallback( |
141 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree, | 141 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree, |
142 base::Unretained(this))); | 142 base::Unretained(this))); |
143 registry_->RegisterOutputSurface(routing_id_, this); | 143 registry_->RegisterOutputSurface(routing_id_, this); |
144 registered_ = true; | 144 registered_ = true; |
145 | 145 |
| 146 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); |
146 surface_manager_->RegisterSurfaceFactoryClient( | 147 surface_manager_->RegisterSurfaceFactoryClient( |
147 surface_id_allocator_->client_id(), this); | 148 surface_id_allocator_->client_id(), this); |
148 | 149 |
149 cc::RendererSettings software_renderer_settings; | 150 cc::RendererSettings software_renderer_settings; |
150 | 151 |
151 // The shared_bitmap_manager and gpu_memory_buffer_manager here are null as | 152 // The shared_bitmap_manager and gpu_memory_buffer_manager here are null as |
152 // this Display is only used for resourcesless software draws, where no | 153 // this Display is only used for resourcesless software draws, where no |
153 // resources are included in the frame swapped from the compositor. So there | 154 // resources are included in the frame swapped from the compositor. So there |
154 // is no need for these. | 155 // is no need for these. |
155 display_.reset(new cc::Display( | 156 display_.reset(new cc::Display( |
(...skipping 11 matching lines...) Expand all Loading... |
167 void SynchronousCompositorOutputSurface::DetachFromClient() { | 168 void SynchronousCompositorOutputSurface::DetachFromClient() { |
168 DCHECK(CalledOnValidThread()); | 169 DCHECK(CalledOnValidThread()); |
169 if (registered_) { | 170 if (registered_) { |
170 registry_->UnregisterOutputSurface(routing_id_, this); | 171 registry_->UnregisterOutputSurface(routing_id_, this); |
171 } | 172 } |
172 client_->SetTreeActivationCallback(base::Closure()); | 173 client_->SetTreeActivationCallback(base::Closure()); |
173 if (!delegated_surface_id_.is_null()) | 174 if (!delegated_surface_id_.is_null()) |
174 surface_factory_->Destroy(delegated_surface_id_); | 175 surface_factory_->Destroy(delegated_surface_id_); |
175 surface_manager_->UnregisterSurfaceFactoryClient( | 176 surface_manager_->UnregisterSurfaceFactoryClient( |
176 surface_id_allocator_->client_id()); | 177 surface_id_allocator_->client_id()); |
| 178 surface_manager_->InvalidateSurfaceClientId( |
| 179 surface_id_allocator_->client_id()); |
177 display_ = nullptr; | 180 display_ = nullptr; |
178 surface_factory_ = nullptr; | 181 surface_factory_ = nullptr; |
179 surface_id_allocator_ = nullptr; | 182 surface_id_allocator_ = nullptr; |
180 surface_manager_ = nullptr; | 183 surface_manager_ = nullptr; |
181 cc::OutputSurface::DetachFromClient(); | 184 cc::OutputSurface::DetachFromClient(); |
182 CancelFallbackTick(); | 185 CancelFallbackTick(); |
183 } | 186 } |
184 | 187 |
185 void SynchronousCompositorOutputSurface::Reshape( | 188 void SynchronousCompositorOutputSurface::Reshape( |
186 const gfx::Size& size, | 189 const gfx::Size& size, |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 client_->ReclaimResources(resources); | 406 client_->ReclaimResources(resources); |
404 } | 407 } |
405 | 408 |
406 void SynchronousCompositorOutputSurface::SetBeginFrameSource( | 409 void SynchronousCompositorOutputSurface::SetBeginFrameSource( |
407 cc::BeginFrameSource* begin_frame_source) { | 410 cc::BeginFrameSource* begin_frame_source) { |
408 // Software output is synchronous and doesn't use a BeginFrameSource. | 411 // Software output is synchronous and doesn't use a BeginFrameSource. |
409 NOTREACHED(); | 412 NOTREACHED(); |
410 } | 413 } |
411 | 414 |
412 } // namespace content | 415 } // namespace content |
OLD | NEW |