| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) | 58 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
| 59 : client_(client), | 59 : client_(client), |
| 60 compositor_(nullptr), | 60 compositor_(nullptr), |
| 61 use_surfaces_(UseSurfacesEnabled()), | 61 use_surfaces_(UseSurfacesEnabled()), |
| 62 last_output_surface_id_(0), | 62 last_output_surface_id_(0), |
| 63 pending_delegated_ack_count_(0), | 63 pending_delegated_ack_count_(0), |
| 64 skipped_frames_(false), | 64 skipped_frames_(false), |
| 65 current_scale_factor_(1.f), | 65 current_scale_factor_(1.f), |
| 66 can_lock_compositor_(YES_CAN_LOCK), | 66 can_lock_compositor_(YES_CAN_LOCK), |
| 67 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 67 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
| 68 ImageTransportFactory::GetInstance()->AddObserver(this); | 68 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 69 factory->AddObserver(this); |
| 70 id_allocator_ = factory->GetContextFactory()->CreateSurfaceIdAllocator(); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { | 73 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { |
| 72 delegated_frame_evictor_->SetVisible(true); | 74 delegated_frame_evictor_->SetVisible(true); |
| 73 | 75 |
| 74 if (surface_id_.is_null() && !frame_provider_.get() && | 76 if (surface_id_.is_null() && !frame_provider_.get() && |
| 75 !released_front_lock_.get()) { | 77 !released_front_lock_.get()) { |
| 76 if (compositor_) | 78 if (compositor_) |
| 77 released_front_lock_ = compositor_->GetCompositorLock(); | 79 released_front_lock_ = compositor_->GetCompositorLock(); |
| 78 } | 80 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void DelegatedFrameHost::BeginFrameSubscription( | 190 void DelegatedFrameHost::BeginFrameSubscription( |
| 189 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 191 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
| 190 frame_subscriber_ = subscriber.Pass(); | 192 frame_subscriber_ = subscriber.Pass(); |
| 191 } | 193 } |
| 192 | 194 |
| 193 void DelegatedFrameHost::EndFrameSubscription() { | 195 void DelegatedFrameHost::EndFrameSubscription() { |
| 194 idle_frame_subscriber_textures_.clear(); | 196 idle_frame_subscriber_textures_.clear(); |
| 195 frame_subscriber_.reset(); | 197 frame_subscriber_.reset(); |
| 196 } | 198 } |
| 197 | 199 |
| 200 uint32_t DelegatedFrameHost::GetSurfaceIdNamespace() { |
| 201 if (!use_surfaces_) |
| 202 return 0; |
| 203 |
| 204 return id_allocator_->id_namespace(); |
| 205 } |
| 206 |
| 198 bool DelegatedFrameHost::ShouldSkipFrame(gfx::Size size_in_dip) const { | 207 bool DelegatedFrameHost::ShouldSkipFrame(gfx::Size size_in_dip) const { |
| 199 // Should skip a frame only when another frame from the renderer is guaranteed | 208 // 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 | 209 // 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.) | 210 // the completion of latency infos (such as when taking a Snapshot.) |
| 202 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || | 211 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || |
| 203 can_lock_compositor_ == NO_PENDING_COMMIT || | 212 can_lock_compositor_ == NO_PENDING_COMMIT || |
| 204 !resize_lock_.get()) | 213 !resize_lock_.get()) |
| 205 return false; | 214 return false; |
| 206 | 215 |
| 207 return size_in_dip != resize_lock_->expected_size(); | 216 return size_in_dip != resize_lock_->expected_size(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 pending_delegated_ack_count_++; | 367 pending_delegated_ack_count_++; |
| 359 | 368 |
| 360 if (frame_size.IsEmpty()) { | 369 if (frame_size.IsEmpty()) { |
| 361 DCHECK(frame_data->resource_list.empty()); | 370 DCHECK(frame_data->resource_list.empty()); |
| 362 EvictDelegatedFrame(); | 371 EvictDelegatedFrame(); |
| 363 } else { | 372 } else { |
| 364 if (use_surfaces_) { | 373 if (use_surfaces_) { |
| 365 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 374 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 366 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 375 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 367 if (!surface_factory_) { | 376 if (!surface_factory_) { |
| 368 id_allocator_ = | |
| 369 factory->GetContextFactory()->CreateSurfaceIdAllocator(); | |
| 370 surface_factory_ = | 377 surface_factory_ = |
| 371 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | 378 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
| 372 } | 379 } |
| 373 if (surface_id_.is_null() || frame_size != current_surface_size_ || | 380 if (surface_id_.is_null() || frame_size != current_surface_size_ || |
| 374 frame_size_in_dip != current_frame_size_in_dip_) { | 381 frame_size_in_dip != current_frame_size_in_dip_) { |
| 375 if (!surface_id_.is_null()) | 382 if (!surface_id_.is_null()) |
| 376 surface_factory_->Destroy(surface_id_); | 383 surface_factory_->Destroy(surface_id_); |
| 377 surface_id_ = id_allocator_->GenerateId(); | 384 surface_id_ = id_allocator_->GenerateId(); |
| 378 surface_factory_->Create(surface_id_); | 385 surface_factory_->Create(surface_id_); |
| 379 // manager must outlive compositors using it. | 386 // manager must outlive compositors using it. |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 1012 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 1006 new_layer->SetShowSurface( | 1013 new_layer->SetShowSurface( |
| 1007 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 1014 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 1008 base::Bind(&RequireCallback, base::Unretained(manager)), | 1015 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 1009 current_surface_size_, current_scale_factor_, | 1016 current_surface_size_, current_scale_factor_, |
| 1010 current_frame_size_in_dip_); | 1017 current_frame_size_in_dip_); |
| 1011 } | 1018 } |
| 1012 } | 1019 } |
| 1013 | 1020 |
| 1014 } // namespace content | 1021 } // namespace content |
| OLD | NEW |