| OLD | NEW |
| 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 #ifndef CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 5 #ifndef CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| 6 #define CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 6 #define CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/base/scoped_ptr_vector.h" | 12 #include "cc/base/scoped_ptr_vector.h" |
| 13 #include "cc/layers/layer_lists.h" |
| 13 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 14 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
| 15 #include "ui/gfx/vector2d.h" | 16 #include "ui/gfx/vector2d.h" |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 | 19 |
| 19 class LayerImpl; | 20 class LayerImpl; |
| 20 class Layer; | 21 class Layer; |
| 21 | 22 |
| 22 class CC_EXPORT LayerTreeHostCommon { | 23 class CC_EXPORT LayerTreeHostCommon { |
| 23 public: | 24 public: |
| 24 static gfx::Rect CalculateVisibleRect(gfx::Rect target_surface_rect, | 25 static gfx::Rect CalculateVisibleRect(gfx::Rect target_surface_rect, |
| 25 gfx::Rect layer_bound_rect, | 26 gfx::Rect layer_bound_rect, |
| 26 const gfx::Transform& transform); | 27 const gfx::Transform& transform); |
| 27 | 28 |
| 28 static void CalculateDrawProperties( | 29 static void CalculateDrawProperties( |
| 29 Layer* root_layer, | 30 Layer* root_layer, |
| 30 gfx::Size device_viewport_size, | 31 gfx::Size device_viewport_size, |
| 31 float device_scale_factor, | 32 float device_scale_factor, |
| 32 float page_scale_factor, | 33 float page_scale_factor, |
| 33 int max_texture_size, | 34 int max_texture_size, |
| 34 bool can_use_lcd_text, | 35 bool can_use_lcd_text, |
| 35 std::vector<scoped_refptr<Layer> >* render_surface_layer_list); | 36 LayerList* render_surface_layer_list); |
| 36 static void CalculateDrawProperties( | 37 static void CalculateDrawProperties( |
| 37 LayerImpl* root_layer, | 38 LayerImpl* root_layer, |
| 38 gfx::Size device_viewport_size, | 39 gfx::Size device_viewport_size, |
| 39 float device_scale_factor, | 40 float device_scale_factor, |
| 40 float page_scale_factor, | 41 float page_scale_factor, |
| 41 int max_texture_size, | 42 int max_texture_size, |
| 42 bool can_use_lcd_text, | 43 bool can_use_lcd_text, |
| 43 std::vector<LayerImpl*>* render_surface_layer_list, | 44 LayerImplList* render_surface_layer_list, |
| 44 bool update_tile_priorities); | 45 bool update_tile_priorities); |
| 45 | 46 |
| 46 // Performs hit testing for a given render_surface_layer_list. | 47 // Performs hit testing for a given render_surface_layer_list. |
| 47 static LayerImpl* FindLayerThatIsHitByPoint( | 48 static LayerImpl* FindLayerThatIsHitByPoint( |
| 48 gfx::PointF screen_space_point, | 49 gfx::PointF screen_space_point, |
| 49 const std::vector<LayerImpl*>& render_surface_layer_list); | 50 const LayerImplList& render_surface_layer_list); |
| 50 | 51 |
| 51 static LayerImpl* FindLayerThatIsHitByPointInTouchHandlerRegion( | 52 static LayerImpl* FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 52 gfx::PointF screen_space_point, | 53 gfx::PointF screen_space_point, |
| 53 const std::vector<LayerImpl*>& render_surface_layer_list); | 54 const LayerImplList& render_surface_layer_list); |
| 54 | 55 |
| 55 static bool LayerHasTouchEventHandlersAt(gfx::PointF screen_space_point, | 56 static bool LayerHasTouchEventHandlersAt(gfx::PointF screen_space_point, |
| 56 LayerImpl* layer_impl); | 57 LayerImpl* layer_impl); |
| 57 | 58 |
| 58 template <typename LayerType> | 59 template <typename LayerType> |
| 59 static bool RenderSurfaceContributesToTarget(LayerType*, | 60 static bool RenderSurfaceContributesToTarget(LayerType*, |
| 60 int target_surface_layer_id); | 61 int target_surface_layer_id); |
| 61 | 62 |
| 62 template <class Function, typename LayerType> | 63 template <class Function, typename LayerType> |
| 63 static void CallFunctionForSubtree(LayerType* root_layer); | 64 static void CallFunctionForSubtree(LayerType* root_layer); |
| 64 | 65 |
| 65 // Returns a layer with the given id if one exists in the subtree starting | 66 // Returns a layer with the given id if one exists in the subtree starting |
| 66 // from the given root layer (including mask and replica layers). | 67 // from the given root layer (including mask and replica layers). |
| 67 template <typename LayerType> | 68 template <typename LayerType> |
| 68 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); | 69 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); |
| 69 | 70 |
| 70 static Layer* get_child_as_raw_ptr( | 71 static Layer* get_child_as_raw_ptr( |
| 71 const std::vector<scoped_refptr<Layer> >& children, | 72 const LayerList& children, |
| 72 size_t index) { | 73 size_t index) { |
| 73 return children[index].get(); | 74 return children[index].get(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 static LayerImpl* get_child_as_raw_ptr( | 77 static LayerImpl* get_child_as_raw_ptr( |
| 77 const ScopedPtrVector<LayerImpl>& children, | 78 const OwnedLayerImplList& children, |
| 78 size_t index) { | 79 size_t index) { |
| 79 return children[index]; | 80 return children[index]; |
| 80 } | 81 } |
| 81 | 82 |
| 82 struct ScrollUpdateInfo { | 83 struct ScrollUpdateInfo { |
| 83 int layer_id; | 84 int layer_id; |
| 84 gfx::Vector2d scroll_delta; | 85 gfx::Vector2d scroll_delta; |
| 85 }; | 86 }; |
| 86 }; | 87 }; |
| 87 | 88 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 144 |
| 144 for (size_t i = 0; i < root_layer->children().size(); ++i) { | 145 for (size_t i = 0; i < root_layer->children().size(); ++i) { |
| 145 CallFunctionForSubtree<Function>( | 146 CallFunctionForSubtree<Function>( |
| 146 get_child_as_raw_ptr(root_layer->children(), i)); | 147 get_child_as_raw_ptr(root_layer->children(), i)); |
| 147 } | 148 } |
| 148 } | 149 } |
| 149 | 150 |
| 150 } // namespace cc | 151 } // namespace cc |
| 151 | 152 |
| 152 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 153 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| OLD | NEW |