| 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 "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/layers/solid_color_layer.h" | 10 #include "cc/layers/solid_color_layer.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 surface_factory_->Reset(); | 189 surface_factory_->Reset(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void DelegatedFrameHostAndroid::UpdateBackgroundColor(SkColor color) { | 192 void DelegatedFrameHostAndroid::UpdateBackgroundColor(SkColor color) { |
| 193 background_layer_->SetBackgroundColor(color); | 193 background_layer_->SetBackgroundColor(color); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP( | 196 void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP( |
| 197 const gfx::Size& size_in_dip) { | 197 const gfx::Size& size_in_dip) { |
| 198 container_size_in_dip_ = size_in_dip; | 198 container_size_in_dip_ = size_in_dip; |
| 199 float device_scale_factor = display::Screen::GetScreen() | 199 float device_scale_factor = |
| 200 ->GetDisplayNearestWindow(view_).device_scale_factor(); | 200 display::Screen::GetScreen() |
| 201 ->GetDisplayNearestWindow(view_->GetWindowAndroid()) |
| 202 .device_scale_factor(); |
| 201 background_layer_->SetBounds( | 203 background_layer_->SetBounds( |
| 202 gfx::ConvertSizeToPixel(device_scale_factor, container_size_in_dip_)); | 204 gfx::ConvertSizeToPixel(device_scale_factor, container_size_in_dip_)); |
| 203 UpdateBackgroundLayer(); | 205 UpdateBackgroundLayer(); |
| 204 } | 206 } |
| 205 | 207 |
| 206 void DelegatedFrameHostAndroid::AttachToCompositor( | 208 void DelegatedFrameHostAndroid::AttachToCompositor( |
| 207 WindowAndroidCompositor* compositor) { | 209 WindowAndroidCompositor* compositor) { |
| 208 if (registered_parent_compositor_) | 210 if (registered_parent_compositor_) |
| 209 DetachFromCompositor(); | 211 DetachFromCompositor(); |
| 210 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 212 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 231 } | 233 } |
| 232 | 234 |
| 233 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() { | 235 void DelegatedFrameHostAndroid::UpdateBackgroundLayer() { |
| 234 // The background layer draws in 2 cases: | 236 // The background layer draws in 2 cases: |
| 235 // 1) When we don't have any content from the renderer. | 237 // 1) When we don't have any content from the renderer. |
| 236 // 2) When the bounds of the content received from the renderer does not match | 238 // 2) When the bounds of the content received from the renderer does not match |
| 237 // the desired content bounds. | 239 // the desired content bounds. |
| 238 bool background_is_drawable = false; | 240 bool background_is_drawable = false; |
| 239 | 241 |
| 240 if (current_frame_) { | 242 if (current_frame_) { |
| 241 float device_scale_factor = display::Screen::GetScreen() | 243 float device_scale_factor = |
| 242 ->GetDisplayNearestWindow(view_).device_scale_factor(); | 244 display::Screen::GetScreen() |
| 245 ->GetDisplayNearestWindow(view_->GetWindowAndroid()) |
| 246 .device_scale_factor(); |
| 243 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( | 247 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( |
| 244 device_scale_factor, current_frame_->surface_size); | 248 device_scale_factor, current_frame_->surface_size); |
| 245 background_is_drawable = | 249 background_is_drawable = |
| 246 content_size_in_dip.width() < container_size_in_dip_.width() || | 250 content_size_in_dip.width() < container_size_in_dip_.width() || |
| 247 content_size_in_dip.height() < container_size_in_dip_.height(); | 251 content_size_in_dip.height() < container_size_in_dip_.height(); |
| 248 } else { | 252 } else { |
| 249 background_is_drawable = true; | 253 background_is_drawable = true; |
| 250 } | 254 } |
| 251 | 255 |
| 252 background_layer_->SetIsDrawable(background_is_drawable); | 256 background_layer_->SetIsDrawable(background_is_drawable); |
| 253 } | 257 } |
| 254 | 258 |
| 255 } // namespace ui | 259 } // namespace ui |
| OLD | NEW |