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

Side by Side Diff: ui/android/delegated_frame_host_android.cc

Issue 2369643002: Fix OOPIFs on Android (Closed)
Patch Set: Add conditional for WebView shutdown Created 4 years, 2 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
« no previous file with comments | « ui/android/delegated_frame_host_android.h ('k') | ui/android/window_android_compositor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/android/delegated_frame_host_android.h" 5 #include "ui/android/delegated_frame_host_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/layers/surface_layer.h" 10 #include "cc/layers/surface_layer.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); 86 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id());
87 87
88 background_layer_->SetBackgroundColor(background_color); 88 background_layer_->SetBackgroundColor(background_color);
89 view_->GetLayer()->AddChild(background_layer_); 89 view_->GetLayer()->AddChild(background_layer_);
90 UpdateBackgroundLayer(); 90 UpdateBackgroundLayer();
91 } 91 }
92 92
93 DelegatedFrameHostAndroid::~DelegatedFrameHostAndroid() { 93 DelegatedFrameHostAndroid::~DelegatedFrameHostAndroid() {
94 DestroyDelegatedContent(); 94 DestroyDelegatedContent();
95 surface_factory_.reset(); 95 surface_factory_.reset();
96 UnregisterSurfaceNamespaceHierarchy();
96 surface_manager_->InvalidateSurfaceClientId( 97 surface_manager_->InvalidateSurfaceClientId(
97 surface_id_allocator_->client_id()); 98 surface_id_allocator_->client_id());
98 background_layer_->RemoveFromParent(); 99 background_layer_->RemoveFromParent();
99 } 100 }
100 101
101 DelegatedFrameHostAndroid::FrameData::FrameData() = default; 102 DelegatedFrameHostAndroid::FrameData::FrameData() = default;
102 103
103 DelegatedFrameHostAndroid::FrameData::~FrameData() = default; 104 DelegatedFrameHostAndroid::FrameData::~FrameData() = default;
104 105
105 void DelegatedFrameHostAndroid::SubmitCompositorFrame( 106 void DelegatedFrameHostAndroid::SubmitCompositorFrame(
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 215 }
215 216
216 void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP( 217 void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP(
217 const gfx::Size& size_in_dip) { 218 const gfx::Size& size_in_dip) {
218 container_size_in_dip_ = size_in_dip; 219 container_size_in_dip_ = size_in_dip;
219 background_layer_->SetBounds(gfx::ConvertSizeToPixel( 220 background_layer_->SetBounds(gfx::ConvertSizeToPixel(
220 gfx::DeviceDisplayInfo().GetDIPScale(), container_size_in_dip_)); 221 gfx::DeviceDisplayInfo().GetDIPScale(), container_size_in_dip_));
221 UpdateBackgroundLayer(); 222 UpdateBackgroundLayer();
222 } 223 }
223 224
225 void DelegatedFrameHostAndroid::RegisterSurfaceNamespaceHierarchy(
226 uint32_t parent_id) {
227 if (registered_parent_client_id_ != 0u)
228 UnregisterSurfaceNamespaceHierarchy();
229 registered_parent_client_id_ = parent_id;
230 surface_manager_->RegisterSurfaceFactoryClient(
231 surface_id_allocator_->client_id(), this);
232 surface_manager_->RegisterSurfaceNamespaceHierarchy(
233 parent_id, surface_id_allocator_->client_id());
234 }
235
236 void DelegatedFrameHostAndroid::UnregisterSurfaceNamespaceHierarchy() {
237 if (registered_parent_client_id_ == 0u)
238 return;
239 surface_manager_->UnregisterSurfaceFactoryClient(
240 surface_id_allocator_->client_id());
241 surface_manager_->UnregisterSurfaceNamespaceHierarchy(
242 registered_parent_client_id_, surface_id_allocator_->client_id());
243 registered_parent_client_id_ = 0u;
244 }
245
224 void DelegatedFrameHostAndroid::ReturnResources( 246 void DelegatedFrameHostAndroid::ReturnResources(
225 const cc::ReturnedResourceArray& resources) { 247 const cc::ReturnedResourceArray& resources) {
226 return_resources_callback_.Run(resources); 248 return_resources_callback_.Run(resources);
227 } 249 }
228 250
229 void DelegatedFrameHostAndroid::SetBeginFrameSource( 251 void DelegatedFrameHostAndroid::SetBeginFrameSource(
230 cc::BeginFrameSource* begin_frame_source) { 252 cc::BeginFrameSource* begin_frame_source) {
231 // TODO(tansell): Hook this up. 253 // TODO(enne): hook this up instead of making RWHVAndroid a
254 // WindowAndroidObserver.
232 } 255 }
233 256
234 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() { 257 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() {
235 // The background layer draws in 2 cases: 258 // The background layer draws in 2 cases:
236 // 1) When we don't have any content from the renderer. 259 // 1) When we don't have any content from the renderer.
237 // 2) When the bounds of the content received from the renderer does not match 260 // 2) When the bounds of the content received from the renderer does not match
238 // the desired content bounds. 261 // the desired content bounds.
239 bool background_is_drawable = false; 262 bool background_is_drawable = false;
240 263
241 if (current_frame_) { 264 if (current_frame_) {
242 float device_scale_factor = gfx::DeviceDisplayInfo().GetDIPScale(); 265 float device_scale_factor = gfx::DeviceDisplayInfo().GetDIPScale();
243 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( 266 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP(
244 device_scale_factor, current_frame_->surface_size); 267 device_scale_factor, current_frame_->surface_size);
245 background_is_drawable = 268 background_is_drawable =
246 content_size_in_dip.width() < container_size_in_dip_.width() || 269 content_size_in_dip.width() < container_size_in_dip_.width() ||
247 content_size_in_dip.height() < container_size_in_dip_.height(); 270 content_size_in_dip.height() < container_size_in_dip_.height();
248 } else { 271 } else {
249 background_is_drawable = true; 272 background_is_drawable = true;
250 } 273 }
251 274
252 background_layer_->SetIsDrawable(background_is_drawable); 275 background_layer_->SetIsDrawable(background_is_drawable);
253 } 276 }
254 277
255 } // namespace ui 278 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/delegated_frame_host_android.h ('k') | ui/android/window_android_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698