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

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

Issue 2773433003: Fix CompositorResizeLock to do something. (Closed)
Patch Set: resizelock: observer-rebase Created 3 years, 8 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 18 matching lines...) Expand all
59 factory->GetContextFactoryPrivate()->GetSurfaceManager()->RegisterFrameSinkId( 59 factory->GetContextFactoryPrivate()->GetSurfaceManager()->RegisterFrameSinkId(
60 frame_sink_id_); 60 frame_sink_id_);
61 CreateCompositorFrameSinkSupport(); 61 CreateCompositorFrameSinkSupport();
62 } 62 }
63 63
64 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { 64 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) {
65 delegated_frame_evictor_->SetVisible(true); 65 delegated_frame_evictor_->SetVisible(true);
66 66
67 if (!has_frame_ && !released_front_lock_.get()) { 67 if (!has_frame_ && !released_front_lock_.get()) {
68 if (compositor_) 68 if (compositor_)
69 released_front_lock_ = compositor_->GetCompositorLock(); 69 released_front_lock_ = compositor_->GetCompositorLock(nullptr);
70 } 70 }
71 71
72 if (compositor_) { 72 if (compositor_) {
73 compositor_->SetLatencyInfo(latency_info); 73 compositor_->SetLatencyInfo(latency_info);
74 } 74 }
75 } 75 }
76 76
77 bool DelegatedFrameHost::HasSavedFrame() { 77 bool DelegatedFrameHost::HasSavedFrame() {
78 return delegated_frame_evictor_->HasFrame(); 78 return delegated_frame_evictor_->HasFrame();
79 } 79 }
80 80
81 void DelegatedFrameHost::WasHidden() { 81 void DelegatedFrameHost::WasHidden() {
82 delegated_frame_evictor_->SetVisible(false); 82 delegated_frame_evictor_->SetVisible(false);
83 released_front_lock_ = NULL; 83 released_front_lock_ = NULL;
84 } 84 }
85 85
86 void DelegatedFrameHost::MaybeCreateResizeLock() { 86 void DelegatedFrameHost::MaybeCreateResizeLock() {
87 if (!ShouldCreateResizeLock()) 87 if (!ShouldCreateResizeLock())
88 return; 88 return;
89 DCHECK(compositor_); 89 DCHECK(compositor_);
90 90
91 bool defer_compositor_lock = 91 bool defer_compositor_lock =
92 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || 92 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME ||
93 can_lock_compositor_ == NO_PENDING_COMMIT; 93 can_lock_compositor_ == NO_PENDING_COMMIT;
94 94
95 if (can_lock_compositor_ == YES_CAN_LOCK) 95 if (can_lock_compositor_ == YES_CAN_LOCK)
96 can_lock_compositor_ = YES_DID_LOCK; 96 can_lock_compositor_ = YES_DID_LOCK;
97 97
98 resize_lock_ = 98 resize_lock_ = client_->DelegatedFrameHostCreateResizeLock();
99 client_->DelegatedFrameHostCreateResizeLock(defer_compositor_lock); 99 if (!defer_compositor_lock) {
100 bool locked = resize_lock_->Lock();
101 DCHECK(locked);
102 }
100 } 103 }
101 104
102 bool DelegatedFrameHost::ShouldCreateResizeLock() { 105 bool DelegatedFrameHost::ShouldCreateResizeLock() {
103 static const bool is_disabled = 106 static const bool is_disabled =
104 base::CommandLine::ForCurrentProcess()->HasSwitch( 107 base::CommandLine::ForCurrentProcess()->HasSwitch(
105 switches::kDisableResizeLock); 108 switches::kDisableResizeLock);
106 if (is_disabled) 109 if (is_disabled)
107 return false; 110 return false;
108 111
109 if (!client_->DelegatedFrameCanCreateResizeLock()) 112 if (!client_->DelegatedFrameCanCreateResizeLock())
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 finished_callback); 716 finished_callback);
714 media::LetterboxYUV(video_frame.get(), region_in_frame); 717 media::LetterboxYUV(video_frame.get(), region_in_frame);
715 } 718 }
716 719
717 //////////////////////////////////////////////////////////////////////////////// 720 ////////////////////////////////////////////////////////////////////////////////
718 // DelegatedFrameHost, ui::CompositorObserver implementation: 721 // DelegatedFrameHost, ui::CompositorObserver implementation:
719 722
720 void DelegatedFrameHost::OnCompositingDidCommit(ui::Compositor* compositor) { 723 void DelegatedFrameHost::OnCompositingDidCommit(ui::Compositor* compositor) {
721 if (can_lock_compositor_ == NO_PENDING_COMMIT) { 724 if (can_lock_compositor_ == NO_PENDING_COMMIT) {
722 can_lock_compositor_ = YES_CAN_LOCK; 725 can_lock_compositor_ = YES_CAN_LOCK;
723 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) 726 if (resize_lock_ && resize_lock_->Lock())
724 can_lock_compositor_ = YES_DID_LOCK; 727 can_lock_compositor_ = YES_DID_LOCK;
725 } 728 }
726 if (resize_lock_ && 729 if (resize_lock_ &&
727 resize_lock_->expected_size() == current_frame_size_in_dip_) { 730 resize_lock_->expected_size() == current_frame_size_in_dip_) {
728 resize_lock_.reset(); 731 resize_lock_.reset();
729 client_->DelegatedFrameHostResizeLockWasReleased(); 732 client_->DelegatedFrameHostResizeLockWasReleased();
730 // We may have had a resize while we had the lock (e.g. if the lock expired, 733 // We may have had a resize while we had the lock (e.g. if the lock expired,
731 // or if the UI still gave us some resizes), so make sure we grab a new lock 734 // or if the UI still gave us some resizes), so make sure we grab a new lock
732 // if necessary. 735 // if necessary.
733 MaybeCreateResizeLock(); 736 MaybeCreateResizeLock();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 } 875 }
873 876
874 if (!skipped_frames_) { 877 if (!skipped_frames_) {
875 latest_confirmed_begin_frame_source_id_ = ack.source_id; 878 latest_confirmed_begin_frame_source_id_ = ack.source_id;
876 latest_confirmed_begin_frame_sequence_number_ = 879 latest_confirmed_begin_frame_sequence_number_ =
877 ack.latest_confirmed_sequence_number; 880 ack.latest_confirmed_sequence_number;
878 } 881 }
879 } 882 }
880 883
881 } // namespace content 884 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/delegated_frame_host.h ('k') | content/browser/renderer_host/delegated_frame_host_client_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698