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,
return false;
}
base::Optional<PropertyTreeManager::CcEffectType>
PropertyTreeManager::NeedsSyntheticEffect(
PropertyTreeManager::CcEffectType PropertyTreeManager::SyntheticEffectType(
const ClipPaintPropertyNode& clip) const {
unsigned effect_type = CcEffectType::kEffect;
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
// surface to correctly apply the clip.
if (current_.may_be_2d_axis_misaligned_to_render_surface |
TransformsMayBe2dAxisMisaligned(clip.LocalTransformSpace(),
current_.Transform()))
return CcEffectType::kSyntheticFor2dAxisAlignment;
return base::nullopt;
effect_type |= CcEffectType::kSyntheticFor2dAxisAlignment;
return static_cast<CcEffectType>(effect_type);
}
SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded(
......@@ -821,8 +820,8 @@ SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded(
Vector<PendingClip> pending_clips;
for (; target_clip && target_clip != current_.clip;
target_clip = SafeUnalias(target_clip->Parent())) {
if (auto type = NeedsSyntheticEffect(*target_clip))
pending_clips.emplace_back(PendingClip{target_clip, *type});
if (auto type = SyntheticEffectType(*target_clip))
pending_clips.emplace_back(PendingClip{target_clip, type});
}
if (!target_clip) {
......@@ -844,7 +843,7 @@ SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded(
// surface which is axis-aligned with the clip.
cc::EffectNode& synthetic_effect = *GetEffectTree().Node(
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);
// 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
......@@ -863,23 +862,23 @@ SkBlendMode PropertyTreeManager::SynthesizeCcEffectsForClipsIfNeeded(
synthetic_effect.transform_id = EnsureCompositorTransformNode(transform);
synthetic_effect.double_sided = !transform.IsBackfaceHidden();
if (RuntimeEnabledFeatures::FastBorderRadiusEnabled()) {
synthetic_effect.rounded_corner_bounds =
gfx::RRectF(pending_clip.clip->ClipRect());
synthetic_effect.is_fast_rounded_corner = true;
} else {
if (pending_clip.type == CcEffectType::kSyntheticForNonTrivialClip) {
if (pending_clip.type & CcEffectType::kSyntheticForNonTrivialClip) {
if (RuntimeEnabledFeatures::FastBorderRadiusEnabled()) {
synthetic_effect.rounded_corner_bounds =
gfx::RRectF(pending_clip.clip->ClipRect());
synthetic_effect.is_fast_rounded_corner = true;
} else {
synthetic_effect.render_surface_reason =
pending_clip.clip->ClipRect().IsRounded()
? cc::RenderSurfaceReason::kRoundedCorner
: cc::RenderSurfaceReason::kClipPath;
} else {
synthetic_effect.render_surface_reason =
cc::RenderSurfaceReason::kClipAxisAlignment;
}
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
// kDstIn is only used internally to implement CSS clip-path and mask,
......
......@@ -173,31 +173,28 @@ class PropertyTreeManager {
cc::TransformNode&,
const TransformPaintPropertyNode&);
bool IsCurrentCcEffectSynthetic() const {
return current_.effect_type != CcEffectType::kEffect;
}
bool IsCurrentCcEffectSynthetic() const { return current_.effect_type; }
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.
enum class CcEffectType {
enum CcEffectType {
// 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
// rasterized because the clip is non-trivial.
kSyntheticForNonTrivialClip,
kSyntheticForNonTrivialClip = 1 << 0,
// 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
// 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.
// TODO(crbug.com/504464): This will be changed when we move render surface
// decision logic into the cc compositor thread.
kSyntheticFor2dAxisAlignment,
kSyntheticFor2dAxisAlignment = 1 << 1
};
base::Optional<CcEffectType> NeedsSyntheticEffect(
const ClipPaintPropertyNode&) const;
CcEffectType SyntheticEffectType(const ClipPaintPropertyNode&) const;
void SetCurrentEffectState(const cc::EffectNode&,
CcEffectType,
......
......@@ -15,19 +15,22 @@ enum {
kBlinkGenPropertyTrees = 1 << 0,
kCompositeAfterPaint = 1 << 1,
kUnderInvalidationChecking = 1 << 2,
kFastBorderRadius = 1 << 3,
};
class PaintTestConfigurations
: public testing::WithParamInterface<unsigned>,
private ScopedBlinkGenPropertyTreesForTest,
private ScopedCompositeAfterPaintForTest,
private ScopedPaintUnderInvalidationCheckingForTest {
private ScopedPaintUnderInvalidationCheckingForTest,
private ScopedFastBorderRadiusForTest {
public:
PaintTestConfigurations()
: ScopedBlinkGenPropertyTreesForTest(GetParam() & kBlinkGenPropertyTrees),
ScopedCompositeAfterPaintForTest(GetParam() & kCompositeAfterPaint),
ScopedPaintUnderInvalidationCheckingForTest(
GetParam() & kUnderInvalidationChecking) {}
ScopedPaintUnderInvalidationCheckingForTest(GetParam() &
kUnderInvalidationChecking),
ScopedFastBorderRadiusForTest(GetParam() & kFastBorderRadius) {}
~PaintTestConfigurations() {
// Must destruct all objects before toggling back feature flags.
WebHeap::CollectAllGarbageForTesting();
......@@ -45,11 +48,12 @@ class PaintTestConfigurations
All, test_class, \
::testing::Values(kBlinkGenPropertyTrees | kCompositeAfterPaint))
#define INSTANTIATE_LAYER_LIST_TEST_SUITE_P(test_class) \
INSTANTIATE_TEST_SUITE_P( \
All, test_class, \
::testing::Values(kBlinkGenPropertyTrees, \
kBlinkGenPropertyTrees | kCompositeAfterPaint))
#define INSTANTIATE_LAYER_LIST_TEST_SUITE_P(test_class) \
INSTANTIATE_TEST_SUITE_P( \
All, test_class, \
::testing::Values(kBlinkGenPropertyTrees, \
kBlinkGenPropertyTrees | kCompositeAfterPaint, \
kBlinkGenPropertyTrees | kFastBorderRadius))
} // 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