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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 511253003: Made Blink aware of top controls offset (Chromium-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 paint_time_counter_(PaintTimeCounter::Create()), 242 paint_time_counter_(PaintTimeCounter::Create()),
243 memory_history_(MemoryHistory::Create()), 243 memory_history_(MemoryHistory::Create()),
244 debug_rect_history_(DebugRectHistory::Create()), 244 debug_rect_history_(DebugRectHistory::Create()),
245 texture_mailbox_deleter_(new TextureMailboxDeleter( 245 texture_mailbox_deleter_(new TextureMailboxDeleter(
246 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() 246 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner()
247 : proxy_->MainThreadTaskRunner())), 247 : proxy_->MainThreadTaskRunner())),
248 max_memory_needed_bytes_(0), 248 max_memory_needed_bytes_(0),
249 zero_budget_(false), 249 zero_budget_(false),
250 device_scale_factor_(1.f), 250 device_scale_factor_(1.f),
251 overhang_ui_resource_id_(0), 251 overhang_ui_resource_id_(0),
252 top_controls_layout_height_(0.f),
253 resourceless_software_draw_(false), 252 resourceless_software_draw_(false),
254 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), 253 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()),
255 animation_registrar_(AnimationRegistrar::Create()), 254 animation_registrar_(AnimationRegistrar::Create()),
256 rendering_stats_instrumentation_(rendering_stats_instrumentation), 255 rendering_stats_instrumentation_(rendering_stats_instrumentation),
257 micro_benchmark_controller_(this), 256 micro_benchmark_controller_(this),
258 need_to_update_visible_tiles_before_draw_(false), 257 need_to_update_visible_tiles_before_draw_(false),
259 shared_bitmap_manager_(manager), 258 shared_bitmap_manager_(manager),
260 id_(id), 259 id_(id),
261 transfer_buffer_memory_limit_(0u) { 260 transfer_buffer_memory_limit_(0u) {
262 DCHECK(proxy_->IsImplThread()); 261 DCHECK(proxy_->IsImplThread());
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 UpdateCurrentBeginFrameArgs(args); 1670 UpdateCurrentBeginFrameArgs(args);
1672 // Cache the begin impl frame interval 1671 // Cache the begin impl frame interval
1673 begin_impl_frame_interval_ = args.interval; 1672 begin_impl_frame_interval_ = args.interval;
1674 } 1673 }
1675 1674
1676 void LayerTreeHostImpl::UpdateInnerViewportContainerSize() { 1675 void LayerTreeHostImpl::UpdateInnerViewportContainerSize() {
1677 LayerImpl* container_layer = active_tree_->InnerViewportContainerLayer(); 1676 LayerImpl* container_layer = active_tree_->InnerViewportContainerLayer();
1678 if (!container_layer) 1677 if (!container_layer)
1679 return; 1678 return;
1680 1679
1681 if (top_controls_manager_) 1680 if (top_controls_manager_) {
1682 container_layer->SetBoundsDelta( 1681 container_layer->SetBoundsDelta(
1683 gfx::Vector2dF(0, 1682 gfx::Vector2dF(0, -active_tree_->top_controls_delta()));
1684 top_controls_layout_height_ - 1683 }
1685 top_controls_manager_->content_top_offset()));
1686 } 1684 }
1687 1685
1688 void LayerTreeHostImpl::DidLoseOutputSurface() { 1686 void LayerTreeHostImpl::DidLoseOutputSurface() {
1689 if (resource_provider_) 1687 if (resource_provider_)
1690 resource_provider_->DidLoseOutputSurface(); 1688 resource_provider_->DidLoseOutputSurface();
1691 client_->DidLoseOutputSurfaceOnImplThread(); 1689 client_->DidLoseOutputSurfaceOnImplThread();
1692 } 1690 }
1693 1691
1694 bool LayerTreeHostImpl::HaveRootScrollLayer() const { 1692 bool LayerTreeHostImpl::HaveRootScrollLayer() const {
1695 return !!InnerViewportScrollLayer(); 1693 return !!InnerViewportScrollLayer();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 pending_tree_->PushPropertiesTo(active_tree_.get()); 1782 pending_tree_->PushPropertiesTo(active_tree_.get());
1785 1783
1786 // Now that we've synced everything from the pending tree to the active 1784 // Now that we've synced everything from the pending tree to the active
1787 // tree, rename the pending tree the recycle tree so we can reuse it on the 1785 // tree, rename the pending tree the recycle tree so we can reuse it on the
1788 // next sync. 1786 // next sync.
1789 DCHECK(!recycle_tree_); 1787 DCHECK(!recycle_tree_);
1790 pending_tree_.swap(recycle_tree_); 1788 pending_tree_.swap(recycle_tree_);
1791 1789
1792 active_tree_->SetRootLayerScrollOffsetDelegate( 1790 active_tree_->SetRootLayerScrollOffsetDelegate(
1793 root_layer_scroll_offset_delegate_); 1791 root_layer_scroll_offset_delegate_);
1792
1793 top_controls_manager_->SetControlsTopOffset(
1794 active_tree_->total_top_controls_content_offset()
1795 - top_controls_manager_->top_controls_height());
1796
1794 UpdateInnerViewportContainerSize(); 1797 UpdateInnerViewportContainerSize();
1795 } else { 1798 } else {
1796 active_tree_->ProcessUIResourceRequestQueue(); 1799 active_tree_->ProcessUIResourceRequestQueue();
1797 } 1800 }
1798 1801
1799 active_tree_->DidBecomeActive(); 1802 active_tree_->DidBecomeActive();
1800 ActivateAnimations(); 1803 ActivateAnimations();
1801 if (settings_.impl_side_painting) 1804 if (settings_.impl_side_painting)
1802 client_->RenewTreePriority(); 1805 client_->RenewTreePriority();
1803 1806
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 active_tree_->SetViewportSizeInvalid(); 2142 active_tree_->SetViewportSizeInvalid();
2140 2143
2141 device_viewport_size_ = device_viewport_size; 2144 device_viewport_size_ = device_viewport_size;
2142 2145
2143 UpdateInnerViewportContainerSize(); 2146 UpdateInnerViewportContainerSize();
2144 client_->OnCanDrawStateChanged(CanDraw()); 2147 client_->OnCanDrawStateChanged(CanDraw());
2145 SetFullRootLayerDamage(); 2148 SetFullRootLayerDamage();
2146 active_tree_->set_needs_update_draw_properties(); 2149 active_tree_->set_needs_update_draw_properties();
2147 } 2150 }
2148 2151
2149 void LayerTreeHostImpl::SetTopControlsLayoutHeight(
2150 float top_controls_layout_height) {
2151 if (top_controls_layout_height_ == top_controls_layout_height)
2152 return;
2153 top_controls_layout_height_ = top_controls_layout_height;
2154
2155 UpdateInnerViewportContainerSize();
2156 SetFullRootLayerDamage();
2157 }
2158
2159 void LayerTreeHostImpl::SetOverhangUIResource( 2152 void LayerTreeHostImpl::SetOverhangUIResource(
2160 UIResourceId overhang_ui_resource_id, 2153 UIResourceId overhang_ui_resource_id,
2161 const gfx::Size& overhang_ui_resource_size) { 2154 const gfx::Size& overhang_ui_resource_size) {
2162 overhang_ui_resource_id_ = overhang_ui_resource_id; 2155 overhang_ui_resource_id_ = overhang_ui_resource_id;
2163 overhang_ui_resource_size_ = overhang_ui_resource_size; 2156 overhang_ui_resource_size_ = overhang_ui_resource_size;
2164 } 2157 }
2165 2158
2166 void LayerTreeHostImpl::SetDeviceScaleFactor(float device_scale_factor) { 2159 void LayerTreeHostImpl::SetDeviceScaleFactor(float device_scale_factor) {
2167 if (device_scale_factor == device_scale_factor_) 2160 if (device_scale_factor == device_scale_factor_)
2168 return; 2161 return;
(...skipping 25 matching lines...) Expand all
2194 return DeviceViewport(); 2187 return DeviceViewport();
2195 2188
2196 return external_clip_; 2189 return external_clip_;
2197 } 2190 }
2198 2191
2199 const gfx::Transform& LayerTreeHostImpl::DrawTransform() const { 2192 const gfx::Transform& LayerTreeHostImpl::DrawTransform() const {
2200 return external_transform_; 2193 return external_transform_;
2201 } 2194 }
2202 2195
2203 void LayerTreeHostImpl::DidChangeTopControlsPosition() { 2196 void LayerTreeHostImpl::DidChangeTopControlsPosition() {
2197 active_tree_->set_top_controls_delta(
aelias_OOO_until_Jul13 2014/08/29 04:37:01 We end up holding a field with redundant informati
bokan 2014/08/29 18:02:14 sgtm
bokan 2014/09/02 18:57:16 Done.
2198 top_controls_manager_->content_top_offset() -
2199 active_tree_->top_controls_content_offset());
2200
2204 UpdateInnerViewportContainerSize(); 2201 UpdateInnerViewportContainerSize();
2205 SetNeedsRedraw(); 2202 SetNeedsRedraw();
2206 SetNeedsAnimate(); 2203 SetNeedsAnimate();
2207 active_tree_->set_needs_update_draw_properties(); 2204 active_tree_->set_needs_update_draw_properties();
2208 SetFullRootLayerDamage(); 2205 SetFullRootLayerDamage();
2209 } 2206 }
2210 2207
2211 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { 2208 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) {
2212 DCHECK(input_handler_client_ == NULL); 2209 DCHECK(input_handler_client_ == NULL);
2213 input_handler_client_ = client; 2210 input_handler_client_ = client;
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2901 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); 2898 CollectScrollDeltas(scroll_info, layer_impl->children()[i]);
2902 } 2899 }
2903 2900
2904 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { 2901 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() {
2905 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); 2902 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet());
2906 2903
2907 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); 2904 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer());
2908 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); 2905 scroll_info->page_scale_delta = active_tree_->page_scale_delta();
2909 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); 2906 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta);
2910 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); 2907 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_);
2908 scroll_info->top_controls_content_offset =
2909 active_tree()->total_top_controls_content_offset();
2910 active_tree_->set_sent_top_controls_delta(
2911 scroll_info->top_controls_content_offset -
2912 active_tree()->top_controls_content_offset());
2911 2913
2912 return scroll_info.Pass(); 2914 return scroll_info.Pass();
2913 } 2915 }
2914 2916
2915 void LayerTreeHostImpl::SetFullRootLayerDamage() { 2917 void LayerTreeHostImpl::SetFullRootLayerDamage() {
2916 SetViewportDamage(gfx::Rect(DrawViewportSize())); 2918 SetViewportDamage(gfx::Rect(DrawViewportSize()));
2917 } 2919 }
2918 2920
2919 void LayerTreeHostImpl::ScrollViewportBy(gfx::Vector2dF scroll_delta) { 2921 void LayerTreeHostImpl::ScrollViewportBy(gfx::Vector2dF scroll_delta) {
2920 DCHECK(InnerViewportScrollLayer()); 2922 DCHECK(InnerViewportScrollLayer());
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
3332 } 3334 }
3333 3335
3334 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3336 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3335 std::vector<PictureLayerImpl*>::iterator it = 3337 std::vector<PictureLayerImpl*>::iterator it =
3336 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3338 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3337 DCHECK(it != picture_layers_.end()); 3339 DCHECK(it != picture_layers_.end());
3338 picture_layers_.erase(it); 3340 picture_layers_.erase(it);
3339 } 3341 }
3340 3342
3341 } // namespace cc 3343 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698