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

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

Issue 2369643002: Fix OOPIFs on Android (Closed)
Patch Set: 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
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 DCHECK_EQ(registered_parent_client_id_, 0u);
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 DCHECK_EQ(registered_parent_client_id_, 0u);
228 registered_parent_client_id_ = parent_id;
229 surface_manager_->RegisterSurfaceFactoryClient(
230 surface_id_allocator_->client_id(), this);
231 surface_manager_->RegisterSurfaceNamespaceHierarchy(
232 parent_id, surface_id_allocator_->client_id());
233 }
234
235 void DelegatedFrameHostAndroid::UnregisterSurfaceNamespaceHierarchy() {
236 DCHECK_NE(registered_parent_client_id_, 0u);
237 surface_manager_->UnregisterSurfaceFactoryClient(
238 surface_id_allocator_->client_id());
239 surface_manager_->UnregisterSurfaceNamespaceHierarchy(
240 registered_parent_client_id_, surface_id_allocator_->client_id());
241 registered_parent_client_id_ = 0u;
242 }
243
224 void DelegatedFrameHostAndroid::ReturnResources( 244 void DelegatedFrameHostAndroid::ReturnResources(
225 const cc::ReturnedResourceArray& resources) { 245 const cc::ReturnedResourceArray& resources) {
226 return_resources_callback_.Run(resources); 246 return_resources_callback_.Run(resources);
227 } 247 }
228 248
229 void DelegatedFrameHostAndroid::SetBeginFrameSource( 249 void DelegatedFrameHostAndroid::SetBeginFrameSource(
230 cc::BeginFrameSource* begin_frame_source) { 250 cc::BeginFrameSource* begin_frame_source) {
231 // TODO(tansell): Hook this up. 251 // TODO(enne): hook this up instead of making RWHVAndroid a
252 // WindowAndroidObserver.
232 } 253 }
233 254
234 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() { 255 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() {
235 // The background layer draws in 2 cases: 256 // The background layer draws in 2 cases:
236 // 1) When we don't have any content from the renderer. 257 // 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 258 // 2) When the bounds of the content received from the renderer does not match
238 // the desired content bounds. 259 // the desired content bounds.
239 bool background_is_drawable = false; 260 bool background_is_drawable = false;
240 261
241 if (current_frame_) { 262 if (current_frame_) {
242 float device_scale_factor = gfx::DeviceDisplayInfo().GetDIPScale(); 263 float device_scale_factor = gfx::DeviceDisplayInfo().GetDIPScale();
243 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( 264 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP(
244 device_scale_factor, current_frame_->surface_size); 265 device_scale_factor, current_frame_->surface_size);
245 background_is_drawable = 266 background_is_drawable =
246 content_size_in_dip.width() < container_size_in_dip_.width() || 267 content_size_in_dip.width() < container_size_in_dip_.width() ||
247 content_size_in_dip.height() < container_size_in_dip_.height(); 268 content_size_in_dip.height() < container_size_in_dip_.height();
248 } else { 269 } else {
249 background_is_drawable = true; 270 background_is_drawable = true;
250 } 271 }
251 272
252 background_layer_->SetIsDrawable(background_is_drawable); 273 background_layer_->SetIsDrawable(background_is_drawable);
253 } 274 }
254 275
255 } // namespace ui 276 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698