| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "cc/layers/solid_color_layer.h" | 8 #include "cc/layers/solid_color_layer.h" |
| 9 #include "cc/layers/surface_layer.h" | 9 #include "cc/layers/surface_layer.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 if (!surface_factory_) { | 106 if (!surface_factory_) { |
| 107 surface_factory_ = | 107 surface_factory_ = |
| 108 base::WrapUnique(new cc::SurfaceFactory(surface_manager_, this)); | 108 base::WrapUnique(new cc::SurfaceFactory(surface_manager_, this)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 cc::RenderPass* root_pass = | 111 cc::RenderPass* root_pass = |
| 112 frame.delegated_frame_data->render_pass_list.back().get(); | 112 frame.delegated_frame_data->render_pass_list.back().get(); |
| 113 gfx::Size surface_size = root_pass->output_rect.size(); | 113 gfx::Size surface_size = root_pass->output_rect.size(); |
| 114 | 114 |
| 115 if (!current_frame_ || surface_size != current_frame_->surface_size || | 115 if (!current_frame_ || surface_size != current_frame_->surface_size || |
| 116 current_frame_->location_bar_content_translation != | 116 current_frame_->top_controls_height != |
| 117 frame.metadata.location_bar_content_translation || | 117 frame.metadata.top_controls_height || |
| 118 current_frame_->top_controls_shown_ratio != |
| 119 frame.metadata.top_controls_shown_ratio || |
| 120 current_frame_->bottom_controls_height != |
| 121 frame.metadata.bottom_controls_height || |
| 122 current_frame_->bottom_controls_shown_ratio != |
| 123 frame.metadata.bottom_controls_shown_ratio || |
| 118 current_frame_->viewport_selection != frame.metadata.selection) { | 124 current_frame_->viewport_selection != frame.metadata.selection) { |
| 119 DestroyDelegatedContent(); | 125 DestroyDelegatedContent(); |
| 120 DCHECK(!content_layer_); | 126 DCHECK(!content_layer_); |
| 121 DCHECK(!current_frame_); | 127 DCHECK(!current_frame_); |
| 122 | 128 |
| 123 current_frame_ = base::MakeUnique<FrameData>(); | 129 current_frame_ = base::MakeUnique<FrameData>(); |
| 124 current_frame_->surface_id = surface_id_allocator_->GenerateId(); | 130 current_frame_->surface_id = surface_id_allocator_->GenerateId(); |
| 125 surface_factory_->Create(current_frame_->surface_id); | 131 surface_factory_->Create(current_frame_->surface_id); |
| 126 | 132 |
| 127 current_frame_->surface_size = surface_size; | 133 current_frame_->surface_size = surface_size; |
| 128 current_frame_->location_bar_content_translation = | 134 current_frame_->top_controls_height = frame.metadata.top_controls_height; |
| 129 frame.metadata.location_bar_content_translation; | 135 current_frame_->top_controls_shown_ratio = |
| 136 frame.metadata.top_controls_shown_ratio; |
| 137 current_frame_->bottom_controls_height = |
| 138 frame.metadata.bottom_controls_height; |
| 139 current_frame_->bottom_controls_shown_ratio = |
| 140 frame.metadata.bottom_controls_shown_ratio; |
| 141 |
| 130 current_frame_->viewport_selection = frame.metadata.selection; | 142 current_frame_->viewport_selection = frame.metadata.selection; |
| 131 content_layer_ = | 143 content_layer_ = |
| 132 CreateSurfaceLayer(surface_manager_, current_frame_->surface_id, | 144 CreateSurfaceLayer(surface_manager_, current_frame_->surface_id, |
| 133 current_frame_->surface_size); | 145 current_frame_->surface_size); |
| 134 view_->GetLayer()->AddChild(content_layer_); | 146 view_->GetLayer()->AddChild(content_layer_); |
| 135 UpdateBackgroundLayer(); | 147 UpdateBackgroundLayer(); |
| 136 } | 148 } |
| 137 | 149 |
| 138 surface_factory_->SubmitCompositorFrame(current_frame_->surface_id, | 150 surface_factory_->SubmitCompositorFrame(current_frame_->surface_id, |
| 139 std::move(frame), draw_callback); | 151 std::move(frame), draw_callback); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // The background layer draws in 2 cases: | 234 // The background layer draws in 2 cases: |
| 223 // 1) When we don't have any content from the renderer. | 235 // 1) When we don't have any content from the renderer. |
| 224 // 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 |
| 225 // the desired content bounds. | 237 // the desired content bounds. |
| 226 bool background_is_drawable = false; | 238 bool background_is_drawable = false; |
| 227 | 239 |
| 228 if (current_frame_) { | 240 if (current_frame_) { |
| 229 float device_scale_factor = gfx::DeviceDisplayInfo().GetDIPScale(); | 241 float device_scale_factor = gfx::DeviceDisplayInfo().GetDIPScale(); |
| 230 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( | 242 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( |
| 231 device_scale_factor, current_frame_->surface_size); | 243 device_scale_factor, current_frame_->surface_size); |
| 244 float top_bar_shown = current_frame_->top_controls_height * |
| 245 current_frame_->top_controls_shown_ratio; |
| 246 float bottom_bar_shown = current_frame_->bottom_controls_height * |
| 247 current_frame_->bottom_controls_shown_ratio; |
| 232 content_size_in_dip.set_height( | 248 content_size_in_dip.set_height( |
| 233 content_size_in_dip.height() + | 249 content_size_in_dip.height() - top_bar_shown - bottom_bar_shown); |
| 234 current_frame_->location_bar_content_translation.y()); | |
| 235 background_is_drawable = | 250 background_is_drawable = |
| 236 content_size_in_dip.width() < container_size_in_dip_.width() || | 251 content_size_in_dip.width() < container_size_in_dip_.width() || |
| 237 content_size_in_dip.height() < container_size_in_dip_.height(); | 252 content_size_in_dip.height() < container_size_in_dip_.height(); |
| 238 } else { | 253 } else { |
| 239 background_is_drawable = true; | 254 background_is_drawable = true; |
| 240 } | 255 } |
| 241 | 256 |
| 242 background_layer_->SetIsDrawable(background_is_drawable); | 257 background_layer_->SetIsDrawable(background_is_drawable); |
| 243 } | 258 } |
| 244 | 259 |
| 245 } // namespace ui | 260 } // namespace ui |
| OLD | NEW |