| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // surface so that we can DCHECK that the surface's draw transform is simply | 235 // surface so that we can DCHECK that the surface's draw transform is simply |
| 236 // a translation when |render_target| reports that it has no unclipped | 236 // a translation when |render_target| reports that it has no unclipped |
| 237 // descendants). | 237 // descendants). |
| 238 LayerType* render_target; | 238 LayerType* render_target; |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 template <typename LayerType> | 241 template <typename LayerType> |
| 242 void UpdateAccumulatedSurfaceState( | 242 void UpdateAccumulatedSurfaceState( |
| 243 LayerType* layer, | 243 LayerType* layer, |
| 244 const gfx::Rect& drawable_content_rect, | 244 const gfx::Rect& drawable_content_rect, |
| 245 std::vector<AccumulatedSurfaceState<LayerType> >* | 245 std::vector<AccumulatedSurfaceState<LayerType>>* |
| 246 accumulated_surface_state) { | 246 accumulated_surface_state) { |
| 247 if (IsRootLayer(layer)) | 247 if (IsRootLayer(layer)) |
| 248 return; | 248 return; |
| 249 | 249 |
| 250 // We will apply our drawable content rect to the accumulated rects for all | 250 // We will apply our drawable content rect to the accumulated rects for all |
| 251 // surfaces between us and |render_target| (inclusive). This is either our | 251 // surfaces between us and |render_target| (inclusive). This is either our |
| 252 // clip parent's target if we are a clip child, or else simply our parent's | 252 // clip parent's target if we are a clip child, or else simply our parent's |
| 253 // target. We use our parent's target because we're either the owner of a | 253 // target. We use our parent's target because we're either the owner of a |
| 254 // render surface and we'll want to add our rect to our *surface's* target, or | 254 // render surface and we'll want to add our rect to our *surface's* target, or |
| 255 // we're not and our target is the same as our parent's. In both cases, the | 255 // we're not and our target is the same as our parent's. In both cases, the |
| (...skipping 21 matching lines...) Expand all Loading... |
| 277 *layer, | 277 *layer, |
| 278 clip_rect, | 278 clip_rect, |
| 279 TranslateRectDirectionToDescendant); | 279 TranslateRectDirectionToDescendant); |
| 280 } | 280 } |
| 281 target_rect.Intersect(clip_rect); | 281 target_rect.Intersect(clip_rect); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // We must have at least one entry in the vector for the root. | 284 // We must have at least one entry in the vector for the root. |
| 285 DCHECK_LT(0ul, accumulated_surface_state->size()); | 285 DCHECK_LT(0ul, accumulated_surface_state->size()); |
| 286 | 286 |
| 287 typedef typename std::vector<AccumulatedSurfaceState<LayerType> > | 287 typedef typename std::vector<AccumulatedSurfaceState<LayerType>> |
| 288 AccumulatedSurfaceStateVector; | 288 AccumulatedSurfaceStateVector; |
| 289 typedef typename AccumulatedSurfaceStateVector::reverse_iterator | 289 typedef typename AccumulatedSurfaceStateVector::reverse_iterator |
| 290 AccumulatedSurfaceStateIterator; | 290 AccumulatedSurfaceStateIterator; |
| 291 AccumulatedSurfaceStateIterator current_state = | 291 AccumulatedSurfaceStateIterator current_state = |
| 292 accumulated_surface_state->rbegin(); | 292 accumulated_surface_state->rbegin(); |
| 293 | 293 |
| 294 // Add this rect to the accumulated content rect for all surfaces until we | 294 // Add this rect to the accumulated content rect for all surfaces until we |
| 295 // reach the target surface. | 295 // reach the target surface. |
| 296 bool found_render_target = false; | 296 bool found_render_target = false; |
| 297 for (; current_state != accumulated_surface_state->rend(); ++current_state) { | 297 for (; current_state != accumulated_surface_state->rend(); ++current_state) { |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 | 1444 |
| 1445 // Recursively walks the layer tree starting at the given node and computes all | 1445 // Recursively walks the layer tree starting at the given node and computes all |
| 1446 // the necessary transformations, clip rects, render surfaces, etc. | 1446 // the necessary transformations, clip rects, render surfaces, etc. |
| 1447 template <typename LayerType> | 1447 template <typename LayerType> |
| 1448 static void CalculateDrawPropertiesInternal( | 1448 static void CalculateDrawPropertiesInternal( |
| 1449 LayerType* layer, | 1449 LayerType* layer, |
| 1450 const SubtreeGlobals<LayerType>& globals, | 1450 const SubtreeGlobals<LayerType>& globals, |
| 1451 const DataForRecursion<LayerType>& data_from_ancestor, | 1451 const DataForRecursion<LayerType>& data_from_ancestor, |
| 1452 typename LayerType::RenderSurfaceListType* render_surface_layer_list, | 1452 typename LayerType::RenderSurfaceListType* render_surface_layer_list, |
| 1453 typename LayerType::LayerListType* layer_list, | 1453 typename LayerType::LayerListType* layer_list, |
| 1454 std::vector<AccumulatedSurfaceState<LayerType> >* accumulated_surface_state, | 1454 std::vector<AccumulatedSurfaceState<LayerType>>* accumulated_surface_state, |
| 1455 int current_render_surface_layer_list_id) { | 1455 int current_render_surface_layer_list_id) { |
| 1456 // This function computes the new matrix transformations recursively for this | 1456 // This function computes the new matrix transformations recursively for this |
| 1457 // layer and all its descendants. It also computes the appropriate render | 1457 // layer and all its descendants. It also computes the appropriate render |
| 1458 // surfaces. | 1458 // surfaces. |
| 1459 // Some important points to remember: | 1459 // Some important points to remember: |
| 1460 // | 1460 // |
| 1461 // 0. Here, transforms are notated in Matrix x Vector order, and in words we | 1461 // 0. Here, transforms are notated in Matrix x Vector order, and in words we |
| 1462 // describe what the transform does from left to right. | 1462 // describe what the transform does from left to right. |
| 1463 // | 1463 // |
| 1464 // 1. In our terminology, the "layer origin" refers to the top-left corner of | 1464 // 1. In our terminology, the "layer origin" refers to the top-left corner of |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2391 | 2391 |
| 2392 void LayerTreeHostCommon::CalculateDrawProperties( | 2392 void LayerTreeHostCommon::CalculateDrawProperties( |
| 2393 CalcDrawPropsMainInputs* inputs) { | 2393 CalcDrawPropsMainInputs* inputs) { |
| 2394 LayerList dummy_layer_list; | 2394 LayerList dummy_layer_list; |
| 2395 SubtreeGlobals<Layer> globals; | 2395 SubtreeGlobals<Layer> globals; |
| 2396 DataForRecursion<Layer> data_for_recursion; | 2396 DataForRecursion<Layer> data_for_recursion; |
| 2397 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); | 2397 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); |
| 2398 | 2398 |
| 2399 PreCalculateMetaInformationRecursiveData recursive_data; | 2399 PreCalculateMetaInformationRecursiveData recursive_data; |
| 2400 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); | 2400 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
| 2401 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; | 2401 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state; |
| 2402 CalculateDrawPropertiesInternal<Layer>( | 2402 CalculateDrawPropertiesInternal<Layer>( |
| 2403 inputs->root_layer, | 2403 inputs->root_layer, |
| 2404 globals, | 2404 globals, |
| 2405 data_for_recursion, | 2405 data_for_recursion, |
| 2406 inputs->render_surface_layer_list, | 2406 inputs->render_surface_layer_list, |
| 2407 &dummy_layer_list, | 2407 &dummy_layer_list, |
| 2408 &accumulated_surface_state, | 2408 &accumulated_surface_state, |
| 2409 inputs->current_render_surface_layer_list_id); | 2409 inputs->current_render_surface_layer_list_id); |
| 2410 | 2410 |
| 2411 // The dummy layer list should not have been used. | 2411 // The dummy layer list should not have been used. |
| 2412 DCHECK_EQ(0u, dummy_layer_list.size()); | 2412 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 2413 // A root layer render_surface should always exist after | 2413 // A root layer render_surface should always exist after |
| 2414 // CalculateDrawProperties. | 2414 // CalculateDrawProperties. |
| 2415 DCHECK(inputs->root_layer->render_surface()); | 2415 DCHECK(inputs->root_layer->render_surface()); |
| 2416 } | 2416 } |
| 2417 | 2417 |
| 2418 void LayerTreeHostCommon::CalculateDrawProperties( | 2418 void LayerTreeHostCommon::CalculateDrawProperties( |
| 2419 CalcDrawPropsImplInputs* inputs) { | 2419 CalcDrawPropsImplInputs* inputs) { |
| 2420 LayerImplList dummy_layer_list; | 2420 LayerImplList dummy_layer_list; |
| 2421 SubtreeGlobals<LayerImpl> globals; | 2421 SubtreeGlobals<LayerImpl> globals; |
| 2422 DataForRecursion<LayerImpl> data_for_recursion; | 2422 DataForRecursion<LayerImpl> data_for_recursion; |
| 2423 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); | 2423 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); |
| 2424 | 2424 |
| 2425 LayerSorter layer_sorter; | 2425 LayerSorter layer_sorter; |
| 2426 globals.layer_sorter = &layer_sorter; | 2426 globals.layer_sorter = &layer_sorter; |
| 2427 | 2427 |
| 2428 PreCalculateMetaInformationRecursiveData recursive_data; | 2428 PreCalculateMetaInformationRecursiveData recursive_data; |
| 2429 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); | 2429 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
| 2430 std::vector<AccumulatedSurfaceState<LayerImpl> > | 2430 std::vector<AccumulatedSurfaceState<LayerImpl>> accumulated_surface_state; |
| 2431 accumulated_surface_state; | |
| 2432 CalculateDrawPropertiesInternal<LayerImpl>( | 2431 CalculateDrawPropertiesInternal<LayerImpl>( |
| 2433 inputs->root_layer, | 2432 inputs->root_layer, |
| 2434 globals, | 2433 globals, |
| 2435 data_for_recursion, | 2434 data_for_recursion, |
| 2436 inputs->render_surface_layer_list, | 2435 inputs->render_surface_layer_list, |
| 2437 &dummy_layer_list, | 2436 &dummy_layer_list, |
| 2438 &accumulated_surface_state, | 2437 &accumulated_surface_state, |
| 2439 inputs->current_render_surface_layer_list_id); | 2438 inputs->current_render_surface_layer_list_id); |
| 2440 | 2439 |
| 2441 // The dummy layer list should not have been used. | 2440 // The dummy layer list should not have been used. |
| 2442 DCHECK_EQ(0u, dummy_layer_list.size()); | 2441 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 2443 // A root layer render_surface should always exist after | 2442 // A root layer render_surface should always exist after |
| 2444 // CalculateDrawProperties. | 2443 // CalculateDrawProperties. |
| 2445 DCHECK(inputs->root_layer->render_surface()); | 2444 DCHECK(inputs->root_layer->render_surface()); |
| 2446 } | 2445 } |
| 2447 | 2446 |
| 2448 } // namespace cc | 2447 } // namespace cc |
| OLD | NEW |