Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 9 additions & 42 deletions flow/layers/physical_shape_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ PhysicalShapeLayer::PhysicalShapeLayer(SkColor color,
// an SkPath.
frameRRect_ = SkRRect::MakeRect(path.getBounds());
}

set_dimensions(frameRRect_);
}

void PhysicalShapeLayer::Preroll(PrerollContext* context,
Expand All @@ -61,57 +59,26 @@ void PhysicalShapeLayer::Preroll(PrerollContext* context,
set_paint_bounds(path_.getBounds());
} else {
if (PhysicalShapeLayerBase::can_system_composite()) {
// always system composite these layers when possible and an elevation is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// present; we are doing it for the shadow effect and in order for
// elevation to be construed as height in Z
set_needs_system_composite(true);

// paint_bounds should be explicitly empty when dimensions is set, or the
// layer's children could be drawn twice
set_dimensions(frameRRect_);
set_paint_bounds(SkRect::MakeEmpty());

return;
}
//#if defined(OS_FUCHSIA)
// // Let the system compositor draw all shadows for us.
// set_needs_system_composite(true);
//#else
// We will draw the shadow in Paint(), so add some margin to the paint
// bounds to leave space for the shadow. We fill this whole region and clip
// children to it so we don't need to join the child paint bounds.
set_paint_bounds(ComputeShadowBounds(path_.getBounds(), elevation(),
context->frame_device_pixel_ratio));
//#endif // defined(OS_FUCHSIA)
}
}

#if defined(OS_FUCHSIA)

void PhysicalShapeLayer::UpdateScene(SceneUpdateContext& context) {
FML_DCHECK(needs_system_composite());
TRACE_EVENT0("flutter", "PhysicalShapeLayer::UpdateScene");

// Retained rendering: speedup by reusing a retained entity node if possible.
// When an entity node is reused, no paint layer is added to the frame so we
// won't call PhysicalShapeLayer::Paint.
LayerRasterCacheKey key(unique_id(), context.Matrix());
if (context.HasRetainedNode(key)) {
TRACE_EVENT_INSTANT0("flutter", "retained layer cache hit");
const scenic::EntityNode& retained_node = context.GetRetainedNode(key);
FML_DCHECK(context.top_entity());
FML_DCHECK(retained_node.session() == context.session());
context.top_entity()->entity_node().AddChild(retained_node);
return;
}

TRACE_EVENT_INSTANT0("flutter", "cache miss, creating");
// If we can't find an existing retained surface, create one.
SceneUpdateContext::Frame frame(context, frameRRect_, color(), opacity(),
elevation(), this);

for (auto& layer : layers()) {
if (layer->needs_painting()) {
frame.AddPaintLayer(layer.get());
}
}

UpdateSceneChildren(context);
}

#endif // defined(OS_FUCHSIA)

void PhysicalShapeLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "PhysicalShapeLayer::Paint");
FML_DCHECK(needs_painting());
Expand Down
4 changes: 0 additions & 4 deletions flow/layers/physical_shape_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class PhysicalShapeLayer : public PhysicalShapeLayerBase {
return clip_behavior_ == Clip::antiAliasWithSaveLayer;
}

#if defined(OS_FUCHSIA)
void UpdateScene(SceneUpdateContext& context) override;
#endif // defined(OS_FUCHSIA)

private:
SkColor shadow_color_;
SkPath path_;
Expand Down