Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
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
2 changes: 1 addition & 1 deletion flow/layers/backdrop_filter_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void BackdropFilterLayer::Paint(PaintContext& context) const {
Layer::AutoSaveLayer save = Layer::AutoSaveLayer::Create(
context,
SkCanvas::SaveLayerRec{&paint_bounds(), nullptr, filter_.get(), 0});
ContainerLayer::Paint(context);
PaintChildren(context);
}

} // namespace flutter
17 changes: 1 addition & 16 deletions flow/layers/child_scene_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,10 @@ ChildSceneLayer::ChildSceneLayer(zx_koid_t layer_id,

void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
set_needs_system_composite(true);

// An alpha "hole punch" is required if the frame behind us is not opaque.
if (!context->is_opaque) {
set_paint_bounds(
SkRect::MakeXYWH(offset_.fX, offset_.fY, size_.fWidth, size_.fHeight));
}
}

void ChildSceneLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ChildSceneLayer::Paint");
FML_DCHECK(needs_painting());

// If we are being rendered into our own frame using the system compositor,
// then it is neccesary to "punch a hole" in the canvas/frame behind us so
// that group opacity looks correct.
SkPaint paint;
paint.setColor(SK_ColorTRANSPARENT);
paint.setBlendMode(SkBlendMode::kSrc);
context.leaf_nodes_canvas->drawRect(paint_bounds(), paint);
FML_NOTREACHED() << "This layer never needs painting.";
}

void ChildSceneLayer::UpdateScene(SceneUpdateContext& context) {
Expand Down
40 changes: 23 additions & 17 deletions flow/layers/clip_path_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

#include "flutter/flow/layers/clip_path_layer.h"

#if defined(OS_FUCHSIA)

#include "lib/ui/scenic/cpp/commands.h"

#endif // defined(OS_FUCHSIA)

namespace flutter {

ClipPathLayer::ClipPathLayer(const SkPath& clip_path, Clip clip_behavior)
Expand All @@ -18,18 +24,29 @@ void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
SkRect clip_path_bounds = clip_path_.getBounds();
if (context->cull_rect.intersect(clip_path_bounds)) {
context->mutators_stack.PushClipPath(clip_path_);
ContainerLayer::Preroll(context, matrix);
SkRect child_paint_bounds = SkRect::MakeEmpty();
PrerollChildren(context, matrix, &child_paint_bounds);

if (clip_path_bounds.intersect(paint_bounds())) {
set_paint_bounds(clip_path_bounds);
} else {
set_paint_bounds(SkRect::MakeEmpty());
if (child_paint_bounds.intersect(clip_path_bounds)) {
set_paint_bounds(child_paint_bounds);
}
context->mutators_stack.Pop();
}
context->cull_rect = previous_cull_rect;
}

#if defined(OS_FUCHSIA)

void ClipPathLayer::UpdateScene(SceneUpdateContext& context) {
FML_DCHECK(needs_system_composite());

// TODO(liyuqian): respect clip_behavior_
SceneUpdateContext::Clip clip(context, clip_path_.getBounds());
UpdateSceneChildren(context);
}

#endif // defined(OS_FUCHSIA)

void ClipPathLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ClipPathLayer::Paint");
FML_DCHECK(needs_painting());
Expand All @@ -41,21 +58,10 @@ void ClipPathLayer::Paint(PaintContext& context) const {
if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
context.internal_nodes_canvas->saveLayer(paint_bounds(), nullptr);
}
ContainerLayer::Paint(context);
PaintChildren(context);
if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
context.internal_nodes_canvas->restore();
}
}

void ClipPathLayer::UpdateScene(SceneUpdateContext& context) {
#if defined(OS_FUCHSIA)
FML_DCHECK(needs_system_composite());

// TODO(liyuqian): respect clip_behavior_
SceneUpdateContext::Clip clip(context, clip_path_.getBounds());

ContainerLayer::UpdateScene(context);
#endif // defined(OS_FUCHSIA)
}

} // namespace flutter
4 changes: 4 additions & 0 deletions flow/layers/clip_path_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ class ClipPathLayer : public ContainerLayer {
~ClipPathLayer() override;

void Preroll(PrerollContext* context, const SkMatrix& matrix) override;

void Paint(PaintContext& context) const override;

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

private:
SkPath clip_path_;
Expand Down
41 changes: 20 additions & 21 deletions flow/layers/clip_rect_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,31 @@ ClipRectLayer::~ClipRectLayer() = default;

void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
SkRect previous_cull_rect = context->cull_rect;
SkRect clip_rect_bounds = clip_rect_;
if (context->cull_rect.intersect(clip_rect_bounds)) {
context->mutators_stack.PushClipRect(clip_rect_bounds);
ContainerLayer::Preroll(context, matrix);

if (clip_rect_bounds.intersect(paint_bounds())) {
set_paint_bounds(clip_rect_bounds);
} else {
set_paint_bounds(SkRect::MakeEmpty());
if (context->cull_rect.intersect(clip_rect_)) {
context->mutators_stack.PushClipRect(clip_rect_);
SkRect child_paint_bounds = SkRect::MakeEmpty();
PrerollChildren(context, matrix, &child_paint_bounds);

if (child_paint_bounds.intersect(clip_rect_)) {
set_paint_bounds(child_paint_bounds);
}
context->mutators_stack.Pop();
}
context->cull_rect = previous_cull_rect;
}

#if defined(OS_FUCHSIA)

void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
FML_DCHECK(needs_system_composite());

// TODO(liyuqian): respect clip_behavior_
SceneUpdateContext::Clip clip(context, clip_rect_);
UpdateSceneChildren(context);
}

#endif // defined(OS_FUCHSIA)

void ClipRectLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ClipRectLayer::Paint");
FML_DCHECK(needs_painting());
Expand All @@ -41,21 +51,10 @@ void ClipRectLayer::Paint(PaintContext& context) const {
if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
context.internal_nodes_canvas->saveLayer(clip_rect_, nullptr);
}
ContainerLayer::Paint(context);
PaintChildren(context);
if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
context.internal_nodes_canvas->restore();
}
}

void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
#if defined(OS_FUCHSIA)
FML_DCHECK(needs_system_composite());

// TODO(liyuqian): respect clip_behavior_
SceneUpdateContext::Clip clip(context, clip_rect_);

ContainerLayer::UpdateScene(context);
#endif // defined(OS_FUCHSIA)
}

} // namespace flutter
3 changes: 3 additions & 0 deletions flow/layers/clip_rect_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class ClipRectLayer : public ContainerLayer {

void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Paint(PaintContext& context) const override;

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

private:
SkRect clip_rect_;
Expand Down
34 changes: 17 additions & 17 deletions flow/layers/clip_rrect_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,29 @@ void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
SkRect clip_rrect_bounds = clip_rrect_.getBounds();
if (context->cull_rect.intersect(clip_rrect_bounds)) {
context->mutators_stack.PushClipRRect(clip_rrect_);
ContainerLayer::Preroll(context, matrix);
SkRect child_paint_bounds = SkRect::MakeEmpty();
PrerollChildren(context, matrix, &child_paint_bounds);

if (clip_rrect_bounds.intersect(paint_bounds())) {
set_paint_bounds(clip_rrect_bounds);
} else {
set_paint_bounds(SkRect::MakeEmpty());
if (child_paint_bounds.intersect(clip_rrect_bounds)) {
set_paint_bounds(child_paint_bounds);
}
context->mutators_stack.Pop();
}
context->cull_rect = previous_cull_rect;
}

#if defined(OS_FUCHSIA)

void ClipRRectLayer::UpdateScene(SceneUpdateContext& context) {
FML_DCHECK(needs_system_composite());

// TODO(liyuqian): respect clip_behavior_
SceneUpdateContext::Clip clip(context, clip_rrect_.getBounds());
UpdateSceneChildren(context);
}

#endif // defined(OS_FUCHSIA)

void ClipRRectLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");
FML_DCHECK(needs_painting());
Expand All @@ -41,21 +52,10 @@ void ClipRRectLayer::Paint(PaintContext& context) const {
if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
context.internal_nodes_canvas->saveLayer(paint_bounds(), nullptr);
}
ContainerLayer::Paint(context);
PaintChildren(context);
if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
context.internal_nodes_canvas->restore();
}
}

void ClipRRectLayer::UpdateScene(SceneUpdateContext& context) {
#if defined(OS_FUCHSIA)
FML_DCHECK(needs_system_composite());

// TODO(liyuqian): respect clip_behavior_
SceneUpdateContext::Clip clip(context, clip_rrect_.getBounds());

ContainerLayer::UpdateScene(context);
#endif // defined(OS_FUCHSIA)
}

} // namespace flutter
4 changes: 4 additions & 0 deletions flow/layers/clip_rrect_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ class ClipRRectLayer : public ContainerLayer {
~ClipRRectLayer() override;

void Preroll(PrerollContext* context, const SkMatrix& matrix) override;

void Paint(PaintContext& context) const override;

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

private:
SkRRect clip_rrect_;
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/color_filter_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void ColorFilterLayer::Paint(PaintContext& context) const {

Layer::AutoSaveLayer save =
Layer::AutoSaveLayer::Create(context, paint_bounds(), &paint);
ContainerLayer::Paint(context);
PaintChildren(context);
}

} // namespace flutter
Loading