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

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

Issue 2585993002: Revert of [android] Make RWHVAndroid a BeginFrameObserver. (Closed)
Patch Set: Created 4 years 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.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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void CopyOutputRequestCallback( 63 void CopyOutputRequestCallback(
64 scoped_refptr<cc::Layer> readback_layer, 64 scoped_refptr<cc::Layer> readback_layer,
65 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback, 65 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback,
66 std::unique_ptr<cc::CopyOutputResult> copy_output_result) { 66 std::unique_ptr<cc::CopyOutputResult> copy_output_result) {
67 readback_layer->RemoveFromParent(); 67 readback_layer->RemoveFromParent();
68 result_callback.Run(std::move(copy_output_result)); 68 result_callback.Run(std::move(copy_output_result));
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72 72
73 DelegatedFrameHostAndroid::DelegatedFrameHostAndroid(ui::ViewAndroid* view, 73 DelegatedFrameHostAndroid::DelegatedFrameHostAndroid(
74 SkColor background_color, 74 ui::ViewAndroid* view,
75 Client* client) 75 SkColor background_color,
76 ReturnResourcesCallback return_resources_callback)
76 : frame_sink_id_( 77 : frame_sink_id_(
77 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()), 78 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()),
78 view_(view), 79 view_(view),
79 client_(client), 80 return_resources_callback_(return_resources_callback),
80 background_layer_(cc::SolidColorLayer::Create()) { 81 background_layer_(cc::SolidColorLayer::Create()) {
81 DCHECK(view_); 82 DCHECK(view_);
82 DCHECK(client_); 83 DCHECK(!return_resources_callback_.is_null());
83 84
84 surface_manager_ = 85 surface_manager_ =
85 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); 86 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager();
86 surface_id_allocator_.reset(new cc::SurfaceIdAllocator()); 87 surface_id_allocator_.reset(new cc::SurfaceIdAllocator());
87 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 88 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
88 surface_factory_ = base::WrapUnique( 89 surface_factory_ = base::WrapUnique(
89 new cc::SurfaceFactory(frame_sink_id_, surface_manager_, this)); 90 new cc::SurfaceFactory(frame_sink_id_, surface_manager_, this));
90 91
91 background_layer_->SetBackgroundColor(background_color); 92 background_layer_->SetBackgroundColor(background_color);
92 view_->GetLayer()->AddChild(background_layer_); 93 view_->GetLayer()->AddChild(background_layer_);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (!registered_parent_frame_sink_id_.is_valid()) 235 if (!registered_parent_frame_sink_id_.is_valid())
235 return; 236 return;
236 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); 237 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
237 surface_manager_->UnregisterFrameSinkHierarchy( 238 surface_manager_->UnregisterFrameSinkHierarchy(
238 registered_parent_frame_sink_id_, frame_sink_id_); 239 registered_parent_frame_sink_id_, frame_sink_id_);
239 registered_parent_frame_sink_id_ = cc::FrameSinkId(); 240 registered_parent_frame_sink_id_ = cc::FrameSinkId();
240 } 241 }
241 242
242 void DelegatedFrameHostAndroid::ReturnResources( 243 void DelegatedFrameHostAndroid::ReturnResources(
243 const cc::ReturnedResourceArray& resources) { 244 const cc::ReturnedResourceArray& resources) {
244 client_->ReturnResources(resources); 245 return_resources_callback_.Run(resources);
245 } 246 }
246 247
247 void DelegatedFrameHostAndroid::SetBeginFrameSource( 248 void DelegatedFrameHostAndroid::SetBeginFrameSource(
248 cc::BeginFrameSource* begin_frame_source) { 249 cc::BeginFrameSource* begin_frame_source) {
249 client_->SetBeginFrameSource(begin_frame_source); 250 // TODO(enne): hook this up instead of making RWHVAndroid a
251 // WindowAndroidObserver.
250 } 252 }
251 253
252 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() { 254 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() {
253 // The background layer draws in 2 cases: 255 // The background layer draws in 2 cases:
254 // 1) When we don't have any content from the renderer. 256 // 1) When we don't have any content from the renderer.
255 // 2) When the bounds of the content received from the renderer does not match 257 // 2) When the bounds of the content received from the renderer does not match
256 // the desired content bounds. 258 // the desired content bounds.
257 bool background_is_drawable = false; 259 bool background_is_drawable = false;
258 260
259 if (current_frame_) { 261 if (current_frame_) {
260 float device_scale_factor = display::Screen::GetScreen() 262 float device_scale_factor = display::Screen::GetScreen()
261 ->GetDisplayNearestWindow(view_).device_scale_factor(); 263 ->GetDisplayNearestWindow(view_).device_scale_factor();
262 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( 264 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP(
263 device_scale_factor, current_frame_->surface_size); 265 device_scale_factor, current_frame_->surface_size);
264 background_is_drawable = 266 background_is_drawable =
265 content_size_in_dip.width() < container_size_in_dip_.width() || 267 content_size_in_dip.width() < container_size_in_dip_.width() ||
266 content_size_in_dip.height() < container_size_in_dip_.height(); 268 content_size_in_dip.height() < container_size_in_dip_.height();
267 } else { 269 } else {
268 background_is_drawable = true; 270 background_is_drawable = true;
269 } 271 }
270 272
271 background_layer_->SetIsDrawable(background_is_drawable); 273 background_layer_->SetIsDrawable(background_is_drawable);
272 } 274 }
273 275
274 } // namespace ui 276 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/delegated_frame_host_android.h ('k') | ui/android/window_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698