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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1463 data_from_ancestor.in_subtree_of_page_scale_layer; | 1463 data_from_ancestor.in_subtree_of_page_scale_layer; |
| 1464 data_for_children.subtree_can_use_lcd_text = | 1464 data_for_children.subtree_can_use_lcd_text = |
| 1465 data_from_ancestor.subtree_can_use_lcd_text; | 1465 data_from_ancestor.subtree_can_use_lcd_text; |
| 1466 | 1466 |
| 1467 // Layers that are marked as hidden will hide themselves and their subtree. | 1467 // Layers that are marked as hidden will hide themselves and their subtree. |
| 1468 // Exception: Layers with copy requests, whether hidden or not, must be drawn | 1468 // Exception: Layers with copy requests, whether hidden or not, must be drawn |
| 1469 // anyway. In this case, we will inform their subtree they are visible to get | 1469 // anyway. In this case, we will inform their subtree they are visible to get |
| 1470 // the right results. | 1470 // the right results. |
| 1471 const bool layer_is_visible = | 1471 const bool layer_is_visible = |
| 1472 data_from_ancestor.subtree_is_visible_from_ancestor && | 1472 data_from_ancestor.subtree_is_visible_from_ancestor && |
| 1473 !layer->hide_layer_and_subtree(); | 1473 layer->opacity() != 0; |
| 1474 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest(); | 1474 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest(); |
| 1475 | 1475 |
| 1476 // The root layer cannot skip CalcDrawProperties. | 1476 // The root layer cannot skip CalcDrawProperties. |
| 1477 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { | 1477 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { |
| 1478 return; | 1478 return; |
| 1479 } | 1479 } |
| 1480 | 1480 |
| 1481 // We need to circumvent the normal recursive flow of information for clip | 1481 // We need to circumvent the normal recursive flow of information for clip |
| 1482 // children (they don't inherit their direct ancestor's clip information). | 1482 // children (they don't inherit their direct ancestor's clip information). |
| 1483 // This is unfortunate, and would be unnecessary if we were to formally | 1483 // This is unfortunate, and would be unnecessary if we were to formally |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2276 } | 2276 } |
| 2277 } | 2277 } |
| 2278 | 2278 |
| 2279 enum PropertyTreeOption { | 2279 enum PropertyTreeOption { |
| 2280 BUILD_PROPERTY_TREES_IF_NEEDED, | 2280 BUILD_PROPERTY_TREES_IF_NEEDED, |
| 2281 DONT_BUILD_PROPERTY_TREES | 2281 DONT_BUILD_PROPERTY_TREES |
| 2282 }; | 2282 }; |
| 2283 | 2283 |
| 2284 void CalculateRenderTargetInternal(LayerImpl* layer, | 2284 void CalculateRenderTargetInternal(LayerImpl* layer, |
| 2285 bool subtree_visible_from_ancestor, | 2285 bool subtree_visible_from_ancestor, |
| 2286 bool can_render_to_separate_surface) { | 2286 bool can_render_to_separate_surface, |
| 2287 const bool layer_is_visible = | 2287 bool use_property_trees) { |
| 2288 subtree_visible_from_ancestor && !layer->hide_layer_and_subtree(); | 2288 bool layer_is_drawn; |
| 2289 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest(); | 2289 if (use_property_trees) { |
| 2290 layer_is_drawn = layer->IsDrawnFromPropertyTrees(); | |
| 2291 } else { | |
| 2292 layer_is_drawn = (subtree_visible_from_ancestor && layer->opacity() != 0) || | |
| 2293 layer->HasCopyRequest(); | |
| 2294 } | |
| 2290 | 2295 |
| 2291 // The root layer cannot be skipped. | 2296 // The root layer cannot be skipped. |
| 2292 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { | 2297 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { |
| 2293 layer->draw_properties().render_target = nullptr; | 2298 layer->draw_properties().render_target = nullptr; |
| 2294 return; | 2299 return; |
| 2295 } | 2300 } |
| 2296 | 2301 |
| 2297 bool render_to_separate_surface = | 2302 bool render_to_separate_surface = |
| 2298 IsRootLayer(layer) || | 2303 IsRootLayer(layer) || |
| 2299 (can_render_to_separate_surface && layer->render_surface()); | 2304 (can_render_to_separate_surface && layer->render_surface()); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2312 layer; | 2317 layer; |
| 2313 | 2318 |
| 2314 } else { | 2319 } else { |
| 2315 DCHECK(layer->parent()); | 2320 DCHECK(layer->parent()); |
| 2316 layer->draw_properties().render_target = layer->parent()->render_target(); | 2321 layer->draw_properties().render_target = layer->parent()->render_target(); |
| 2317 } | 2322 } |
| 2318 | 2323 |
| 2319 for (size_t i = 0; i < layer->children().size(); ++i) { | 2324 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 2320 CalculateRenderTargetInternal( | 2325 CalculateRenderTargetInternal( |
| 2321 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i), | 2326 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i), |
| 2322 layer_is_drawn, can_render_to_separate_surface); | 2327 layer_is_drawn, can_render_to_separate_surface, use_property_trees); |
| 2323 } | 2328 } |
| 2324 } | 2329 } |
| 2325 | 2330 |
| 2326 void CalculateRenderSurfaceLayerListInternal( | 2331 void CalculateRenderSurfaceLayerListInternal( |
| 2327 LayerImpl* layer, | 2332 LayerImpl* layer, |
| 2328 PropertyTrees* property_trees, | 2333 PropertyTrees* property_trees, |
| 2329 LayerImplList* render_surface_layer_list, | 2334 LayerImplList* render_surface_layer_list, |
| 2330 LayerImplList* descendants, | 2335 LayerImplList* descendants, |
| 2331 RenderSurfaceImpl* nearest_occlusion_immune_ancestor, | 2336 RenderSurfaceImpl* nearest_occlusion_immune_ancestor, |
| 2332 bool subtree_visible_from_ancestor, | 2337 bool subtree_visible_from_ancestor, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2343 // |render_surface_layer_list| is the top level RenderSurfaceLayerList. | 2348 // |render_surface_layer_list| is the top level RenderSurfaceLayerList. |
| 2344 | 2349 |
| 2345 // |descendants| is used to determine what's in current layer's render | 2350 // |descendants| is used to determine what's in current layer's render |
| 2346 // surface's layer list. | 2351 // surface's layer list. |
| 2347 | 2352 |
| 2348 // |subtree_visible_from_ancestor| is set during recursion to affect current | 2353 // |subtree_visible_from_ancestor| is set during recursion to affect current |
| 2349 // layer's subtree. | 2354 // layer's subtree. |
| 2350 | 2355 |
| 2351 // |can_render_to_separate_surface| and |current_render_surface_layer_list_id| | 2356 // |can_render_to_separate_surface| and |current_render_surface_layer_list_id| |
| 2352 // are settings that should stay the same during recursion. | 2357 // are settings that should stay the same during recursion. |
| 2353 | 2358 bool layer_is_drawn; |
| 2354 // Layers that are marked as hidden will hide themselves and their subtree. | 2359 if (use_property_trees) { |
| 2355 // Exception: Layers with copy requests, whether hidden or not, must be drawn | 2360 layer_is_drawn = layer->IsDrawnFromPropertyTrees(); |
| 2356 // anyway. In this case, we will inform their subtree they are visible to get | 2361 } else { |
| 2357 // the right results. | 2362 layer_is_drawn = (subtree_visible_from_ancestor && layer->opacity() != 0) || |
| 2358 const bool layer_is_visible = | 2363 layer->HasCopyRequest(); |
| 2359 subtree_visible_from_ancestor && !layer->hide_layer_and_subtree(); | 2364 } |
| 2360 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest(); | |
| 2361 | 2365 |
| 2362 // The root layer cannot be skipped. | 2366 // The root layer cannot be skipped. |
| 2363 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { | 2367 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { |
| 2364 if (layer->render_surface()) | 2368 if (layer->render_surface()) |
| 2365 layer->ClearRenderSurfaceLayerList(); | 2369 layer->ClearRenderSurfaceLayerList(); |
| 2366 layer->draw_properties().render_target = nullptr; | 2370 layer->draw_properties().render_target = nullptr; |
| 2367 return; | 2371 return; |
| 2368 } | 2372 } |
| 2369 | 2373 |
| 2370 bool render_to_separate_surface = | 2374 bool render_to_separate_surface = |
| 2371 IsRootLayer(layer) || | 2375 IsRootLayer(layer) || |
| 2372 (can_render_to_separate_surface && layer->render_surface()); | 2376 (can_render_to_separate_surface && layer->render_surface()); |
| 2373 | 2377 |
| 2374 if (render_to_separate_surface) { | 2378 if (render_to_separate_surface) { |
| 2375 DCHECK(layer->render_surface()); | 2379 DCHECK(layer->render_surface()); |
| 2376 | 2380 |
| 2381 bool contributes_to_drawn_surface; | |
| 2377 if (use_property_trees) { | 2382 if (use_property_trees) { |
| 2378 RenderSurfaceDrawProperties draw_properties; | 2383 RenderSurfaceDrawProperties draw_properties; |
| 2379 ComputeSurfaceDrawPropertiesUsingPropertyTrees( | 2384 ComputeSurfaceDrawPropertiesUsingPropertyTrees( |
| 2380 layer->render_surface(), property_trees, &draw_properties); | 2385 layer->render_surface(), property_trees, &draw_properties); |
| 2381 // TODO(ajuma): Once property tree verification is removed, make the above | 2386 // TODO(ajuma): Once property tree verification is removed, make the above |
| 2382 // call directly set the surface's properties, so that the copying below | 2387 // call directly set the surface's properties, so that the copying below |
| 2383 // is no longer needed. | 2388 // is no longer needed. |
| 2384 layer->render_surface()->SetIsClipped(draw_properties.is_clipped); | 2389 layer->render_surface()->SetIsClipped(draw_properties.is_clipped); |
| 2385 layer->render_surface()->SetDrawOpacity(draw_properties.draw_opacity); | 2390 layer->render_surface()->SetDrawOpacity(draw_properties.draw_opacity); |
| 2386 layer->render_surface()->SetDrawTransform(draw_properties.draw_transform); | 2391 layer->render_surface()->SetDrawTransform(draw_properties.draw_transform); |
| 2387 layer->render_surface()->SetScreenSpaceTransform( | 2392 layer->render_surface()->SetScreenSpaceTransform( |
| 2388 draw_properties.screen_space_transform); | 2393 draw_properties.screen_space_transform); |
| 2389 layer->render_surface()->SetReplicaDrawTransform( | 2394 layer->render_surface()->SetReplicaDrawTransform( |
| 2390 draw_properties.replica_draw_transform); | 2395 draw_properties.replica_draw_transform); |
| 2391 layer->render_surface()->SetReplicaScreenSpaceTransform( | 2396 layer->render_surface()->SetReplicaScreenSpaceTransform( |
| 2392 draw_properties.replica_screen_space_transform); | 2397 draw_properties.replica_screen_space_transform); |
| 2393 layer->render_surface()->SetClipRect(draw_properties.clip_rect); | 2398 layer->render_surface()->SetClipRect(draw_properties.clip_rect); |
| 2399 // All drawn layers contribute to drawn surface. | |
| 2400 // Exception : Layers that are hidden and are drawn only for the sake of | |
| 2401 // copy requests. | |
| 2402 contributes_to_drawn_surface = | |
| 2403 layer_is_drawn && !(layer->IsHidden() && layer->HasCopyRequest()); | |
|
ajuma
2016/01/15 15:02:46
This seems almost equivalent to:
layer_is_drawn &&
jaydasika
2016/01/15 18:23:05
Is we have R->R1->R2, render surfaces R1 and R2 ar
ajuma
2016/01/15 18:48:16
Hmm, true. layer_is_drawn (roughly, ignoring backg
| |
| 2404 } else { | |
| 2405 contributes_to_drawn_surface = | |
| 2406 subtree_visible_from_ancestor && layer->opacity() != 0.f; | |
| 2394 } | 2407 } |
| 2395 | 2408 |
| 2396 if (!layer->double_sided() && | 2409 if (!layer->double_sided() && |
| 2397 IsSurfaceBackFaceVisible(layer, | 2410 IsSurfaceBackFaceVisible(layer, |
| 2398 layer->render_surface()->draw_transform())) { | 2411 layer->render_surface()->draw_transform())) { |
| 2399 layer->ClearRenderSurfaceLayerList(); | 2412 layer->ClearRenderSurfaceLayerList(); |
| 2400 layer->draw_properties().render_target = nullptr; | 2413 layer->draw_properties().render_target = nullptr; |
| 2401 return; | 2414 return; |
| 2402 } | 2415 } |
| 2403 | 2416 |
| 2404 if (IsRootLayer(layer)) { | 2417 if (IsRootLayer(layer)) { |
| 2405 // The root surface does not contribute to any other surface, it has no | 2418 // The root surface does not contribute to any other surface, it has no |
| 2406 // target. | 2419 // target. |
| 2407 layer->render_surface()->set_contributes_to_drawn_surface(false); | 2420 layer->render_surface()->set_contributes_to_drawn_surface(false); |
| 2408 } else { | 2421 } else { |
| 2409 // Even if the |layer_is_drawn|, it only contributes to a drawn surface | 2422 // Even if the |layer_is_drawn|, it only contributes to a drawn surface |
| 2410 // when the |layer_is_visible|. | 2423 // when the |layer_is_visible|. |
| 2411 layer->render_surface()->set_contributes_to_drawn_surface( | 2424 layer->render_surface()->set_contributes_to_drawn_surface( |
| 2412 layer_is_visible); | 2425 contributes_to_drawn_surface); |
| 2413 } | 2426 } |
| 2414 | 2427 |
| 2415 // Ignore occlusion from outside the surface when surface contents need to | 2428 // Ignore occlusion from outside the surface when surface contents need to |
| 2416 // be fully drawn. Layers with copy-request need to be complete. | 2429 // be fully drawn. Layers with copy-request need to be complete. |
| 2417 // We could be smarter about layers with replica and exclude regions | 2430 // We could be smarter about layers with replica and exclude regions |
| 2418 // where both layer and the replica are occluded, but this seems like an | 2431 // where both layer and the replica are occluded, but this seems like an |
| 2419 // overkill. The same is true for layers with filters that move pixels. | 2432 // overkill. The same is true for layers with filters that move pixels. |
| 2420 // TODO(senorblanco): make this smarter for the SkImageFilter case (check | 2433 // TODO(senorblanco): make this smarter for the SkImageFilter case (check |
| 2421 // for pixel-moving filters) | 2434 // for pixel-moving filters) |
| 2422 if (layer->HasCopyRequest() || layer->has_replica() || | 2435 if (layer->HasCopyRequest() || layer->has_replica() || |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2567 | 2580 |
| 2568 if (layer->HasContributingDelegatedRenderPasses()) { | 2581 if (layer->HasContributingDelegatedRenderPasses()) { |
| 2569 layer->render_target() | 2582 layer->render_target() |
| 2570 ->render_surface() | 2583 ->render_surface() |
| 2571 ->AddContributingDelegatedRenderPassLayer(layer); | 2584 ->AddContributingDelegatedRenderPassLayer(layer); |
| 2572 } | 2585 } |
| 2573 } | 2586 } |
| 2574 | 2587 |
| 2575 void CalculateRenderTarget( | 2588 void CalculateRenderTarget( |
| 2576 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { | 2589 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { |
| 2577 CalculateRenderTargetInternal(inputs->root_layer, true, | 2590 CalculateRenderTargetInternal( |
| 2578 inputs->can_render_to_separate_surface); | 2591 inputs->root_layer, true, inputs->can_render_to_separate_surface, |
| 2592 inputs->verify_property_trees || inputs->use_property_trees); | |
| 2579 } | 2593 } |
| 2580 | 2594 |
| 2581 void CalculateRenderSurfaceLayerList( | 2595 void CalculateRenderSurfaceLayerList( |
| 2582 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { | 2596 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { |
| 2583 const bool subtree_visible_from_ancestor = true; | 2597 const bool subtree_visible_from_ancestor = true; |
| 2584 DCHECK_EQ( | 2598 DCHECK_EQ( |
| 2585 inputs->current_render_surface_layer_list_id, | 2599 inputs->current_render_surface_layer_list_id, |
| 2586 inputs->root_layer->layer_tree_impl()->current_render_surface_list_id()); | 2600 inputs->root_layer->layer_tree_impl()->current_render_surface_list_id()); |
| 2587 CalculateRenderSurfaceLayerListInternal( | 2601 CalculateRenderSurfaceLayerListInternal( |
| 2588 inputs->root_layer, inputs->property_trees, | 2602 inputs->root_layer, inputs->property_trees, |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2782 | 2796 |
| 2783 PropertyTrees* GetPropertyTrees(Layer* layer) { | 2797 PropertyTrees* GetPropertyTrees(Layer* layer) { |
| 2784 return layer->layer_tree_host()->property_trees(); | 2798 return layer->layer_tree_host()->property_trees(); |
| 2785 } | 2799 } |
| 2786 | 2800 |
| 2787 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 2801 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
| 2788 return layer->layer_tree_impl()->property_trees(); | 2802 return layer->layer_tree_impl()->property_trees(); |
| 2789 } | 2803 } |
| 2790 | 2804 |
| 2791 } // namespace cc | 2805 } // namespace cc |
| OLD | NEW |