| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef CC_TREES_LAYER_TREE_IMPL_H_ | 5 #ifndef CC_TREES_LAYER_TREE_IMPL_H_ |
| 6 #define CC_TREES_LAYER_TREE_IMPL_H_ | 6 #define CC_TREES_LAYER_TREE_IMPL_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "cc/base/scoped_ptr_vector.h" | 15 #include "cc/base/scoped_ptr_vector.h" |
| 16 #include "cc/base/swap_promise.h" | 16 #include "cc/base/swap_promise.h" |
| 17 #include "cc/base/synced_property.h" |
| 17 #include "cc/layers/layer_impl.h" | 18 #include "cc/layers/layer_impl.h" |
| 18 #include "cc/output/renderer.h" | 19 #include "cc/output/renderer.h" |
| 19 #include "cc/resources/ui_resource_client.h" | 20 #include "cc/resources/ui_resource_client.h" |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 namespace debug { | 23 namespace debug { |
| 23 class TracedValue; | 24 class TracedValue; |
| 24 } | 25 } |
| 25 } | 26 } |
| 26 | 27 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 46 class UIResourceRequest; | 47 class UIResourceRequest; |
| 47 struct PendingPageScaleAnimation; | 48 struct PendingPageScaleAnimation; |
| 48 struct RendererCapabilities; | 49 struct RendererCapabilities; |
| 49 struct SelectionHandle; | 50 struct SelectionHandle; |
| 50 | 51 |
| 51 typedef std::list<UIResourceRequest> UIResourceRequestQueue; | 52 typedef std::list<UIResourceRequest> UIResourceRequestQueue; |
| 52 | 53 |
| 53 class CC_EXPORT LayerTreeImpl { | 54 class CC_EXPORT LayerTreeImpl { |
| 54 public: | 55 public: |
| 55 static scoped_ptr<LayerTreeImpl> create( | 56 static scoped_ptr<LayerTreeImpl> create( |
| 56 LayerTreeHostImpl* layer_tree_host_impl) { | 57 LayerTreeHostImpl* layer_tree_host_impl, |
| 57 return make_scoped_ptr(new LayerTreeImpl(layer_tree_host_impl)); | 58 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor) { |
| 59 return make_scoped_ptr( |
| 60 new LayerTreeImpl(layer_tree_host_impl, page_scale_factor)); |
| 58 } | 61 } |
| 59 virtual ~LayerTreeImpl(); | 62 virtual ~LayerTreeImpl(); |
| 60 | 63 |
| 61 void Shutdown(); | 64 void Shutdown(); |
| 62 void ReleaseResources(); | 65 void ReleaseResources(); |
| 63 | 66 |
| 64 // Methods called by the layer tree that pass-through or access LTHI. | 67 // Methods called by the layer tree that pass-through or access LTHI. |
| 65 // --------------------------------------------------------------------------- | 68 // --------------------------------------------------------------------------- |
| 66 const LayerTreeSettings& settings() const; | 69 const LayerTreeSettings& settings() const; |
| 67 const RendererCapabilitiesImpl& GetRendererCapabilities() const; | 70 const RendererCapabilitiesImpl& GetRendererCapabilities() const; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 SkColor background_color() const { return background_color_; } | 157 SkColor background_color() const { return background_color_; } |
| 155 void set_background_color(SkColor color) { background_color_ = color; } | 158 void set_background_color(SkColor color) { background_color_ = color; } |
| 156 | 159 |
| 157 bool has_transparent_background() const { | 160 bool has_transparent_background() const { |
| 158 return has_transparent_background_; | 161 return has_transparent_background_; |
| 159 } | 162 } |
| 160 void set_has_transparent_background(bool transparent) { | 163 void set_has_transparent_background(bool transparent) { |
| 161 has_transparent_background_ = transparent; | 164 has_transparent_background_ = transparent; |
| 162 } | 165 } |
| 163 | 166 |
| 164 void SetPageScaleFactorAndLimits(float page_scale_factor, | 167 void SetPageScaleOnActiveTree(float active_page_scale); |
| 165 float min_page_scale_factor, float max_page_scale_factor); | 168 void PushPageScaleFromMainThread(float page_scale_factor, |
| 166 void SetPageScaleDelta(float delta); | 169 float min_page_scale_factor, |
| 167 void SetPageScaleValues(float page_scale_factor, | 170 float max_page_scale_factor); |
| 168 float min_page_scale_factor, float max_page_scale_factor, | 171 float current_page_scale_factor() const { |
| 169 float page_scale_delta); | 172 return page_scale_factor()->Current(IsActiveTree()); |
| 170 float total_page_scale_factor() const { | |
| 171 return page_scale_factor_ * page_scale_delta_; | |
| 172 } | 173 } |
| 173 float page_scale_factor() const { return page_scale_factor_; } | |
| 174 float min_page_scale_factor() const { return min_page_scale_factor_; } | 174 float min_page_scale_factor() const { return min_page_scale_factor_; } |
| 175 float max_page_scale_factor() const { return max_page_scale_factor_; } | 175 float max_page_scale_factor() const { return max_page_scale_factor_; } |
| 176 float page_scale_delta() const { return page_scale_delta_; } | 176 |
| 177 void set_sent_page_scale_delta(float delta) { | 177 float page_scale_delta() const { return page_scale_factor()->Delta(); } |
| 178 sent_page_scale_delta_ = delta; | 178 |
| 179 } | 179 SyncedProperty<ScaleGroup>* page_scale_factor(); |
| 180 float sent_page_scale_delta() const { return sent_page_scale_delta_; } | 180 const SyncedProperty<ScaleGroup>* page_scale_factor() const; |
| 181 | 181 |
| 182 // Updates draw properties and render surface layer list, as well as tile | 182 // Updates draw properties and render surface layer list, as well as tile |
| 183 // priorities. Returns false if it was unable to update. | 183 // priorities. Returns false if it was unable to update. |
| 184 bool UpdateDrawProperties(); | 184 bool UpdateDrawProperties(); |
| 185 | 185 |
| 186 void set_needs_update_draw_properties() { | 186 void set_needs_update_draw_properties() { |
| 187 needs_update_draw_properties_ = true; | 187 needs_update_draw_properties_ = true; |
| 188 } | 188 } |
| 189 bool needs_update_draw_properties() const { | 189 bool needs_update_draw_properties() const { |
| 190 return needs_update_draw_properties_; | 190 return needs_update_draw_properties_; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 const LayerSelectionBound& end); | 280 const LayerSelectionBound& end); |
| 281 | 281 |
| 282 // Compute the current selection handle location and visbility with respect to | 282 // Compute the current selection handle location and visbility with respect to |
| 283 // the viewport. | 283 // the viewport. |
| 284 void GetViewportSelection(ViewportSelectionBound* start, | 284 void GetViewportSelection(ViewportSelectionBound* start, |
| 285 ViewportSelectionBound* end); | 285 ViewportSelectionBound* end); |
| 286 | 286 |
| 287 void RegisterPictureLayerImpl(PictureLayerImpl* layer); | 287 void RegisterPictureLayerImpl(PictureLayerImpl* layer); |
| 288 void UnregisterPictureLayerImpl(PictureLayerImpl* layer); | 288 void UnregisterPictureLayerImpl(PictureLayerImpl* layer); |
| 289 | 289 |
| 290 void set_top_controls_layout_height(float height) { | 290 void set_top_controls_shrink_blink_size(bool shrink) { |
| 291 top_controls_layout_height_ = height; | 291 top_controls_shrink_blink_size_ = shrink; |
| 292 } | 292 } |
| 293 void set_top_controls_height(float height) { top_controls_height_ = height; } |
| 293 void set_top_controls_content_offset(float offset) { | 294 void set_top_controls_content_offset(float offset) { |
| 294 top_controls_content_offset_ = offset; | 295 top_controls_content_offset_ = offset; |
| 295 } | 296 } |
| 296 void set_top_controls_delta(float delta) { | 297 void set_top_controls_delta(float delta) { |
| 297 top_controls_delta_ = delta; | 298 top_controls_delta_ = delta; |
| 298 } | 299 } |
| 299 void set_sent_top_controls_delta(float sent_delta) { | 300 void set_sent_top_controls_delta(float sent_delta) { |
| 300 sent_top_controls_delta_ = sent_delta; | 301 sent_top_controls_delta_ = sent_delta; |
| 301 } | 302 } |
| 302 | 303 |
| 303 float top_controls_layout_height() const { | 304 bool top_controls_shrink_blink_size() const { |
| 304 return top_controls_layout_height_; | 305 return top_controls_shrink_blink_size_; |
| 305 } | 306 } |
| 307 float top_controls_height() const { return top_controls_height_; } |
| 306 float top_controls_content_offset() const { | 308 float top_controls_content_offset() const { |
| 307 return top_controls_content_offset_; | 309 return top_controls_content_offset_; |
| 308 } | 310 } |
| 309 float top_controls_delta() const { | 311 float top_controls_delta() const { |
| 310 return top_controls_delta_; | 312 return top_controls_delta_; |
| 311 } | 313 } |
| 312 float sent_top_controls_delta() const { | 314 float sent_top_controls_delta() const { |
| 313 return sent_top_controls_delta_; | 315 return sent_top_controls_delta_; |
| 314 } | 316 } |
| 315 float total_top_controls_content_offset() const { | 317 float total_top_controls_content_offset() const { |
| 316 return top_controls_content_offset_ + top_controls_delta_; | 318 return top_controls_content_offset_ + top_controls_delta_; |
| 317 } | 319 } |
| 318 | 320 |
| 319 void SetPendingPageScaleAnimation( | 321 void SetPendingPageScaleAnimation( |
| 320 scoped_ptr<PendingPageScaleAnimation> pending_animation); | 322 scoped_ptr<PendingPageScaleAnimation> pending_animation); |
| 321 scoped_ptr<PendingPageScaleAnimation> TakePendingPageScaleAnimation(); | 323 scoped_ptr<PendingPageScaleAnimation> TakePendingPageScaleAnimation(); |
| 322 | 324 |
| 323 protected: | 325 protected: |
| 324 explicit LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl); | 326 explicit LayerTreeImpl( |
| 327 LayerTreeHostImpl* layer_tree_host_impl, |
| 328 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor); |
| 325 void ReleaseResourcesRecursive(LayerImpl* current); | 329 void ReleaseResourcesRecursive(LayerImpl* current); |
| 330 float ClampPageScaleFactorToLimits(float page_scale_factor) const; |
| 331 void PushPageScaleFactorAndLimits(const float* page_scale_factor, |
| 332 float min_page_scale_factor, |
| 333 float max_page_scale_factor); |
| 334 bool SetPageScaleFactorLimits(float min_page_scale_factor, |
| 335 float max_page_scale_factor); |
| 336 void DidUpdatePageScale(); |
| 326 | 337 |
| 327 LayerTreeHostImpl* layer_tree_host_impl_; | 338 LayerTreeHostImpl* layer_tree_host_impl_; |
| 328 int source_frame_number_; | 339 int source_frame_number_; |
| 329 scoped_ptr<LayerImpl> root_layer_; | 340 scoped_ptr<LayerImpl> root_layer_; |
| 330 HeadsUpDisplayLayerImpl* hud_layer_; | 341 HeadsUpDisplayLayerImpl* hud_layer_; |
| 331 LayerImpl* currently_scrolling_layer_; | 342 LayerImpl* currently_scrolling_layer_; |
| 332 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_; | 343 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_; |
| 333 scoped_ptr<LayerScrollOffsetDelegateProxy> | 344 scoped_ptr<LayerScrollOffsetDelegateProxy> |
| 334 inner_viewport_scroll_delegate_proxy_; | 345 inner_viewport_scroll_delegate_proxy_; |
| 335 scoped_ptr<LayerScrollOffsetDelegateProxy> | 346 scoped_ptr<LayerScrollOffsetDelegateProxy> |
| 336 outer_viewport_scroll_delegate_proxy_; | 347 outer_viewport_scroll_delegate_proxy_; |
| 337 SkColor background_color_; | 348 SkColor background_color_; |
| 338 bool has_transparent_background_; | 349 bool has_transparent_background_; |
| 339 | 350 |
| 340 LayerImpl* overscroll_elasticity_layer_; | 351 LayerImpl* overscroll_elasticity_layer_; |
| 341 LayerImpl* page_scale_layer_; | 352 LayerImpl* page_scale_layer_; |
| 342 LayerImpl* inner_viewport_scroll_layer_; | 353 LayerImpl* inner_viewport_scroll_layer_; |
| 343 LayerImpl* outer_viewport_scroll_layer_; | 354 LayerImpl* outer_viewport_scroll_layer_; |
| 344 | 355 |
| 345 LayerSelectionBound selection_start_; | 356 LayerSelectionBound selection_start_; |
| 346 LayerSelectionBound selection_end_; | 357 LayerSelectionBound selection_end_; |
| 347 | 358 |
| 348 float page_scale_factor_; | 359 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor_; |
| 349 float page_scale_delta_; | |
| 350 float sent_page_scale_delta_; | |
| 351 float min_page_scale_factor_; | 360 float min_page_scale_factor_; |
| 352 float max_page_scale_factor_; | 361 float max_page_scale_factor_; |
| 353 | 362 |
| 354 typedef base::hash_map<int, LayerImpl*> LayerIdMap; | 363 typedef base::hash_map<int, LayerImpl*> LayerIdMap; |
| 355 LayerIdMap layer_id_map_; | 364 LayerIdMap layer_id_map_; |
| 356 | 365 |
| 357 std::vector<LayerImpl*> layers_with_copy_output_request_; | 366 std::vector<LayerImpl*> layers_with_copy_output_request_; |
| 358 | 367 |
| 359 // Persisted state for non-impl-side-painting. | 368 // Persisted state for non-impl-side-painting. |
| 360 int scrolling_layer_id_from_previous_tree_; | 369 int scrolling_layer_id_from_previous_tree_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 373 bool next_activation_forces_redraw_; | 382 bool next_activation_forces_redraw_; |
| 374 | 383 |
| 375 bool has_ever_been_drawn_; | 384 bool has_ever_been_drawn_; |
| 376 | 385 |
| 377 ScopedPtrVector<SwapPromise> swap_promise_list_; | 386 ScopedPtrVector<SwapPromise> swap_promise_list_; |
| 378 | 387 |
| 379 UIResourceRequestQueue ui_resource_request_queue_; | 388 UIResourceRequestQueue ui_resource_request_queue_; |
| 380 | 389 |
| 381 int render_surface_layer_list_id_; | 390 int render_surface_layer_list_id_; |
| 382 | 391 |
| 383 // The top controls content offset at the time of the last layout (and thus, | 392 // Whether or not Blink's viewport size was shrunk by the height of the top |
| 384 // viewport resize) in Blink. i.e. How much the viewport was shrunk by the top | 393 // controls at the time of the last layout. |
| 385 // controls. | 394 bool top_controls_shrink_blink_size_; |
| 386 float top_controls_layout_height_; | 395 |
| 396 float top_controls_height_; |
| 387 | 397 |
| 388 // The up-to-date content offset of the top controls, i.e. the amount that the | 398 // The up-to-date content offset of the top controls, i.e. the amount that the |
| 389 // web contents have been shifted down from the top of the device viewport. | 399 // web contents have been shifted down from the top of the device viewport. |
| 390 float top_controls_content_offset_; | 400 float top_controls_content_offset_; |
| 391 float top_controls_delta_; | 401 float top_controls_delta_; |
| 392 float sent_top_controls_delta_; | 402 float sent_top_controls_delta_; |
| 393 | 403 |
| 394 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; | 404 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
| 395 | 405 |
| 396 private: | 406 private: |
| 397 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); | 407 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); |
| 398 }; | 408 }; |
| 399 | 409 |
| 400 } // namespace cc | 410 } // namespace cc |
| 401 | 411 |
| 402 #endif // CC_TREES_LAYER_TREE_IMPL_H_ | 412 #endif // CC_TREES_LAYER_TREE_IMPL_H_ |
| OLD | NEW |