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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 scoped_ptr<cc::CopyOutputRequest> request) { | 47 scoped_ptr<cc::CopyOutputRequest> request) { |
48 GetDelegatedFrameHost()->RequestCopyOfOutput(request.Pass()); | 48 GetDelegatedFrameHost()->RequestCopyOfOutput(request.Pass()); |
49 } | 49 } |
50 | 50 |
51 //////////////////////////////////////////////////////////////////////////////// | 51 //////////////////////////////////////////////////////////////////////////////// |
52 // DelegatedFrameHost | 52 // DelegatedFrameHost |
53 | 53 |
54 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) | 54 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
55 : client_(client), | 55 : client_(client), |
56 use_surfaces_(base::CommandLine::ForCurrentProcess()->HasSwitch( | 56 use_surfaces_(base::CommandLine::ForCurrentProcess()->HasSwitch( |
57 switches::kUseSurfaces)), | 57 switches::kUseSurfaces)), |
58 last_output_surface_id_(0), | 58 last_output_surface_id_(0), |
59 pending_delegated_ack_count_(0), | 59 pending_delegated_ack_count_(0), |
60 skipped_frames_(false), | 60 skipped_frames_(false), |
61 can_lock_compositor_(YES_CAN_LOCK), | 61 can_lock_compositor_(YES_CAN_LOCK), |
62 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 62 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
63 ImageTransportFactory::GetInstance()->AddObserver(this); | 63 ImageTransportFactory::GetInstance()->AddObserver(this); |
64 } | 64 } |
65 | 65 |
66 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { | 66 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { |
67 delegated_frame_evictor_->SetVisible(true); | 67 delegated_frame_evictor_->SetVisible(true); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 ui::Compositor* compositor = client_->GetCompositor(); | 365 ui::Compositor* compositor = client_->GetCompositor(); |
366 if (frame_size.IsEmpty()) { | 366 if (frame_size.IsEmpty()) { |
367 DCHECK(frame_data->resource_list.empty()); | 367 DCHECK(frame_data->resource_list.empty()); |
368 EvictDelegatedFrame(); | 368 EvictDelegatedFrame(); |
369 modified_layers = true; | 369 modified_layers = true; |
370 } else { | 370 } else { |
371 if (use_surfaces_) { | 371 if (use_surfaces_) { |
372 if (!surface_factory_) { | 372 if (!surface_factory_) { |
373 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 373 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
374 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 374 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
375 id_allocator_ = factory->CreateSurfaceIdAllocator(); | 375 id_allocator_ = |
376 factory->GetContextFactory()->CreateSurfaceIdAllocator(); | |
376 surface_factory_ = | 377 surface_factory_ = |
377 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | 378 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
378 } | 379 } |
379 if (surface_id_.is_null() || frame_size != current_surface_size_ || | 380 if (surface_id_.is_null() || frame_size != current_surface_size_ || |
380 frame_size_in_dip != current_frame_size_in_dip_) { | 381 frame_size_in_dip != current_frame_size_in_dip_) { |
381 // TODO(jbauman): Wait to destroy this surface until the parent has | 382 if (!surface_id_.is_null()) { |
382 // finished using it. | 383 if (compositor) { |
383 if (!surface_id_.is_null()) | 384 std::set<cc::SurfaceSequence> s; |
jamesr
2014/09/12 01:08:55
's' seems a bit too terse, maybe 'seq' ?
jbauman
2014/09/23 01:58:05
Done.
| |
384 surface_factory_->Destroy(surface_id_); | 385 s.insert(compositor->CreateSurfaceSequence()); |
386 surface_factory_->DestroyOnSequence(surface_id_, s); | |
387 } else { | |
388 surface_factory_->Destroy(surface_id_); | |
389 } | |
390 } | |
385 surface_id_ = id_allocator_->GenerateId(); | 391 surface_id_ = id_allocator_->GenerateId(); |
386 surface_factory_->Create(surface_id_, frame_size); | 392 surface_factory_->Create(surface_id_, frame_size); |
387 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); | 393 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); |
388 current_surface_size_ = frame_size; | 394 current_surface_size_ = frame_size; |
389 modified_layers = true; | 395 modified_layers = true; |
390 } | 396 } |
391 scoped_ptr<cc::CompositorFrame> compositor_frame = | 397 scoped_ptr<cc::CompositorFrame> compositor_frame = |
392 make_scoped_ptr(new cc::CompositorFrame()); | 398 make_scoped_ptr(new cc::CompositorFrame()); |
393 compositor_frame->delegated_frame_data = frame_data.Pass(); | 399 compositor_frame->delegated_frame_data = frame_data.Pass(); |
394 base::Closure ack_callback; | 400 base::Closure ack_callback; |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 if (frame_provider_.get()) { | 982 if (frame_provider_.get()) { |
977 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 983 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
978 current_frame_size_in_dip_); | 984 current_frame_size_in_dip_); |
979 } | 985 } |
980 if (!surface_id_.is_null()) { | 986 if (!surface_id_.is_null()) { |
981 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); | 987 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); |
982 } | 988 } |
983 } | 989 } |
984 | 990 |
985 } // namespace content | 991 } // namespace content |
OLD | NEW |