summaryrefslogtreecommitdiffstats
path: root/cc/trees/occlusion.cc
diff options
context:
space:
mode:
authorvmpstr <vmpstr@chromium.org>2014-09-10 17:58:37 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-11 01:01:15 +0000
commitcdcb5f741f8163b771d66f6017a67cff06193b50 (patch)
treeefafd4b81d85a74d8efd0596b3a628a2bbd7aec3 /cc/trees/occlusion.cc
parented1a1429274647b00fe9365223d567981e7049b6 (diff)
downloadchromium_src-cdcb5f741f8163b771d66f6017a67cff06193b50.zip
chromium_src-cdcb5f741f8163b771d66f6017a67cff06193b50.tar.gz
chromium_src-cdcb5f741f8163b771d66f6017a67cff06193b50.tar.bz2
Reland of: cc: Add occlusion checker as a fixed view of occlusion tracker.
This patch adds an occlusion checker to get the state of occlusion tracker for permanent checks. That is, occlusion checker does not have to be queried during a layer walk. BUG=410932 R=danakj Committed: https://crrev.com/1af780529157c94a9e0f05bcf478543b85714f6b Cr-Commit-Position: refs/heads/master@{#294205} Review URL: https://codereview.chromium.org/547723002 Cr-Commit-Position: refs/heads/master@{#294280}
Diffstat (limited to 'cc/trees/occlusion.cc')
-rw-r--r--cc/trees/occlusion.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/cc/trees/occlusion.cc b/cc/trees/occlusion.cc
new file mode 100644
index 0000000..c91c0ca
--- /dev/null
+++ b/cc/trees/occlusion.cc
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/trees/occlusion.h"
+
+#include "cc/base/math_util.h"
+#include "ui/gfx/rect.h"
+
+namespace cc {
+
+Occlusion::Occlusion() {
+}
+
+Occlusion::Occlusion(const gfx::Transform& draw_transform,
+ const SimpleEnclosedRegion& occlusion_from_outside_target,
+ const SimpleEnclosedRegion& occlusion_from_inside_target)
+ : draw_transform_(draw_transform),
+ occlusion_from_outside_target_(occlusion_from_outside_target),
+ occlusion_from_inside_target_(occlusion_from_inside_target) {
+}
+
+bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const {
+ if (content_rect.IsEmpty())
+ return true;
+
+ if (occlusion_from_inside_target_.IsEmpty() &&
+ occlusion_from_outside_target_.IsEmpty()) {
+ return false;
+ }
+
+ // Take the ToEnclosingRect at each step, as we want to contain any unoccluded
+ // partial pixels in the resulting Rect.
+ gfx::Rect unoccluded_rect_in_target_surface =
+ MathUtil::MapEnclosingClippedRect(draw_transform_, content_rect);
+ DCHECK_LE(occlusion_from_inside_target_.GetRegionComplexity(), 1u);
+ DCHECK_LE(occlusion_from_outside_target_.GetRegionComplexity(), 1u);
+ // These subtract operations are more lossy than if we did both operations at
+ // once.
+ unoccluded_rect_in_target_surface.Subtract(
+ occlusion_from_inside_target_.bounds());
+ unoccluded_rect_in_target_surface.Subtract(
+ occlusion_from_outside_target_.bounds());
+
+ return unoccluded_rect_in_target_surface.IsEmpty();
+}
+
+} // namespace cc