summaryrefslogtreecommitdiffstats
path: root/cc/trees
diff options
context:
space:
mode:
authorajuma <ajuma@chromium.org>2015-11-04 17:06:55 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-05 01:07:52 +0000
commit962aa72eda10fe9e05fc6b800a430ee2bedca9f0 (patch)
treecc8e7ee9000cc338e922ea3932aa9325ac826064 /cc/trees
parent4f5d484cfe4e2bb268dd479b6fbc23963aac564b (diff)
downloadchromium_src-962aa72eda10fe9e05fc6b800a430ee2bedca9f0.zip
chromium_src-962aa72eda10fe9e05fc6b800a430ee2bedca9f0.tar.gz
chromium_src-962aa72eda10fe9e05fc6b800a430ee2bedca9f0.tar.bz2
Add a flag for enabling compositor property trees
This adds a command-line flag and LayerTreeSetting for enabling compositor property trees. BUG=545587 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1413153014 Cr-Commit-Position: refs/heads/master@{#357965}
Diffstat (limited to 'cc/trees')
-rw-r--r--cc/trees/draw_property_utils.cc28
-rw-r--r--cc/trees/draw_property_utils.h4
-rw-r--r--cc/trees/layer_tree_host_common.cc96
-rw-r--r--cc/trees/layer_tree_host_common.h2
-rw-r--r--cc/trees/layer_tree_host_common_perftest.cc4
-rw-r--r--cc/trees/layer_tree_impl.cc42
-rw-r--r--cc/trees/layer_tree_settings.cc1
-rw-r--r--cc/trees/layer_tree_settings.h1
8 files changed, 126 insertions, 52 deletions
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc
index 402a1d5..1f59140 100644
--- a/cc/trees/draw_property_utils.cc
+++ b/cc/trees/draw_property_utils.cc
@@ -599,7 +599,8 @@ void ComputeVisibleRectsUsingPropertyTreesInternal(
LayerType* root_layer,
PropertyTrees* property_trees,
bool can_render_to_separate_surface,
- typename LayerType::LayerListType* update_layer_list) {
+ typename LayerType::LayerListType* update_layer_list,
+ std::vector<LayerType*>* visible_layer_list) {
if (property_trees->non_root_surfaces_enabled !=
can_render_to_separate_surface) {
property_trees->non_root_surfaces_enabled = can_render_to_separate_surface;
@@ -613,12 +614,11 @@ void ComputeVisibleRectsUsingPropertyTreesInternal(
ComputeOpacities(&property_trees->effect_tree);
const bool subtree_is_visible_from_ancestor = true;
- std::vector<LayerType*> visible_layer_list;
FindLayersThatNeedUpdates(root_layer, property_trees->transform_tree,
subtree_is_visible_from_ancestor, update_layer_list,
- &visible_layer_list);
+ visible_layer_list);
CalculateVisibleRects<LayerType>(
- visible_layer_list, property_trees->clip_tree,
+ *visible_layer_list, property_trees->clip_tree,
property_trees->transform_tree, can_render_to_separate_surface);
}
@@ -654,32 +654,34 @@ void BuildPropertyTreesAndComputeVisibleRects(
const gfx::Transform& device_transform,
bool can_render_to_separate_surface,
PropertyTrees* property_trees,
- LayerImplList* update_layer_list) {
+ LayerImplList* visible_layer_list) {
PropertyTreeBuilder::BuildPropertyTrees(
root_layer, page_scale_layer, inner_viewport_scroll_layer,
outer_viewport_scroll_layer, page_scale_factor, device_scale_factor,
viewport, device_transform, property_trees);
ComputeVisibleRectsUsingPropertyTrees(root_layer, property_trees,
can_render_to_separate_surface,
- update_layer_list);
+ visible_layer_list);
}
void ComputeVisibleRectsUsingPropertyTrees(Layer* root_layer,
PropertyTrees* property_trees,
bool can_render_to_separate_surface,
LayerList* update_layer_list) {
- ComputeVisibleRectsUsingPropertyTreesInternal(root_layer, property_trees,
- can_render_to_separate_surface,
- update_layer_list);
+ std::vector<Layer*> visible_layer_list;
+ ComputeVisibleRectsUsingPropertyTreesInternal(
+ root_layer, property_trees, can_render_to_separate_surface,
+ update_layer_list, &visible_layer_list);
}
void ComputeVisibleRectsUsingPropertyTrees(LayerImpl* root_layer,
PropertyTrees* property_trees,
bool can_render_to_separate_surface,
- LayerImplList* update_layer_list) {
- ComputeVisibleRectsUsingPropertyTreesInternal(root_layer, property_trees,
- can_render_to_separate_surface,
- update_layer_list);
+ LayerImplList* visible_layer_list) {
+ LayerImplList update_layer_list;
+ ComputeVisibleRectsUsingPropertyTreesInternal(
+ root_layer, property_trees, can_render_to_separate_surface,
+ &update_layer_list, visible_layer_list);
}
template <typename LayerType>
diff --git a/cc/trees/draw_property_utils.h b/cc/trees/draw_property_utils.h
index 13dc9ae..5c99458 100644
--- a/cc/trees/draw_property_utils.h
+++ b/cc/trees/draw_property_utils.h
@@ -65,7 +65,7 @@ void CC_EXPORT BuildPropertyTreesAndComputeVisibleRects(
const gfx::Transform& device_transform,
bool can_render_to_separate_surface,
PropertyTrees* property_trees,
- LayerImplList* update_layer_list);
+ LayerImplList* visible_layer_list);
void CC_EXPORT
ComputeVisibleRectsUsingPropertyTrees(Layer* root_layer,
@@ -77,7 +77,7 @@ void CC_EXPORT
ComputeVisibleRectsUsingPropertyTrees(LayerImpl* root_layer,
PropertyTrees* property_trees,
bool can_render_to_separate_surface,
- LayerImplList* update_layer_list);
+ LayerImplList* visible_layer_list);
void CC_EXPORT ComputeLayerDrawPropertiesUsingPropertyTrees(
const LayerImpl* layer,
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 5fcf03d..4d14ff7 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -79,6 +79,7 @@ LayerTreeHostCommon::CalcDrawPropsImplInputs::CalcDrawPropsImplInputs(
bool can_render_to_separate_surface,
bool can_adjust_raster_scales,
bool verify_property_trees,
+ bool use_property_trees,
LayerImplList* render_surface_layer_list,
int current_render_surface_layer_list_id,
PropertyTrees* property_trees)
@@ -99,6 +100,7 @@ LayerTreeHostCommon::CalcDrawPropsImplInputs::CalcDrawPropsImplInputs(
can_render_to_separate_surface(can_render_to_separate_surface),
can_adjust_raster_scales(can_adjust_raster_scales),
verify_property_trees(verify_property_trees),
+ use_property_trees(use_property_trees),
render_surface_layer_list(render_surface_layer_list),
current_render_surface_layer_list_id(
current_render_surface_layer_list_id),
@@ -125,6 +127,7 @@ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting::
true,
false,
true,
+ false,
render_surface_layer_list,
0,
GetPropertyTrees(root_layer)) {
@@ -2435,7 +2438,8 @@ void CalculateRenderSurfaceLayerListInternal(
const bool can_render_to_separate_surface,
const int current_render_surface_layer_list_id,
const int max_texture_size,
- const bool verify_property_trees) {
+ const bool verify_property_trees,
+ const bool use_property_trees) {
// This calculates top level Render Surface Layer List, and Layer List for all
// Render Surfaces.
@@ -2480,6 +2484,26 @@ void CalculateRenderSurfaceLayerListInternal(
layer->draw_properties().render_target = nullptr;
return;
}
+
+ if (use_property_trees) {
+ RenderSurfaceDrawProperties draw_properties;
+ ComputeSurfaceDrawPropertiesUsingPropertyTrees(
+ layer->render_surface(), property_trees, &draw_properties);
+ // TODO(ajuma): Once property tree verification is removed, make the above
+ // call directly set the surface's properties, so that the copying below
+ // is no longer needed.
+ layer->render_surface()->SetIsClipped(draw_properties.is_clipped);
+ layer->render_surface()->SetDrawOpacity(draw_properties.draw_opacity);
+ layer->render_surface()->SetDrawTransform(draw_properties.draw_transform);
+ layer->render_surface()->SetScreenSpaceTransform(
+ draw_properties.screen_space_transform);
+ layer->render_surface()->SetReplicaDrawTransform(
+ draw_properties.replica_draw_transform);
+ layer->render_surface()->SetReplicaScreenSpaceTransform(
+ draw_properties.replica_screen_space_transform);
+ layer->render_surface()->SetClipRect(draw_properties.clip_rect);
+ }
+
if (IsRootLayer(layer)) {
// The root surface does not contribute to any other surface, it has no
// target.
@@ -2521,8 +2545,10 @@ void CalculateRenderSurfaceLayerListInternal(
descendants->push_back(layer);
}
+ bool compute_content_rects = verify_property_trees || use_property_trees;
+
// Clear the old accumulated content rect of surface.
- if (verify_property_trees && render_to_separate_surface)
+ if (compute_content_rects && render_to_separate_surface)
layer->render_surface()->SetAccumulatedContentRect(gfx::Rect());
for (auto& child_layer : layer->children()) {
@@ -2530,7 +2556,7 @@ void CalculateRenderSurfaceLayerListInternal(
child_layer, property_trees, render_surface_layer_list, descendants,
nearest_occlusion_immune_ancestor, layer_is_drawn,
can_render_to_separate_surface, current_render_surface_layer_list_id,
- max_texture_size, verify_property_trees);
+ max_texture_size, verify_property_trees, use_property_trees);
// If the child is its own render target, then it has a render surface.
if (child_layer->render_target() == child_layer &&
@@ -2559,7 +2585,7 @@ void CalculateRenderSurfaceLayerListInternal(
// 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 (compute_content_rects) {
if (!IsRootLayer(layer)) {
if (render_to_separate_surface) {
gfx::Rect surface_content_rect =
@@ -2590,8 +2616,12 @@ void CalculateRenderSurfaceLayerListInternal(
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()->SetContentRectFromPropertyTrees(
- surface_content_rect);
+ if (use_property_trees)
+ layer->render_surface()->SetContentRect(surface_content_rect);
+ if (verify_property_trees) {
+ layer->render_surface()->SetContentRectFromPropertyTrees(
+ surface_content_rect);
+ }
}
const LayerImpl* parent_target = layer->parent()->render_target();
if (!IsRootLayer(parent_target)) {
@@ -2616,7 +2646,10 @@ void CalculateRenderSurfaceLayerListInternal(
// 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 (use_property_trees)
+ layer->render_surface()->SetContentRect(viewport);
+ if (verify_property_trees)
+ layer->render_surface()->SetContentRectFromPropertyTrees(viewport);
}
}
@@ -2653,17 +2686,25 @@ void CalculateRenderSurfaceLayerList(
inputs->render_surface_layer_list, nullptr, nullptr,
subtree_visible_from_ancestor, inputs->can_render_to_separate_surface,
inputs->current_render_surface_layer_list_id, inputs->max_texture_size,
- inputs->verify_property_trees);
+ inputs->verify_property_trees, inputs->use_property_trees);
+}
+
+static void ComputeMaskLayerDrawProperties(const LayerImpl* layer,
+ LayerImpl* mask_layer) {
+ DrawProperties& mask_layer_draw_properties = mask_layer->draw_properties();
+ mask_layer_draw_properties.visible_layer_rect = gfx::Rect(layer->bounds());
+ mask_layer_draw_properties.target_space_transform = layer->draw_transform();
+ mask_layer_draw_properties.maximum_animation_contents_scale =
+ layer->draw_properties().maximum_animation_contents_scale;
+ mask_layer_draw_properties.starting_animation_contents_scale =
+ layer->draw_properties().starting_animation_contents_scale;
}
void CalculateDrawPropertiesAndVerify(
LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs,
PropertyTreeOption property_tree_option) {
- SubtreeGlobals globals;
- DataForRecursion data_for_recursion;
inputs->render_surface_layer_list->clear();
- ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
UpdateMetaInformationSequenceNumber(inputs->root_layer);
PreCalculateMetaInformationRecursiveData recursive_data;
PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data);
@@ -2672,9 +2713,8 @@ void CalculateDrawPropertiesAndVerify(
inputs->verify_property_trees &&
(property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED);
- if (inputs->verify_property_trees) {
- LayerImplList update_layer_list;
-
+ LayerImplList visible_layer_list;
+ if (inputs->verify_property_trees || inputs->use_property_trees) {
switch (property_tree_option) {
case BUILD_PROPERTY_TREES_IF_NEEDED: {
// The translation from layer to property trees is an intermediate
@@ -2693,7 +2733,7 @@ void CalculateDrawPropertiesAndVerify(
inputs->device_scale_factor,
gfx::Rect(inputs->device_viewport_size), inputs->device_transform,
inputs->can_render_to_separate_surface, inputs->property_trees,
- &update_layer_list);
+ &visible_layer_list);
if (should_measure_property_tree_performance) {
TRACE_EVENT_END0(
@@ -2725,7 +2765,7 @@ void CalculateDrawPropertiesAndVerify(
inputs->device_transform);
ComputeVisibleRectsUsingPropertyTrees(
inputs->root_layer, inputs->property_trees,
- inputs->can_render_to_separate_surface, &update_layer_list);
+ inputs->can_render_to_separate_surface, &visible_layer_list);
break;
}
}
@@ -2738,9 +2778,27 @@ void CalculateDrawPropertiesAndVerify(
std::vector<AccumulatedSurfaceState> accumulated_surface_state;
CalculateRenderTarget(inputs);
- CalculateDrawPropertiesInternal(inputs->root_layer, globals,
- data_for_recursion,
- &accumulated_surface_state);
+ if (inputs->use_property_trees) {
+ for (LayerImpl* layer : visible_layer_list) {
+ ComputeLayerDrawPropertiesUsingPropertyTrees(
+ layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text,
+ inputs->can_use_lcd_text, &layer->draw_properties());
+ if (layer->mask_layer())
+ ComputeMaskLayerDrawProperties(layer, layer->mask_layer());
+ LayerImpl* replica_mask_layer = layer->replica_layer()
+ ? layer->replica_layer()->mask_layer()
+ : nullptr;
+ if (replica_mask_layer)
+ ComputeMaskLayerDrawProperties(layer, replica_mask_layer);
+ }
+ } else {
+ SubtreeGlobals globals;
+ DataForRecursion data_for_recursion;
+ ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
+ CalculateDrawPropertiesInternal(inputs->root_layer, globals,
+ data_for_recursion,
+ &accumulated_surface_state);
+ }
CalculateRenderSurfaceLayerList(inputs);
if (should_measure_property_tree_performance) {
diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h
index 814833d..7593314 100644
--- a/cc/trees/layer_tree_host_common.h
+++ b/cc/trees/layer_tree_host_common.h
@@ -75,6 +75,7 @@ class CC_EXPORT LayerTreeHostCommon {
bool can_render_to_separate_surface,
bool can_adjust_raster_scales,
bool verify_property_trees,
+ bool use_property_trees,
LayerImplList* render_surface_layer_list,
int current_render_surface_layer_list_id,
PropertyTrees* property_trees);
@@ -95,6 +96,7 @@ class CC_EXPORT LayerTreeHostCommon {
bool can_render_to_separate_surface;
bool can_adjust_raster_scales;
bool verify_property_trees;
+ bool use_property_trees;
LayerImplList* render_surface_layer_list;
int current_render_surface_layer_list_id;
PropertyTrees* property_trees;
diff --git a/cc/trees/layer_tree_host_common_perftest.cc b/cc/trees/layer_tree_host_common_perftest.cc
index f326ec2..357db7c 100644
--- a/cc/trees/layer_tree_host_common_perftest.cc
+++ b/cc/trees/layer_tree_host_common_perftest.cc
@@ -108,6 +108,7 @@ class CalcDrawPropsTest : public LayerTreeHostCommonPerfTest {
LayerImplList update_list;
PropertyTrees property_trees;
bool verify_property_trees = false;
+ bool use_property_trees = false;
LayerTreeHostCommon::CalcDrawPropsImplInputs inputs(
active_tree->root_layer(), active_tree->DrawViewportSize(),
host_impl->DrawTransform(), active_tree->device_scale_factor(),
@@ -121,7 +122,8 @@ class CalcDrawPropsTest : public LayerTreeHostCommonPerfTest {
host_impl->settings().layers_always_allowed_lcd_text,
can_render_to_separate_surface,
host_impl->settings().layer_transforms_should_scale_layer_contents,
- verify_property_trees, &update_list, 0, &property_trees);
+ verify_property_trees, use_property_trees, &update_list, 0,
+ &property_trees);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
}
};
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index c9b4dbc..2ba6ade 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -648,8 +648,9 @@ bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) {
settings().can_use_lcd_text, settings().layers_always_allowed_lcd_text,
can_render_to_separate_surface,
settings().layer_transforms_should_scale_layer_contents,
- settings().verify_property_trees, &render_surface_layer_list_,
- render_surface_layer_list_id_, &property_trees_);
+ settings().verify_property_trees, settings().use_property_trees,
+ &render_surface_layer_list_, render_surface_layer_list_id_,
+ &property_trees_);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
}
@@ -1540,10 +1541,11 @@ struct FindScrollingLayerFunctor {
LayerImpl* LayerTreeImpl::FindFirstScrollingLayerThatIsHitByPoint(
const gfx::PointF& screen_space_point) {
FindClosestMatchingLayerDataForRecursion data_for_recursion;
+ bool use_property_trees =
+ settings().use_property_trees || settings().verify_property_trees;
FindClosestMatchingLayer(
screen_space_point, root_layer(), FindScrollingLayerFunctor(),
- property_trees_.transform_tree, settings().verify_property_trees,
- &data_for_recursion);
+ property_trees_.transform_tree, use_property_trees, &data_for_recursion);
return data_for_recursion.closest_match;
}
@@ -1563,11 +1565,12 @@ LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint(
bool update_lcd_text = false;
if (!UpdateDrawProperties(update_lcd_text))
return NULL;
+ bool use_property_trees =
+ settings().use_property_trees || settings().verify_property_trees;
FindClosestMatchingLayerDataForRecursion data_for_recursion;
FindClosestMatchingLayer(screen_space_point, root_layer(),
HitTestVisibleScrollableOrTouchableFunctor(),
- property_trees_.transform_tree,
- settings().verify_property_trees,
+ property_trees_.transform_tree, use_property_trees,
&data_for_recursion);
return data_for_recursion.closest_match;
}
@@ -1609,11 +1612,13 @@ LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint(
bool update_lcd_text = false;
if (!UpdateDrawProperties(update_lcd_text))
return NULL;
+ bool use_property_trees =
+ settings().use_property_trees || settings().verify_property_trees;
FindWheelEventLayerFunctor func;
FindClosestMatchingLayerDataForRecursion data_for_recursion;
- FindClosestMatchingLayer(
- screen_space_point, root_layer(), func, property_trees_.transform_tree,
- settings().verify_property_trees, &data_for_recursion);
+ FindClosestMatchingLayer(screen_space_point, root_layer(), func,
+ property_trees_.transform_tree, use_property_trees,
+ &data_for_recursion);
return data_for_recursion.closest_match;
}
@@ -1634,13 +1639,14 @@ LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion(
bool update_lcd_text = false;
if (!UpdateDrawProperties(update_lcd_text))
return NULL;
- FindTouchEventLayerFunctor func = {screen_space_point,
- property_trees_.transform_tree,
- settings().verify_property_trees};
+ bool use_property_trees =
+ settings().use_property_trees || settings().verify_property_trees;
+ FindTouchEventLayerFunctor func = {
+ screen_space_point, property_trees_.transform_tree, use_property_trees};
FindClosestMatchingLayerDataForRecursion data_for_recursion;
- FindClosestMatchingLayer(
- screen_space_point, root_layer(), func, property_trees_.transform_tree,
- settings().verify_property_trees, &data_for_recursion);
+ FindClosestMatchingLayer(screen_space_point, root_layer(), func,
+ property_trees_.transform_tree, use_property_trees,
+ &data_for_recursion);
return data_for_recursion.closest_match;
}
@@ -1707,11 +1713,13 @@ static ViewportSelectionBound ComputeViewportSelectionBound(
void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) {
DCHECK(selection);
+ bool use_property_trees =
+ settings().use_property_trees || settings().verify_property_trees;
selection->start = ComputeViewportSelectionBound(
selection_.start,
selection_.start.layer_id ? LayerById(selection_.start.layer_id) : NULL,
device_scale_factor(), property_trees_.transform_tree,
- settings().verify_property_trees);
+ use_property_trees);
selection->is_editable = selection_.is_editable;
selection->is_empty_text_form_control = selection_.is_empty_text_form_control;
if (selection->start.type == SELECTION_BOUND_CENTER ||
@@ -1722,7 +1730,7 @@ void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) {
selection_.end,
selection_.end.layer_id ? LayerById(selection_.end.layer_id) : NULL,
device_scale_factor(), property_trees_.transform_tree,
- settings().verify_property_trees);
+ use_property_trees);
}
}
diff --git a/cc/trees/layer_tree_settings.cc b/cc/trees/layer_tree_settings.cc
index 751b31c..dcafd87 100644
--- a/cc/trees/layer_tree_settings.cc
+++ b/cc/trees/layer_tree_settings.cc
@@ -66,6 +66,7 @@ LayerTreeSettings::LayerTreeSettings()
use_occlusion_for_tile_prioritization(false),
record_full_layer(false),
verify_property_trees(false),
+ use_property_trees(false),
image_decode_tasks_enabled(false),
use_compositor_animation_timelines(false),
wait_for_beginframe_interval(true),
diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h
index e6d467f..822de1d 100644
--- a/cc/trees/layer_tree_settings.h
+++ b/cc/trees/layer_tree_settings.h
@@ -81,6 +81,7 @@ class CC_EXPORT LayerTreeSettings {
bool use_occlusion_for_tile_prioritization;
bool record_full_layer;
bool verify_property_trees;
+ bool use_property_trees;
bool image_decode_tasks_enabled;
bool use_compositor_animation_timelines;
bool wait_for_beginframe_interval;