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 |
| 9 namespace cc { |
| 10 |
| 11 Occlusion::Occlusion() { |
| 12 } |
| 13 |
| 14 Occlusion::Occlusion(const gfx::Transform& draw_transform, |
| 15 const SimpleEnclosedRegion& occlusion_from_outside_target, |
| 16 const SimpleEnclosedRegion& occlusion_from_inside_target) |
| 17 : draw_transform_(draw_transform), |
| 18 occlusion_from_outside_target_(occlusion_from_outside_target), |
| 19 occlusion_from_inside_target_(occlusion_from_inside_target) { |
| 20 } |
| 21 |
| 22 bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const { |
| 23 if (content_rect.IsEmpty()) |
| 24 return true; |
| 25 |
| 26 if (occlusion_from_inside_target_.IsEmpty() && |
| 27 occlusion_from_outside_target_.IsEmpty()) { |
| 28 return false; |
| 29 } |
| 30 |
| 31 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded |
| 32 // partial pixels in the resulting Rect. |
| 33 gfx::Rect unoccluded_rect_in_target_surface = |
| 34 MathUtil::MapEnclosingClippedRect(draw_transform_, content_rect); |
| 35 DCHECK_LE(occlusion_from_inside_target_.GetRegionComplexity(), 1u); |
| 36 DCHECK_LE(occlusion_from_outside_target_.GetRegionComplexity(), 1u); |
| 37 // These subtract operations are more lossy than if we did both operations at |
| 38 // once. |
| 39 unoccluded_rect_in_target_surface.Subtract( |
| 40 occlusion_from_inside_target_.bounds()); |
| 41 unoccluded_rect_in_target_surface.Subtract( |
| 42 occlusion_from_outside_target_.bounds()); |
| 43 |
| 44 return unoccluded_rect_in_target_surface.IsEmpty(); |
| 45 } |
| 46 |
| 47 } // namespace cc |
OLD | NEW |