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

Unified Diff: cc/trees/layer_tree_host_common.cc

Issue 1902893002: cc: Move calculation of content rect to RenderSurfaceImpl class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@targetid
Patch Set: Created 4 years, 8 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/layer_tree_host_common.cc
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 5eed406a0cc803ee4ced22d195a8e34aa26bb288..0e5cd12b7d4fe522a811ca6658fe3ae383aa1a01 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -194,56 +194,6 @@ void ScrollAndScaleSet::FromProtobuf(const proto::ScrollAndScaleSet& proto) {
top_controls_delta = proto.top_controls_delta();
}
-inline gfx::Rect CalculateVisibleRectWithCachedLayerRect(
- const gfx::Rect& target_surface_rect,
- const gfx::Rect& layer_bound_rect,
- const gfx::Rect& layer_rect_in_target_space,
- const gfx::Transform& transform) {
- if (layer_rect_in_target_space.IsEmpty())
- return gfx::Rect();
-
- // Is this layer fully contained within the target surface?
- if (target_surface_rect.Contains(layer_rect_in_target_space))
- return layer_bound_rect;
-
- // If the layer doesn't fill up the entire surface, then find the part of
- // the surface rect where the layer could be visible. This avoids trying to
- // project surface rect points that are behind the projection point.
- gfx::Rect minimal_surface_rect = target_surface_rect;
- minimal_surface_rect.Intersect(layer_rect_in_target_space);
-
- if (minimal_surface_rect.IsEmpty())
- return gfx::Rect();
-
- // Project the corners of the target surface rect into the layer space.
- // This bounding rectangle may be larger than it needs to be (being
- // axis-aligned), but is a reasonable filter on the space to consider.
- // Non-invertible transforms will create an empty rect here.
-
- gfx::Transform surface_to_layer(gfx::Transform::kSkipInitialization);
- if (!transform.GetInverse(&surface_to_layer)) {
- // Because we cannot use the surface bounds to determine what portion of
- // the layer is visible, we must conservatively assume the full layer is
- // visible.
- return layer_bound_rect;
- }
-
- gfx::Rect layer_rect = MathUtil::ProjectEnclosingClippedRect(
- surface_to_layer, minimal_surface_rect);
- layer_rect.Intersect(layer_bound_rect);
- return layer_rect;
-}
-
-gfx::Rect LayerTreeHostCommon::CalculateVisibleRect(
- const gfx::Rect& target_surface_rect,
- const gfx::Rect& layer_bound_rect,
- const gfx::Transform& transform) {
- gfx::Rect layer_in_surface_space =
- MathUtil::MapEnclosingClippedRect(transform, layer_bound_rect);
- return CalculateVisibleRectWithCachedLayerRect(
- target_surface_rect, layer_bound_rect, layer_in_surface_space, transform);
-}
-
static inline bool IsRootLayer(const Layer* layer) {
return !layer->parent();
}
@@ -666,32 +616,10 @@ void CalculateRenderSurfaceLayerList(
layer->render_target()->AccumulateContentRectFromContributingLayer(layer);
if (render_to_separate_surface) {
- gfx::Rect surface_content_rect =
- layer->render_surface()->accumulated_content_rect();
-
- if (!layer->replica_layer() && !layer->HasCopyRequest() &&
- 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);
- }
- }
- // The RenderSurfaceImpl backing texture cannot exceed the maximum
- // supported texture size.
- surface_content_rect.set_width(
- std::min(surface_content_rect.width(), max_texture_size));
- surface_content_rect.set_height(
- std::min(surface_content_rect.height(), max_texture_size));
- layer->render_surface()->SetContentRect(surface_content_rect);
-
+ // Now all contributing drawable content rect has been accumulated to this
+ // render surface, calculate the content rect.
+ layer->render_surface()->CalculateContentRectFromAccumulatedContentRect(
+ max_texture_size);
// Now the render surface's content rect is calculated correctly, it could
// contribute to its render target.
layer->render_surface()
@@ -701,9 +629,7 @@ void CalculateRenderSurfaceLayerList(
}
} 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()->SetContentRect(viewport);
+ layer->render_surface()->SetContentRectToViewport();
}
if (render_to_separate_surface && !IsRootLayer(layer) &&

Powered by Google App Engine
This is Rietveld 408576698