OLD | NEW |
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" |
11 #include "cc/output/compositor_frame.h" | 11 #include "cc/output/compositor_frame.h" |
12 #include "cc/output/copy_output_result.h" | 12 #include "cc/output/copy_output_result.h" |
13 #include "cc/surfaces/surface.h" | 13 #include "cc/surfaces/surface.h" |
14 #include "cc/surfaces/surface_id.h" | 14 #include "cc/surfaces/surface_id.h" |
15 #include "cc/surfaces/surface_id_allocator.h" | 15 #include "cc/surfaces/surface_id_allocator.h" |
16 #include "cc/surfaces/surface_manager.h" | 16 #include "cc/surfaces/surface_manager.h" |
17 #include "ui/android/context_provider_factory.h" | 17 #include "ui/android/context_provider_factory.h" |
18 #include "ui/android/view_android.h" | 18 #include "ui/android/view_android.h" |
19 #include "ui/android/window_android_compositor.h" | 19 #include "ui/android/window_android_compositor.h" |
20 #include "ui/gfx/android/device_display_info.h" | 20 #include "ui/display/display.h" |
| 21 #include "ui/display/screen.h" |
21 #include "ui/gfx/geometry/dip_util.h" | 22 #include "ui/gfx/geometry/dip_util.h" |
22 | 23 |
23 namespace ui { | 24 namespace ui { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 void SatisfyCallback(cc::SurfaceManager* manager, | 28 void SatisfyCallback(cc::SurfaceManager* manager, |
28 const cc::SurfaceSequence& sequence) { | 29 const cc::SurfaceSequence& sequence) { |
29 std::vector<uint32_t> sequences; | 30 std::vector<uint32_t> sequences; |
30 sequences.push_back(sequence.sequence); | 31 sequences.push_back(sequence.sequence); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 surface_factory_->Reset(); | 207 surface_factory_->Reset(); |
207 } | 208 } |
208 | 209 |
209 void DelegatedFrameHostAndroid::UpdateBackgroundColor(SkColor color) { | 210 void DelegatedFrameHostAndroid::UpdateBackgroundColor(SkColor color) { |
210 background_layer_->SetBackgroundColor(color); | 211 background_layer_->SetBackgroundColor(color); |
211 } | 212 } |
212 | 213 |
213 void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP( | 214 void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP( |
214 const gfx::Size& size_in_dip) { | 215 const gfx::Size& size_in_dip) { |
215 container_size_in_dip_ = size_in_dip; | 216 container_size_in_dip_ = size_in_dip; |
216 background_layer_->SetBounds(gfx::ConvertSizeToPixel( | 217 float device_scale_factor = display::Screen::GetScreen() |
217 gfx::DeviceDisplayInfo().GetDIPScale(), container_size_in_dip_)); | 218 ->GetDisplayNearestWindow(view_).device_scale_factor(); |
| 219 background_layer_->SetBounds( |
| 220 gfx::ConvertSizeToPixel(device_scale_factor, container_size_in_dip_)); |
218 UpdateBackgroundLayer(); | 221 UpdateBackgroundLayer(); |
219 } | 222 } |
220 | 223 |
221 void DelegatedFrameHostAndroid::RegisterFrameSinkHierarchy( | 224 void DelegatedFrameHostAndroid::RegisterFrameSinkHierarchy( |
222 const cc::FrameSinkId& parent_id) { | 225 const cc::FrameSinkId& parent_id) { |
223 if (registered_parent_frame_sink_id_.is_valid()) | 226 if (registered_parent_frame_sink_id_.is_valid()) |
224 UnregisterFrameSinkHierarchy(); | 227 UnregisterFrameSinkHierarchy(); |
225 registered_parent_frame_sink_id_ = parent_id; | 228 registered_parent_frame_sink_id_ = parent_id; |
226 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 229 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
227 surface_manager_->RegisterFrameSinkHierarchy(parent_id, frame_sink_id_); | 230 surface_manager_->RegisterFrameSinkHierarchy(parent_id, frame_sink_id_); |
(...skipping 20 matching lines...) Expand all Loading... |
248 } | 251 } |
249 | 252 |
250 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() { | 253 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() { |
251 // The background layer draws in 2 cases: | 254 // The background layer draws in 2 cases: |
252 // 1) When we don't have any content from the renderer. | 255 // 1) When we don't have any content from the renderer. |
253 // 2) When the bounds of the content received from the renderer does not match | 256 // 2) When the bounds of the content received from the renderer does not match |
254 // the desired content bounds. | 257 // the desired content bounds. |
255 bool background_is_drawable = false; | 258 bool background_is_drawable = false; |
256 | 259 |
257 if (current_frame_) { | 260 if (current_frame_) { |
258 float device_scale_factor = gfx::DeviceDisplayInfo().GetDIPScale(); | 261 float device_scale_factor = display::Screen::GetScreen() |
| 262 ->GetDisplayNearestWindow(view_).device_scale_factor(); |
259 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( | 263 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( |
260 device_scale_factor, current_frame_->surface_size); | 264 device_scale_factor, current_frame_->surface_size); |
261 background_is_drawable = | 265 background_is_drawable = |
262 content_size_in_dip.width() < container_size_in_dip_.width() || | 266 content_size_in_dip.width() < container_size_in_dip_.width() || |
263 content_size_in_dip.height() < container_size_in_dip_.height(); | 267 content_size_in_dip.height() < container_size_in_dip_.height(); |
264 } else { | 268 } else { |
265 background_is_drawable = true; | 269 background_is_drawable = true; |
266 } | 270 } |
267 | 271 |
268 background_layer_->SetIsDrawable(background_is_drawable); | 272 background_layer_->SetIsDrawable(background_is_drawable); |
269 } | 273 } |
270 | 274 |
271 } // namespace ui | 275 } // namespace ui |
OLD | NEW |