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