| 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 29 matching lines...) Expand all Loading... |
| 40 : client_(client), | 40 : client_(client), |
| 41 last_output_surface_id_(0), | 41 last_output_surface_id_(0), |
| 42 pending_delegated_ack_count_(0), | 42 pending_delegated_ack_count_(0), |
| 43 skipped_frames_(false), | 43 skipped_frames_(false), |
| 44 can_lock_compositor_(YES_CAN_LOCK), | 44 can_lock_compositor_(YES_CAN_LOCK), |
| 45 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 45 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
| 46 ImageTransportFactory::GetInstance()->AddObserver(this); | 46 ImageTransportFactory::GetInstance()->AddObserver(this); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void DelegatedFrameHost::WasShown() { | 49 void DelegatedFrameHost::WasShown() { |
| 50 RenderWidgetHostImpl* host = client_->GetHost(); | |
| 51 delegated_frame_evictor_->SetVisible(true); | 50 delegated_frame_evictor_->SetVisible(true); |
| 52 | 51 |
| 53 if (host->is_accelerated_compositing_active() && | 52 if (!released_front_lock_.get()) { |
| 54 !released_front_lock_.get()) { | |
| 55 ui::Compositor* compositor = client_->GetCompositor(); | 53 ui::Compositor* compositor = client_->GetCompositor(); |
| 56 if (compositor) | 54 if (compositor) |
| 57 released_front_lock_ = compositor->GetCompositorLock(); | 55 released_front_lock_ = compositor->GetCompositorLock(); |
| 58 } | 56 } |
| 59 } | 57 } |
| 60 | 58 |
| 61 void DelegatedFrameHost::WasHidden() { | 59 void DelegatedFrameHost::WasHidden() { |
| 62 delegated_frame_evictor_->SetVisible(false); | 60 delegated_frame_evictor_->SetVisible(false); |
| 63 released_front_lock_ = NULL; | 61 released_front_lock_ = NULL; |
| 64 } | 62 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 93 #if !defined(OS_CHROMEOS) | 91 #if !defined(OS_CHROMEOS) |
| 94 return false; | 92 return false; |
| 95 #else | 93 #else |
| 96 RenderWidgetHostImpl* host = client_->GetHost(); | 94 RenderWidgetHostImpl* host = client_->GetHost(); |
| 97 | 95 |
| 98 if (resize_lock_) | 96 if (resize_lock_) |
| 99 return false; | 97 return false; |
| 100 | 98 |
| 101 if (host->should_auto_resize()) | 99 if (host->should_auto_resize()) |
| 102 return false; | 100 return false; |
| 103 if (!host->is_accelerated_compositing_active()) | |
| 104 return false; | |
| 105 | 101 |
| 106 gfx::Size desired_size = client_->DesiredFrameSize(); | 102 gfx::Size desired_size = client_->DesiredFrameSize(); |
| 107 if (desired_size == current_frame_size_in_dip_) | 103 if (desired_size == current_frame_size_in_dip_) |
| 108 return false; | 104 return false; |
| 109 | 105 |
| 110 ui::Compositor* compositor = client_->GetCompositor(); | 106 ui::Compositor* compositor = client_->GetCompositor(); |
| 111 if (!compositor) | 107 if (!compositor) |
| 112 return false; | 108 return false; |
| 113 | 109 |
| 114 return true; | 110 return true; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 190 } |
| 195 client_->RequestCopyOfOutput(request.Pass()); | 191 client_->RequestCopyOfOutput(request.Pass()); |
| 196 } | 192 } |
| 197 | 193 |
| 198 bool DelegatedFrameHost::CanCopyToBitmap() const { | 194 bool DelegatedFrameHost::CanCopyToBitmap() const { |
| 199 return client_->GetCompositor() && | 195 return client_->GetCompositor() && |
| 200 client_->GetLayer()->has_external_content(); | 196 client_->GetLayer()->has_external_content(); |
| 201 } | 197 } |
| 202 | 198 |
| 203 bool DelegatedFrameHost::CanCopyToVideoFrame() const { | 199 bool DelegatedFrameHost::CanCopyToVideoFrame() const { |
| 204 RenderWidgetHostImpl* host = client_->GetHost(); | |
| 205 return client_->GetCompositor() && | 200 return client_->GetCompositor() && |
| 206 client_->GetLayer()->has_external_content() && | 201 client_->GetLayer()->has_external_content(); |
| 207 host->is_accelerated_compositing_active(); | |
| 208 } | 202 } |
| 209 | 203 |
| 210 bool DelegatedFrameHost::CanSubscribeFrame() const { | 204 bool DelegatedFrameHost::CanSubscribeFrame() const { |
| 211 return true; | 205 return true; |
| 212 } | 206 } |
| 213 | 207 |
| 214 void DelegatedFrameHost::BeginFrameSubscription( | 208 void DelegatedFrameHost::BeginFrameSubscription( |
| 215 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 209 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
| 216 frame_subscriber_ = subscriber.Pass(); | 210 frame_subscriber_ = subscriber.Pass(); |
| 217 } | 211 } |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 // that should keep our frame. old_layer will be returned to the | 853 // that should keep our frame. old_layer will be returned to the |
| 860 // RecreateLayer caller, and should have a copy. | 854 // RecreateLayer caller, and should have a copy. |
| 861 if (frame_provider_.get()) { | 855 if (frame_provider_.get()) { |
| 862 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 856 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
| 863 current_frame_size_in_dip_); | 857 current_frame_size_in_dip_); |
| 864 } | 858 } |
| 865 } | 859 } |
| 866 | 860 |
| 867 } // namespace content | 861 } // namespace content |
| 868 | 862 |
| OLD | NEW |