Commit 73fe3c43 authored by Weiliang Chen's avatar Weiliang Chen Committed by Commit Bot

cc: Compute |visible_rect| for tiled mask layers to limit raster

For single tile mask layers |visible_rect| is only used as bool to
check for non empty. For tiled mask layers correct |visible_rect| is
needed to limit the amount of resource we generated for raster the
tiled masks. This bug was discovered when we have a tiled mask layer
with big scale and we try to create tiles to covered enlarged space
and eventually OOM.

Compute |visible_rect| correctly results in breaking the assumption
that tiled mask layer's |to_target| is only a scale. This changes the
computation in |RenderSurfaceImpl| of how to convert tile quads into
tiled mask render pass quads.

This CL is aimed to fix release blocking bug and thus has limited
scoped. There are two potential follow-ups: check for scale of tiled
mask layer, and adjust render surface rect.

For scale check: ideally tiled mask layer should be in the same
space as the render surface, this should simplify computation when
converting from tiled quads to render pass quads.

For render surface rect: it does not make sense for render surface to
have different size than the mask layer's visible rect. Right now
render surfaces are unclipped and bounded by maxium texture size, while
tiled mask visible size is clipped. To make these two sizes match there
needs more investigation into whether unit tests still make sense, and
should be in another CL.


R=danakj

Bug: 820727
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I62c7c992d99088c1f8cdbe4ffbac520b0a7d1a53
Reviewed-on: https://chromium-review.googlesource.com/1037629
Commit-Queue: weiliangc <weiliangc@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557985}
parent ac91857b
......@@ -678,6 +678,7 @@ cc_test("cc_unittests") {
"trees/layer_tree_host_unittest_context.cc",
"trees/layer_tree_host_unittest_copyrequest.cc",
"trees/layer_tree_host_unittest_damage.cc",
"trees/layer_tree_host_unittest_masks.cc",
"trees/layer_tree_host_unittest_occlusion.cc",
"trees/layer_tree_host_unittest_picture.cc",
"trees/layer_tree_host_unittest_proxy.cc",
......
......@@ -163,11 +163,20 @@ class CC_EXPORT PictureLayerImpl
scoped_refptr<RasterSource> raster_source_;
Region invalidation_;
// Ideal scales are calcuated from the transforms applied to the layer. They
// represent the best known scale from the layer to the final output.
// Page scale is from user pinch/zoom.
float ideal_page_scale_;
// Device scale is from screen dpi, and it comes from device scale facter.
float ideal_device_scale_;
// Source scale comes from javascript css scale.
float ideal_source_scale_;
// Contents scale = device scale * page scale * source scale.
float ideal_contents_scale_;
// Raster scales are set from ideal scales. They are scales we choose to
// raster at. They may not match the ideal scales at times to avoid raster for
// performance reasons.
float raster_page_scale_;
float raster_device_scale_;
float raster_source_scale_;
......
This diff is collapsed.
......@@ -189,7 +189,7 @@ class CC_EXPORT RenderSurfaceImpl {
const gfx::Transform& target_to_surface);
void TileMaskLayer(viz::RenderPass* render_pass,
viz::SharedQuadState* shared_quad_state,
const gfx::Rect& visible_layer_rect);
const gfx::Rect& unoccluded_content_rect);
LayerTreeImpl* layer_tree_impl_;
uint64_t stable_id_;
......
......@@ -153,8 +153,11 @@ TEST(RenderSurfaceLayerImplTest,
viz::RenderPassDrawQuad::MaterialCast(render_pass->quad_list.front());
EXPECT_EQ(gfx::Transform(),
quad->shared_quad_state->quad_to_target_transform);
// With tiled mask layer, we only generate mask quads for visible rect. In
// this case |quad_layer_rect| is not fully covered, but
// |visible_quad_layer_rect| is fully covered.
LayerTestCommon::VerifyQuadsExactlyCoverRect(
render_pass->quad_list, quad->shared_quad_state->quad_layer_rect);
render_pass->quad_list, quad->shared_quad_state->visible_quad_layer_rect);
}
} // namespace
......
......@@ -245,6 +245,8 @@ TEST(RenderSurfaceTest, SanityCheckSurfaceDropsOccludedRenderPassDrawQuads) {
std::unique_ptr<LayerTreeFrameSink> layer_tree_frame_sink =
FakeLayerTreeFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
// Set a big enough viewport to show the entire render pass.
host_impl.SetViewportSize(gfx::Size(1000, 1000));
std::unique_ptr<LayerImpl> root_layer =
LayerImpl::Create(host_impl.active_tree(), 1);
......@@ -312,6 +314,8 @@ TEST(RenderSurfaceTest, SanityCheckSurfaceIgnoreMaskLayerOcclusion) {
std::unique_ptr<LayerTreeFrameSink> layer_tree_frame_sink =
FakeLayerTreeFrameSink::Create3d();
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
// Set a big enough viewport to show the entire render pass.
host_impl.SetViewportSize(gfx::Size(1000, 1000));
std::unique_ptr<LayerImpl> root_layer =
LayerImpl::Create(host_impl.active_tree(), 1);
......
......@@ -1004,7 +1004,7 @@ void ComputeDrawPropertiesOfVisibleLayers(const LayerImplList* layer_list,
}
void ComputeMaskDrawProperties(LayerImpl* mask_layer,
const PropertyTrees* property_trees) {
PropertyTrees* property_trees) {
// Mask draw properties are used only for rastering, so most of the draw
// properties computed for other layers are not needed.
// Draw transform of a mask layer has to be a 2d scale.
......@@ -1016,8 +1016,17 @@ void ComputeMaskDrawProperties(LayerImpl* mask_layer,
mask_layer->draw_properties().screen_space_transform =
ScreenSpaceTransformInternal(mask_layer,
property_trees->transform_tree);
ConditionalClip clip = LayerClipRect(property_trees, mask_layer);
// is_clipped should be set before visible rect computation as it is used
// there.
mask_layer->draw_properties().is_clipped = clip.is_clipped;
mask_layer->draw_properties().clip_rect =
gfx::ToEnclosingRect(clip.clip_rect);
// Calculate actual visible layer rect for mask layers, since we could have
// tiled mask layers and the tile manager would need this info for rastering.
mask_layer->draw_properties().visible_layer_rect =
gfx::Rect(mask_layer->bounds());
LayerVisibleRect(property_trees, mask_layer);
mask_layer->draw_properties().opacity = 1;
}
......
......@@ -59,7 +59,7 @@ ComputeDrawPropertiesOfVisibleLayers(const LayerImplList* layer_list,
PropertyTrees* property_trees);
void CC_EXPORT ComputeMaskDrawProperties(LayerImpl* mask_layer,
const PropertyTrees* property_trees);
PropertyTrees* property_trees);
void CC_EXPORT ComputeSurfaceDrawProperties(PropertyTrees* property_trees,
RenderSurfaceImpl* render_surface);
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment