0

[Element Capture ] properly generate effect nodes

This Patch:
This patch contains a fix for element capture where
EffectPaintPropertyNode instances marked with an ID for element
capture do not get properly converted into EffectNodes. It also
includes a very minor cleanup to the element capture compositing
reasons, where CompositingReason::kElementCapture was ordered
incorrectly.

The Project:
Element level capture is a new mode of tab capture being implemented that allows developers to capture subsections of the DOM, meaning that occluding content is never captured (unless the currently existing region capture mode). For more information, Googlers may visit: go/element-capture

All developers are welcome to visit the W3 spec page at:
https://screen-share.github.io/element-capture/

Coming Up Next:
1. Adding a command line flag to enable a hack so that element
   capture can actually be enabled.
2. Modify the FrameSinkVideoCapturerImpl to enable element capture,
   fix issues with overlay calculation.
3. Working with eladlon@ to replace the hack with the proper
   restrictTo API.
4. Bug fixing and stabilizations.

Bug: 1418194
Change-Id: I39c2b48342f90c12125beec4bedcbf12e305e9b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4779181
Reviewed-by: Philip Rogers <pdr@chromium.org>
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1184824}
This commit is contained in:
Jordan Bayles
2023-08-17 18:43:32 +00:00
committed by Chromium LUCI CQ
parent 134c26d4c9
commit 2d417a7f8f
4 changed files with 20 additions and 7 deletions

@ -1158,8 +1158,9 @@ void PropertyTreeManager::BuildEffectNodesRecursively(
// with the first contiguous set of chunks) is tagged with the shared
// element resource ID. The view transition should either prevent such
// content or ensure effect nodes are contiguous. See crbug.com/1303081 for
// details.
DCHECK(!next_effect.ViewTransitionElementId().valid() ||
// details. This restriction also applies to element capture.
DCHECK((!next_effect.ViewTransitionElementId().valid() &&
next_effect.ElementCaptureId()->is_zero()) ||
!has_multiple_groups)
<< next_effect.ToString();
PopulateCcEffectNode(effect_node, next_effect, output_clip_id);
@ -1238,6 +1239,9 @@ static cc::RenderSurfaceReason RenderSurfaceReasonForEffect(
if (effect.FlattensAtLeafOf3DScene())
return cc::RenderSurfaceReason::k3dTransformFlattening;
if (!effect.ElementCaptureId()->is_zero()) {
return cc::RenderSurfaceReason::kSubtreeIsBeingCaptured;
}
auto conditional_reason = ConditionalRenderSurfaceReasonForEffect(effect);
DCHECK(conditional_reason == cc::RenderSurfaceReason::kNone ||
IsConditionalRenderSurfaceReason(conditional_reason));
@ -1273,6 +1277,9 @@ void PropertyTreeManager::PopulateCcEffectNode(
effect.ViewTransitionElementId();
effect_node.view_transition_element_resource_id =
effect.ViewTransitionElementResourceId();
effect_node.subtree_capture_id =
viz::SubtreeCaptureId(*effect.ElementCaptureId());
}
void PropertyTreeManager::UpdateConditionalRenderSurfaceReasons(

@ -88,6 +88,8 @@ constexpr ReasonAndDescription kReasonDescriptionMap[] = {
"transition."},
{CompositingReason::kOverflowScrolling,
"Is a scrollable overflow element using accelerated scrolling."},
{CompositingReason::kElementCapture,
"This element is undergoing element-level capture."},
{CompositingReason::kOverlap, "Overlaps other composited content."},
{CompositingReason::kBackfaceVisibilityHidden,
"Has backface-visibility: hidden."},
@ -104,8 +106,6 @@ constexpr ReasonAndDescription kReasonDescriptionMap[] = {
{CompositingReason::kDevToolsOverlay, "Is DevTools overlay."},
{CompositingReason::kViewTransitionContent,
"The layer containing the contents of a view transition element."},
{CompositingReason::kElementCapture,
"This element is undergoing element-level capture."},
};
} // anonymous namespace

@ -71,6 +71,9 @@ using CompositingReasons = uint64_t;
determined after paint. */ \
V(OverflowScrolling) \
\
/* Element is participating in element capture. */ \
V(ElementCapture) \
\
/* The following reasons are not used in paint properties, but are \
determined after paint, for debugging. See PaintArtifactCompositor. */ \
/* This is based on overlapping relationship among pending layers. */ \
@ -85,8 +88,7 @@ using CompositingReasons = uint64_t;
V(Scrollbar) \
V(LinkHighlight) \
V(DevToolsOverlay) \
V(ViewTransitionContent) \
V(ElementCapture)
V(ViewTransitionContent)
class PLATFORM_EXPORT CompositingReason {
DISALLOW_NEW();

@ -304,7 +304,7 @@ class PLATFORM_EXPORT EffectPaintPropertyNode
// is entirely empty.
bool DrawsContent() const {
return MayHaveFilter() || MayHaveBackdropEffect() ||
ViewTransitionElementId().valid();
ViewTransitionElementId().valid() || !ElementCaptureId()->is_zero();
}
CompositingReasons DirectCompositingReasonsForDebugging() const {
@ -324,6 +324,10 @@ class PLATFORM_EXPORT EffectPaintPropertyNode
return state_.view_transition_element_resource_id;
}
const RegionCaptureCropId& ElementCaptureId() const {
return state_.element_capture_id;
}
bool SelfOrAncestorParticipatesInViewTransition() const {
return state_.self_or_ancestor_participates_in_view_transition;
}