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