summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanakj <danakj@chromium.org>2015-02-10 18:07:08 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-11 02:07:54 +0000
commit206a581e83726ff0b2b961a11ecd03f86f016787 (patch)
tree5837e14cca0bf180961e39662277353098219e09
parent3782bc8d618d8f4a3de3592e0a860fab28055521 (diff)
downloadchromium_src-206a581e83726ff0b2b961a11ecd03f86f016787.zip
chromium_src-206a581e83726ff0b2b961a11ecd03f86f016787.tar.gz
chromium_src-206a581e83726ff0b2b961a11ecd03f86f016787.tar.bz2
cc: Remove OcclusionTracker::UnoccludedContributingSurfaceContentRect.
Instead have OcclusionTracker return an Occlusion object for use with a RenderSurface (or a replica), and call GetUnoccludedContentRect on that Occlusion object instead. This lets us avoid passing an OcclusionTracker to RenderSurfaceImpl during AppendQuads. R=enne, vmpstr BUG=446751 Review URL: https://codereview.chromium.org/917543002 Cr-Commit-Position: refs/heads/master@{#315710}
-rw-r--r--cc/layers/render_surface_impl.cc5
-rw-r--r--cc/trees/occlusion_tracker.cc73
-rw-r--r--cc/trees/occlusion_tracker.h9
-rw-r--r--cc/trees/occlusion_tracker_unittest.cc5
4 files changed, 30 insertions, 62 deletions
diff --git a/cc/layers/render_surface_impl.cc b/cc/layers/render_surface_impl.cc
index 9d36235..8f52316 100644
--- a/cc/layers/render_surface_impl.cc
+++ b/cc/layers/render_surface_impl.cc
@@ -143,8 +143,9 @@ void RenderSurfaceImpl::AppendQuads(
const gfx::Transform& draw_transform =
for_replica ? replica_draw_transform_ : draw_transform_;
gfx::Rect visible_content_rect =
- occlusion_tracker.UnoccludedContributingSurfaceContentRect(
- content_rect_, draw_transform);
+ occlusion_tracker.GetCurrentOcclusionForContributingSurface(
+ draw_transform)
+ .GetUnoccludedContentRect(content_rect_);
if (visible_content_rect.IsEmpty())
return;
diff --git a/cc/trees/occlusion_tracker.cc b/cc/trees/occlusion_tracker.cc
index bce1fd5..97bd2cf 100644
--- a/cc/trees/occlusion_tracker.cc
+++ b/cc/trees/occlusion_tracker.cc
@@ -38,6 +38,21 @@ Occlusion OcclusionTracker<LayerType>::GetCurrentOcclusionForLayer(
}
template <typename LayerType>
+Occlusion
+OcclusionTracker<LayerType>::GetCurrentOcclusionForContributingSurface(
+ const gfx::Transform& draw_transform) const {
+ DCHECK(!stack_.empty());
+ if (stack_.size() < 2)
+ return Occlusion();
+ // A contributing surface doesn't get occluded by things inside its own
+ // surface, so only things outside the surface can occlude it. That occlusion
+ // is found just below the top of the stack (if it exists).
+ const StackObject& second_last = stack_[stack_.size() - 2];
+ return Occlusion(draw_transform, second_last.occlusion_from_outside_target,
+ second_last.occlusion_from_inside_target);
+}
+
+template <typename LayerType>
void OcclusionTracker<LayerType>::EnterLayer(
const LayerIteratorPosition<LayerType>& layer_iterator) {
LayerType* render_target = layer_iterator.target_render_surface_layer;
@@ -340,12 +355,15 @@ void OcclusionTracker<LayerType>::LeaveToRenderTarget(
gfx::Rect unoccluded_surface_rect;
gfx::Rect unoccluded_replica_rect;
if (old_target->background_filters().HasFilterThatMovesPixels()) {
- unoccluded_surface_rect = UnoccludedContributingSurfaceContentRect(
- old_surface->content_rect(), old_surface->draw_transform());
+ Occlusion surface_occlusion = GetCurrentOcclusionForContributingSurface(
+ old_surface->draw_transform());
+ unoccluded_surface_rect =
+ surface_occlusion.GetUnoccludedContentRect(old_surface->content_rect());
if (old_target->has_replica()) {
- unoccluded_replica_rect = UnoccludedContributingSurfaceContentRect(
- old_surface->content_rect(),
+ Occlusion replica_occlusion = GetCurrentOcclusionForContributingSurface(
old_surface->replica_draw_transform());
+ unoccluded_replica_rect = replica_occlusion.GetUnoccludedContentRect(
+ old_surface->content_rect());
}
}
@@ -493,53 +511,6 @@ void OcclusionTracker<LayerType>::MarkOccludedBehindLayer(
}
template <typename LayerType>
-gfx::Rect OcclusionTracker<LayerType>::UnoccludedContributingSurfaceContentRect(
- const gfx::Rect& content_rect,
- const gfx::Transform& draw_transform) const {
- if (content_rect.IsEmpty())
- return content_rect;
-
- // A contributing surface doesn't get occluded by things inside its own
- // surface, so only things outside the surface can occlude it. That occlusion
- // is found just below the top of the stack (if it exists).
- bool has_occlusion = stack_.size() > 1;
- if (!has_occlusion)
- return content_rect;
-
- const StackObject& second_last = stack_[stack_.size() - 2];
- if (second_last.occlusion_from_inside_target.IsEmpty() &&
- second_last.occlusion_from_outside_target.IsEmpty())
- return content_rect;
-
- gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization);
- bool ok = draw_transform.GetInverse(&inverse_draw_transform);
- DCHECK(ok);
-
- // 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(second_last.occlusion_from_inside_target.GetRegionComplexity(), 1u);
- DCHECK_LE(second_last.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(
- second_last.occlusion_from_inside_target.bounds());
- unoccluded_rect_in_target_surface.Subtract(
- second_last.occlusion_from_outside_target.bounds());
-
- if (unoccluded_rect_in_target_surface.IsEmpty())
- return gfx::Rect();
-
- gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect(
- inverse_draw_transform, unoccluded_rect_in_target_surface);
- unoccluded_rect.Intersect(content_rect);
-
- return unoccluded_rect;
-}
-
-template <typename LayerType>
Region OcclusionTracker<LayerType>::ComputeVisibleRegionInScreen() const {
DCHECK(!stack_.back().target->parent());
const SimpleEnclosedRegion& occluded =
diff --git a/cc/trees/occlusion_tracker.h b/cc/trees/occlusion_tracker.h
index 4d6555a..b14baae 100644
--- a/cc/trees/occlusion_tracker.h
+++ b/cc/trees/occlusion_tracker.h
@@ -40,6 +40,8 @@ class CC_EXPORT OcclusionTracker {
// and can be used outside of a layer walk to check occlusion.
Occlusion GetCurrentOcclusionForLayer(
const gfx::Transform& draw_transform) const;
+ Occlusion GetCurrentOcclusionForContributingSurface(
+ const gfx::Transform& draw_transform) const;
// Called at the beginning of each step in the LayerIterator's front-to-back
// traversal.
@@ -48,13 +50,6 @@ class CC_EXPORT OcclusionTracker {
// traversal.
void LeaveLayer(const LayerIteratorPosition<LayerType>& layer_iterator);
- // Gives an unoccluded sub-rect of |content_rect| in the content space of the
- // render_target owned by the layer. Used when considering occlusion for a
- // contributing surface that is rendering into another target.
- gfx::Rect UnoccludedContributingSurfaceContentRect(
- const gfx::Rect& content_rect,
- const gfx::Transform& draw_transform) const;
-
// Gives the region of the screen that is not occluded by something opaque.
Region ComputeVisibleRegionInScreen() const;
diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc
index 172b227..847d60c 100644
--- a/cc/trees/occlusion_tracker_unittest.cc
+++ b/cc/trees/occlusion_tracker_unittest.cc
@@ -101,8 +101,9 @@ class TestOcclusionTrackerWithClip : public TestOcclusionTracker<LayerType> {
gfx::Rect UnoccludedSurfaceContentRect(const LayerType* layer,
const gfx::Rect& content_rect) const {
typename LayerType::RenderSurfaceType* surface = layer->render_surface();
- return this->UnoccludedContributingSurfaceContentRect(
- content_rect, surface->draw_transform());
+ return this->GetCurrentOcclusionForContributingSurface(
+ surface->draw_transform())
+ .GetUnoccludedContentRect(content_rect);
}
};