Commit b43e8129 authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

Reland: Update cc layers when collecting layer tree for devtools

We use cc::Layer::ScreenSpaceTransform() when collecting layer tree
for devtools in layer list mode. We need to ensure the screen space
transforms are up-to-date before using them.

This is a reland of https://crrev.com/671720 which was rolled out in
https://crrev.com/677720 due to multiple UpdateLayers calls. Full layer
updates (e.g., with invalidation) are not needed for up-to-date
to-screen transforms.

Bug: 977578
Change-Id: I21a39a4198290c64e315c586c64a4da3a83da83d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1720791Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681382}
parent d9c73a42
...@@ -716,6 +716,10 @@ bool LayerTreeHost::UpdateLayers() { ...@@ -716,6 +716,10 @@ bool LayerTreeHost::UpdateLayers() {
return result; return result;
} }
void LayerTreeHost::UpdatePropertyTrees() {
draw_property_utils::UpdatePropertyTrees(this, &property_trees_);
}
void LayerTreeHost::DidPresentCompositorFrame( void LayerTreeHost::DidPresentCompositorFrame(
uint32_t frame_token, uint32_t frame_token,
std::vector<LayerTreeHost::PresentationTimeCallback> callbacks, std::vector<LayerTreeHost::PresentationTimeCallback> callbacks,
...@@ -847,7 +851,7 @@ bool LayerTreeHost::DoUpdateLayers() { ...@@ -847,7 +851,7 @@ bool LayerTreeHost::DoUpdateLayers() {
CHECK(property_trees_.effect_tree.Node(root_layer_->effect_tree_index())); CHECK(property_trees_.effect_tree.Node(root_layer_->effect_tree_index()));
#endif #endif
draw_property_utils::UpdatePropertyTrees(this, &property_trees_); UpdatePropertyTrees();
LayerList update_layer_list; LayerList update_layer_list;
draw_property_utils::FindLayersThatNeedUpdates(this, &property_trees_, draw_property_utils::FindLayersThatNeedUpdates(this, &property_trees_,
......
...@@ -586,6 +586,7 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient { ...@@ -586,6 +586,7 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
client_->DidReceiveCompositorFrameAck(); client_->DidReceiveCompositorFrameAck();
} }
bool UpdateLayers(); bool UpdateLayers();
void UpdatePropertyTrees();
void DidPresentCompositorFrame( void DidPresentCompositorFrame(
uint32_t frame_token, uint32_t frame_token,
std::vector<LayerTreeHost::PresentationTimeCallback> callbacks, std::vector<LayerTreeHost::PresentationTimeCallback> callbacks,
......
...@@ -173,13 +173,16 @@ BuildStickyInfoForLayer(const cc::Layer* root, const cc::Layer* layer) { ...@@ -173,13 +173,16 @@ BuildStickyInfoForLayer(const cc::Layer* root, const cc::Layer* layer) {
return constraints_obj; return constraints_obj;
} }
static bool IsUsingLayerLists(const cc::Layer* root) {
return root->layer_tree_host() &&
root->layer_tree_host()->IsUsingLayerLists();
}
static std::unique_ptr<protocol::LayerTree::Layer> BuildObjectForLayer( static std::unique_ptr<protocol::LayerTree::Layer> BuildObjectForLayer(
const cc::Layer* root, const cc::Layer* root,
const cc::Layer* layer, const cc::Layer* layer,
bool report_wheel_event_listeners) { bool report_wheel_event_listeners) {
bool using_layer_list = bool is_using_layer_lists = IsUsingLayerLists(root);
RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||
RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled();
// When the front-end doesn't show internal layers, it will use the the first // When the front-end doesn't show internal layers, it will use the the first
// DrawsContent layer as the root of the shown layer tree. This doesn't work // DrawsContent layer as the root of the shown layer tree. This doesn't work
...@@ -187,13 +190,13 @@ static std::unique_ptr<protocol::LayerTree::Layer> BuildObjectForLayer( ...@@ -187,13 +190,13 @@ static std::unique_ptr<protocol::LayerTree::Layer> BuildObjectForLayer(
// all DrawsContent layers. We have to cheat the front-end by setting // all DrawsContent layers. We have to cheat the front-end by setting
// drawsContent to true for the root layer. // drawsContent to true for the root layer.
bool draws_content = bool draws_content =
(using_layer_list && root == layer) || layer->DrawsContent(); (is_using_layer_lists && root == layer) || layer->DrawsContent();
std::unique_ptr<protocol::LayerTree::Layer> layer_object = std::unique_ptr<protocol::LayerTree::Layer> layer_object =
protocol::LayerTree::Layer::create() protocol::LayerTree::Layer::create()
.setLayerId(IdForLayer(layer)) .setLayerId(IdForLayer(layer))
.setOffsetX(using_layer_list ? 0 : layer->position().x()) .setOffsetX(is_using_layer_lists ? 0 : layer->position().x())
.setOffsetY(using_layer_list ? 0 : layer->position().y()) .setOffsetY(is_using_layer_lists ? 0 : layer->position().y())
.setWidth(layer->bounds().width()) .setWidth(layer->bounds().width())
.setHeight(layer->bounds().height()) .setHeight(layer->bounds().height())
.setPaintCount(layer->paint_count()) .setPaintCount(layer->paint_count())
...@@ -208,7 +211,7 @@ static std::unique_ptr<protocol::LayerTree::Layer> BuildObjectForLayer( ...@@ -208,7 +211,7 @@ static std::unique_ptr<protocol::LayerTree::Layer> BuildObjectForLayer(
gfx::Transform transform; gfx::Transform transform;
gfx::Point3F transform_origin; gfx::Point3F transform_origin;
if (using_layer_list) { if (is_using_layer_lists) {
transform = layer->ScreenSpaceTransform(); transform = layer->ScreenSpaceTransform();
} else { } else {
transform = layer->transform(); transform = layer->transform();
...@@ -348,6 +351,11 @@ InspectorLayerTreeAgent::BuildLayerTree() { ...@@ -348,6 +351,11 @@ InspectorLayerTreeAgent::BuildLayerTree() {
root_frame, cc::EventListenerClass::kMouseWheel) == root_frame, cc::EventListenerClass::kMouseWheel) ==
cc::EventListenerProperties::kBlocking; cc::EventListenerProperties::kBlocking;
if (IsUsingLayerLists(root_layer)) {
// The property trees must be updated for correct screen space transforms.
root_layer->layer_tree_host()->UpdatePropertyTrees();
}
GatherLayers(root_layer, layers, have_blocking_wheel_event_handlers, GatherLayers(root_layer, layers, have_blocking_wheel_event_handlers,
scrolling_layer_id); scrolling_layer_id);
return layers; return layers;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
(async function() { (async function() {
TestRunner.addResult(`Tests hit testing in Layers3DView\n`); TestRunner.addResult(`Tests hit testing in Layers3DView\n`);
await TestRunner.loadModule('layers_test_runner'); await TestRunner.loadModule('layers_test_runner');
await TestRunner.showPanel('layers');
await TestRunner.loadHTML(` await TestRunner.loadHTML(`
<div id="a" style="transform:translateZ(0px) translateY(60px) rotateZ(45deg);width:300px;height:300px;margin-left:100px; border: 1px solid black;"> <div id="a" style="transform:translateZ(0px) translateY(60px) rotateZ(45deg);width:300px;height:300px;margin-left:100px; border: 1px solid black;">
...@@ -18,7 +19,6 @@ ...@@ -18,7 +19,6 @@
var canvas; var canvas;
const ButtonByEventType = {mousemove: -1, mousedown: 0, mouseup: 0}; const ButtonByEventType = {mousemove: -1, mousedown: 0, mouseup: 0};
TestRunner.showPanel('layers');
await LayersTestRunner.requestLayers(); await LayersTestRunner.requestLayers();
initLayers(); initLayers();
initSizes(); initSizes();
......
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