| 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_ &&
|
|
|