| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 | 143 |
| 144 template <typename LayerType> | 144 template <typename LayerType> |
| 145 static inline bool LayerClipsSubtree(LayerType* layer) { | 145 static inline bool LayerClipsSubtree(LayerType* layer) { |
| 146 return layer->masks_to_bounds() || layer->mask_layer(); | 146 return layer->masks_to_bounds() || layer->mask_layer(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 template <typename LayerType> | 149 template <typename LayerType> |
| 150 static gfx::Rect CalculateVisibleContentRect( | 150 static gfx::Rect CalculateVisibleContentRect( |
| 151 LayerType* layer, | 151 LayerType* layer, |
| 152 gfx::Rect ancestor_clip_rect_in_descendant_surface_space, | 152 gfx::Rect clip_rect_of_target_surface_in_target_space, |
| 153 gfx::Rect layer_rect_in_target_space) { | 153 gfx::Rect layer_rect_in_target_space) { |
| 154 DCHECK(layer->render_target()); | 154 DCHECK(layer->render_target()); |
| 155 | 155 |
| 156 // Nothing is visible if the layer bounds are empty. | 156 // Nothing is visible if the layer bounds are empty. |
| 157 if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() || | 157 if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() || |
| 158 layer->drawable_content_rect().IsEmpty()) | 158 layer->drawable_content_rect().IsEmpty()) |
| 159 return gfx::Rect(); | 159 return gfx::Rect(); |
| 160 | 160 |
| 161 // Compute visible bounds in target surface space. | 161 // Compute visible bounds in target surface space. |
| 162 gfx::Rect visible_rect_in_target_surface_space = | 162 gfx::Rect visible_rect_in_target_surface_space = |
| 163 layer->drawable_content_rect(); | 163 layer->drawable_content_rect(); |
| 164 | 164 |
| 165 if (!layer->render_target()->render_surface()->clip_rect().IsEmpty()) { | 165 if (!layer->render_target()->render_surface()->clip_rect().IsEmpty()) { |
| 166 // In this case the target surface does clip layers that contribute to | 166 // The |layer| L has a target T which owns a surface Ts. The surface Ts |
| 167 // it. So, we have to convert the current surface's clip rect from its | 167 // has a target TsT. |
| 168 // ancestor surface space to the current (descendant) surface | 168 // |
| 169 // space. This conversion is done outside this function so that it can | 169 // In this case the target surface Ts does clip the layer L that contributes |
| 170 // be cached instead of computing it redundantly for every layer. | 170 // to it. So, we have to convert the clip rect of Ts from the target space |
| 171 // of Ts (that is the space of TsT), to the current render target's space |
| 172 // (that is the space of T). This conversion is done outside this function |
| 173 // so that it can be cached instead of computing it redundantly for every |
| 174 // layer. |
| 171 visible_rect_in_target_surface_space.Intersect( | 175 visible_rect_in_target_surface_space.Intersect( |
| 172 ancestor_clip_rect_in_descendant_surface_space); | 176 clip_rect_of_target_surface_in_target_space); |
| 173 } | 177 } |
| 174 | 178 |
| 175 if (visible_rect_in_target_surface_space.IsEmpty()) | 179 if (visible_rect_in_target_surface_space.IsEmpty()) |
| 176 return gfx::Rect(); | 180 return gfx::Rect(); |
| 177 | 181 |
| 178 return CalculateVisibleRectWithCachedLayerRect( | 182 return CalculateVisibleRectWithCachedLayerRect( |
| 179 visible_rect_in_target_surface_space, | 183 visible_rect_in_target_surface_space, |
| 180 gfx::Rect(layer->content_bounds()), | 184 gfx::Rect(layer->content_bounds()), |
| 181 layer_rect_in_target_space, | 185 layer_rect_in_target_space, |
| 182 layer->draw_transform()); | 186 layer->draw_transform()); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 // the necessary transformations, clip rects, render surfaces, etc. | 859 // the necessary transformations, clip rects, render surfaces, etc. |
| 856 template <typename LayerType, | 860 template <typename LayerType, |
| 857 typename LayerListType, | 861 typename LayerListType, |
| 858 typename RenderSurfaceType> | 862 typename RenderSurfaceType> |
| 859 static void CalculateDrawPropertiesInternal( | 863 static void CalculateDrawPropertiesInternal( |
| 860 LayerType* layer, | 864 LayerType* layer, |
| 861 const gfx::Transform& parent_matrix, | 865 const gfx::Transform& parent_matrix, |
| 862 const gfx::Transform& full_hierarchy_matrix, | 866 const gfx::Transform& full_hierarchy_matrix, |
| 863 const gfx::Transform& current_scroll_compensation_matrix, | 867 const gfx::Transform& current_scroll_compensation_matrix, |
| 864 LayerType* current_fixed_container, | 868 LayerType* current_fixed_container, |
| 865 gfx::Rect clip_rect_from_ancestor, | 869 gfx::Rect clip_rect_from_ancestor_in_ancestor_target_space, |
| 866 gfx::Rect clip_rect_from_ancestor_in_descendant_space, | 870 gfx::Rect clip_rect_of_target_surface_from_ancestor_in_target_space, |
| 867 bool ancestor_clips_subtree, | 871 bool ancestor_clips_subtree, |
| 868 RenderSurfaceType* nearest_ancestor_that_moves_pixels, | 872 RenderSurfaceType* nearest_ancestor_that_moves_pixels, |
| 869 LayerListType* render_surface_layer_list, | 873 LayerListType* render_surface_layer_list, |
| 870 LayerListType* layer_list, | 874 LayerListType* layer_list, |
| 871 LayerSorter* layer_sorter, | 875 LayerSorter* layer_sorter, |
| 872 int max_texture_size, | 876 int max_texture_size, |
| 873 float device_scale_factor, | 877 float device_scale_factor, |
| 874 float page_scale_factor, | 878 float page_scale_factor, |
| 875 LayerType* page_scale_application_layer, | 879 LayerType* page_scale_application_layer, |
| 876 bool in_subtree_of_page_scale_application_layer, | 880 bool in_subtree_of_page_scale_application_layer, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_visible)) | 1024 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_visible)) |
| 1021 return; | 1025 return; |
| 1022 | 1026 |
| 1023 // As this function proceeds, these are the properties for the current | 1027 // As this function proceeds, these are the properties for the current |
| 1024 // layer that actually get computed. To avoid unnecessary copies | 1028 // layer that actually get computed. To avoid unnecessary copies |
| 1025 // (particularly for matrices), we do computations directly on these values | 1029 // (particularly for matrices), we do computations directly on these values |
| 1026 // when possible. | 1030 // when possible. |
| 1027 DrawProperties<LayerType, RenderSurfaceType>& layer_draw_properties = | 1031 DrawProperties<LayerType, RenderSurfaceType>& layer_draw_properties = |
| 1028 layer->draw_properties(); | 1032 layer->draw_properties(); |
| 1029 | 1033 |
| 1030 gfx::Rect clip_rect_for_subtree; | 1034 gfx::Rect clip_rect_in_target_space; |
| 1031 bool subtree_should_be_clipped = false; | 1035 bool layer_or_ancestor_clips_descendants = false; |
| 1032 | 1036 |
| 1033 // This value is cached on the stack so that we don't have to inverse-project | 1037 // This value is cached on the stack so that we don't have to inverse-project |
| 1034 // the surface's clip rect redundantly for every layer. This value is the | 1038 // the surface's clip rect redundantly for every layer. This value is the |
| 1035 // same as the surface's clip rect, except that instead of being described | 1039 // same as the target surface's clip rect, except that instead of being |
| 1036 // in the target surface space (i.e. the ancestor surface space), it is | 1040 // described in the target surface's target's space, it is described in the |
| 1037 // described in the current surface space. | 1041 // current render target's space. |
| 1038 gfx::Rect clip_rect_for_subtree_in_descendant_space; | 1042 gfx::Rect clip_rect_of_target_surface_in_target_space; |
| 1039 | 1043 |
| 1040 float accumulated_draw_opacity = layer->opacity(); | 1044 float accumulated_draw_opacity = layer->opacity(); |
| 1041 bool animating_opacity_to_target = layer->OpacityIsAnimating(); | 1045 bool animating_opacity_to_target = layer->OpacityIsAnimating(); |
| 1042 bool animating_opacity_to_screen = animating_opacity_to_target; | 1046 bool animating_opacity_to_screen = animating_opacity_to_target; |
| 1043 if (layer->parent()) { | 1047 if (layer->parent()) { |
| 1044 accumulated_draw_opacity *= layer->parent()->draw_opacity(); | 1048 accumulated_draw_opacity *= layer->parent()->draw_opacity(); |
| 1045 animating_opacity_to_target |= layer->parent()->draw_opacity_is_animating(); | 1049 animating_opacity_to_target |= layer->parent()->draw_opacity_is_animating(); |
| 1046 animating_opacity_to_screen |= | 1050 animating_opacity_to_screen |= |
| 1047 layer->parent()->screen_space_opacity_is_animating(); | 1051 layer->parent()->screen_space_opacity_is_animating(); |
| 1048 } | 1052 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 | 1232 |
| 1229 // Update the aggregate hierarchy matrix to include the transform of the | 1233 // Update the aggregate hierarchy matrix to include the transform of the |
| 1230 // newly created RenderSurfaceImpl. | 1234 // newly created RenderSurfaceImpl. |
| 1231 next_hierarchy_matrix.PreconcatTransform(render_surface->draw_transform()); | 1235 next_hierarchy_matrix.PreconcatTransform(render_surface->draw_transform()); |
| 1232 | 1236 |
| 1233 // The new render_surface here will correctly clip the entire subtree. So, | 1237 // The new render_surface here will correctly clip the entire subtree. So, |
| 1234 // we do not need to continue propagating the clipping state further down | 1238 // we do not need to continue propagating the clipping state further down |
| 1235 // the tree. This way, we can avoid transforming clip rects from ancestor | 1239 // the tree. This way, we can avoid transforming clip rects from ancestor |
| 1236 // target surface space to current target surface space that could cause | 1240 // target surface space to current target surface space that could cause |
| 1237 // more w < 0 headaches. | 1241 // more w < 0 headaches. |
| 1238 subtree_should_be_clipped = false; | 1242 layer_or_ancestor_clips_descendants = false; |
| 1239 | 1243 |
| 1240 if (layer->mask_layer()) { | 1244 if (layer->mask_layer()) { |
| 1241 DrawProperties<LayerType, RenderSurfaceType>& mask_layer_draw_properties = | 1245 DrawProperties<LayerType, RenderSurfaceType>& mask_layer_draw_properties = |
| 1242 layer->mask_layer()->draw_properties(); | 1246 layer->mask_layer()->draw_properties(); |
| 1243 mask_layer_draw_properties.render_target = layer; | 1247 mask_layer_draw_properties.render_target = layer; |
| 1244 mask_layer_draw_properties.visible_content_rect = | 1248 mask_layer_draw_properties.visible_content_rect = |
| 1245 gfx::Rect(layer->content_bounds()); | 1249 gfx::Rect(layer->content_bounds()); |
| 1246 } | 1250 } |
| 1247 | 1251 |
| 1248 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { | 1252 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { |
| 1249 DrawProperties<LayerType, RenderSurfaceType>& | 1253 DrawProperties<LayerType, RenderSurfaceType>& |
| 1250 replica_mask_draw_properties = | 1254 replica_mask_draw_properties = |
| 1251 layer->replica_layer()->mask_layer()->draw_properties(); | 1255 layer->replica_layer()->mask_layer()->draw_properties(); |
| 1252 replica_mask_draw_properties.render_target = layer; | 1256 replica_mask_draw_properties.render_target = layer; |
| 1253 replica_mask_draw_properties.visible_content_rect = | 1257 replica_mask_draw_properties.visible_content_rect = |
| 1254 gfx::Rect(layer->content_bounds()); | 1258 gfx::Rect(layer->content_bounds()); |
| 1255 } | 1259 } |
| 1256 | 1260 |
| 1257 // TODO(senorblanco): make this smarter for the SkImageFilter case (check | 1261 // TODO(senorblanco): make this smarter for the SkImageFilter case (check |
| 1258 // for pixel-moving filters) | 1262 // for pixel-moving filters) |
| 1259 if (layer->filters().HasFilterThatMovesPixels() || layer->filter()) | 1263 if (layer->filters().HasFilterThatMovesPixels() || layer->filter()) |
| 1260 nearest_ancestor_that_moves_pixels = render_surface; | 1264 nearest_ancestor_that_moves_pixels = render_surface; |
| 1261 | 1265 |
| 1262 // The render surface clip rect is expressed in the space where this surface | 1266 // The render surface clip rect is expressed in the space where this surface |
| 1263 // draws, i.e. the same space as clip_rect_from_ancestor. | 1267 // draws, i.e. the same space as |
| 1268 // clip_rect_from_ancestor_in_ancestor_target_space. |
| 1264 render_surface->SetIsClipped(ancestor_clips_subtree); | 1269 render_surface->SetIsClipped(ancestor_clips_subtree); |
| 1265 if (ancestor_clips_subtree) { | 1270 if (ancestor_clips_subtree) { |
| 1266 render_surface->SetClipRect(clip_rect_from_ancestor); | 1271 render_surface->SetClipRect( |
| 1272 clip_rect_from_ancestor_in_ancestor_target_space); |
| 1267 | 1273 |
| 1268 gfx::Transform inverse_surface_draw_transform( | 1274 gfx::Transform inverse_surface_draw_transform( |
| 1269 gfx::Transform::kSkipInitialization); | 1275 gfx::Transform::kSkipInitialization); |
| 1270 if (!render_surface->draw_transform().GetInverse( | 1276 if (!render_surface->draw_transform().GetInverse( |
| 1271 &inverse_surface_draw_transform)) { | 1277 &inverse_surface_draw_transform)) { |
| 1272 // TODO(shawnsingh): Either we need to handle uninvertible transforms | 1278 // TODO(shawnsingh): Either we need to handle uninvertible transforms |
| 1273 // here, or DCHECK that the transform is invertible. | 1279 // here, or DCHECK that the transform is invertible. |
| 1274 } | 1280 } |
| 1275 clip_rect_for_subtree_in_descendant_space = | 1281 clip_rect_of_target_surface_in_target_space = |
| 1276 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 1282 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 1277 inverse_surface_draw_transform, render_surface->clip_rect())); | 1283 inverse_surface_draw_transform, render_surface->clip_rect())); |
| 1278 } else { | 1284 } else { |
| 1279 render_surface->SetClipRect(gfx::Rect()); | 1285 render_surface->SetClipRect(gfx::Rect()); |
| 1280 clip_rect_for_subtree_in_descendant_space = | 1286 clip_rect_of_target_surface_in_target_space = |
| 1281 clip_rect_from_ancestor_in_descendant_space; | 1287 clip_rect_of_target_surface_from_ancestor_in_target_space; |
| 1282 } | 1288 } |
| 1283 | 1289 |
| 1284 render_surface->SetNearestAncestorThatMovesPixels( | 1290 render_surface->SetNearestAncestorThatMovesPixels( |
| 1285 nearest_ancestor_that_moves_pixels); | 1291 nearest_ancestor_that_moves_pixels); |
| 1286 | 1292 |
| 1287 // If the new render surface is drawn translucent or with a non-integral | 1293 // If the new render surface is drawn translucent or with a non-integral |
| 1288 // translation then the subtree that gets drawn on this render surface | 1294 // translation then the subtree that gets drawn on this render surface |
| 1289 // cannot use LCD text. | 1295 // cannot use LCD text. |
| 1290 subtree_can_use_lcd_text = layer_can_use_lcd_text; | 1296 subtree_can_use_lcd_text = layer_can_use_lcd_text; |
| 1291 | 1297 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1302 layer_draw_properties.opacity = accumulated_draw_opacity; | 1308 layer_draw_properties.opacity = accumulated_draw_opacity; |
| 1303 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; | 1309 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; |
| 1304 layer_draw_properties.screen_space_opacity_is_animating = | 1310 layer_draw_properties.screen_space_opacity_is_animating = |
| 1305 animating_opacity_to_screen; | 1311 animating_opacity_to_screen; |
| 1306 sublayer_matrix = combined_transform; | 1312 sublayer_matrix = combined_transform; |
| 1307 | 1313 |
| 1308 layer->ClearRenderSurface(); | 1314 layer->ClearRenderSurface(); |
| 1309 | 1315 |
| 1310 // Layers without render_surfaces directly inherit the ancestor's clip | 1316 // Layers without render_surfaces directly inherit the ancestor's clip |
| 1311 // status. | 1317 // status. |
| 1312 subtree_should_be_clipped = ancestor_clips_subtree; | 1318 layer_or_ancestor_clips_descendants = ancestor_clips_subtree; |
| 1313 if (ancestor_clips_subtree) | 1319 if (ancestor_clips_subtree) { |
| 1314 clip_rect_for_subtree = clip_rect_from_ancestor; | 1320 clip_rect_in_target_space = |
| 1321 clip_rect_from_ancestor_in_ancestor_target_space; |
| 1322 } |
| 1315 | 1323 |
| 1316 // The surface's cached clip rect value propagates regardless of what | 1324 // The surface's cached clip rect value propagates regardless of what |
| 1317 // clipping goes on between layers here. | 1325 // clipping goes on between layers here. |
| 1318 clip_rect_for_subtree_in_descendant_space = | 1326 clip_rect_of_target_surface_in_target_space = |
| 1319 clip_rect_from_ancestor_in_descendant_space; | 1327 clip_rect_of_target_surface_from_ancestor_in_target_space; |
| 1320 | 1328 |
| 1321 // Layers that are not their own render_target will render into the target | 1329 // Layers that are not their own render_target will render into the target |
| 1322 // of their nearest ancestor. | 1330 // of their nearest ancestor. |
| 1323 layer_draw_properties.render_target = layer->parent()->render_target(); | 1331 layer_draw_properties.render_target = layer->parent()->render_target(); |
| 1324 } | 1332 } |
| 1325 | 1333 |
| 1326 // Mark whether a layer could be drawn directly to the back buffer, for | 1334 // Mark whether a layer could be drawn directly to the back buffer, for |
| 1327 // example when it could use LCD text even though it's in a non-contents | 1335 // example when it could use LCD text even though it's in a non-contents |
| 1328 // opaque layer. This means that it can't be drawn to an intermediate | 1336 // opaque layer. This means that it can't be drawn to an intermediate |
| 1329 // render target and also that no blending is applied to the layer as a whole | 1337 // render target and also that no blending is applied to the layer as a whole |
| 1330 // (meaning that its contents don't have to be pre-composited into a bitmap or | 1338 // (meaning that its contents don't have to be pre-composited into a bitmap or |
| 1331 // a render target). | 1339 // a render target). |
| 1332 // | 1340 // |
| 1333 // Ignoring animations is an optimization, | 1341 // Ignoring animations is an optimization, |
| 1334 // as it means that we're going to need some retained resources for this | 1342 // as it means that we're going to need some retained resources for this |
| 1335 // layer in the near future even if its opacity is 1 now. | 1343 // layer in the near future even if its opacity is 1 now. |
| 1336 layer_draw_properties.can_draw_directly_to_backbuffer = | 1344 layer_draw_properties.can_draw_directly_to_backbuffer = |
| 1337 IsRootLayer(layer_draw_properties.render_target) && | 1345 IsRootLayer(layer_draw_properties.render_target) && |
| 1338 layer->draw_properties().opacity == 1.f && | 1346 layer->draw_properties().opacity == 1.f && |
| 1339 !animating_opacity_to_screen; | 1347 !animating_opacity_to_screen; |
| 1340 | 1348 |
| 1341 if (adjust_text_aa) | 1349 if (adjust_text_aa) |
| 1342 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; | 1350 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; |
| 1343 | 1351 |
| 1344 gfx::Rect rect_in_target_space = ToEnclosingRect( | 1352 gfx::Rect rect_in_target_space = ToEnclosingRect( |
| 1345 MathUtil::MapClippedRect(layer->draw_transform(), content_rect)); | 1353 MathUtil::MapClippedRect(layer->draw_transform(), content_rect)); |
| 1346 | 1354 |
| 1347 if (LayerClipsSubtree(layer)) { | 1355 if (LayerClipsSubtree(layer)) { |
| 1348 subtree_should_be_clipped = true; | 1356 layer_or_ancestor_clips_descendants = true; |
| 1349 if (ancestor_clips_subtree && !layer->render_surface()) { | 1357 if (ancestor_clips_subtree && !layer->render_surface()) { |
| 1350 clip_rect_for_subtree = clip_rect_from_ancestor; | 1358 // A layer without render surface shares the same target as its ancestor. |
| 1351 clip_rect_for_subtree.Intersect(rect_in_target_space); | 1359 clip_rect_in_target_space = |
| 1360 clip_rect_from_ancestor_in_ancestor_target_space; |
| 1361 clip_rect_in_target_space.Intersect(rect_in_target_space); |
| 1352 } else { | 1362 } else { |
| 1353 clip_rect_for_subtree = rect_in_target_space; | 1363 clip_rect_in_target_space = rect_in_target_space; |
| 1354 } | 1364 } |
| 1355 } | 1365 } |
| 1356 | 1366 |
| 1357 if (layer == page_scale_application_layer) { | 1367 if (layer == page_scale_application_layer) { |
| 1358 sublayer_matrix.Scale(page_scale_factor, page_scale_factor); | 1368 sublayer_matrix.Scale(page_scale_factor, page_scale_factor); |
| 1359 in_subtree_of_page_scale_application_layer = true; | 1369 in_subtree_of_page_scale_application_layer = true; |
| 1360 } | 1370 } |
| 1361 | 1371 |
| 1362 // Flatten to 2D if the layer doesn't preserve 3D. | 1372 // Flatten to 2D if the layer doesn't preserve 3D. |
| 1363 if (!layer->preserves_3d()) | 1373 if (!layer->preserves_3d()) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 gfx::Rect drawable_content_rect_of_child_subtree; | 1409 gfx::Rect drawable_content_rect_of_child_subtree; |
| 1400 gfx::Transform identity_matrix; | 1410 gfx::Transform identity_matrix; |
| 1401 CalculateDrawPropertiesInternal<LayerType, | 1411 CalculateDrawPropertiesInternal<LayerType, |
| 1402 LayerListType, | 1412 LayerListType, |
| 1403 RenderSurfaceType>( | 1413 RenderSurfaceType>( |
| 1404 child, | 1414 child, |
| 1405 sublayer_matrix, | 1415 sublayer_matrix, |
| 1406 next_hierarchy_matrix, | 1416 next_hierarchy_matrix, |
| 1407 next_scroll_compensation_matrix, | 1417 next_scroll_compensation_matrix, |
| 1408 next_fixed_container, | 1418 next_fixed_container, |
| 1409 clip_rect_for_subtree, | 1419 clip_rect_in_target_space, |
| 1410 clip_rect_for_subtree_in_descendant_space, | 1420 clip_rect_of_target_surface_in_target_space, |
| 1411 subtree_should_be_clipped, | 1421 layer_or_ancestor_clips_descendants, |
| 1412 nearest_ancestor_that_moves_pixels, | 1422 nearest_ancestor_that_moves_pixels, |
| 1413 render_surface_layer_list, | 1423 render_surface_layer_list, |
| 1414 &descendants, | 1424 &descendants, |
| 1415 layer_sorter, | 1425 layer_sorter, |
| 1416 max_texture_size, | 1426 max_texture_size, |
| 1417 device_scale_factor, | 1427 device_scale_factor, |
| 1418 page_scale_factor, | 1428 page_scale_factor, |
| 1419 page_scale_application_layer, | 1429 page_scale_application_layer, |
| 1420 in_subtree_of_page_scale_application_layer, | 1430 in_subtree_of_page_scale_application_layer, |
| 1421 subtree_can_use_lcd_text, | 1431 subtree_can_use_lcd_text, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1435 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); | 1445 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); |
| 1436 return; | 1446 return; |
| 1437 } | 1447 } |
| 1438 | 1448 |
| 1439 // Compute the total drawable_content_rect for this subtree (the rect is in | 1449 // Compute the total drawable_content_rect for this subtree (the rect is in |
| 1440 // target surface space). | 1450 // target surface space). |
| 1441 gfx::Rect local_drawable_content_rect_of_subtree = | 1451 gfx::Rect local_drawable_content_rect_of_subtree = |
| 1442 accumulated_drawable_content_rect_of_children; | 1452 accumulated_drawable_content_rect_of_children; |
| 1443 if (layer->DrawsContent()) | 1453 if (layer->DrawsContent()) |
| 1444 local_drawable_content_rect_of_subtree.Union(rect_in_target_space); | 1454 local_drawable_content_rect_of_subtree.Union(rect_in_target_space); |
| 1445 if (subtree_should_be_clipped) | 1455 if (layer_or_ancestor_clips_descendants) |
| 1446 local_drawable_content_rect_of_subtree.Intersect(clip_rect_for_subtree); | 1456 local_drawable_content_rect_of_subtree.Intersect(clip_rect_in_target_space); |
| 1447 | 1457 |
| 1448 // Compute the layer's drawable content rect (the rect is in target surface | 1458 // Compute the layer's drawable content rect (the rect is in target surface |
| 1449 // space). | 1459 // space). |
| 1450 layer_draw_properties.drawable_content_rect = rect_in_target_space; | 1460 layer_draw_properties.drawable_content_rect = rect_in_target_space; |
| 1451 if (subtree_should_be_clipped) { | 1461 if (layer_or_ancestor_clips_descendants) { |
| 1452 layer_draw_properties.drawable_content_rect. | 1462 layer_draw_properties.drawable_content_rect. |
| 1453 Intersect(clip_rect_for_subtree); | 1463 Intersect(clip_rect_in_target_space); |
| 1454 } | 1464 } |
| 1455 | 1465 |
| 1456 // Tell the layer the rect that is clipped by. In theory we could use a | 1466 // Tell the layer the rect that is clipped by. In theory we could use a |
| 1457 // tighter clip rect here (drawable_content_rect), but that actually does not | 1467 // tighter clip rect here (drawable_content_rect), but that actually does not |
| 1458 // reduce how much would be drawn, and instead it would create unnecessary | 1468 // reduce how much would be drawn, and instead it would create unnecessary |
| 1459 // changes to scissor state affecting GPU performance. | 1469 // changes to scissor state affecting GPU performance. |
| 1460 layer_draw_properties.is_clipped = subtree_should_be_clipped; | 1470 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; |
| 1461 if (subtree_should_be_clipped) { | 1471 if (layer_or_ancestor_clips_descendants) { |
| 1462 layer_draw_properties.clip_rect = clip_rect_for_subtree; | 1472 layer_draw_properties.clip_rect = clip_rect_in_target_space; |
| 1463 } else { | 1473 } else { |
| 1464 // Initialize the clip rect to a safe value that will not clip the | 1474 // Initialize the clip rect to a safe value that will not clip the |
| 1465 // layer, just in case clipping is still accidentally used. | 1475 // layer, just in case clipping is still accidentally used. |
| 1466 layer_draw_properties.clip_rect = rect_in_target_space; | 1476 layer_draw_properties.clip_rect = rect_in_target_space; |
| 1467 } | 1477 } |
| 1468 | 1478 |
| 1469 // Compute the layer's visible content rect (the rect is in content space) | 1479 // Compute the layer's visible content rect (the rect is in content space). |
| 1470 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( | 1480 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( |
| 1471 layer, clip_rect_for_subtree_in_descendant_space, rect_in_target_space); | 1481 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); |
| 1472 | 1482 |
| 1473 // Compute the remaining properties for the render surface, if the layer has | 1483 // Compute the remaining properties for the render surface, if the layer has |
| 1474 // one. | 1484 // one. |
| 1475 if (IsRootLayer(layer)) { | 1485 if (IsRootLayer(layer)) { |
| 1476 // The root layer's surface's content_rect is always the entire viewport. | 1486 // The root layer's surface's content_rect is always the entire viewport. |
| 1477 DCHECK(layer->render_surface()); | 1487 DCHECK(layer->render_surface()); |
| 1478 layer->render_surface()->SetContentRect(clip_rect_from_ancestor); | 1488 layer->render_surface()->SetContentRect( |
| 1489 clip_rect_from_ancestor_in_ancestor_target_space); |
| 1479 } else if (layer->render_surface() && !IsRootLayer(layer)) { | 1490 } else if (layer->render_surface() && !IsRootLayer(layer)) { |
| 1480 RenderSurfaceType* render_surface = layer->render_surface(); | 1491 RenderSurfaceType* render_surface = layer->render_surface(); |
| 1481 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; | 1492 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; |
| 1482 | 1493 |
| 1483 // Don't clip if the layer is reflected as the reflection shouldn't be | 1494 // Don't clip if the layer is reflected as the reflection shouldn't be |
| 1484 // clipped. If the layer is animating, then the surface's transform to | 1495 // clipped. If the layer is animating, then the surface's transform to |
| 1485 // its target is not known on the main thread, and we should not use it | 1496 // its target is not known on the main thread, and we should not use it |
| 1486 // to clip. | 1497 // to clip. |
| 1487 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { | 1498 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { |
| 1488 // Note, it is correct to use ancestor_clips_subtree here, because we are | 1499 // Note, it is correct to use ancestor_clips_subtree here, because we are |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1597 bool can_adjust_raster_scales, | 1608 bool can_adjust_raster_scales, |
| 1598 RenderSurfaceLayerList* render_surface_layer_list) { | 1609 RenderSurfaceLayerList* render_surface_layer_list) { |
| 1599 gfx::Rect total_drawable_content_rect; | 1610 gfx::Rect total_drawable_content_rect; |
| 1600 gfx::Transform identity_matrix; | 1611 gfx::Transform identity_matrix; |
| 1601 gfx::Transform scaled_device_transform = device_transform; | 1612 gfx::Transform scaled_device_transform = device_transform; |
| 1602 scaled_device_transform.Scale(device_scale_factor, device_scale_factor); | 1613 scaled_device_transform.Scale(device_scale_factor, device_scale_factor); |
| 1603 RenderSurfaceLayerList dummy_layer_list; | 1614 RenderSurfaceLayerList dummy_layer_list; |
| 1604 | 1615 |
| 1605 // The root layer's render_surface should receive the device viewport as the | 1616 // The root layer's render_surface should receive the device viewport as the |
| 1606 // initial clip rect. | 1617 // initial clip rect. |
| 1607 bool subtree_should_be_clipped = true; | 1618 bool layer_or_ancestor_clips_descendants = true; |
| 1608 gfx::Rect device_viewport_rect(device_viewport_size); | 1619 gfx::Rect device_viewport_rect(device_viewport_size); |
| 1609 bool in_subtree_of_page_scale_application_layer = false; | 1620 bool in_subtree_of_page_scale_application_layer = false; |
| 1610 bool subtree_is_visible = true; | 1621 bool subtree_is_visible = true; |
| 1611 | 1622 |
| 1612 // This function should have received a root layer. | 1623 // This function should have received a root layer. |
| 1613 DCHECK(IsRootLayer(root_layer)); | 1624 DCHECK(IsRootLayer(root_layer)); |
| 1614 | 1625 |
| 1615 PreCalculateMetaInformationRecursiveData recursive_data; | 1626 PreCalculateMetaInformationRecursiveData recursive_data; |
| 1616 PreCalculateMetaInformation(root_layer, &recursive_data); | 1627 PreCalculateMetaInformation(root_layer, &recursive_data); |
| 1617 | 1628 |
| 1618 CalculateDrawPropertiesInternal<Layer, RenderSurfaceLayerList, RenderSurface>( | 1629 CalculateDrawPropertiesInternal<Layer, RenderSurfaceLayerList, RenderSurface>( |
| 1619 root_layer, | 1630 root_layer, |
| 1620 scaled_device_transform, | 1631 scaled_device_transform, |
| 1621 identity_matrix, | 1632 identity_matrix, |
| 1622 identity_matrix, | 1633 identity_matrix, |
| 1623 root_layer, | 1634 root_layer, |
| 1624 device_viewport_rect, | 1635 device_viewport_rect, |
| 1625 device_viewport_rect, | 1636 device_viewport_rect, |
| 1626 subtree_should_be_clipped, | 1637 layer_or_ancestor_clips_descendants, |
| 1627 NULL, | 1638 NULL, |
| 1628 render_surface_layer_list, | 1639 render_surface_layer_list, |
| 1629 &dummy_layer_list, | 1640 &dummy_layer_list, |
| 1630 NULL, | 1641 NULL, |
| 1631 max_texture_size, | 1642 max_texture_size, |
| 1632 device_scale_factor, | 1643 device_scale_factor, |
| 1633 page_scale_factor, | 1644 page_scale_factor, |
| 1634 page_scale_application_layer, | 1645 page_scale_application_layer, |
| 1635 in_subtree_of_page_scale_application_layer, | 1646 in_subtree_of_page_scale_application_layer, |
| 1636 can_use_lcd_text, | 1647 can_use_lcd_text, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1658 LayerImplList* render_surface_layer_list) { | 1669 LayerImplList* render_surface_layer_list) { |
| 1659 gfx::Rect total_drawable_content_rect; | 1670 gfx::Rect total_drawable_content_rect; |
| 1660 gfx::Transform identity_matrix; | 1671 gfx::Transform identity_matrix; |
| 1661 gfx::Transform scaled_device_transform = device_transform; | 1672 gfx::Transform scaled_device_transform = device_transform; |
| 1662 scaled_device_transform.Scale(device_scale_factor, device_scale_factor); | 1673 scaled_device_transform.Scale(device_scale_factor, device_scale_factor); |
| 1663 LayerImplList dummy_layer_list; | 1674 LayerImplList dummy_layer_list; |
| 1664 LayerSorter layer_sorter; | 1675 LayerSorter layer_sorter; |
| 1665 | 1676 |
| 1666 // The root layer's render_surface should receive the device viewport as the | 1677 // The root layer's render_surface should receive the device viewport as the |
| 1667 // initial clip rect. | 1678 // initial clip rect. |
| 1668 bool subtree_should_be_clipped = true; | 1679 bool layer_or_ancestor_clips_descendants = true; |
| 1669 gfx::Rect device_viewport_rect(device_viewport_size); | 1680 gfx::Rect device_viewport_rect(device_viewport_size); |
| 1670 bool in_subtree_of_page_scale_application_layer = false; | 1681 bool in_subtree_of_page_scale_application_layer = false; |
| 1671 bool subtree_is_visible = true; | 1682 bool subtree_is_visible = true; |
| 1672 | 1683 |
| 1673 // This function should have received a root layer. | 1684 // This function should have received a root layer. |
| 1674 DCHECK(IsRootLayer(root_layer)); | 1685 DCHECK(IsRootLayer(root_layer)); |
| 1675 | 1686 |
| 1676 PreCalculateMetaInformationRecursiveData recursive_data; | 1687 PreCalculateMetaInformationRecursiveData recursive_data; |
| 1677 PreCalculateMetaInformation(root_layer, &recursive_data); | 1688 PreCalculateMetaInformation(root_layer, &recursive_data); |
| 1678 | 1689 |
| 1679 CalculateDrawPropertiesInternal<LayerImpl, | 1690 CalculateDrawPropertiesInternal<LayerImpl, |
| 1680 LayerImplList, | 1691 LayerImplList, |
| 1681 RenderSurfaceImpl>( | 1692 RenderSurfaceImpl>( |
| 1682 root_layer, | 1693 root_layer, |
| 1683 scaled_device_transform, | 1694 scaled_device_transform, |
| 1684 identity_matrix, | 1695 identity_matrix, |
| 1685 identity_matrix, | 1696 identity_matrix, |
| 1686 root_layer, | 1697 root_layer, |
| 1687 device_viewport_rect, | 1698 device_viewport_rect, |
| 1688 device_viewport_rect, | 1699 device_viewport_rect, |
| 1689 subtree_should_be_clipped, | 1700 layer_or_ancestor_clips_descendants, |
| 1690 NULL, | 1701 NULL, |
| 1691 render_surface_layer_list, | 1702 render_surface_layer_list, |
| 1692 &dummy_layer_list, | 1703 &dummy_layer_list, |
| 1693 &layer_sorter, | 1704 &layer_sorter, |
| 1694 max_texture_size, | 1705 max_texture_size, |
| 1695 device_scale_factor, | 1706 device_scale_factor, |
| 1696 page_scale_factor, | 1707 page_scale_factor, |
| 1697 page_scale_application_layer, | 1708 page_scale_application_layer, |
| 1698 in_subtree_of_page_scale_application_layer, | 1709 in_subtree_of_page_scale_application_layer, |
| 1699 can_use_lcd_text, | 1710 can_use_lcd_text, |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 // At this point, we think the point does hit the touch event handler region | 1904 // At this point, we think the point does hit the touch event handler region |
| 1894 // on the layer, but we need to walk up the parents to ensure that the layer | 1905 // on the layer, but we need to walk up the parents to ensure that the layer |
| 1895 // was not clipped in such a way that the hit point actually should not hit | 1906 // was not clipped in such a way that the hit point actually should not hit |
| 1896 // the layer. | 1907 // the layer. |
| 1897 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 1908 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
| 1898 return false; | 1909 return false; |
| 1899 | 1910 |
| 1900 return true; | 1911 return true; |
| 1901 } | 1912 } |
| 1902 } // namespace cc | 1913 } // namespace cc |
| OLD | NEW |