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