Commit e5b6ed3a authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Trigger render surfaces always for rotated clips.

Previously, we skipped a render surface for a rotated clip
(rounded or not) when the FastBorderMask runtime feature was enabled.

Also, made the unittests in paint_artifact_compositor_test work
with FastBorderRadius mode.

Bug: 947715

Change-Id: Ib5d0afd645c10cf219e2db7cb9c19a7155be97e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1594333
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656455}
parent f00c5e6b
...@@ -761,20 +761,19 @@ static bool IsNodeOnAncestorChain(const ClipPaintPropertyNode& find, ...@@ -761,20 +761,19 @@ static bool IsNodeOnAncestorChain(const ClipPaintPropertyNode& find,
return false; return false;
} }
base::Optional<PropertyTreeManager::CcEffectType> PropertyTreeManager::CcEffectType PropertyTreeManager::SyntheticEffectType(
PropertyTreeManager::NeedsSyntheticEffect(
const ClipPaintPropertyNode& clip) const { const ClipPaintPropertyNode& clip) const {
unsigned effect_type = CcEffectType::kEffect;
if (clip.ClipRect().IsRounded() || clip.ClipPath()) if (clip.ClipRect().IsRounded() || clip.ClipPath())
return CcEffectType::kSyntheticForNonTrivialClip; effect_type |= CcEffectType::kSyntheticForNonTrivialClip;
// Cc requires that a rectangluar clip is 2d-axis-aligned with the render // Cc requires that a rectangluar clip is 2d-axis-aligned with the render
// surface to correctly apply the clip. // surface to correctly apply the clip.
if (current_.may_be_2d_axis_misaligned_to_render_surface | if (current_.may_be_2d_axis_misaligned_to_render_surface |
TransformsMayBe2dAxisMisaligned(clip.LocalTransformSpace(), TransformsMayBe2dAxisMisaligned(clip.LocalTransformSpace(),
current_.Transform())) current_.Transform()))
return CcEffectType::kSyntheticFor2dAxisAlignment; effect_type |= CcEffectType::kSyntheticFor2dAxisAlignment;
return static_cast<CcEffectType>(effect_type);
return base::nullopt;
} }
SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded( SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded(
...@@ -821,8 +820,8 @@ SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded( ...@@ -821,8 +820,8 @@ SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded(
Vector<PendingClip> pending_clips; Vector<PendingClip> pending_clips;
for (; target_clip && target_clip != current_.clip; for (; target_clip && target_clip != current_.clip;
target_clip = SafeUnalias(target_clip->Parent())) { target_clip = SafeUnalias(target_clip->Parent())) {
if (auto type = NeedsSyntheticEffect(*target_clip)) if (auto type = SyntheticEffectType(*target_clip))
pending_clips.emplace_back(PendingClip{target_clip, *type}); pending_clips.emplace_back(PendingClip{target_clip, type});
} }
if (!target_clip) { if (!target_clip) {
...@@ -844,7 +843,7 @@ SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded( ...@@ -844,7 +843,7 @@ SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded(
// surface which is axis-aligned with the clip. // surface which is axis-aligned with the clip.
cc::EffectNode& synthetic_effect = *GetEffectTree().Node( cc::EffectNode& synthetic_effect = *GetEffectTree().Node(
GetEffectTree().Insert(cc::EffectNode(), current_.effect_id)); GetEffectTree().Insert(cc::EffectNode(), current_.effect_id));
if (pending_clip.type == CcEffectType::kSyntheticForNonTrivialClip) { if (pending_clip.type & CcEffectType::kSyntheticForNonTrivialClip) {
synthetic_effect.clip_id = EnsureCompositorClipNode(*pending_clip.clip); synthetic_effect.clip_id = EnsureCompositorClipNode(*pending_clip.clip);
// For non-trivial clip, isolation_effect.stable_id will be assigned later // For non-trivial clip, isolation_effect.stable_id will be assigned later
// when the effect is closed. For now the default value INVALID_STABLE_ID // when the effect is closed. For now the default value INVALID_STABLE_ID
...@@ -863,23 +862,23 @@ SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded( ...@@ -863,23 +862,23 @@ SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded(
synthetic_effect.transform_id = EnsureCompositorTransformNode(transform); synthetic_effect.transform_id = EnsureCompositorTransformNode(transform);
synthetic_effect.double_sided = !transform.IsBackfaceHidden(); synthetic_effect.double_sided = !transform.IsBackfaceHidden();
if (RuntimeEnabledFeatures::FastBorderRadiusEnabled()) { if (pending_clip.type & CcEffectType::kSyntheticForNonTrivialClip) {
synthetic_effect.rounded_corner_bounds = if (RuntimeEnabledFeatures::FastBorderRadiusEnabled()) {
gfx::RRectF(pending_clip.clip->ClipRect()); synthetic_effect.rounded_corner_bounds =
synthetic_effect.is_fast_rounded_corner = true; gfx::RRectF(pending_clip.clip->ClipRect());
} else { synthetic_effect.is_fast_rounded_corner = true;
if (pending_clip.type == CcEffectType::kSyntheticForNonTrivialClip) { } else {
synthetic_effect.render_surface_reason = synthetic_effect.render_surface_reason =
pending_clip.clip->ClipRect().IsRounded() pending_clip.clip->ClipRect().IsRounded()
? cc::RenderSurfaceReason::kRoundedCorner ? cc::RenderSurfaceReason::kRoundedCorner
: cc::RenderSurfaceReason::kClipPath; : cc::RenderSurfaceReason::kClipPath;
} else {
synthetic_effect.render_surface_reason =
cc::RenderSurfaceReason::kClipAxisAlignment;
} }
pending_synthetic_mask_layers_.insert(synthetic_effect.id); pending_synthetic_mask_layers_.insert(synthetic_effect.id);
} }
if (pending_clip.type & CcEffectType::kSyntheticFor2dAxisAlignment) {
synthetic_effect.render_surface_reason =
cc::RenderSurfaceReason::kClipAxisAlignment;
}
// Clip and kDstIn do not commute. This shall never be reached because // Clip and kDstIn do not commute. This shall never be reached because
// kDstIn is only used internally to implement CSS clip-path and mask, // kDstIn is only used internally to implement CSS clip-path and mask,
......
...@@ -173,31 +173,28 @@ class PropertyTreeManager { ...@@ -173,31 +173,28 @@ class PropertyTreeManager {
cc::TransformNode&, cc::TransformNode&,
const TransformPaintPropertyNode&); const TransformPaintPropertyNode&);
bool IsCurrentCcEffectSynthetic() const { bool IsCurrentCcEffectSynthetic() const { return current_.effect_type; }
return current_.effect_type != CcEffectType::kEffect;
}
bool IsCurrentCcEffectSyntheticForNonTrivialClip() const { bool IsCurrentCcEffectSyntheticForNonTrivialClip() const {
return current_.effect_type == CcEffectType::kSyntheticForNonTrivialClip; return current_.effect_type & CcEffectType::kSyntheticForNonTrivialClip;
} }
// The type of operation the current cc effect node applies. // The type of operation the current cc effect node applies.
enum class CcEffectType { enum CcEffectType {
// The cc effect corresponds to a Blink effect node. // The cc effect corresponds to a Blink effect node.
kEffect, kEffect = 0,
// The cc effect is synthetic for a blink clip node that has to be // The cc effect is synthetic for a blink clip node that has to be
// rasterized because the clip is non-trivial. // rasterized because the clip is non-trivial.
kSyntheticForNonTrivialClip, kSyntheticForNonTrivialClip = 1 << 0,
// The cc effect is synthetic to create a render surface that is // The cc effect is synthetic to create a render surface that is
// 2d-axis-aligned with a blink clip node that is non-2d-axis-aligned // 2d-axis-aligned with a blink clip node that is non-2d-axis-aligned
// in the the original render surface. Cc requires a rectangular clip to be // in the the original render surface. Cc requires a rectangular clip to be
// 2d-axis-aligned with the render surface to correctly apply the clip. // 2d-axis-aligned with the render surface to correctly apply the clip.
// TODO(crbug.com/504464): This will be changed when we move render surface // TODO(crbug.com/504464): This will be changed when we move render surface
// decision logic into the cc compositor thread. // decision logic into the cc compositor thread.
kSyntheticFor2dAxisAlignment, kSyntheticFor2dAxisAlignment = 1 << 1
}; };
base::Optional<CcEffectType> NeedsSyntheticEffect( CcEffectType SyntheticEffectType(const ClipPaintPropertyNode&) const;
const ClipPaintPropertyNode&) const;
void SetCurrentEffectState(const cc::EffectNode&, void SetCurrentEffectState(const cc::EffectNode&,
CcEffectType, CcEffectType,
......
...@@ -15,19 +15,22 @@ enum { ...@@ -15,19 +15,22 @@ enum {
kBlinkGenPropertyTrees = 1 << 0, kBlinkGenPropertyTrees = 1 << 0,
kCompositeAfterPaint = 1 << 1, kCompositeAfterPaint = 1 << 1,
kUnderInvalidationChecking = 1 << 2, kUnderInvalidationChecking = 1 << 2,
kFastBorderRadius = 1 << 3,
}; };
class PaintTestConfigurations class PaintTestConfigurations
: public testing::WithParamInterface<unsigned>, : public testing::WithParamInterface<unsigned>,
private ScopedBlinkGenPropertyTreesForTest, private ScopedBlinkGenPropertyTreesForTest,
private ScopedCompositeAfterPaintForTest, private ScopedCompositeAfterPaintForTest,
private ScopedPaintUnderInvalidationCheckingForTest { private ScopedPaintUnderInvalidationCheckingForTest,
private ScopedFastBorderRadiusForTest {
public: public:
PaintTestConfigurations() PaintTestConfigurations()
: ScopedBlinkGenPropertyTreesForTest(GetParam() & kBlinkGenPropertyTrees), : ScopedBlinkGenPropertyTreesForTest(GetParam() & kBlinkGenPropertyTrees),
ScopedCompositeAfterPaintForTest(GetParam() & kCompositeAfterPaint), ScopedCompositeAfterPaintForTest(GetParam() & kCompositeAfterPaint),
ScopedPaintUnderInvalidationCheckingForTest( ScopedPaintUnderInvalidationCheckingForTest(GetParam() &
GetParam() & kUnderInvalidationChecking) {} kUnderInvalidationChecking),
ScopedFastBorderRadiusForTest(GetParam() & kFastBorderRadius) {}
~PaintTestConfigurations() { ~PaintTestConfigurations() {
// Must destruct all objects before toggling back feature flags. // Must destruct all objects before toggling back feature flags.
WebHeap::CollectAllGarbageForTesting(); WebHeap::CollectAllGarbageForTesting();
...@@ -45,11 +48,12 @@ class PaintTestConfigurations ...@@ -45,11 +48,12 @@ class PaintTestConfigurations
All, test_class, \ All, test_class, \
::testing::Values(kBlinkGenPropertyTrees | kCompositeAfterPaint)) ::testing::Values(kBlinkGenPropertyTrees | kCompositeAfterPaint))
#define INSTANTIATE_LAYER_LIST_TEST_SUITE_P(test_class) \ #define INSTANTIATE_LAYER_LIST_TEST_SUITE_P(test_class) \
INSTANTIATE_TEST_SUITE_P( \ INSTANTIATE_TEST_SUITE_P( \
All, test_class, \ All, test_class, \
::testing::Values(kBlinkGenPropertyTrees, \ ::testing::Values(kBlinkGenPropertyTrees, \
kBlinkGenPropertyTrees | kCompositeAfterPaint)) kBlinkGenPropertyTrees | kCompositeAfterPaint, \
kBlinkGenPropertyTrees | kFastBorderRadius))
} // namespace blink } // namespace blink
......
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