summaryrefslogtreecommitdiffstats
path: root/cc/trees/layer_tree_host_common.cc
diff options
context:
space:
mode:
authorjaydasika <jaydasika@chromium.org>2015-10-20 14:47:27 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-20 21:48:11 +0000
commit77a4a07ac7110b78428012f8c1b56f4cb4a37954 (patch)
tree6b7267485d48c97e4c7678031bac63481a244058 /cc/trees/layer_tree_host_common.cc
parent65e7fba107d7af4b65e8b4af4eaec0b04423bb29 (diff)
downloadchromium_src-77a4a07ac7110b78428012f8c1b56f4cb4a37954.zip
chromium_src-77a4a07ac7110b78428012f8c1b56f4cb4a37954.tar.gz
chromium_src-77a4a07ac7110b78428012f8c1b56f4cb4a37954.tar.bz2
Intersect surface content rect from property trees with clip rect of target.
For layers that don't own a render surface, their drawable content rect is already clipped with clip rect when their target is clipped. But the render surface's drawable content rect is not clipped with its target's owning layer's clip. So, we need to apply this clip separately. BUG=544233 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1403373003 Cr-Commit-Position: refs/heads/master@{#355162}
Diffstat (limited to 'cc/trees/layer_tree_host_common.cc')
-rw-r--r--cc/trees/layer_tree_host_common.cc122
1 files changed, 56 insertions, 66 deletions
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 02e1d0c..143c7b1 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -2520,36 +2520,9 @@ void CalculateRenderSurfaceLayerListInternal(
descendants->push_back(layer);
}
- // The render surface's content rect is the union of drawable content rects
- // of the layers that draw into the surface. If the render surface is clipped,
- // it is also intersected with the render's surface clip rect.
- if (verify_property_trees) {
- if (render_to_separate_surface) {
- if (IsRootLayer(layer)) {
- // The root layer's surface content rect is always the entire viewport.
- gfx::Rect viewport =
- gfx::ToEnclosingRect(property_trees->clip_tree.ViewportClip());
- layer->render_surface()->SetAccumulatedContentRect(viewport);
- } else {
- // If the owning layer of a render surface draws content, the content
- // rect of the render surface is initialized to the drawable content
- // rect of the layer.
- gfx::Rect content_rect = layer->DrawsContent()
- ? layer->drawable_content_rect()
- : gfx::Rect();
- layer->render_surface()->SetAccumulatedContentRect(content_rect);
- }
- } else if (!layer_should_be_skipped &&
- !IsRootLayer(layer->render_target())) {
- // In this case, the layer's drawable content rect can expand the
- // content rect of the render surface it is drawing into.
- gfx::Rect surface_content_rect =
- layer->render_target()->render_surface()->accumulated_content_rect();
- surface_content_rect.Union(layer->drawable_content_rect());
- layer->render_target()->render_surface()->SetAccumulatedContentRect(
- surface_content_rect);
- }
- }
+ // Clear the old accumulated content rect of surface.
+ if (verify_property_trees && render_to_separate_surface)
+ layer->render_surface()->SetAccumulatedContentRect(gfx::Rect());
for (auto& child_layer : layer->children()) {
CalculateRenderSurfaceLayerListInternal(
@@ -2582,47 +2555,64 @@ void CalculateRenderSurfaceLayerListInternal(
return;
}
- if (verify_property_trees && render_to_separate_surface &&
- !IsRootLayer(layer)) {
- if (!layer->replica_layer() && layer->render_surface()->is_clipped()) {
- // Here, we clip the render surface's content rect with its clip rect.
- // As the clip rect of render surface is in the surface's target space,
- // we first map the content rect into the target space, intersect it with
- // clip rect and project back the result to the surface space.
- gfx::Rect surface_content_rect =
- layer->render_surface()->accumulated_content_rect();
-
- if (!surface_content_rect.IsEmpty()) {
- gfx::Rect surface_clip_rect = LayerTreeHostCommon::CalculateVisibleRect(
- layer->render_surface()->clip_rect(), surface_content_rect,
- layer->render_surface()->draw_transform());
- surface_content_rect.Intersect(surface_clip_rect);
- layer->render_surface()->SetAccumulatedContentRect(
+ // The render surface's content rect is the union of drawable content rects
+ // of the layers that draw into the surface. If the render surface is clipped,
+ // it is also intersected with the render's surface clip rect.
+ if (verify_property_trees) {
+ if (!IsRootLayer(layer)) {
+ if (render_to_separate_surface) {
+ gfx::Rect surface_content_rect =
+ layer->render_surface()->accumulated_content_rect();
+ // If the owning layer of a render surface draws content, the content
+ // rect of the render surface is expanded to include the drawable
+ // content rect of the layer.
+ if (layer->DrawsContent())
+ surface_content_rect.Union(layer->drawable_content_rect());
+
+ if (!layer->replica_layer() && layer->render_surface()->is_clipped()) {
+ // Here, we clip the render surface's content rect with its clip rect.
+ // As the clip rect of render surface is in the surface's target
+ // space, we first map the content rect into the target space,
+ // intersect it with clip rect and project back the result to the
+ // surface space.
+ if (!surface_content_rect.IsEmpty()) {
+ gfx::Rect surface_clip_rect =
+ LayerTreeHostCommon::CalculateVisibleRect(
+ layer->render_surface()->clip_rect(), surface_content_rect,
+ layer->render_surface()->draw_transform());
+ surface_content_rect.Intersect(surface_clip_rect);
+ }
+ }
+ layer->render_surface()->SetContentRectFromPropertyTrees(
surface_content_rect);
}
- }
- layer->render_surface()->SetContentRectFromPropertyTrees(
- layer->render_surface()->accumulated_content_rect());
- if (!IsRootLayer(layer->parent()->render_target())) {
- // The surface's drawable content rect may expand the content rect
- // of its target's surface(surface's target's surface).
- gfx::Rect surface_target_rect = layer->parent()
- ->render_target()
- ->render_surface()
- ->accumulated_content_rect();
- surface_target_rect.Union(
- gfx::ToEnclosedRect(layer->render_surface()->DrawableContentRect()));
- layer->parent()
- ->render_target()
- ->render_surface()
- ->SetAccumulatedContentRect(surface_target_rect);
+ const LayerImpl* parent_target = layer->parent()->render_target();
+ if (!IsRootLayer(parent_target)) {
+ gfx::Rect surface_content_rect =
+ parent_target->render_surface()->accumulated_content_rect();
+ if (render_to_separate_surface) {
+ // If the layer owns a surface, then the content rect is in the wrong
+ // space. Instead, we will use the surface's DrawableContentRect which
+ // is in target space as required. We also need to clip it with the
+ // target's clip if the target is clipped.
+ surface_content_rect.Union(gfx::ToEnclosedRect(
+ layer->render_surface()->DrawableContentRect()));
+ if (parent_target->is_clipped())
+ surface_content_rect.Intersect(parent_target->clip_rect());
+ } else if (layer->DrawsContent()) {
+ surface_content_rect.Union(layer->drawable_content_rect());
+ }
+ parent_target->render_surface()->SetAccumulatedContentRect(
+ surface_content_rect);
+ }
+ } else {
+ // The root layer's surface content rect is always the entire viewport.
+ gfx::Rect viewport =
+ gfx::ToEnclosingRect(property_trees->clip_tree.ViewportClip());
+ layer->render_surface()->SetContentRectFromPropertyTrees(viewport);
}
}
- if (verify_property_trees && IsRootLayer(layer))
- layer->render_surface()->SetContentRectFromPropertyTrees(
- layer->render_surface()->accumulated_content_rect());
-
if (render_to_separate_surface && !IsRootLayer(layer) &&
layer->render_surface()->DrawableContentRect().IsEmpty()) {
RemoveSurfaceForEarlyExit(layer, render_surface_layer_list);