| 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 #include "cc/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 template <typename LayerType> | 1083 template <typename LayerType> |
| 1084 struct SubtreeGlobals { | 1084 struct SubtreeGlobals { |
| 1085 LayerSorter* layer_sorter; | 1085 LayerSorter* layer_sorter; |
| 1086 int max_texture_size; | 1086 int max_texture_size; |
| 1087 float device_scale_factor; | 1087 float device_scale_factor; |
| 1088 float page_scale_factor; | 1088 float page_scale_factor; |
| 1089 LayerType* page_scale_application_layer; | 1089 LayerType* page_scale_application_layer; |
| 1090 bool can_adjust_raster_scales; | 1090 bool can_adjust_raster_scales; |
| 1091 bool can_render_to_separate_surface; |
| 1091 }; | 1092 }; |
| 1092 | 1093 |
| 1093 template<typename LayerType, typename RenderSurfaceType> | 1094 template<typename LayerType, typename RenderSurfaceType> |
| 1094 struct DataForRecursion { | 1095 struct DataForRecursion { |
| 1095 // The accumulated sequence of transforms a layer will use to determine its | 1096 // The accumulated sequence of transforms a layer will use to determine its |
| 1096 // own draw transform. | 1097 // own draw transform. |
| 1097 gfx::Transform parent_matrix; | 1098 gfx::Transform parent_matrix; |
| 1098 | 1099 |
| 1099 // The accumulated sequence of transforms a layer will use to determine its | 1100 // The accumulated sequence of transforms a layer will use to determine its |
| 1100 // own screen-space transform. | 1101 // own screen-space transform. |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 data_from_ancestor.full_hierarchy_matrix; | 1442 data_from_ancestor.full_hierarchy_matrix; |
| 1442 | 1443 |
| 1443 // If the subtree will scale layer contents by the transform hierarchy, then | 1444 // If the subtree will scale layer contents by the transform hierarchy, then |
| 1444 // we should scale things into the render surface by the transform hierarchy | 1445 // we should scale things into the render surface by the transform hierarchy |
| 1445 // to take advantage of that. | 1446 // to take advantage of that. |
| 1446 gfx::Vector2dF render_surface_sublayer_scale = | 1447 gfx::Vector2dF render_surface_sublayer_scale = |
| 1447 globals.can_adjust_raster_scales | 1448 globals.can_adjust_raster_scales |
| 1448 ? combined_transform_scales | 1449 ? combined_transform_scales |
| 1449 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); | 1450 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); |
| 1450 | 1451 |
| 1451 if (SubtreeShouldRenderToSeparateSurface( | 1452 bool render_to_separate_surface; |
| 1452 layer, combined_transform.Preserves2dAxisAlignment())) { | 1453 if (globals.can_render_to_separate_surface) { |
| 1454 render_to_separate_surface = SubtreeShouldRenderToSeparateSurface( |
| 1455 layer, combined_transform.Preserves2dAxisAlignment()); |
| 1456 } else { |
| 1457 render_to_separate_surface = IsRootLayer(layer); |
| 1458 } |
| 1459 if (render_to_separate_surface) { |
| 1453 // Check back-face visibility before continuing with this surface and its | 1460 // Check back-face visibility before continuing with this surface and its |
| 1454 // subtree | 1461 // subtree |
| 1455 if (!layer->double_sided() && TransformToParentIsKnown(layer) && | 1462 if (!layer->double_sided() && TransformToParentIsKnown(layer) && |
| 1456 IsSurfaceBackFaceVisible(layer, combined_transform)) { | 1463 IsSurfaceBackFaceVisible(layer, combined_transform)) { |
| 1457 layer->ClearRenderSurface(); | 1464 layer->ClearRenderSurface(); |
| 1458 return; | 1465 return; |
| 1459 } | 1466 } |
| 1460 | 1467 |
| 1461 RenderSurfaceType* render_surface = CreateOrReuseRenderSurface(layer); | 1468 RenderSurfaceType* render_surface = CreateOrReuseRenderSurface(layer); |
| 1462 | 1469 |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1932 // The root layer's render_surface should receive the device viewport as the | 1939 // The root layer's render_surface should receive the device viewport as the |
| 1933 // initial clip rect. | 1940 // initial clip rect. |
| 1934 gfx::Rect device_viewport_rect(inputs->device_viewport_size); | 1941 gfx::Rect device_viewport_rect(inputs->device_viewport_size); |
| 1935 | 1942 |
| 1936 SubtreeGlobals<Layer> globals; | 1943 SubtreeGlobals<Layer> globals; |
| 1937 globals.layer_sorter = NULL; | 1944 globals.layer_sorter = NULL; |
| 1938 globals.max_texture_size = inputs->max_texture_size; | 1945 globals.max_texture_size = inputs->max_texture_size; |
| 1939 globals.device_scale_factor = inputs->device_scale_factor; | 1946 globals.device_scale_factor = inputs->device_scale_factor; |
| 1940 globals.page_scale_factor = inputs->page_scale_factor; | 1947 globals.page_scale_factor = inputs->page_scale_factor; |
| 1941 globals.page_scale_application_layer = inputs->page_scale_application_layer; | 1948 globals.page_scale_application_layer = inputs->page_scale_application_layer; |
| 1949 globals.can_render_to_separate_surface = |
| 1950 inputs->can_render_to_separate_surface; |
| 1942 globals.can_adjust_raster_scales = inputs->can_adjust_raster_scales; | 1951 globals.can_adjust_raster_scales = inputs->can_adjust_raster_scales; |
| 1943 | 1952 |
| 1944 DataForRecursion<Layer, RenderSurface> data_for_recursion; | 1953 DataForRecursion<Layer, RenderSurface> data_for_recursion; |
| 1945 data_for_recursion.parent_matrix = scaled_device_transform; | 1954 data_for_recursion.parent_matrix = scaled_device_transform; |
| 1946 data_for_recursion.full_hierarchy_matrix = identity_matrix; | 1955 data_for_recursion.full_hierarchy_matrix = identity_matrix; |
| 1947 data_for_recursion.scroll_compensation_matrix = identity_matrix; | 1956 data_for_recursion.scroll_compensation_matrix = identity_matrix; |
| 1948 data_for_recursion.fixed_container = inputs->root_layer; | 1957 data_for_recursion.fixed_container = inputs->root_layer; |
| 1949 data_for_recursion.clip_rect_in_target_space = device_viewport_rect; | 1958 data_for_recursion.clip_rect_in_target_space = device_viewport_rect; |
| 1950 data_for_recursion.clip_rect_of_target_surface_in_target_space = | 1959 data_for_recursion.clip_rect_of_target_surface_in_target_space = |
| 1951 device_viewport_rect; | 1960 device_viewport_rect; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 // The root layer's render_surface should receive the device viewport as the | 1998 // The root layer's render_surface should receive the device viewport as the |
| 1990 // initial clip rect. | 1999 // initial clip rect. |
| 1991 gfx::Rect device_viewport_rect(inputs->device_viewport_size); | 2000 gfx::Rect device_viewport_rect(inputs->device_viewport_size); |
| 1992 | 2001 |
| 1993 SubtreeGlobals<LayerImpl> globals; | 2002 SubtreeGlobals<LayerImpl> globals; |
| 1994 globals.layer_sorter = &layer_sorter; | 2003 globals.layer_sorter = &layer_sorter; |
| 1995 globals.max_texture_size = inputs->max_texture_size; | 2004 globals.max_texture_size = inputs->max_texture_size; |
| 1996 globals.device_scale_factor = inputs->device_scale_factor; | 2005 globals.device_scale_factor = inputs->device_scale_factor; |
| 1997 globals.page_scale_factor = inputs->page_scale_factor; | 2006 globals.page_scale_factor = inputs->page_scale_factor; |
| 1998 globals.page_scale_application_layer = inputs->page_scale_application_layer; | 2007 globals.page_scale_application_layer = inputs->page_scale_application_layer; |
| 2008 globals.can_render_to_separate_surface = |
| 2009 inputs->can_render_to_separate_surface; |
| 1999 globals.can_adjust_raster_scales = inputs->can_adjust_raster_scales; | 2010 globals.can_adjust_raster_scales = inputs->can_adjust_raster_scales; |
| 2000 | 2011 |
| 2001 DataForRecursion<LayerImpl, RenderSurfaceImpl> data_for_recursion; | 2012 DataForRecursion<LayerImpl, RenderSurfaceImpl> data_for_recursion; |
| 2002 data_for_recursion.parent_matrix = scaled_device_transform; | 2013 data_for_recursion.parent_matrix = scaled_device_transform; |
| 2003 data_for_recursion.full_hierarchy_matrix = identity_matrix; | 2014 data_for_recursion.full_hierarchy_matrix = identity_matrix; |
| 2004 data_for_recursion.scroll_compensation_matrix = identity_matrix; | 2015 data_for_recursion.scroll_compensation_matrix = identity_matrix; |
| 2005 data_for_recursion.fixed_container = inputs->root_layer; | 2016 data_for_recursion.fixed_container = inputs->root_layer; |
| 2006 data_for_recursion.clip_rect_in_target_space = device_viewport_rect; | 2017 data_for_recursion.clip_rect_in_target_space = device_viewport_rect; |
| 2007 data_for_recursion.clip_rect_of_target_surface_in_target_space = | 2018 data_for_recursion.clip_rect_of_target_surface_in_target_space = |
| 2008 device_viewport_rect; | 2019 device_viewport_rect; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2216 // At this point, we think the point does hit the touch event handler region | 2227 // At this point, we think the point does hit the touch event handler region |
| 2217 // on the layer, but we need to walk up the parents to ensure that the layer | 2228 // on the layer, but we need to walk up the parents to ensure that the layer |
| 2218 // was not clipped in such a way that the hit point actually should not hit | 2229 // was not clipped in such a way that the hit point actually should not hit |
| 2219 // the layer. | 2230 // the layer. |
| 2220 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2231 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
| 2221 return false; | 2232 return false; |
| 2222 | 2233 |
| 2223 return true; | 2234 return true; |
| 2224 } | 2235 } |
| 2225 } // namespace cc | 2236 } // namespace cc |
| OLD | NEW |