OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/trees/occlusion.h" |
| 6 |
| 7 #include "cc/base/math_util.h" |
| 8 #include "ui/gfx/rect.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 Occlusion::Occlusion() { |
| 13 } |
| 14 |
| 15 Occlusion::Occlusion(const gfx::Transform& draw_transform, |
| 16 const SimpleEnclosedRegion& occlusion_from_outside_target, |
| 17 const SimpleEnclosedRegion& occlusion_from_inside_target) |
| 18 : draw_transform_(draw_transform), |
| 19 occlusion_from_outside_target_(occlusion_from_outside_target), |
| 20 occlusion_from_inside_target_(occlusion_from_inside_target) { |
| 21 } |
| 22 |
| 23 bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const { |
| 24 if (content_rect.IsEmpty()) |
| 25 return true; |
| 26 |
| 27 if (occlusion_from_inside_target_.IsEmpty() && |
| 28 occlusion_from_outside_target_.IsEmpty()) { |
| 29 return false; |
| 30 } |
| 31 |
| 32 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded |
| 33 // partial pixels in the resulting Rect. |
| 34 gfx::Rect unoccluded_rect_in_target_surface = |
| 35 MathUtil::MapEnclosingClippedRect(draw_transform_, content_rect); |
| 36 DCHECK_LE(occlusion_from_inside_target_.GetRegionComplexity(), 1u); |
| 37 DCHECK_LE(occlusion_from_outside_target_.GetRegionComplexity(), 1u); |
| 38 // These subtract operations are more lossy than if we did both operations at |
| 39 // once. |
| 40 unoccluded_rect_in_target_surface.Subtract( |
| 41 occlusion_from_inside_target_.bounds()); |
| 42 unoccluded_rect_in_target_surface.Subtract( |
| 43 occlusion_from_outside_target_.bounds()); |
| 44 |
| 45 return unoccluded_rect_in_target_surface.IsEmpty(); |
| 46 } |
| 47 |
| 48 } // namespace cc |
OLD | NEW |