OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/occlusion_tracker.h" | 5 #include "cc/trees/occlusion_tracker.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/base/region.h" | 10 #include "cc/base/region.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 bool entering_root_target = new_target->parent() == NULL; | 206 bool entering_root_target = new_target->parent() == NULL; |
207 | 207 |
208 bool copy_outside_occlusion_forward = | 208 bool copy_outside_occlusion_forward = |
209 stack_.size() > 1 && | 209 stack_.size() > 1 && |
210 !entering_unoccluded_subtree && | 210 !entering_unoccluded_subtree && |
211 have_transform_from_screen_to_new_target && | 211 have_transform_from_screen_to_new_target && |
212 !entering_root_target; | 212 !entering_root_target; |
213 if (!copy_outside_occlusion_forward) | 213 if (!copy_outside_occlusion_forward) |
214 return; | 214 return; |
215 | 215 |
216 int last_index = stack_.size() - 1; | 216 size_t last_index = stack_.size() - 1; |
217 gfx::Transform old_target_to_new_target_transform( | 217 gfx::Transform old_target_to_new_target_transform( |
218 inverse_new_target_screen_space_transform, | 218 inverse_new_target_screen_space_transform, |
219 old_target->render_surface()->screen_space_transform()); | 219 old_target->render_surface()->screen_space_transform()); |
220 stack_[last_index].occlusion_from_outside_target = | 220 stack_[last_index].occlusion_from_outside_target = |
221 TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( | 221 TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( |
222 stack_[last_index - 1].occlusion_from_outside_target, | 222 stack_[last_index - 1].occlusion_from_outside_target, |
223 false, | 223 false, |
224 gfx::Rect(), | 224 gfx::Rect(), |
225 old_target_to_new_target_transform); | 225 old_target_to_new_target_transform); |
226 stack_[last_index].occlusion_from_outside_target.Union( | 226 stack_[last_index].occlusion_from_outside_target.Union( |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 occlusion_rect.Inset(shrink_left, shrink_top, shrink_right, shrink_bottom); | 312 occlusion_rect.Inset(shrink_left, shrink_top, shrink_right, shrink_bottom); |
313 | 313 |
314 occlusion_from_inside_target->Union(occlusion_rect); | 314 occlusion_from_inside_target->Union(occlusion_rect); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 template <typename LayerType> | 318 template <typename LayerType> |
319 void OcclusionTracker<LayerType>::LeaveToRenderTarget( | 319 void OcclusionTracker<LayerType>::LeaveToRenderTarget( |
320 const LayerType* new_target) { | 320 const LayerType* new_target) { |
321 int last_index = stack_.size() - 1; | 321 DCHECK(!stack_.empty()); |
| 322 size_t last_index = stack_.size() - 1; |
322 bool surface_will_be_at_top_after_pop = | 323 bool surface_will_be_at_top_after_pop = |
323 stack_.size() > 1 && stack_[last_index - 1].target == new_target; | 324 stack_.size() > 1 && stack_[last_index - 1].target == new_target; |
324 | 325 |
325 // We merge the screen occlusion from the current RenderSurfaceImpl subtree | 326 // We merge the screen occlusion from the current RenderSurfaceImpl subtree |
326 // out to its parent target RenderSurfaceImpl. The target occlusion can be | 327 // out to its parent target RenderSurfaceImpl. The target occlusion can be |
327 // merged out as well but needs to be transformed to the new target. | 328 // merged out as well but needs to be transformed to the new target. |
328 | 329 |
329 const LayerType* old_target = stack_[last_index].target; | 330 const LayerType* old_target = stack_[last_index].target; |
330 const typename LayerType::RenderSurfaceType* old_surface = | 331 const typename LayerType::RenderSurfaceType* old_surface = |
331 old_target->render_surface(); | 332 old_target->render_surface(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) | 478 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) |
478 visible_region.Subtract(occluded.GetRect(i)); | 479 visible_region.Subtract(occluded.GetRect(i)); |
479 return visible_region; | 480 return visible_region; |
480 } | 481 } |
481 | 482 |
482 // Instantiate (and export) templates here for the linker. | 483 // Instantiate (and export) templates here for the linker. |
483 template class OcclusionTracker<Layer>; | 484 template class OcclusionTracker<Layer>; |
484 template class OcclusionTracker<LayerImpl>; | 485 template class OcclusionTracker<LayerImpl>; |
485 | 486 |
486 } // namespace cc | 487 } // namespace cc |
OLD | NEW |