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" |
11 #include "cc/output/copy_output_request.h" | 11 #include "cc/output/copy_output_request.h" |
12 #include "cc/resources/single_release_callback.h" | 12 #include "cc/resources/single_release_callback.h" |
13 #include "cc/resources/texture_mailbox.h" | 13 #include "cc/resources/texture_mailbox.h" |
14 #include "content/browser/compositor/resize_lock.h" | 14 #include "content/browser/compositor/resize_lock.h" |
| 15 #include "content/common/gpu/client/gl_helper.h" |
15 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" | 16 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" |
16 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
17 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
18 #include "media/base/video_util.h" | 19 #include "media/base/video_util.h" |
19 #include "skia/ext/image_operations.h" | 20 #include "skia/ext/image_operations.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 //////////////////////////////////////////////////////////////////////////////// | 24 //////////////////////////////////////////////////////////////////////////////// |
24 // DelegatedFrameHostClient | 25 // DelegatedFrameHostClient |
25 | 26 |
26 bool DelegatedFrameHostClient::ShouldCreateResizeLock() { | 27 bool DelegatedFrameHostClient::ShouldCreateResizeLock() { |
27 return GetDelegatedFrameHost()->ShouldCreateResizeLock(); | 28 return GetDelegatedFrameHost()->ShouldCreateResizeLock(); |
28 } | 29 } |
29 | 30 |
30 void DelegatedFrameHostClient::RequestCopyOfOutput( | 31 void DelegatedFrameHostClient::RequestCopyOfOutput( |
31 scoped_ptr<cc::CopyOutputRequest> request) { | 32 scoped_ptr<cc::CopyOutputRequest> request) { |
32 return GetDelegatedFrameHost()->RequestCopyOfOutput(request.Pass()); | 33 return GetDelegatedFrameHost()->RequestCopyOfOutput(request.Pass()); |
33 } | 34 } |
34 | 35 |
35 //////////////////////////////////////////////////////////////////////////////// | 36 //////////////////////////////////////////////////////////////////////////////// |
36 // DelegatedFrameHost | 37 // DelegatedFrameHost |
37 | 38 |
38 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) | 39 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
39 : client_(client), | 40 : client_(client), |
40 last_output_surface_id_(0), | 41 last_output_surface_id_(0), |
41 pending_delegated_ack_count_(0), | 42 pending_delegated_ack_count_(0), |
42 skipped_frames_(false), | 43 skipped_frames_(false), |
43 can_lock_compositor_(YES), | 44 can_lock_compositor_(YES_CAN_LOCK), |
44 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 45 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
45 ImageTransportFactory::GetInstance()->AddObserver(this); | 46 ImageTransportFactory::GetInstance()->AddObserver(this); |
46 } | 47 } |
47 | 48 |
48 void DelegatedFrameHost::WasShown() { | 49 void DelegatedFrameHost::WasShown() { |
49 RenderWidgetHostImpl* host = client_->GetHost(); | 50 RenderWidgetHostImpl* host = client_->GetHost(); |
50 delegated_frame_evictor_->SetVisible(true); | 51 delegated_frame_evictor_->SetVisible(true); |
51 | 52 |
52 if (host->is_accelerated_compositing_active() && | 53 if (host->is_accelerated_compositing_active() && |
53 !released_front_lock_.get()) { | 54 !released_front_lock_.get()) { |
(...skipping 15 matching lines...) Expand all Loading... |
69 | 70 |
70 // Listen to changes in the compositor lock state. | 71 // Listen to changes in the compositor lock state. |
71 ui::Compositor* compositor = client_->GetCompositor(); | 72 ui::Compositor* compositor = client_->GetCompositor(); |
72 if (!compositor->HasObserver(this)) | 73 if (!compositor->HasObserver(this)) |
73 compositor->AddObserver(this); | 74 compositor->AddObserver(this); |
74 | 75 |
75 bool defer_compositor_lock = | 76 bool defer_compositor_lock = |
76 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || | 77 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || |
77 can_lock_compositor_ == NO_PENDING_COMMIT; | 78 can_lock_compositor_ == NO_PENDING_COMMIT; |
78 | 79 |
79 if (can_lock_compositor_ == YES) | 80 if (can_lock_compositor_ == YES_CAN_LOCK) |
80 can_lock_compositor_ = YES_DID_LOCK; | 81 can_lock_compositor_ = YES_DID_LOCK; |
81 | 82 |
82 resize_lock_ = client_->CreateResizeLock(defer_compositor_lock); | 83 resize_lock_ = client_->CreateResizeLock(defer_compositor_lock); |
83 } | 84 } |
84 | 85 |
85 bool DelegatedFrameHost::ShouldCreateResizeLock() { | 86 bool DelegatedFrameHost::ShouldCreateResizeLock() { |
86 RenderWidgetHostImpl* host = client_->GetHost(); | |
87 | |
88 // On Windows while resizing, the the resize locks makes us mis-paint a white | 87 // On Windows while resizing, the the resize locks makes us mis-paint a white |
89 // vertical strip (including the non-client area) if the content composition | 88 // vertical strip (including the non-client area) if the content composition |
90 // is lagging the UI composition. So here we disable the throttling so that | 89 // is lagging the UI composition. So here we disable the throttling so that |
91 // the UI bits can draw ahead of the content thereby reducing the amount of | 90 // the UI bits can draw ahead of the content thereby reducing the amount of |
92 // whiteout. Because this causes the content to be drawn at wrong sizes while | 91 // whiteout. Because this causes the content to be drawn at wrong sizes while |
93 // resizing we compensate by blocking the UI thread in Compositor::Draw() by | 92 // resizing we compensate by blocking the UI thread in Compositor::Draw() by |
94 // issuing a FinishAllRendering() if we are resizing. | 93 // issuing a FinishAllRendering() if we are resizing. |
95 #if defined(OS_WIN) | 94 // TODO(ccameron): Mac browser window resizing is incompletely implemented. |
| 95 #if defined(OS_WIN) || defined(OS_MACOSX) |
96 return false; | 96 return false; |
97 #else | 97 #else |
| 98 RenderWidgetHostImpl* host = client_->GetHost(); |
| 99 |
98 if (resize_lock_) | 100 if (resize_lock_) |
99 return false; | 101 return false; |
100 | 102 |
101 if (host->should_auto_resize()) | 103 if (host->should_auto_resize()) |
102 return false; | 104 return false; |
103 if (!host->is_accelerated_compositing_active()) | 105 if (!host->is_accelerated_compositing_active()) |
104 return false; | 106 return false; |
105 | 107 |
106 gfx::Size desired_size = client_->DesiredFrameSize(); | 108 gfx::Size desired_size = client_->DesiredFrameSize(); |
107 if (desired_size == current_frame_size_in_dip_) | 109 if (desired_size == current_frame_size_in_dip_) |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 finished_callback); | 719 finished_callback); |
718 } | 720 } |
719 | 721 |
720 //////////////////////////////////////////////////////////////////////////////// | 722 //////////////////////////////////////////////////////////////////////////////// |
721 // DelegatedFrameHost, ui::CompositorObserver implementation: | 723 // DelegatedFrameHost, ui::CompositorObserver implementation: |
722 | 724 |
723 void DelegatedFrameHost::OnCompositingDidCommit( | 725 void DelegatedFrameHost::OnCompositingDidCommit( |
724 ui::Compositor* compositor) { | 726 ui::Compositor* compositor) { |
725 RenderWidgetHostImpl* host = client_->GetHost(); | 727 RenderWidgetHostImpl* host = client_->GetHost(); |
726 if (can_lock_compositor_ == NO_PENDING_COMMIT) { | 728 if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
727 can_lock_compositor_ = YES; | 729 can_lock_compositor_ = YES_CAN_LOCK; |
728 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) | 730 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) |
729 can_lock_compositor_ = YES_DID_LOCK; | 731 can_lock_compositor_ = YES_DID_LOCK; |
730 } | 732 } |
731 RunOnCommitCallbacks(); | 733 RunOnCommitCallbacks(); |
732 if (resize_lock_ && | 734 if (resize_lock_ && |
733 resize_lock_->expected_size() == current_frame_size_in_dip_) { | 735 resize_lock_->expected_size() == current_frame_size_in_dip_) { |
734 resize_lock_.reset(); | 736 resize_lock_.reset(); |
735 host->WasResized(); | 737 host->WasResized(); |
736 // We may have had a resize while we had the lock (e.g. if the lock expired, | 738 // We may have had a resize while we had the lock (e.g. if the lock expired, |
737 // or if the UI still gave us some resizes), so make sure we grab a new lock | 739 // or if the UI still gave us some resizes), so make sure we grab a new lock |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 // that should keep our frame. old_layer will be returned to the | 869 // that should keep our frame. old_layer will be returned to the |
868 // RecreateLayer caller, and should have a copy. | 870 // RecreateLayer caller, and should have a copy. |
869 if (frame_provider_.get()) { | 871 if (frame_provider_.get()) { |
870 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 872 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
871 current_frame_size_in_dip_); | 873 current_frame_size_in_dip_); |
872 } | 874 } |
873 } | 875 } |
874 | 876 |
875 } // namespace content | 877 } // namespace content |
876 | 878 |
OLD | NEW |