| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 284 |
| 285 static void ComputeInitialRenderSurfaceLayerList( | 285 static void ComputeInitialRenderSurfaceLayerList( |
| 286 LayerTreeImpl* layer_tree_impl, | 286 LayerTreeImpl* layer_tree_impl, |
| 287 PropertyTrees* property_trees, | 287 PropertyTrees* property_trees, |
| 288 LayerImplList* render_surface_layer_list, | 288 LayerImplList* render_surface_layer_list, |
| 289 bool can_render_to_separate_surface) { | 289 bool can_render_to_separate_surface) { |
| 290 // Add all non-skipped surfaces to the initial render surface layer list. Add | 290 // Add all non-skipped surfaces to the initial render surface layer list. Add |
| 291 // all non-skipped layers to the layer list of their target surface, and | 291 // all non-skipped layers to the layer list of their target surface, and |
| 292 // add their content rect to their target surface's accumulated content rect. | 292 // add their content rect to their target surface's accumulated content rect. |
| 293 for (LayerImpl* layer : *layer_tree_impl) { | 293 for (LayerImpl* layer : *layer_tree_impl) { |
| 294 if (layer->render_surface()) { | 294 RenderSurfaceImpl* render_surface = layer->render_surface(); |
| 295 layer->ClearRenderSurfaceLayerList(); | 295 if (render_surface) { |
| 296 ClearMaskLayersAreDrawnRenderSurfaceLayerListMembers( | 296 render_surface->ClearLayerLists(); |
| 297 layer->render_surface()); | 297 ClearMaskLayersAreDrawnRenderSurfaceLayerListMembers(render_surface); |
| 298 } | 298 } |
| 299 layer->set_is_drawn_render_surface_layer_list_member(false); | 299 layer->set_is_drawn_render_surface_layer_list_member(false); |
| 300 | 300 |
| 301 bool is_root = layer_tree_impl->IsRootLayer(layer); | 301 bool is_root = layer_tree_impl->IsRootLayer(layer); |
| 302 bool skip_layer = !is_root && draw_property_utils::LayerShouldBeSkipped( | 302 bool skip_layer = !is_root && draw_property_utils::LayerShouldBeSkipped( |
| 303 layer, property_trees->transform_tree, | 303 layer, property_trees->transform_tree, |
| 304 property_trees->effect_tree); | 304 property_trees->effect_tree); |
| 305 if (skip_layer) | 305 if (skip_layer) |
| 306 continue; | 306 continue; |
| 307 | 307 |
| 308 bool render_to_separate_surface = | 308 bool render_to_separate_surface = |
| 309 is_root || (can_render_to_separate_surface && layer->render_surface()); | 309 is_root || (can_render_to_separate_surface && render_surface); |
| 310 | 310 |
| 311 if (render_to_separate_surface) { | 311 if (render_to_separate_surface) { |
| 312 DCHECK(layer->render_surface()); | 312 DCHECK(render_surface); |
| 313 DCHECK(layer->render_target() == layer->render_surface()); | 313 DCHECK(layer->render_target() == render_surface); |
| 314 RenderSurfaceImpl* surface = layer->render_surface(); | 314 render_surface->ClearAccumulatedContentRect(); |
| 315 surface->ClearAccumulatedContentRect(); | |
| 316 render_surface_layer_list->push_back(layer); | 315 render_surface_layer_list->push_back(layer); |
| 317 if (is_root) { | 316 if (is_root) { |
| 318 // The root surface does not contribute to any other surface, it has no | 317 // The root surface does not contribute to any other surface, it has no |
| 319 // target. | 318 // target. |
| 320 layer->render_surface()->set_contributes_to_drawn_surface(false); | 319 render_surface->set_contributes_to_drawn_surface(false); |
| 321 } else { | 320 } else { |
| 322 surface->render_target()->layer_list().push_back(layer); | 321 render_surface->render_target()->layer_list().push_back(layer); |
| 323 bool contributes_to_drawn_surface = | 322 bool contributes_to_drawn_surface = |
| 324 property_trees->effect_tree.ContributesToDrawnSurface( | 323 property_trees->effect_tree.ContributesToDrawnSurface( |
| 325 layer->effect_tree_index()); | 324 layer->effect_tree_index()); |
| 326 layer->render_surface()->set_contributes_to_drawn_surface( | 325 render_surface->set_contributes_to_drawn_surface( |
| 327 contributes_to_drawn_surface); | 326 contributes_to_drawn_surface); |
| 328 } | 327 } |
| 329 | 328 |
| 330 draw_property_utils::ComputeSurfaceDrawProperties(property_trees, | 329 draw_property_utils::ComputeSurfaceDrawProperties(property_trees, |
| 331 surface); | 330 render_surface); |
| 332 | 331 |
| 333 // Ignore occlusion from outside the surface when surface contents need to | 332 // Ignore occlusion from outside the surface when surface contents need to |
| 334 // be fully drawn. Layers with copy-request need to be complete. We could | 333 // be fully drawn. Layers with copy-request need to be complete. We could |
| 335 // be smarter about layers with filters that move pixels and exclude | 334 // be smarter about layers with filters that move pixels and exclude |
| 336 // regions where both layers and the filters are occluded, but this seems | 335 // regions where both layers and the filters are occluded, but this seems |
| 337 // like overkill. | 336 // like overkill. |
| 338 // TODO(senorblanco): make this smarter for the SkImageFilter case (check | 337 // TODO(senorblanco): make this smarter for the SkImageFilter case (check |
| 339 // for pixel-moving filters) | 338 // for pixel-moving filters) |
| 340 const FilterOperations& filters = surface->Filters(); | 339 const FilterOperations& filters = render_surface->Filters(); |
| 341 bool is_occlusion_immune = surface->HasCopyRequest() || | 340 bool is_occlusion_immune = render_surface->HasCopyRequest() || |
| 342 filters.HasReferenceFilter() || | 341 filters.HasReferenceFilter() || |
| 343 filters.HasFilterThatMovesPixels(); | 342 filters.HasFilterThatMovesPixels(); |
| 344 if (is_occlusion_immune) { | 343 if (is_occlusion_immune) { |
| 345 surface->SetNearestOcclusionImmuneAncestor(surface); | 344 render_surface->SetNearestOcclusionImmuneAncestor(render_surface); |
| 346 } else if (is_root) { | 345 } else if (is_root) { |
| 347 surface->SetNearestOcclusionImmuneAncestor(nullptr); | 346 render_surface->SetNearestOcclusionImmuneAncestor(nullptr); |
| 348 } else { | 347 } else { |
| 349 surface->SetNearestOcclusionImmuneAncestor( | 348 render_surface->SetNearestOcclusionImmuneAncestor( |
| 350 surface->render_target()->nearest_occlusion_immune_ancestor()); | 349 render_surface->render_target() |
| 350 ->nearest_occlusion_immune_ancestor()); |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 bool layer_is_drawn = | 353 bool layer_is_drawn = |
| 354 property_trees->effect_tree.Node(layer->effect_tree_index())->is_drawn; | 354 property_trees->effect_tree.Node(layer->effect_tree_index())->is_drawn; |
| 355 bool layer_should_be_drawn = draw_property_utils::LayerNeedsUpdate( | 355 bool layer_should_be_drawn = draw_property_utils::LayerNeedsUpdate( |
| 356 layer, layer_is_drawn, property_trees); | 356 layer, layer_is_drawn, property_trees); |
| 357 if (!layer_should_be_drawn) | 357 if (!layer_should_be_drawn) |
| 358 continue; | 358 continue; |
| 359 | 359 |
| 360 layer->set_is_drawn_render_surface_layer_list_member(true); | 360 layer->set_is_drawn_render_surface_layer_list_member(true); |
| 361 layer->render_target()->layer_list().push_back(layer); | 361 layer->render_target()->layer_list().push_back(layer); |
| 362 | 362 |
| 363 // The layer contributes its drawable content rect to its render target. | 363 // The layer contributes its drawable content rect to its render target. |
| 364 layer->render_target()->AccumulateContentRectFromContributingLayer(layer); | 364 layer->render_target()->AccumulateContentRectFromContributingLayer(layer); |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 | 367 |
| 368 static void ComputeSurfaceContentRects(LayerTreeImpl* layer_tree_impl, | 368 static void ComputeSurfaceContentRects(LayerTreeImpl* layer_tree_impl, |
| 369 PropertyTrees* property_trees, | 369 PropertyTrees* property_trees, |
| 370 LayerImplList* render_surface_layer_list, | 370 LayerImplList* render_surface_layer_list, |
| 371 int max_texture_size) { | 371 int max_texture_size) { |
| 372 // Walk the list backwards, accumulating each surface's content rect into its | 372 // Walk the list backwards, accumulating each surface's content rect into its |
| 373 // target's content rect. | 373 // target's content rect. |
| 374 for (LayerImpl* layer : base::Reversed(*render_surface_layer_list)) { | 374 for (LayerImpl* layer : base::Reversed(*render_surface_layer_list)) { |
| 375 RenderSurfaceImpl* render_surface = layer->render_surface(); |
| 375 if (layer_tree_impl->IsRootLayer(layer)) { | 376 if (layer_tree_impl->IsRootLayer(layer)) { |
| 376 // The root layer's surface content rect is always the entire viewport. | 377 // The root layer's surface content rect is always the entire viewport. |
| 377 layer->render_surface()->SetContentRectToViewport(); | 378 render_surface->SetContentRectToViewport(); |
| 378 continue; | 379 continue; |
| 379 } | 380 } |
| 380 RenderSurfaceImpl* surface = layer->render_surface(); | 381 |
| 381 // Now all contributing drawable content rect has been accumulated to this | 382 // Now all contributing drawable content rect has been accumulated to this |
| 382 // render surface, calculate the content rect. | 383 // render surface, calculate the content rect. |
| 383 surface->CalculateContentRectFromAccumulatedContentRect(max_texture_size); | 384 render_surface->CalculateContentRectFromAccumulatedContentRect( |
| 385 max_texture_size); |
| 384 | 386 |
| 385 // Now the render surface's content rect is calculated correctly, it could | 387 // Now the render surface's content rect is calculated correctly, it could |
| 386 // contribute to its render target. | 388 // contribute to its render target. |
| 387 surface->render_target() | 389 render_surface->render_target() |
| 388 ->AccumulateContentRectFromContributingRenderSurface(surface); | 390 ->AccumulateContentRectFromContributingRenderSurface(render_surface); |
| 389 } | 391 } |
| 390 } | 392 } |
| 391 | 393 |
| 392 static void ComputeListOfNonEmptySurfaces(LayerTreeImpl* layer_tree_impl, | 394 static void ComputeListOfNonEmptySurfaces(LayerTreeImpl* layer_tree_impl, |
| 393 PropertyTrees* property_trees, | 395 PropertyTrees* property_trees, |
| 394 LayerImplList* initial_surface_list, | 396 LayerImplList* initial_surface_list, |
| 395 LayerImplList* final_surface_list) { | 397 LayerImplList* final_surface_list) { |
| 396 // Walk the initial surface list forwards. The root surface and each | 398 // Walk the initial surface list forwards. The root surface and each |
| 397 // surface with a non-empty content rect go into the final render surface | 399 // surface with a non-empty content rect go into the final render surface |
| 398 // layer list. Surfaces with empty content rects or whose target isn't in | 400 // layer list. Surfaces with empty content rects or whose target isn't in |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 650 |
| 649 PropertyTrees* GetPropertyTrees(Layer* layer) { | 651 PropertyTrees* GetPropertyTrees(Layer* layer) { |
| 650 return layer->layer_tree_host()->property_trees(); | 652 return layer->layer_tree_host()->property_trees(); |
| 651 } | 653 } |
| 652 | 654 |
| 653 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 655 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
| 654 return layer->layer_tree_impl()->property_trees(); | 656 return layer->layer_tree_impl()->property_trees(); |
| 655 } | 657 } |
| 656 | 658 |
| 657 } // namespace cc | 659 } // namespace cc |
| OLD | NEW |