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

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

Issue 2780713004: Hide compositor_frame_sink_id from RenderWidgetHostView* (Closed)
Patch Set: Fixed typo 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 #include "ui/gfx/android/java_bitmap.h" 94 #include "ui/gfx/android/java_bitmap.h"
95 #include "ui/gfx/android/view_configuration.h" 95 #include "ui/gfx/android/view_configuration.h"
96 #include "ui/gfx/geometry/dip_util.h" 96 #include "ui/gfx/geometry/dip_util.h"
97 #include "ui/gfx/geometry/size_conversions.h" 97 #include "ui/gfx/geometry/size_conversions.h"
98 #include "ui/touch_selection/touch_selection_controller.h" 98 #include "ui/touch_selection/touch_selection_controller.h"
99 99
100 namespace content { 100 namespace content {
101 101
102 namespace { 102 namespace {
103 103
104 const int kUndefinedCompositorFrameSinkId = -1;
105
106 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; 104 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime";
107 105
108 class PendingReadbackLock; 106 class PendingReadbackLock;
109 107
110 PendingReadbackLock* g_pending_readback_lock = nullptr; 108 PendingReadbackLock* g_pending_readback_lock = nullptr;
111 109
112 class PendingReadbackLock : public base::RefCounted<PendingReadbackLock> { 110 class PendingReadbackLock : public base::RefCounted<PendingReadbackLock> {
113 public: 111 public:
114 PendingReadbackLock() { 112 PendingReadbackLock() {
115 DCHECK_EQ(g_pending_readback_lock, nullptr); 113 DCHECK_EQ(g_pending_readback_lock, nullptr);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 begin_frame_source_(nullptr), 444 begin_frame_source_(nullptr),
447 outstanding_begin_frame_requests_(0), 445 outstanding_begin_frame_requests_(0),
448 is_showing_(!widget_host->is_hidden()), 446 is_showing_(!widget_host->is_hidden()),
449 is_window_visible_(true), 447 is_window_visible_(true),
450 is_window_activity_started_(true), 448 is_window_activity_started_(true),
451 is_in_vr_(false), 449 is_in_vr_(false),
452 content_view_core_(nullptr), 450 content_view_core_(nullptr),
453 ime_adapter_android_(nullptr), 451 ime_adapter_android_(nullptr),
454 cached_background_color_(SK_ColorWHITE), 452 cached_background_color_(SK_ColorWHITE),
455 view_(this), 453 view_(this),
456 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId),
457 gesture_provider_(ui::GetGestureProviderConfig( 454 gesture_provider_(ui::GetGestureProviderConfig(
458 ui::GestureProviderConfigType::CURRENT_PLATFORM), 455 ui::GestureProviderConfigType::CURRENT_PLATFORM),
459 this), 456 this),
460 stylus_text_selector_(this), 457 stylus_text_selector_(this),
461 using_browser_compositor_(CompositorImpl::IsInitialized()), 458 using_browser_compositor_(CompositorImpl::IsInitialized()),
462 synchronous_compositor_client_(nullptr), 459 synchronous_compositor_client_(nullptr),
463 frame_evictor_(new DelegatedFrameEvictor(this)), 460 frame_evictor_(new DelegatedFrameEvictor(this)),
464 observing_root_window_(false), 461 observing_root_window_(false),
465 prev_top_shown_pix_(0.f), 462 prev_top_shown_pix_(0.f),
466 prev_bottom_shown_pix_(0.f), 463 prev_bottom_shown_pix_(0.f),
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 } 1092 }
1096 1093
1097 std::unique_ptr<SyntheticGestureTarget> 1094 std::unique_ptr<SyntheticGestureTarget>
1098 RenderWidgetHostViewAndroid::CreateSyntheticGestureTarget() { 1095 RenderWidgetHostViewAndroid::CreateSyntheticGestureTarget() {
1099 return std::unique_ptr<SyntheticGestureTarget>( 1096 return std::unique_ptr<SyntheticGestureTarget>(
1100 new SyntheticGestureTargetAndroid( 1097 new SyntheticGestureTargetAndroid(
1101 host_, content_view_core_->CreateMotionEventSynthesizer())); 1098 host_, content_view_core_->CreateMotionEventSynthesizer()));
1102 } 1099 }
1103 1100
1104 void RenderWidgetHostViewAndroid::SendReclaimCompositorResources( 1101 void RenderWidgetHostViewAndroid::SendReclaimCompositorResources(
1105 uint32_t compositor_frame_sink_id,
1106 bool is_swap_ack) { 1102 bool is_swap_ack) {
1107 DCHECK(host_); 1103 DCHECK(host_);
1108 host_->Send(new ViewMsg_ReclaimCompositorResources( 1104 host_->SendReclaimCompositorResources(is_swap_ack,
1109 host_->GetRoutingID(), compositor_frame_sink_id, is_swap_ack, 1105 surface_returned_resources_);
1110 surface_returned_resources_));
1111 surface_returned_resources_.clear(); 1106 surface_returned_resources_.clear();
1112 } 1107 }
1113 1108
1114 void RenderWidgetHostViewAndroid::DidReceiveCompositorFrameAck() { 1109 void RenderWidgetHostViewAndroid::DidReceiveCompositorFrameAck() {
1115 RunAckCallbacks(); 1110 RunAckCallbacks();
1116 } 1111 }
1117 1112
1118 void RenderWidgetHostViewAndroid::ReclaimResources( 1113 void RenderWidgetHostViewAndroid::ReclaimResources(
1119 const cc::ReturnedResourceArray& resources) { 1114 const cc::ReturnedResourceArray& resources) {
1120 if (resources.empty()) 1115 if (resources.empty())
1121 return; 1116 return;
1122 std::copy(resources.begin(), resources.end(), 1117 std::copy(resources.begin(), resources.end(),
1123 std::back_inserter(surface_returned_resources_)); 1118 std::back_inserter(surface_returned_resources_));
1124 if (ack_callbacks_.empty()) 1119 if (ack_callbacks_.empty())
1125 SendReclaimCompositorResources(last_compositor_frame_sink_id_, 1120 SendReclaimCompositorResources(false /* is_swap_ack */);
1126 false /* is_swap_ack */);
1127 } 1121 }
1128 1122
1129 void RenderWidgetHostViewAndroid::CheckCompositorFrameSinkChanged( 1123 void RenderWidgetHostViewAndroid::DidCreateNewRendererCompositorFrameSink() {
1130 uint32_t compositor_frame_sink_id) { 1124 surface_returned_resources_.clear();
piman 2017/03/28 23:07:46 Is it ok not to return the resources? Why?
Saman Sami 2017/03/28 23:36:30 Because the resources we currently have belong to
piman 2017/03/29 17:41:49 Maybe worth a comment.
1131 if (compositor_frame_sink_id == last_compositor_frame_sink_id_)
1132 return;
1133
1134 delegated_frame_host_->CompositorFrameSinkChanged(); 1125 delegated_frame_host_->CompositorFrameSinkChanged();
1135
1136 if (!surface_returned_resources_.empty())
1137 SendReclaimCompositorResources(last_compositor_frame_sink_id_,
1138 false /* is_swap_ack */);
1139
1140 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
1141 } 1126 }
1142 1127
1143 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( 1128 void RenderWidgetHostViewAndroid::SubmitCompositorFrame(
1144 uint32_t compositor_frame_sink_id,
1145 const cc::LocalSurfaceId& local_surface_id, 1129 const cc::LocalSurfaceId& local_surface_id,
1146 cc::CompositorFrame frame) { 1130 cc::CompositorFrame frame) {
1147 last_scroll_offset_ = frame.metadata.root_scroll_offset; 1131 last_scroll_offset_ = frame.metadata.root_scroll_offset;
1148 DCHECK(delegated_frame_host_); 1132 DCHECK(delegated_frame_host_);
1149 DCHECK(!frame.render_pass_list.empty()); 1133 DCHECK(!frame.render_pass_list.empty());
1150 1134
1151 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 1135 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
1152 current_surface_size_ = root_pass->output_rect.size(); 1136 current_surface_size_ = root_pass->output_rect.size();
1153 bool is_transparent = root_pass->has_transparent_background; 1137 bool is_transparent = root_pass->has_transparent_background;
1154 1138
1155 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); 1139 cc::CompositorFrameMetadata metadata = frame.metadata.Clone();
1156 1140
1157 CheckCompositorFrameSinkChanged(compositor_frame_sink_id);
1158 bool has_content = !current_surface_size_.IsEmpty(); 1141 bool has_content = !current_surface_size_.IsEmpty();
1159 1142
1160 base::Closure ack_callback = 1143 base::Closure ack_callback =
1161 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources, 1144 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources,
1162 weak_ptr_factory_.GetWeakPtr(), compositor_frame_sink_id, 1145 weak_ptr_factory_.GetWeakPtr(), true /* is_swap_ack */);
1163 true /* is_swap_ack */);
1164 1146
1165 ack_callbacks_.push(ack_callback); 1147 ack_callbacks_.push(ack_callback);
1166 1148
1167 if (!has_content) { 1149 if (!has_content) {
1168 DestroyDelegatedContent(); 1150 DestroyDelegatedContent();
1169 } else { 1151 } else {
1170 delegated_frame_host_->SubmitCompositorFrame(local_surface_id, 1152 delegated_frame_host_->SubmitCompositorFrame(local_surface_id,
1171 std::move(frame)); 1153 std::move(frame));
1172 frame_evictor_->SwappedFrame(!host_->is_hidden()); 1154 frame_evictor_->SwappedFrame(!host_->is_hidden());
1173 } 1155 }
(...skipping 14 matching lines...) Expand all
1188 if (!delegated_frame_host_) 1170 if (!delegated_frame_host_)
1189 return; 1171 return;
1190 1172
1191 if (!delegated_frame_host_->HasDelegatedContent()) 1173 if (!delegated_frame_host_->HasDelegatedContent())
1192 return; 1174 return;
1193 1175
1194 frame_evictor_->DiscardedFrame(); 1176 frame_evictor_->DiscardedFrame();
1195 delegated_frame_host_->DestroyDelegatedContent(); 1177 delegated_frame_host_->DestroyDelegatedContent();
1196 } 1178 }
1197 1179
1198 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame(
1199 uint32_t compositor_frame_sink_id,
1200 const cc::LocalSurfaceId& local_surface_id,
1201 cc::CompositorFrame frame) {
1202 InternalSwapCompositorFrame(compositor_frame_sink_id, local_surface_id,
1203 std::move(frame));
1204 }
1205
1206 void RenderWidgetHostViewAndroid::ClearCompositorFrame() { 1180 void RenderWidgetHostViewAndroid::ClearCompositorFrame() {
1207 DestroyDelegatedContent(); 1181 DestroyDelegatedContent();
1208 } 1182 }
1209 1183
1210 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( 1184 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata(
1211 cc::CompositorFrameMetadata frame_metadata) { 1185 cc::CompositorFrameMetadata frame_metadata) {
1212 if (!content_view_core_) 1186 if (!content_view_core_)
1213 return; 1187 return;
1214 1188
1215 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); 1189 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata);
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 2114
2141 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 2115 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
2142 if (!compositor) 2116 if (!compositor)
2143 return; 2117 return;
2144 2118
2145 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 2119 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
2146 overscroll_refresh_handler, compositor, view_.GetDipScale()); 2120 overscroll_refresh_handler, compositor, view_.GetDipScale());
2147 } 2121 }
2148 2122
2149 } // namespace content 2123 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698