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

Unified Diff: cc/trees/occlusion.cc

Issue 2402583005: Split picture layer quads to allow removing more occluded area. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 3 years, 6 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_unittest.cc » ('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
index e86a1a05e32cffd9d5946dffe5c1a8ddcaa11a30..05a428075ab04b84fc0e4f528e805d04c1fb7639 100644
--- a/cc/trees/occlusion.cc
+++ b/cc/trees/occlusion.cc
@@ -5,6 +5,7 @@
#include "cc/trees/occlusion.h"
#include "cc/base/math_util.h"
+#include "cc/base/region.h"
#include "ui/gfx/geometry/rect.h"
namespace cc {
@@ -16,9 +17,9 @@ Occlusion::Occlusion(const gfx::Transform& draw_transform,
const SimpleEnclosedRegion& occlusion_from_outside_target,
const SimpleEnclosedRegion& occlusion_from_inside_target)
: draw_transform_(draw_transform),
+ inverse_draw_transform_(gfx::Transform::kSkipInitialization),
occlusion_from_outside_target_(occlusion_from_outside_target),
- occlusion_from_inside_target_(occlusion_from_inside_target) {
-}
+ occlusion_from_inside_target_(occlusion_from_inside_target) {}
Occlusion Occlusion::GetOcclusionWithGivenDrawTransform(
const gfx::Transform& transform) const {
@@ -56,15 +57,17 @@ gfx::Rect Occlusion::GetUnoccludedContentRect(
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);
- // TODO(ajuma): Skip drawing layers with uninvertible draw transforms, and
- // change this to a DCHECK. crbug.com/517170
- if (!ok)
- return content_rect;
+ if (!inverse_transform_initialized_) {
+ bool ok = draw_transform_.GetInverse(&inverse_draw_transform_);
+ // TODO(ajuma): Skip drawing layers with uninvertible draw transforms, and
+ // change this to a DCHECK. crbug.com/517170
+ if (!ok)
+ return content_rect;
+ inverse_transform_initialized_ = true;
+ }
gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect(
- inverse_draw_transform, unoccluded_rect_in_target_surface);
+ inverse_draw_transform_, unoccluded_rect_in_target_surface);
unoccluded_rect.Intersect(content_rect);
return unoccluded_rect;
@@ -88,6 +91,27 @@ gfx::Rect Occlusion::GetUnoccludedRectInTargetSurface(
return unoccluded_rect_in_target_surface;
}
+void Occlusion::OccludeContentRegion(Region* region) const {
+ if (!draw_transform_.IsScaleOrTranslation())
+ return;
+
+ if (!inverse_transform_initialized_) {
+ bool ok = draw_transform_.GetInverse(&inverse_draw_transform_);
+ if (!ok)
+ return;
+ inverse_transform_initialized_ = true;
+ }
+
+ if (!occlusion_from_inside_target_.IsEmpty()) {
+ region->Subtract(MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(
+ inverse_draw_transform_, occlusion_from_inside_target_.bounds()));
+ }
+ if (!occlusion_from_outside_target_.IsEmpty()) {
+ region->Subtract(MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(
+ inverse_draw_transform_, occlusion_from_outside_target_.bounds()));
+ }
+}
+
bool Occlusion::IsEqual(const Occlusion& other) const {
return draw_transform_ == other.draw_transform_ &&
occlusion_from_inside_target_ == other.occlusion_from_inside_target_ &&
« no previous file with comments | « cc/trees/occlusion.h ('k') | cc/trees/occlusion_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698