| 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/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 512 |
| 513 DCHECK_EQ(render_target->render_target(), render_target); | 513 DCHECK_EQ(render_target->render_target(), render_target); |
| 514 DCHECK(render_target->render_surface()); | 514 DCHECK(render_target->render_surface()); |
| 515 DCHECK_EQ(render_target, stack_.back().target); | 515 DCHECK_EQ(render_target, stack_.back().target); |
| 516 | 516 |
| 517 if (stack_.back().occlusion_from_inside_target.IsEmpty() && | 517 if (stack_.back().occlusion_from_inside_target.IsEmpty() && |
| 518 stack_.back().occlusion_from_outside_target.IsEmpty()) { | 518 stack_.back().occlusion_from_outside_target.IsEmpty()) { |
| 519 return false; | 519 return false; |
| 520 } | 520 } |
| 521 | 521 |
| 522 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); | |
| 523 if (!draw_transform.GetInverse(&inverse_draw_transform)) | |
| 524 return false; | |
| 525 | |
| 526 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded | 522 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded |
| 527 // partial pixels in the resulting Rect. | 523 // partial pixels in the resulting Rect. |
| 528 Region unoccluded_region_in_target_surface = | 524 Region unoccluded_region_in_target_surface = |
| 529 MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); | 525 MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); |
| 530 unoccluded_region_in_target_surface.Subtract( | 526 unoccluded_region_in_target_surface.Subtract( |
| 531 stack_.back().occlusion_from_inside_target); | 527 stack_.back().occlusion_from_inside_target); |
| 532 gfx::RectF unoccluded_rect_in_target_surface_without_outside_occlusion = | 528 gfx::RectF unoccluded_rect_in_target_surface_without_outside_occlusion = |
| 533 unoccluded_region_in_target_surface.bounds(); | 529 unoccluded_region_in_target_surface.bounds(); |
| 534 unoccluded_region_in_target_surface.Subtract( | 530 unoccluded_region_in_target_surface.Subtract( |
| 535 stack_.back().occlusion_from_outside_target); | 531 stack_.back().occlusion_from_outside_target); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 548 return content_rect; | 544 return content_rect; |
| 549 if (content_rect.IsEmpty()) | 545 if (content_rect.IsEmpty()) |
| 550 return content_rect; | 546 return content_rect; |
| 551 | 547 |
| 552 if (stack_.back().occlusion_from_inside_target.IsEmpty() && | 548 if (stack_.back().occlusion_from_inside_target.IsEmpty() && |
| 553 stack_.back().occlusion_from_outside_target.IsEmpty()) { | 549 stack_.back().occlusion_from_outside_target.IsEmpty()) { |
| 554 return content_rect; | 550 return content_rect; |
| 555 } | 551 } |
| 556 | 552 |
| 557 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); | 553 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); |
| 558 if (!draw_transform.GetInverse(&inverse_draw_transform)) | 554 bool ok = draw_transform.GetInverse(&inverse_draw_transform); |
| 559 return content_rect; | 555 DCHECK(ok); |
| 560 | 556 |
| 561 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded | 557 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded |
| 562 // partial pixels in the resulting Rect. | 558 // partial pixels in the resulting Rect. |
| 563 Region unoccluded_region_in_target_surface = | 559 Region unoccluded_region_in_target_surface = |
| 564 MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); | 560 MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); |
| 565 unoccluded_region_in_target_surface.Subtract( | 561 unoccluded_region_in_target_surface.Subtract( |
| 566 stack_.back().occlusion_from_inside_target); | 562 stack_.back().occlusion_from_inside_target); |
| 567 unoccluded_region_in_target_surface.Subtract( | 563 unoccluded_region_in_target_surface.Subtract( |
| 568 stack_.back().occlusion_from_outside_target); | 564 stack_.back().occlusion_from_outside_target); |
| 569 | 565 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 593 if (!has_occlusion) | 589 if (!has_occlusion) |
| 594 return content_rect; | 590 return content_rect; |
| 595 | 591 |
| 596 const StackObject& second_last = stack_[stack_.size() - 2]; | 592 const StackObject& second_last = stack_[stack_.size() - 2]; |
| 597 | 593 |
| 598 if (second_last.occlusion_from_inside_target.IsEmpty() && | 594 if (second_last.occlusion_from_inside_target.IsEmpty() && |
| 599 second_last.occlusion_from_outside_target.IsEmpty()) | 595 second_last.occlusion_from_outside_target.IsEmpty()) |
| 600 return content_rect; | 596 return content_rect; |
| 601 | 597 |
| 602 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); | 598 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); |
| 603 if (!draw_transform.GetInverse(&inverse_draw_transform)) | 599 bool ok = draw_transform.GetInverse(&inverse_draw_transform); |
| 604 return content_rect; | 600 DCHECK(ok); |
| 605 | 601 |
| 606 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded | 602 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded |
| 607 // partial pixels in the resulting Rect. | 603 // partial pixels in the resulting Rect. |
| 608 Region unoccluded_region_in_target_surface = | 604 Region unoccluded_region_in_target_surface = |
| 609 MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); | 605 MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); |
| 610 unoccluded_region_in_target_surface.Subtract( | 606 unoccluded_region_in_target_surface.Subtract( |
| 611 second_last.occlusion_from_inside_target); | 607 second_last.occlusion_from_inside_target); |
| 612 unoccluded_region_in_target_surface.Subtract( | 608 unoccluded_region_in_target_surface.Subtract( |
| 613 second_last.occlusion_from_outside_target); | 609 second_last.occlusion_from_outside_target); |
| 614 | 610 |
| 615 if (unoccluded_region_in_target_surface.IsEmpty()) | 611 if (unoccluded_region_in_target_surface.IsEmpty()) |
| 616 return gfx::Rect(); | 612 return gfx::Rect(); |
| 617 | 613 |
| 618 gfx::Rect unoccluded_rect_in_target_surface = | 614 gfx::Rect unoccluded_rect_in_target_surface = |
| 619 unoccluded_region_in_target_surface.bounds(); | 615 unoccluded_region_in_target_surface.bounds(); |
| 620 gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect( | 616 gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect( |
| 621 inverse_draw_transform, unoccluded_rect_in_target_surface); | 617 inverse_draw_transform, unoccluded_rect_in_target_surface); |
| 622 unoccluded_rect.Intersect(content_rect); | 618 unoccluded_rect.Intersect(content_rect); |
| 623 | 619 |
| 624 return unoccluded_rect; | 620 return unoccluded_rect; |
| 625 } | 621 } |
| 626 | 622 |
| 627 // Instantiate (and export) templates here for the linker. | 623 // Instantiate (and export) templates here for the linker. |
| 628 template class OcclusionTracker<Layer>; | 624 template class OcclusionTracker<Layer>; |
| 629 template class OcclusionTracker<LayerImpl>; | 625 template class OcclusionTracker<LayerImpl>; |
| 630 | 626 |
| 631 } // namespace cc | 627 } // namespace cc |
| OLD | NEW |