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

Unified Diff: cc/trees/layer_tree_host_common.cc

Issue 1921503005: cc: Move main thread hierarchy dependencies into PropertyTreeBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 aef8d33d12be26734564bf6f9754f6b5f88f1ebd..55c2f45a3e5a1fa8ddf687d6db5bfb5da9756210 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -188,19 +188,6 @@ void ScrollAndScaleSet::FromProtobuf(const proto::ScrollAndScaleSet& proto) {
top_controls_delta = proto.top_controls_delta();
}
-static inline bool IsRootLayer(const Layer* layer) {
- return !layer->parent();
-}
-
-static bool HasInvertibleOrAnimatedTransform(Layer* layer) {
- return layer->transform_is_invertible() ||
- layer->HasPotentiallyRunningTransformAnimation();
-}
-
-static bool HasInvertibleOrAnimatedTransformForTesting(LayerImpl* layer) {
- return layer->transform().IsInvertible() ||
- layer->HasPotentiallyRunningTransformAnimation();
-}
static inline void SetMaskLayersAreDrawnRenderSurfaceLayerListMembers(
LayerImpl* layer) {
@@ -240,145 +227,6 @@ static inline void ClearIsDrawnRenderSurfaceLayerListMember(
}
}
-struct PreCalculateMetaInformationRecursiveData {
- size_t num_unclipped_descendants;
- int num_layer_or_descendants_with_copy_request;
- int num_layer_or_descendants_with_touch_handler;
- int num_descendants_that_draw_content;
-
- PreCalculateMetaInformationRecursiveData()
- : num_unclipped_descendants(0),
- num_layer_or_descendants_with_copy_request(0),
- num_layer_or_descendants_with_touch_handler(0),
- num_descendants_that_draw_content(0) {}
-
- void Merge(const PreCalculateMetaInformationRecursiveData& data) {
- num_layer_or_descendants_with_copy_request +=
- data.num_layer_or_descendants_with_copy_request;
- num_layer_or_descendants_with_touch_handler +=
- data.num_layer_or_descendants_with_touch_handler;
- num_unclipped_descendants += data.num_unclipped_descendants;
- num_descendants_that_draw_content += data.num_descendants_that_draw_content;
- }
-};
-
-static bool IsMetaInformationRecomputationNeeded(Layer* layer) {
- return layer->layer_tree_host()->needs_meta_info_recomputation();
-}
-
-static void UpdateMetaInformationSequenceNumber(Layer* root_layer) {
- root_layer->layer_tree_host()->IncrementMetaInformationSequenceNumber();
-}
-
-// Recursively walks the layer tree(if needed) to compute any information
-// that is needed before doing the main recursion.
-static void PreCalculateMetaInformationInternal(
- Layer* layer,
- PreCalculateMetaInformationRecursiveData* recursive_data) {
- if (!IsMetaInformationRecomputationNeeded(layer)) {
- DCHECK(IsRootLayer(layer));
- return;
- }
-
- if (layer->clip_parent())
- recursive_data->num_unclipped_descendants++;
-
- if (!HasInvertibleOrAnimatedTransform(layer)) {
- // Layers with singular transforms should not be drawn, the whole subtree
- // can be skipped.
- return;
- }
-
- for (size_t i = 0; i < layer->children().size(); ++i) {
- Layer* child_layer = layer->child_at(i);
-
- PreCalculateMetaInformationRecursiveData data_for_child;
- PreCalculateMetaInformationInternal(child_layer, &data_for_child);
- recursive_data->Merge(data_for_child);
- }
-
- if (layer->clip_children()) {
- size_t num_clip_children = layer->clip_children()->size();
- DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children);
- recursive_data->num_unclipped_descendants -= num_clip_children;
- }
-
- if (layer->HasCopyRequest())
- recursive_data->num_layer_or_descendants_with_copy_request++;
-
- if (!layer->touch_event_handler_region().IsEmpty())
- recursive_data->num_layer_or_descendants_with_touch_handler++;
-
- layer->set_num_unclipped_descendants(
- recursive_data->num_unclipped_descendants);
-
- if (IsRootLayer(layer))
- layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false);
-}
-
-static void PreCalculateMetaInformationInternalForTesting(
- LayerImpl* layer,
- PreCalculateMetaInformationRecursiveData* recursive_data) {
- if (layer->test_properties()->clip_parent)
- recursive_data->num_unclipped_descendants++;
-
- if (!HasInvertibleOrAnimatedTransformForTesting(layer)) {
- // Layers with singular transforms should not be drawn, the whole subtree
- // can be skipped.
- return;
- }
-
- for (size_t i = 0; i < layer->children().size(); ++i) {
- LayerImpl* child_layer = layer->child_at(i);
-
- PreCalculateMetaInformationRecursiveData data_for_child;
- PreCalculateMetaInformationInternalForTesting(child_layer, &data_for_child);
- recursive_data->Merge(data_for_child);
- }
-
- if (layer->test_properties()->clip_children) {
- size_t num_clip_children = layer->test_properties()->clip_children->size();
- DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children);
- recursive_data->num_unclipped_descendants -= num_clip_children;
- }
-
- if (layer->HasCopyRequest())
- recursive_data->num_layer_or_descendants_with_copy_request++;
-
- if (!layer->touch_event_handler_region().IsEmpty())
- recursive_data->num_layer_or_descendants_with_touch_handler++;
-
- layer->draw_properties().num_unclipped_descendants =
- recursive_data->num_unclipped_descendants;
- layer->set_layer_or_descendant_has_touch_handler(
- (recursive_data->num_layer_or_descendants_with_touch_handler != 0));
- // TODO(enne): this should be synced from the main thread, so is only
- // for tests constructing layers on the compositor thread.
- layer->test_properties()->num_descendants_that_draw_content =
- recursive_data->num_descendants_that_draw_content;
-
- if (layer->DrawsContent())
- recursive_data->num_descendants_that_draw_content++;
-}
-
-void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) {
- PreCalculateMetaInformationRecursiveData recursive_data;
- PreCalculateMetaInformationInternal(root_layer, &recursive_data);
-}
-
-void LayerTreeHostCommon::PreCalculateMetaInformationForTesting(
- LayerImpl* root_layer) {
- PreCalculateMetaInformationRecursiveData recursive_data;
- PreCalculateMetaInformationInternalForTesting(root_layer, &recursive_data);
-}
-
-void LayerTreeHostCommon::PreCalculateMetaInformationForTesting(
- Layer* root_layer) {
- UpdateMetaInformationSequenceNumber(root_layer);
- PreCalculateMetaInformationRecursiveData recursive_data;
- PreCalculateMetaInformationInternal(root_layer, &recursive_data);
-}
-
static bool CdpPerfTracingEnabled() {
bool tracing_enabled;
TRACE_EVENT_CATEGORY_GROUP_ENABLED("cdp.perf", &tracing_enabled);
@@ -842,11 +690,10 @@ void LayerTreeHostCommon::CalculateDrawProperties(
}
}
-void LayerTreeHostCommon::CalculateDrawProperties(
+void LayerTreeHostCommon::CalculateDrawPropertiesForTesting(
CalcDrawPropsImplInputsForTesting* inputs) {
- PreCalculateMetaInformationRecursiveData recursive_data;
- PreCalculateMetaInformationInternalForTesting(inputs->root_layer,
- &recursive_data);
+ PropertyTreeBuilder::PreCalculateMetaInformationForTesting(
+ inputs->root_layer);
CalculateDrawPropertiesInternal(inputs, BUILD_PROPERTY_TREES_IF_NEEDED);
}
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698