| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 351 |
| 352 if (layer->draw_opacity() < 1) | 352 if (layer->draw_opacity() < 1) |
| 353 return; | 353 return; |
| 354 | 354 |
| 355 if (!layer->uses_default_blend_mode()) | 355 if (!layer->uses_default_blend_mode()) |
| 356 return; | 356 return; |
| 357 | 357 |
| 358 if (layer->Is3dSorted()) | 358 if (layer->Is3dSorted()) |
| 359 return; | 359 return; |
| 360 | 360 |
| 361 SimpleEnclosedRegion opaque_contents = layer->VisibleContentOpaqueRegion(); | 361 SimpleEnclosedRegion opaque_layer_region = layer->VisibleOpaqueRegion(); |
| 362 if (opaque_contents.IsEmpty()) | 362 if (opaque_layer_region.IsEmpty()) |
| 363 return; | 363 return; |
| 364 | 364 |
| 365 DCHECK(layer->visible_content_rect().Contains(opaque_contents.bounds())); | 365 DCHECK(layer->visible_layer_rect().Contains(opaque_layer_region.bounds())); |
| 366 | 366 |
| 367 // TODO(danakj): Find a rect interior to each transformed quad. | 367 // TODO(danakj): Find a rect interior to each transformed quad. |
| 368 if (!layer->draw_transform().Preserves2dAxisAlignment()) | 368 if (!layer->draw_transform().Preserves2dAxisAlignment()) |
| 369 return; | 369 return; |
| 370 | 370 |
| 371 gfx::Rect clip_rect_in_target = ScreenSpaceClipRectInTargetSurface( | 371 gfx::Rect clip_rect_in_target = ScreenSpaceClipRectInTargetSurface( |
| 372 layer->render_target()->render_surface(), screen_space_clip_rect_); | 372 layer->render_target()->render_surface(), screen_space_clip_rect_); |
| 373 if (layer->is_clipped()) { | 373 if (layer->is_clipped()) { |
| 374 clip_rect_in_target.Intersect(layer->clip_rect()); | 374 clip_rect_in_target.Intersect(layer->clip_rect()); |
| 375 } else { | 375 } else { |
| 376 clip_rect_in_target.Intersect( | 376 clip_rect_in_target.Intersect( |
| 377 layer->render_target()->render_surface()->content_rect()); | 377 layer->render_target()->render_surface()->content_rect()); |
| 378 } | 378 } |
| 379 | 379 |
| 380 for (size_t i = 0; i < opaque_contents.GetRegionComplexity(); ++i) { | 380 for (size_t i = 0; i < opaque_layer_region.GetRegionComplexity(); ++i) { |
| 381 gfx::Rect transformed_rect = | 381 gfx::Rect transformed_rect = |
| 382 MathUtil::MapEnclosedRectWith2dAxisAlignedTransform( | 382 MathUtil::MapEnclosedRectWith2dAxisAlignedTransform( |
| 383 layer->draw_transform(), opaque_contents.GetRect(i)); | 383 layer->draw_transform(), opaque_layer_region.GetRect(i)); |
| 384 transformed_rect.Intersect(clip_rect_in_target); | 384 transformed_rect.Intersect(clip_rect_in_target); |
| 385 if (transformed_rect.width() < minimum_tracking_size_.width() && | 385 if (transformed_rect.width() < minimum_tracking_size_.width() && |
| 386 transformed_rect.height() < minimum_tracking_size_.height()) | 386 transformed_rect.height() < minimum_tracking_size_.height()) |
| 387 continue; | 387 continue; |
| 388 stack_.back().occlusion_from_inside_target.Union(transformed_rect); | 388 stack_.back().occlusion_from_inside_target.Union(transformed_rect); |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 Region OcclusionTracker::ComputeVisibleRegionInScreen() const { | 392 Region OcclusionTracker::ComputeVisibleRegionInScreen() const { |
| 393 DCHECK(!stack_.back().target->parent()); | 393 DCHECK(!stack_.back().target->parent()); |
| 394 const SimpleEnclosedRegion& occluded = | 394 const SimpleEnclosedRegion& occluded = |
| 395 stack_.back().occlusion_from_inside_target; | 395 stack_.back().occlusion_from_inside_target; |
| 396 Region visible_region(screen_space_clip_rect_); | 396 Region visible_region(screen_space_clip_rect_); |
| 397 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) | 397 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) |
| 398 visible_region.Subtract(occluded.GetRect(i)); | 398 visible_region.Subtract(occluded.GetRect(i)); |
| 399 return visible_region; | 399 return visible_region; |
| 400 } | 400 } |
| 401 | 401 |
| 402 } // namespace cc | 402 } // namespace cc |
| OLD | NEW |