Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3910)

Unified Diff: cc/trees/occlusion.cc

Issue 547723002: Reland of: cc: Add occlusion checker as a fixed view of occlusion tracker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/occlusion.h ('k') | cc/trees/occlusion_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/occlusion.cc
diff --git a/cc/trees/occlusion.cc b/cc/trees/occlusion.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c91c0ca25d586b13eb2638c404b71d450ec10b42
--- /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
« no previous file with comments | « cc/trees/occlusion.h ('k') | cc/trees/occlusion_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698