Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: content/browser/renderer_host/delegated_frame_host.cc

Issue 2773433003: Fix CompositorResizeLock to do something. (Closed)
Patch Set: resizelock: timeoutparam Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/renderer_host/delegated_frame_host.h" 5 #include "content/browser/renderer_host/delegated_frame_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/time/default_tick_clock.h" 15 #include "base/time/default_tick_clock.h"
16 #include "cc/base/switches.h" 16 #include "cc/base/switches.h"
17 #include "cc/output/compositor_frame.h" 17 #include "cc/output/compositor_frame.h"
18 #include "cc/output/copy_output_request.h" 18 #include "cc/output/copy_output_request.h"
19 #include "cc/resources/single_release_callback.h" 19 #include "cc/resources/single_release_callback.h"
20 #include "cc/resources/texture_mailbox.h" 20 #include "cc/resources/texture_mailbox.h"
21 #include "cc/surfaces/compositor_frame_sink_support.h" 21 #include "cc/surfaces/compositor_frame_sink_support.h"
22 #include "cc/surfaces/surface.h" 22 #include "cc/surfaces/surface.h"
23 #include "cc/surfaces/surface_factory.h" 23 #include "cc/surfaces/surface_factory.h"
24 #include "cc/surfaces/surface_hittest.h" 24 #include "cc/surfaces/surface_hittest.h"
25 #include "cc/surfaces/surface_manager.h" 25 #include "cc/surfaces/surface_manager.h"
26 #include "components/display_compositor/gl_helper.h" 26 #include "components/display_compositor/gl_helper.h"
27 #include "content/browser/compositor/surface_utils.h" 27 #include "content/browser/compositor/surface_utils.h"
28 #include "content/browser/gpu/compositor_util.h" 28 #include "content/browser/gpu/compositor_util.h"
29 #include "content/browser/renderer_host/compositor_resize_lock.h"
29 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber .h" 30 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber .h"
30 #include "content/browser/renderer_host/resize_lock.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "media/base/video_frame.h" 32 #include "media/base/video_frame.h"
33 #include "media/base/video_util.h" 33 #include "media/base/video_util.h"
34 #include "skia/ext/image_operations.h" 34 #include "skia/ext/image_operations.h"
35 #include "third_party/skia/include/core/SkCanvas.h" 35 #include "third_party/skia/include/core/SkCanvas.h"
36 #include "third_party/skia/include/core/SkPaint.h" 36 #include "third_party/skia/include/core/SkPaint.h"
37 #include "third_party/skia/include/effects/SkLumaColorFilter.h" 37 #include "third_party/skia/include/effects/SkLumaColorFilter.h"
38 #include "ui/gfx/geometry/dip_util.h" 38 #include "ui/gfx/geometry/dip_util.h"
39 39
40 namespace content { 40 namespace content {
(...skipping 20 matching lines...) Expand all
61 CreateCompositorFrameSinkSupport(); 61 CreateCompositorFrameSinkSupport();
62 begin_frame_source_ = base::MakeUnique<cc::ExternalBeginFrameSource>(this); 62 begin_frame_source_ = base::MakeUnique<cc::ExternalBeginFrameSource>(this);
63 client_->SetBeginFrameSource(begin_frame_source_.get()); 63 client_->SetBeginFrameSource(begin_frame_source_.get());
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);
68 68
69 if (!has_frame_ && !released_front_lock_.get()) { 69 if (!has_frame_ && !released_front_lock_.get()) {
70 if (compositor_) 70 if (compositor_)
71 released_front_lock_ = compositor_->GetCompositorLock(); 71 released_front_lock_ = compositor_->GetCompositorLock(nullptr);
72 } 72 }
73 73
74 if (compositor_) { 74 if (compositor_) {
75 compositor_->SetLatencyInfo(latency_info); 75 compositor_->SetLatencyInfo(latency_info);
76 } 76 }
77 } 77 }
78 78
79 bool DelegatedFrameHost::HasSavedFrame() { 79 bool DelegatedFrameHost::HasSavedFrame() {
80 return delegated_frame_evictor_->HasFrame(); 80 return delegated_frame_evictor_->HasFrame();
81 } 81 }
82 82
83 void DelegatedFrameHost::WasHidden() { 83 void DelegatedFrameHost::WasHidden() {
84 delegated_frame_evictor_->SetVisible(false); 84 delegated_frame_evictor_->SetVisible(false);
85 released_front_lock_ = NULL; 85 released_front_lock_ = NULL;
86 } 86 }
87 87
88 void DelegatedFrameHost::MaybeCreateResizeLock() { 88 void DelegatedFrameHost::MaybeCreateResizeLock() {
89 if (!ShouldCreateResizeLock()) 89 if (!ShouldCreateResizeLock())
90 return; 90 return;
91 DCHECK(compositor_); 91 DCHECK(compositor_);
92 92
93 bool defer_compositor_lock = 93 bool defer_compositor_lock =
94 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || 94 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME ||
95 can_lock_compositor_ == NO_PENDING_COMMIT; 95 can_lock_compositor_ == NO_PENDING_COMMIT;
96 96
97 if (can_lock_compositor_ == YES_CAN_LOCK) 97 if (can_lock_compositor_ == YES_CAN_LOCK)
98 can_lock_compositor_ = YES_DID_LOCK; 98 can_lock_compositor_ = YES_DID_LOCK;
99 99
100 resize_lock_ = 100 resize_lock_ = client_->DelegatedFrameHostCreateResizeLock();
101 client_->DelegatedFrameHostCreateResizeLock(defer_compositor_lock); 101 if (!defer_compositor_lock) {
102 bool locked = resize_lock_->Lock();
103 DCHECK(locked);
104 }
102 } 105 }
103 106
104 bool DelegatedFrameHost::ShouldCreateResizeLock() { 107 bool DelegatedFrameHost::ShouldCreateResizeLock() {
105 static const bool is_disabled = 108 static const bool is_disabled =
106 base::CommandLine::ForCurrentProcess()->HasSwitch( 109 base::CommandLine::ForCurrentProcess()->HasSwitch(
107 switches::kDisableResizeLock); 110 switches::kDisableResizeLock);
108 if (is_disabled) 111 if (is_disabled)
109 return false; 112 return false;
110 113
111 if (!client_->DelegatedFrameCanCreateResizeLock()) 114 if (!client_->DelegatedFrameCanCreateResizeLock())
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 finished_callback); 693 finished_callback);
691 media::LetterboxYUV(video_frame.get(), region_in_frame); 694 media::LetterboxYUV(video_frame.get(), region_in_frame);
692 } 695 }
693 696
694 //////////////////////////////////////////////////////////////////////////////// 697 ////////////////////////////////////////////////////////////////////////////////
695 // DelegatedFrameHost, ui::CompositorObserver implementation: 698 // DelegatedFrameHost, ui::CompositorObserver implementation:
696 699
697 void DelegatedFrameHost::OnCompositingDidCommit(ui::Compositor* compositor) { 700 void DelegatedFrameHost::OnCompositingDidCommit(ui::Compositor* compositor) {
698 if (can_lock_compositor_ == NO_PENDING_COMMIT) { 701 if (can_lock_compositor_ == NO_PENDING_COMMIT) {
699 can_lock_compositor_ = YES_CAN_LOCK; 702 can_lock_compositor_ = YES_CAN_LOCK;
700 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) 703 if (resize_lock_ && resize_lock_->Lock())
701 can_lock_compositor_ = YES_DID_LOCK; 704 can_lock_compositor_ = YES_DID_LOCK;
702 } 705 }
703 if (resize_lock_ && 706 if (resize_lock_ &&
704 resize_lock_->expected_size() == current_frame_size_in_dip_) { 707 resize_lock_->expected_size() == current_frame_size_in_dip_) {
705 resize_lock_.reset(); 708 resize_lock_.reset();
706 client_->DelegatedFrameHostResizeLockWasReleased(); 709 client_->DelegatedFrameHostResizeLockWasReleased();
707 // We may have had a resize while we had the lock (e.g. if the lock expired, 710 // We may have had a resize while we had the lock (e.g. if the lock expired,
708 // or if the UI still gave us some resizes), so make sure we grab a new lock 711 // or if the UI still gave us some resizes), so make sure we grab a new lock
709 // if necessary. 712 // if necessary.
710 MaybeCreateResizeLock(); 713 MaybeCreateResizeLock();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 872
870 void DelegatedFrameHost::ResetCompositorFrameSinkSupport() { 873 void DelegatedFrameHost::ResetCompositorFrameSinkSupport() {
871 if (!support_) 874 if (!support_)
872 return; 875 return;
873 if (compositor_) 876 if (compositor_)
874 compositor_->RemoveFrameSink(frame_sink_id_); 877 compositor_->RemoveFrameSink(frame_sink_id_);
875 support_.reset(); 878 support_.reset();
876 } 879 }
877 880
878 } // namespace content 881 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698