Commit 679b0b3a authored by jongdeok.kim's avatar jongdeok.kim Committed by Commit Bot

Reland: Disallow LCD text for backdrop filter

In this CL, all effect node that is affected by backdrop filter is marked.
So that the layer can find the LCD text disallowed reason for the backdrop filter.

Bug: 1115564
Change-Id: Iad23ca619d21d7436786fe9d6e112a198ca638d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404908
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806659}
parent e9a93954
......@@ -873,7 +873,8 @@ LCDTextDisallowedReason PictureLayerImpl::ComputeLCDTextDisallowedReason(
return LCDTextDisallowedReason::kTransformAnimation;
EffectNode* effect_node = GetEffectTree().Node(effect_tree_index());
if (effect_node->node_or_ancestor_has_filters)
if (effect_node->node_or_ancestor_has_filters ||
effect_node->affected_by_backdrop_filter)
return LCDTextDisallowedReason::kPixelOrColorEffect;
return LCDTextDisallowedReason::kNone;
......
......@@ -6412,6 +6412,22 @@ TEST_P(LCDTextTest, Filter) {
CheckCanUseLCDText(LCDTextDisallowedReason::kNone, "no filter");
}
TEST_P(LCDTextTest, BackdropFilter) {
FilterOperations backdrop_filter;
backdrop_filter.Append(FilterOperation::CreateBlurFilter(4.0f));
SetBackdropFilter(descendant_, backdrop_filter);
UpdateDrawProperties(host_impl()->active_tree());
CheckCanUseLCDText(LCDTextDisallowedReason::kPixelOrColorEffect,
"backdrop-filter", layer_);
CheckCanUseLCDText(LCDTextDisallowedReason::kNone, "backdrop-filter",
descendant_);
SetBackdropFilter(descendant_, FilterOperations());
UpdateDrawProperties(host_impl()->active_tree());
CheckCanUseLCDText(LCDTextDisallowedReason::kNone, "no backdrop-filter",
layer_);
}
TEST_P(LCDTextTest, ContentsOpaqueForText) {
layer_->SetContentsOpaque(false);
layer_->SetBackgroundColor(SK_ColorGREEN);
......
......@@ -765,6 +765,7 @@ std::pair<gfx::RRectF, bool> GetRoundedCornerRRect(
}
void UpdateRenderTarget(EffectTree* effect_tree) {
int last_backdrop_filter = kInvalidNodeId;
for (int i = EffectTree::kContentsRootNodeId;
i < static_cast<int>(effect_tree->size()); ++i) {
EffectNode* node = effect_tree->Node(i);
......@@ -776,6 +777,27 @@ void UpdateRenderTarget(EffectTree* effect_tree) {
} else {
node->target_id = effect_tree->parent(node)->target_id;
}
if (!node->backdrop_filters.IsEmpty())
last_backdrop_filter = node->id;
node->affected_by_backdrop_filter = false;
}
if (last_backdrop_filter == kInvalidNodeId)
return;
// Update effect nodes for the backdrop filter due to the target id change.
int current_target_id = effect_tree->Node(last_backdrop_filter)->target_id;
for (int i = last_backdrop_filter - 1; EffectTree::kContentsRootNodeId <= i;
--i) {
EffectNode* node = effect_tree->Node(i);
node->affected_by_backdrop_filter = current_target_id <= i ? true : false;
if (node->id == current_target_id)
current_target_id = kInvalidNodeId;
// While down to kContentsRootNodeId, move |current_target_id| forward if
// |node| has backdrop filter.
if (!node->backdrop_filters.IsEmpty() &&
current_target_id == kInvalidNodeId)
current_target_id = node->target_id;
}
}
......
......@@ -36,6 +36,7 @@ EffectNode::EffectNode()
subtree_has_copy_request(false),
is_fast_rounded_corner(false),
node_or_ancestor_has_filters(false),
affected_by_backdrop_filter(false),
render_surface_reason(RenderSurfaceReason::kNone),
transform_id(0),
clip_id(0),
......@@ -62,6 +63,7 @@ bool EffectNode::operator==(const EffectNode& other) const {
rounded_corner_bounds == other.rounded_corner_bounds &&
is_fast_rounded_corner == other.is_fast_rounded_corner &&
node_or_ancestor_has_filters == other.node_or_ancestor_has_filters &&
affected_by_backdrop_filter == other.affected_by_backdrop_filter &&
// The specific reason is just for tracing/testing/debugging, so just
// check whether a render surface is needed.
HasRenderSurface() == other.HasRenderSurface() &&
......@@ -190,6 +192,7 @@ void EffectNode::AsValueInto(base::trace_event::TracedValue* value) const {
closest_ancestor_with_cached_render_surface_id);
value->SetInteger("closest_ancestor_with_copy_request_id",
closest_ancestor_with_copy_request_id);
value->SetBoolean("affected_by_backdrop_filter", affected_by_backdrop_filter);
}
} // namespace cc
......@@ -132,6 +132,10 @@ struct CC_EXPORT EffectNode {
bool is_fast_rounded_corner : 1;
// If the node or it's parent has the filters, it sets to true.
bool node_or_ancestor_has_filters : 1;
// All node in the subtree starting from the containing render surface, and
// before the backdrop filter node in pre tree order.
// This is set and used for the impl-side effect tree only.
bool affected_by_backdrop_filter: 1;
// RenderSurfaceReason::kNone if this effect node should not create a render
// surface, or the reason that this effect node should create one.
RenderSurfaceReason render_surface_reason;
......@@ -144,6 +148,7 @@ struct CC_EXPORT EffectNode {
// This is the id of the ancestor effect node that induces a
// RenderSurfaceImpl.
// This is set and used for the impl-side effect tree only.
int target_id;
int closest_ancestor_with_cached_render_surface_id;
int closest_ancestor_with_copy_request_id;
......
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