OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/compositor/delegated_frame_host.h" | 5 #include "content/browser/compositor/delegated_frame_host.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 void DelegatedFrameHost::BeginFrameSubscription( | 188 void DelegatedFrameHost::BeginFrameSubscription( |
189 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 189 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
190 frame_subscriber_ = subscriber.Pass(); | 190 frame_subscriber_ = subscriber.Pass(); |
191 } | 191 } |
192 | 192 |
193 void DelegatedFrameHost::EndFrameSubscription() { | 193 void DelegatedFrameHost::EndFrameSubscription() { |
194 idle_frame_subscriber_textures_.clear(); | 194 idle_frame_subscriber_textures_.clear(); |
195 frame_subscriber_.reset(); | 195 frame_subscriber_.reset(); |
196 } | 196 } |
197 | 197 |
198 uint32_t DelegatedFrameHost::GetSurfaceIdNamespace() { | |
199 if (!use_surfaces_) | |
200 return 0; | |
201 | |
202 if (!surface_factory_) { | |
203 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
204 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | |
205 id_allocator_ = factory->GetContextFactory()->CreateSurfaceIdAllocator(); | |
206 surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | |
207 } | |
208 return id_allocator_->id_namespace(); | |
209 } | |
210 | |
198 bool DelegatedFrameHost::ShouldSkipFrame(gfx::Size size_in_dip) const { | 211 bool DelegatedFrameHost::ShouldSkipFrame(gfx::Size size_in_dip) const { |
199 // Should skip a frame only when another frame from the renderer is guaranteed | 212 // Should skip a frame only when another frame from the renderer is guaranteed |
200 // to replace it. Otherwise may cause hangs when the renderer is waiting for | 213 // to replace it. Otherwise may cause hangs when the renderer is waiting for |
201 // the completion of latency infos (such as when taking a Snapshot.) | 214 // the completion of latency infos (such as when taking a Snapshot.) |
202 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || | 215 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || |
203 can_lock_compositor_ == NO_PENDING_COMMIT || | 216 can_lock_compositor_ == NO_PENDING_COMMIT || |
204 !resize_lock_.get()) | 217 !resize_lock_.get()) |
205 return false; | 218 return false; |
206 | 219 |
207 return size_in_dip != resize_lock_->expected_size(); | 220 return size_in_dip != resize_lock_->expected_size(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 EvictDelegatedFrame(); | 375 EvictDelegatedFrame(); |
363 } else { | 376 } else { |
364 if (use_surfaces_) { | 377 if (use_surfaces_) { |
365 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 378 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
366 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 379 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
367 if (!surface_factory_) { | 380 if (!surface_factory_) { |
368 id_allocator_ = | 381 id_allocator_ = |
369 factory->GetContextFactory()->CreateSurfaceIdAllocator(); | 382 factory->GetContextFactory()->CreateSurfaceIdAllocator(); |
370 surface_factory_ = | 383 surface_factory_ = |
371 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | 384 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
385 client_->DelegatedFrameHostUpdateSurfaceIdNamespace( | |
jbauman
2015/05/12 00:09:12
Let's just create the id_allocator_ in the constru
kenrb
2015/05/12 20:01:41
Done.
| |
386 id_allocator_->id_namespace()); | |
372 } | 387 } |
373 if (surface_id_.is_null() || frame_size != current_surface_size_ || | 388 if (surface_id_.is_null() || frame_size != current_surface_size_ || |
374 frame_size_in_dip != current_frame_size_in_dip_) { | 389 frame_size_in_dip != current_frame_size_in_dip_) { |
375 if (!surface_id_.is_null()) | 390 if (!surface_id_.is_null()) |
376 surface_factory_->Destroy(surface_id_); | 391 surface_factory_->Destroy(surface_id_); |
377 surface_id_ = id_allocator_->GenerateId(); | 392 surface_id_ = id_allocator_->GenerateId(); |
378 surface_factory_->Create(surface_id_); | 393 surface_factory_->Create(surface_id_); |
379 // manager must outlive compositors using it. | 394 // manager must outlive compositors using it. |
380 client_->DelegatedFrameHostGetLayer()->SetShowSurface( | 395 client_->DelegatedFrameHostGetLayer()->SetShowSurface( |
381 surface_id_, | 396 surface_id_, |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 1020 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
1006 new_layer->SetShowSurface( | 1021 new_layer->SetShowSurface( |
1007 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 1022 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
1008 base::Bind(&RequireCallback, base::Unretained(manager)), | 1023 base::Bind(&RequireCallback, base::Unretained(manager)), |
1009 current_surface_size_, current_scale_factor_, | 1024 current_surface_size_, current_scale_factor_, |
1010 current_frame_size_in_dip_); | 1025 current_frame_size_in_dip_); |
1011 } | 1026 } |
1012 } | 1027 } |
1013 | 1028 |
1014 } // namespace content | 1029 } // namespace content |
OLD | NEW |