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

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

Issue 2106753004: Introduce bottom controls to CC and let it respond to scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
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/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
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_shown_ratio !=
117 frame.metadata.location_bar_content_translation || 117 frame.metadata.top_controls_shown_ratio ||
Khushal 2016/08/17 04:45:34 Should this check for a change in height too?
118 current_frame_->bottom_controls_shown_ratio !=
119 frame.metadata.bottom_controls_shown_ratio ||
118 current_frame_->viewport_selection != frame.metadata.selection) { 120 current_frame_->viewport_selection != frame.metadata.selection) {
119 DestroyDelegatedContent(); 121 DestroyDelegatedContent();
120 DCHECK(!content_layer_); 122 DCHECK(!content_layer_);
121 DCHECK(!current_frame_); 123 DCHECK(!current_frame_);
122 124
123 current_frame_ = base::MakeUnique<FrameData>(); 125 current_frame_ = base::MakeUnique<FrameData>();
124 current_frame_->surface_id = surface_id_allocator_->GenerateId(); 126 current_frame_->surface_id = surface_id_allocator_->GenerateId();
125 surface_factory_->Create(current_frame_->surface_id); 127 surface_factory_->Create(current_frame_->surface_id);
126 128
127 current_frame_->surface_size = surface_size; 129 current_frame_->surface_size = surface_size;
128 current_frame_->location_bar_content_translation = 130 current_frame_->top_controls_shown_ratio =
Khushal 2016/08/17 04:45:34 Need to update the top and bottom height also here
129 frame.metadata.location_bar_content_translation; 131 frame.metadata.top_controls_shown_ratio;
132 current_frame_->bottom_controls_shown_ratio =
133 frame.metadata.bottom_controls_shown_ratio;
130 current_frame_->viewport_selection = frame.metadata.selection; 134 current_frame_->viewport_selection = frame.metadata.selection;
131 content_layer_ = 135 content_layer_ =
132 CreateSurfaceLayer(surface_manager_, current_frame_->surface_id, 136 CreateSurfaceLayer(surface_manager_, current_frame_->surface_id,
133 current_frame_->surface_size); 137 current_frame_->surface_size);
134 view_->GetLayer()->AddChild(content_layer_); 138 view_->GetLayer()->AddChild(content_layer_);
135 UpdateBackgroundLayer(); 139 UpdateBackgroundLayer();
136 } 140 }
137 141
138 surface_factory_->SubmitCompositorFrame(current_frame_->surface_id, 142 surface_factory_->SubmitCompositorFrame(current_frame_->surface_id,
139 std::move(frame), draw_callback); 143 std::move(frame), draw_callback);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // The background layer draws in 2 cases: 226 // The background layer draws in 2 cases:
223 // 1) When we don't have any content from the renderer. 227 // 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 228 // 2) When the bounds of the content received from the renderer does not match
225 // the desired content bounds. 229 // the desired content bounds.
226 bool background_is_drawable = false; 230 bool background_is_drawable = false;
227 231
228 if (current_frame_) { 232 if (current_frame_) {
229 float device_scale_factor = gfx::DeviceDisplayInfo().GetDIPScale(); 233 float device_scale_factor = gfx::DeviceDisplayInfo().GetDIPScale();
230 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP( 234 gfx::Size content_size_in_dip = gfx::ConvertSizeToDIP(
231 device_scale_factor, current_frame_->surface_size); 235 device_scale_factor, current_frame_->surface_size);
236 float top_bar_shown = current_frame_->top_controls_height *
237 current_frame_->top_controls_shown_ratio;
238 float bottom_bar_shown = current_frame_->bottom_controls_height *
239 current_frame_->bottom_controls_shown_ratio;
232 content_size_in_dip.set_height( 240 content_size_in_dip.set_height(
233 content_size_in_dip.height() + 241 content_size_in_dip.height() - top_bar_shown - bottom_bar_shown);
Khushal 2016/08/17 04:45:34 The top and bottom bar should be added. This will
234 current_frame_->location_bar_content_translation.y());
235 background_is_drawable = 242 background_is_drawable =
236 content_size_in_dip.width() < container_size_in_dip_.width() || 243 content_size_in_dip.width() < container_size_in_dip_.width() ||
237 content_size_in_dip.height() < container_size_in_dip_.height(); 244 content_size_in_dip.height() < container_size_in_dip_.height();
238 } else { 245 } else {
239 background_is_drawable = true; 246 background_is_drawable = true;
240 } 247 }
241 248
242 background_layer_->SetIsDrawable(background_is_drawable); 249 background_layer_->SetIsDrawable(background_is_drawable);
243 } 250 }
244 251
245 } // namespace ui 252 } // namespace ui
OLDNEW
« cc/trees/layer_tree_host.cc ('K') | « ui/android/delegated_frame_host_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698