Commit 1b5d37c4 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[CompositeAfterPaint] Plumb ViewportProperties and Settings to PaintArtifactCompositor

For now ViewportProperties contains the page scale node only, and
Settings contains prefer_compositing_to_lcd_text only. In the future
they will contain more properties/settings.

Change-Id: I760b79191aa25a8fc489aa9c4d9ab1dc1e6204fc
Reviewed-on: https://chromium-review.googlesource.com/c/1370278Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615442}
parent cceefec6
......@@ -2959,9 +2959,16 @@ void LocalFrameView::PushPaintArtifactToCompositor(
SCOPED_UMA_AND_UKM_TIMER(EnsureUkmAggregator(),
LocalFrameUkmAggregator::kCompositingCommit);
PaintArtifactCompositor::ViewportProperties viewport_properties;
viewport_properties.page_scale = page->GetVisualViewport().GetPageScaleNode();
PaintArtifactCompositor::Settings settings;
settings.prefer_compositing_to_lcd_text =
page->GetSettings().GetPreferCompositingToLCDTextEnabled();
paint_artifact_compositor_->Update(
paint_controller_->GetPaintArtifactShared(), composited_element_ids,
page->GetVisualViewport().GetPageScaleNode());
viewport_properties, settings);
}
std::unique_ptr<JSONObject> LocalFrameView::CompositedLayersAsJSON(
......
......@@ -519,6 +519,7 @@ static bool SkipGroupIfEffectivelyInvisible(
void PaintArtifactCompositor::LayerizeGroup(
const PaintArtifact& paint_artifact,
const Settings& settings,
Vector<PendingLayer>& pending_layers,
const EffectPaintPropertyNode& current_group,
Vector<PaintChunk>::const_iterator& chunk_it) {
......@@ -579,8 +580,8 @@ void PaintArtifactCompositor::LayerizeGroup(
// Case C: The following chunks belong to a subgroup. Process them by
// a recursion call.
wtf_size_t first_layer_in_subgroup = pending_layers.size();
LayerizeGroup(paint_artifact, pending_layers, *unaliased_subgroup,
chunk_it);
LayerizeGroup(paint_artifact, settings, pending_layers,
*unaliased_subgroup, chunk_it);
// Now the chunk iterator stepped over the subgroup we just saw.
// If the subgroup generated 2 or more layers then the subgroup must be
// composited to satisfy grouping requirement.
......@@ -625,11 +626,12 @@ void PaintArtifactCompositor::LayerizeGroup(
void PaintArtifactCompositor::CollectPendingLayers(
const PaintArtifact& paint_artifact,
const Settings& settings,
Vector<PendingLayer>& pending_layers) {
Vector<PaintChunk>::const_iterator cursor =
paint_artifact.PaintChunks().begin();
LayerizeGroup(paint_artifact, pending_layers, EffectPaintPropertyNode::Root(),
cursor);
LayerizeGroup(paint_artifact, settings, pending_layers,
EffectPaintPropertyNode::Root(), cursor);
DCHECK_EQ(paint_artifact.PaintChunks().end(), cursor);
}
......@@ -753,7 +755,8 @@ cc::Layer* PaintArtifactCompositor::CreateOrReuseSynthesizedClipLayer(
void PaintArtifactCompositor::Update(
scoped_refptr<const PaintArtifact> paint_artifact,
CompositorElementIdSet& composited_element_ids,
TransformPaintPropertyNode* viewport_scale_node) {
const ViewportProperties& viewport_properties,
const Settings& settings) {
DCHECK(root_layer_);
// The tree will be null after detaching and this update can be ignored.
......@@ -779,13 +782,13 @@ void PaintArtifactCompositor::Update(
PropertyTreeManager property_tree_manager(
*this, *host->property_trees(), root_layer_.get(), &layer_list_builder);
Vector<PendingLayer, 0> pending_layers;
CollectPendingLayers(*paint_artifact, pending_layers);
CollectPendingLayers(*paint_artifact, settings, pending_layers);
cc::LayerTreeHost::ViewportPropertyIds viewport_property_ids;
if (viewport_scale_node) {
if (viewport_properties.page_scale) {
viewport_property_ids.page_scale_transform =
property_tree_manager.EnsureCompositorPageScaleTransformNode(
viewport_scale_node);
viewport_properties.page_scale);
}
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
host->RegisterViewportPropertyIds(viewport_property_ids);
......
......@@ -69,13 +69,22 @@ class PLATFORM_EXPORT PaintArtifactCompositor final
new PaintArtifactCompositor(std::move(scroll_callback)));
}
struct ViewportProperties {
const TransformPaintPropertyNode* page_scale = nullptr;
};
struct Settings {
bool prefer_compositing_to_lcd_text = false;
};
// Updates the layer tree to match the provided paint artifact.
//
// Populates |composited_element_ids| with the CompositorElementId of all
// animations for which we saw a paint chunk and created a layer.
void Update(scoped_refptr<const PaintArtifact>,
CompositorElementIdSet& composited_element_ids,
TransformPaintPropertyNode* viewport_scale_node);
const ViewportProperties& viewport_properties,
const Settings& settings);
// The root layer of the tree managed by this object.
cc::Layer* RootLayer() const { return root_layer_.get(); }
......@@ -154,7 +163,9 @@ class PLATFORM_EXPORT PaintArtifactCompositor final
// Collects the PaintChunks into groups which will end up in the same
// cc layer. This is the entry point of the layerization algorithm.
void CollectPendingLayers(const PaintArtifact&,
const Settings& settings,
Vector<PendingLayer>& pending_layers);
// This is the internal recursion of collectPendingLayers. This function
// loops over the list of paint chunks, scoped by an isolated group
// (i.e. effect node). Inside of the loop, chunks are tested for overlap
......@@ -173,6 +184,7 @@ class PLATFORM_EXPORT PaintArtifactCompositor final
// overlap with other chunks in the parent group, if grouping requirement
// can be satisfied (and the effect node has no direct reason).
static void LayerizeGroup(const PaintArtifact&,
const Settings& settings,
Vector<PendingLayer>& pending_layers,
const EffectPaintPropertyNode&,
Vector<PaintChunk>::const_iterator& chunk_cursor);
......
......@@ -131,18 +131,16 @@ class PaintArtifactCompositorTest : public testing::Test,
Update(artifact, element_ids);
}
void Update(scoped_refptr<const PaintArtifact> artifact,
CompositorElementIdSet& element_ids) {
// Pass nullptr for the visual viewport paint property nodes since we're
// really just checking the internals of PaintArtifactCompositor.
Update(artifact, element_ids, nullptr);
}
void Update(scoped_refptr<const PaintArtifact> artifact,
CompositorElementIdSet& element_ids,
TransformPaintPropertyNode* viewport_scale_transform_node) {
using ViewportProperties = PaintArtifactCompositor::ViewportProperties;
using Settings = PaintArtifactCompositor::Settings;
void Update(
scoped_refptr<const PaintArtifact> artifact,
CompositorElementIdSet& element_ids,
const ViewportProperties& viewport_properties = ViewportProperties(),
const Settings& settings = Settings()) {
paint_artifact_compositor_->Update(artifact, element_ids,
viewport_scale_transform_node);
viewport_properties, settings);
layer_tree_->layer_tree_host()->LayoutAndUpdateLayers();
}
......@@ -3255,8 +3253,10 @@ TEST_P(PaintArtifactCompositorTest, CreatesViewportNodes) {
TransformPaintPropertyNode::Root(), std::move(transform_state));
TestPaintArtifact artifact;
ViewportProperties viewport_properties;
viewport_properties.page_scale = scale_transform_node.get();
CompositorElementIdSet element_ids;
Update(artifact.Build(), element_ids, scale_transform_node.get());
Update(artifact.Build(), element_ids, viewport_properties);
cc::TransformTree& transform_tree = GetPropertyTrees().transform_tree;
cc::TransformNode* cc_transform_node = transform_tree.FindNodeFromElementId(
......
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