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

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

Issue 2527283003: cc: Introduce BeginFrame sequence numbers and acknowledgements.
Patch Set: Address Brian's comments. 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( 73 DelegatedFrameHostAndroid::DelegatedFrameHostAndroid(ui::ViewAndroid* view,
74 ui::ViewAndroid* view, 74 SkColor background_color,
75 SkColor background_color, 75 Client* client)
76 ReturnResourcesCallback return_resources_callback)
77 : frame_sink_id_( 76 : frame_sink_id_(
78 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()), 77 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()),
79 view_(view), 78 view_(view),
80 return_resources_callback_(return_resources_callback), 79 client_(client),
81 background_layer_(cc::SolidColorLayer::Create()) { 80 background_layer_(cc::SolidColorLayer::Create()) {
82 DCHECK(view_); 81 DCHECK(view_);
83 DCHECK(!return_resources_callback_.is_null()); 82 DCHECK(client_);
84 83
85 surface_manager_ = 84 surface_manager_ =
86 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); 85 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager();
87 surface_id_allocator_.reset(new cc::SurfaceIdAllocator()); 86 surface_id_allocator_.reset(new cc::SurfaceIdAllocator());
88 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 87 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
89 surface_factory_ = base::WrapUnique( 88 surface_factory_ = base::WrapUnique(
90 new cc::SurfaceFactory(frame_sink_id_, surface_manager_, this)); 89 new cc::SurfaceFactory(frame_sink_id_, surface_manager_, this));
91 90
92 background_layer_->SetBackgroundColor(background_color); 91 background_layer_->SetBackgroundColor(background_color);
93 view_->GetLayer()->AddChild(background_layer_); 92 view_->GetLayer()->AddChild(background_layer_);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (!registered_parent_frame_sink_id_.is_valid()) 234 if (!registered_parent_frame_sink_id_.is_valid())
236 return; 235 return;
237 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); 236 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
238 surface_manager_->UnregisterFrameSinkHierarchy( 237 surface_manager_->UnregisterFrameSinkHierarchy(
239 registered_parent_frame_sink_id_, frame_sink_id_); 238 registered_parent_frame_sink_id_, frame_sink_id_);
240 registered_parent_frame_sink_id_ = cc::FrameSinkId(); 239 registered_parent_frame_sink_id_ = cc::FrameSinkId();
241 } 240 }
242 241
243 void DelegatedFrameHostAndroid::ReturnResources( 242 void DelegatedFrameHostAndroid::ReturnResources(
244 const cc::ReturnedResourceArray& resources) { 243 const cc::ReturnedResourceArray& resources) {
245 return_resources_callback_.Run(resources); 244 client_->ReturnResources(resources);
246 } 245 }
247 246
248 void DelegatedFrameHostAndroid::SetBeginFrameSource( 247 void DelegatedFrameHostAndroid::SetBeginFrameSource(
249 cc::BeginFrameSource* begin_frame_source) { 248 cc::BeginFrameSource* begin_frame_source) {
250 // TODO(enne): hook this up instead of making RWHVAndroid a 249 client_->SetBeginFrameSource(begin_frame_source);
251 // WindowAndroidObserver.
252 } 250 }
253 251
254 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() { 252 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() {
255 // The background layer draws in 2 cases: 253 // The background layer draws in 2 cases:
256 // 1) When we don't have any content from the renderer. 254 // 1) When we don't have any content from the renderer.
257 // 2) When the bounds of the content received from the renderer does not match 255 // 2) When the bounds of the content received from the renderer does not match
258 // the desired content bounds. 256 // the desired content bounds.
259 bool background_is_drawable = false; 257 bool background_is_drawable = false;
260 258
261 if (current_frame_) { 259 if (current_frame_) {
262 float device_scale_factor = display::Screen::GetScreen() 260 float device_scale_factor = display::Screen::GetScreen()
263 ->GetDisplayNearestWindow(view_).device_scale_factor(); 261 ->GetDisplayNearestWindow(view_).device_scale_factor();
264 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( 262 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP(
265 device_scale_factor, current_frame_->surface_size); 263 device_scale_factor, current_frame_->surface_size);
266 background_is_drawable = 264 background_is_drawable =
267 content_size_in_dip.width() < container_size_in_dip_.width() || 265 content_size_in_dip.width() < container_size_in_dip_.width() ||
268 content_size_in_dip.height() < container_size_in_dip_.height(); 266 content_size_in_dip.height() < container_size_in_dip_.height();
269 } else { 267 } else {
270 background_is_drawable = true; 268 background_is_drawable = true;
271 } 269 }
272 270
273 background_layer_->SetIsDrawable(background_is_drawable); 271 background_layer_->SetIsDrawable(background_is_drawable);
274 } 272 }
275 273
276 } // namespace ui 274 } // 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