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

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

Issue 2564403002: [android] Make RWHVAndroid a BeginFrameObserver. (Closed)
Patch Set: rebase Created 3 years, 12 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.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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void CopyOutputRequestCallback( 44 void CopyOutputRequestCallback(
45 scoped_refptr<cc::Layer> readback_layer, 45 scoped_refptr<cc::Layer> readback_layer,
46 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback, 46 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback,
47 std::unique_ptr<cc::CopyOutputResult> copy_output_result) { 47 std::unique_ptr<cc::CopyOutputResult> copy_output_result) {
48 readback_layer->RemoveFromParent(); 48 readback_layer->RemoveFromParent();
49 result_callback.Run(std::move(copy_output_result)); 49 result_callback.Run(std::move(copy_output_result));
50 } 50 }
51 51
52 } // namespace 52 } // namespace
53 53
54 DelegatedFrameHostAndroid::DelegatedFrameHostAndroid( 54 DelegatedFrameHostAndroid::DelegatedFrameHostAndroid(ui::ViewAndroid* view,
55 ui::ViewAndroid* view, 55 SkColor background_color,
56 SkColor background_color, 56 Client* client)
57 ReturnResourcesCallback return_resources_callback)
58 : frame_sink_id_( 57 : frame_sink_id_(
59 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()), 58 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()),
60 view_(view), 59 view_(view),
61 return_resources_callback_(return_resources_callback), 60 client_(client),
62 background_layer_(cc::SolidColorLayer::Create()) { 61 background_layer_(cc::SolidColorLayer::Create()) {
63 DCHECK(view_); 62 DCHECK(view_);
64 DCHECK(!return_resources_callback_.is_null()); 63 DCHECK(client_);
65 64
66 surface_manager_ = 65 surface_manager_ =
67 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); 66 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager();
68 surface_id_allocator_.reset(new cc::SurfaceIdAllocator()); 67 surface_id_allocator_.reset(new cc::SurfaceIdAllocator());
69 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 68 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
70 surface_factory_ = base::WrapUnique( 69 surface_factory_ = base::WrapUnique(
71 new cc::SurfaceFactory(frame_sink_id_, surface_manager_, this)); 70 new cc::SurfaceFactory(frame_sink_id_, surface_manager_, this));
72 71
73 background_layer_->SetBackgroundColor(background_color); 72 background_layer_->SetBackgroundColor(background_color);
74 view_->GetLayer()->AddChild(background_layer_); 73 view_->GetLayer()->AddChild(background_layer_);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if (!registered_parent_frame_sink_id_.is_valid()) 215 if (!registered_parent_frame_sink_id_.is_valid())
217 return; 216 return;
218 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); 217 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
219 surface_manager_->UnregisterFrameSinkHierarchy( 218 surface_manager_->UnregisterFrameSinkHierarchy(
220 registered_parent_frame_sink_id_, frame_sink_id_); 219 registered_parent_frame_sink_id_, frame_sink_id_);
221 registered_parent_frame_sink_id_ = cc::FrameSinkId(); 220 registered_parent_frame_sink_id_ = cc::FrameSinkId();
222 } 221 }
223 222
224 void DelegatedFrameHostAndroid::ReturnResources( 223 void DelegatedFrameHostAndroid::ReturnResources(
225 const cc::ReturnedResourceArray& resources) { 224 const cc::ReturnedResourceArray& resources) {
226 return_resources_callback_.Run(resources); 225 client_->ReturnResources(resources);
227 } 226 }
228 227
229 void DelegatedFrameHostAndroid::SetBeginFrameSource( 228 void DelegatedFrameHostAndroid::SetBeginFrameSource(
230 cc::BeginFrameSource* begin_frame_source) { 229 cc::BeginFrameSource* begin_frame_source) {
231 // TODO(enne): hook this up instead of making RWHVAndroid a 230 client_->SetBeginFrameSource(begin_frame_source);
232 // WindowAndroidObserver.
233 } 231 }
234 232
235 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() { 233 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() {
236 // The background layer draws in 2 cases: 234 // The background layer draws in 2 cases:
237 // 1) When we don't have any content from the renderer. 235 // 1) When we don't have any content from the renderer.
238 // 2) When the bounds of the content received from the renderer does not match 236 // 2) When the bounds of the content received from the renderer does not match
239 // the desired content bounds. 237 // the desired content bounds.
240 bool background_is_drawable = false; 238 bool background_is_drawable = false;
241 239
242 if (current_frame_) { 240 if (current_frame_) {
243 float device_scale_factor = display::Screen::GetScreen() 241 float device_scale_factor = display::Screen::GetScreen()
244 ->GetDisplayNearestWindow(view_).device_scale_factor(); 242 ->GetDisplayNearestWindow(view_).device_scale_factor();
245 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( 243 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP(
246 device_scale_factor, current_frame_->surface_size); 244 device_scale_factor, current_frame_->surface_size);
247 background_is_drawable = 245 background_is_drawable =
248 content_size_in_dip.width() < container_size_in_dip_.width() || 246 content_size_in_dip.width() < container_size_in_dip_.width() ||
249 content_size_in_dip.height() < container_size_in_dip_.height(); 247 content_size_in_dip.height() < container_size_in_dip_.height();
250 } else { 248 } else {
251 background_is_drawable = true; 249 background_is_drawable = true;
252 } 250 }
253 251
254 background_layer_->SetIsDrawable(background_is_drawable); 252 background_layer_->SetIsDrawable(background_is_drawable);
255 } 253 }
256 254
257 } // namespace ui 255 } // 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