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