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 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 | 1262 |
1263 template <typename LayerType> | 1263 template <typename LayerType> |
1264 struct SubtreeGlobals { | 1264 struct SubtreeGlobals { |
1265 LayerSorter* layer_sorter; | 1265 LayerSorter* layer_sorter; |
1266 int max_texture_size; | 1266 int max_texture_size; |
1267 float device_scale_factor; | 1267 float device_scale_factor; |
1268 float page_scale_factor; | 1268 float page_scale_factor; |
1269 const LayerType* page_scale_application_layer; | 1269 const LayerType* page_scale_application_layer; |
1270 bool can_adjust_raster_scales; | 1270 bool can_adjust_raster_scales; |
1271 bool can_render_to_separate_surface; | 1271 bool can_render_to_separate_surface; |
| 1272 bool layers_always_allowed_lcd_text; |
1272 }; | 1273 }; |
1273 | 1274 |
1274 template<typename LayerType> | 1275 template<typename LayerType> |
1275 struct DataForRecursion { | 1276 struct DataForRecursion { |
1276 // The accumulated sequence of transforms a layer will use to determine its | 1277 // The accumulated sequence of transforms a layer will use to determine its |
1277 // own draw transform. | 1278 // own draw transform. |
1278 gfx::Transform parent_matrix; | 1279 gfx::Transform parent_matrix; |
1279 | 1280 |
1280 // The accumulated sequence of transforms a layer will use to determine its | 1281 // The accumulated sequence of transforms a layer will use to determine its |
1281 // own screen-space transform. | 1282 // own screen-space transform. |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 data_from_ancestor.full_hierarchy_matrix; | 1785 data_from_ancestor.full_hierarchy_matrix; |
1785 if (layer->should_flatten_transform()) | 1786 if (layer->should_flatten_transform()) |
1786 layer_draw_properties.screen_space_transform.FlattenTo2d(); | 1787 layer_draw_properties.screen_space_transform.FlattenTo2d(); |
1787 layer_draw_properties.screen_space_transform.PreconcatTransform | 1788 layer_draw_properties.screen_space_transform.PreconcatTransform |
1788 (layer_draw_properties.target_space_transform); | 1789 (layer_draw_properties.target_space_transform); |
1789 | 1790 |
1790 // Adjusting text AA method during animation may cause repaints, which in-turn | 1791 // Adjusting text AA method during animation may cause repaints, which in-turn |
1791 // causes jank. | 1792 // causes jank. |
1792 bool adjust_text_aa = | 1793 bool adjust_text_aa = |
1793 !animating_opacity_to_screen && !animating_transform_to_screen; | 1794 !animating_opacity_to_screen && !animating_transform_to_screen; |
1794 // To avoid color fringing, LCD text should only be used on opaque layers with | 1795 bool layer_can_use_lcd_text = true; |
1795 // just integral translation. | 1796 bool subtree_can_use_lcd_text = true; |
1796 bool layer_can_use_lcd_text = | 1797 if (!globals.layers_always_allowed_lcd_text) { |
1797 data_from_ancestor.subtree_can_use_lcd_text && | 1798 // To avoid color fringing, LCD text should only be used on opaque layers |
1798 accumulated_draw_opacity == 1.f && | 1799 // with just integral translation. |
1799 layer_draw_properties.target_space_transform. | 1800 subtree_can_use_lcd_text = data_from_ancestor.subtree_can_use_lcd_text && |
1800 IsIdentityOrIntegerTranslation(); | 1801 accumulated_draw_opacity == 1.f && |
| 1802 layer_draw_properties.target_space_transform |
| 1803 .IsIdentityOrIntegerTranslation(); |
| 1804 // Also disable LCD text locally for non-opaque content. |
| 1805 layer_can_use_lcd_text = subtree_can_use_lcd_text && |
| 1806 layer->contents_opaque(); |
| 1807 } |
1801 | 1808 |
1802 gfx::Rect content_rect(layer->content_bounds()); | 1809 gfx::Rect content_rect(layer->content_bounds()); |
1803 | 1810 |
1804 // full_hierarchy_matrix is the matrix that transforms objects between screen | 1811 // full_hierarchy_matrix is the matrix that transforms objects between screen |
1805 // space (except projection matrix) and the most recent RenderSurfaceImpl's | 1812 // space (except projection matrix) and the most recent RenderSurfaceImpl's |
1806 // space. next_hierarchy_matrix will only change if this layer uses a new | 1813 // space. next_hierarchy_matrix will only change if this layer uses a new |
1807 // RenderSurfaceImpl, otherwise remains the same. | 1814 // RenderSurfaceImpl, otherwise remains the same. |
1808 data_for_children.full_hierarchy_matrix = | 1815 data_for_children.full_hierarchy_matrix = |
1809 data_from_ancestor.full_hierarchy_matrix; | 1816 data_from_ancestor.full_hierarchy_matrix; |
1810 | 1817 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 render_surface->SetIsClipped(subtree_is_clipped_by_surface_bounds); | 1995 render_surface->SetIsClipped(subtree_is_clipped_by_surface_bounds); |
1989 if (!subtree_is_clipped_by_surface_bounds) { | 1996 if (!subtree_is_clipped_by_surface_bounds) { |
1990 render_surface->SetClipRect(gfx::Rect()); | 1997 render_surface->SetClipRect(gfx::Rect()); |
1991 clip_rect_of_target_surface_in_target_space = | 1998 clip_rect_of_target_surface_in_target_space = |
1992 data_from_ancestor.clip_rect_of_target_surface_in_target_space; | 1999 data_from_ancestor.clip_rect_of_target_surface_in_target_space; |
1993 } | 2000 } |
1994 | 2001 |
1995 // If the new render surface is drawn translucent or with a non-integral | 2002 // If the new render surface is drawn translucent or with a non-integral |
1996 // translation then the subtree that gets drawn on this render surface | 2003 // translation then the subtree that gets drawn on this render surface |
1997 // cannot use LCD text. | 2004 // cannot use LCD text. |
1998 data_for_children.subtree_can_use_lcd_text = layer_can_use_lcd_text; | 2005 data_for_children.subtree_can_use_lcd_text = subtree_can_use_lcd_text; |
1999 | 2006 |
2000 render_surface_layer_list->push_back(layer); | 2007 render_surface_layer_list->push_back(layer); |
2001 } else { | 2008 } else { |
2002 DCHECK(layer->parent()); | 2009 DCHECK(layer->parent()); |
2003 | 2010 |
2004 // Note: layer_draw_properties.target_space_transform is computed above, | 2011 // Note: layer_draw_properties.target_space_transform is computed above, |
2005 // before this if-else statement. | 2012 // before this if-else statement. |
2006 layer_draw_properties.target_space_transform_is_animating = | 2013 layer_draw_properties.target_space_transform_is_animating = |
2007 animating_transform_to_target; | 2014 animating_transform_to_target; |
2008 layer_draw_properties.screen_space_transform_is_animating = | 2015 layer_draw_properties.screen_space_transform_is_animating = |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2367 | 2374 |
2368 globals->layer_sorter = NULL; | 2375 globals->layer_sorter = NULL; |
2369 globals->max_texture_size = inputs.max_texture_size; | 2376 globals->max_texture_size = inputs.max_texture_size; |
2370 globals->device_scale_factor = | 2377 globals->device_scale_factor = |
2371 inputs.device_scale_factor * device_transform_scale; | 2378 inputs.device_scale_factor * device_transform_scale; |
2372 globals->page_scale_factor = inputs.page_scale_factor; | 2379 globals->page_scale_factor = inputs.page_scale_factor; |
2373 globals->page_scale_application_layer = inputs.page_scale_application_layer; | 2380 globals->page_scale_application_layer = inputs.page_scale_application_layer; |
2374 globals->can_render_to_separate_surface = | 2381 globals->can_render_to_separate_surface = |
2375 inputs.can_render_to_separate_surface; | 2382 inputs.can_render_to_separate_surface; |
2376 globals->can_adjust_raster_scales = inputs.can_adjust_raster_scales; | 2383 globals->can_adjust_raster_scales = inputs.can_adjust_raster_scales; |
| 2384 globals->layers_always_allowed_lcd_text = |
| 2385 inputs.layers_always_allowed_lcd_text; |
2377 | 2386 |
2378 data_for_recursion->parent_matrix = scaled_device_transform; | 2387 data_for_recursion->parent_matrix = scaled_device_transform; |
2379 data_for_recursion->full_hierarchy_matrix = identity_matrix; | 2388 data_for_recursion->full_hierarchy_matrix = identity_matrix; |
2380 data_for_recursion->scroll_compensation_matrix = identity_matrix; | 2389 data_for_recursion->scroll_compensation_matrix = identity_matrix; |
2381 data_for_recursion->fixed_container = inputs.root_layer; | 2390 data_for_recursion->fixed_container = inputs.root_layer; |
2382 data_for_recursion->clip_rect_in_target_space = device_viewport_rect; | 2391 data_for_recursion->clip_rect_in_target_space = device_viewport_rect; |
2383 data_for_recursion->clip_rect_of_target_surface_in_target_space = | 2392 data_for_recursion->clip_rect_of_target_surface_in_target_space = |
2384 device_viewport_rect; | 2393 device_viewport_rect; |
2385 data_for_recursion->maximum_animation_contents_scale = 0.f; | 2394 data_for_recursion->maximum_animation_contents_scale = 0.f; |
2386 data_for_recursion->ancestor_is_animating_scale = false; | 2395 data_for_recursion->ancestor_is_animating_scale = false; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2440 inputs->current_render_surface_layer_list_id); | 2449 inputs->current_render_surface_layer_list_id); |
2441 | 2450 |
2442 // The dummy layer list should not have been used. | 2451 // The dummy layer list should not have been used. |
2443 DCHECK_EQ(0u, dummy_layer_list.size()); | 2452 DCHECK_EQ(0u, dummy_layer_list.size()); |
2444 // A root layer render_surface should always exist after | 2453 // A root layer render_surface should always exist after |
2445 // CalculateDrawProperties. | 2454 // CalculateDrawProperties. |
2446 DCHECK(inputs->root_layer->render_surface()); | 2455 DCHECK(inputs->root_layer->render_surface()); |
2447 } | 2456 } |
2448 | 2457 |
2449 } // namespace cc | 2458 } // namespace cc |
OLD | NEW |