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

Unified Diff: cc/trees/occlusion.cc

Issue 576173003: cc: Move UnoccludedContentRect to Occlusion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: cc/trees/occlusion.cc
diff --git a/cc/trees/occlusion.cc b/cc/trees/occlusion.cc
index c91c0ca25d586b13eb2638c404b71d450ec10b42..d9da9382bcafc6788128ba25488412599dc11356 100644
--- a/cc/trees/occlusion.cc
+++ b/cc/trees/occlusion.cc
@@ -29,6 +29,39 @@ bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const {
return false;
}
+ gfx::Rect unoccluded_rect_in_target_surface =
+ GetUnoccludedRectInTargetSurface(content_rect);
+ return unoccluded_rect_in_target_surface.IsEmpty();
+}
+
+gfx::Rect Occlusion::GetUnoccludedContentRect(
+ const gfx::Rect& content_rect) const {
+ if (content_rect.IsEmpty())
+ return content_rect;
+
+ if (occlusion_from_inside_target_.IsEmpty() &&
+ occlusion_from_outside_target_.IsEmpty()) {
+ return content_rect;
+ }
+
+ gfx::Rect unoccluded_rect_in_target_surface =
+ GetUnoccludedRectInTargetSurface(content_rect);
+ if (unoccluded_rect_in_target_surface.IsEmpty())
+ return gfx::Rect();
+
+ gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization);
+ bool ok = draw_transform_.GetInverse(&inverse_draw_transform);
+ DCHECK(ok);
+
+ gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect(
+ inverse_draw_transform, unoccluded_rect_in_target_surface);
+ unoccluded_rect.Intersect(content_rect);
+
+ return unoccluded_rect;
+}
+
+gfx::Rect Occlusion::GetUnoccludedRectInTargetSurface(
+ const gfx::Rect& content_rect) const {
// 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 =
@@ -42,7 +75,7 @@ bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const {
unoccluded_rect_in_target_surface.Subtract(
occlusion_from_outside_target_.bounds());
- return unoccluded_rect_in_target_surface.IsEmpty();
+ return unoccluded_rect_in_target_surface;
}
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698