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
33 changes: 23 additions & 10 deletions flow/layers/shader_mask_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,32 @@ void ShaderMaskLayer::Paint(PaintContext& context) const {
return;
}
}
auto shader_rect = SkRect::MakeWH(mask_rect_.width(), mask_rect_.height());

Layer::AutoSaveLayer save = Layer::AutoSaveLayer::Create(
context, paint_bounds(), cache_paint.sk_paint());
PaintChildren(context);
if (context.leaf_nodes_builder) {
context.builder_multiplexer->saveLayer(&paint_bounds(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is actually the important part of this fix... ;)

cache_paint.dl_paint());
PaintChildren(context);

SkPaint paint;
paint.setBlendMode(ToSk(blend_mode_));
if (shader_) {
paint.setShader(shader_->skia_object());
DlPaint dl_paint;
dl_paint.setBlendMode(blend_mode_);
if (shader_) {
dl_paint.setColorSource(shader_.get());
}
context.leaf_nodes_builder->translate(mask_rect_.left(), mask_rect_.top());
context.leaf_nodes_builder->drawRect(shader_rect, dl_paint);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we forgot a restore here which made the rendering completely fail on internal tests.

} else {
Layer::AutoSaveLayer save = Layer::AutoSaveLayer::Create(
context, paint_bounds(), cache_paint.sk_paint());
PaintChildren(context);
SkPaint paint;
paint.setBlendMode(ToSk(blend_mode_));
if (shader_) {
paint.setShader(shader_->skia_object());
}
context.leaf_nodes_canvas->translate(mask_rect_.left(), mask_rect_.top());
context.leaf_nodes_canvas->drawRect(shader_rect, paint);
}
context.leaf_nodes_canvas->translate(mask_rect_.left(), mask_rect_.top());
context.leaf_nodes_canvas->drawRect(
SkRect::MakeWH(mask_rect_.width(), mask_rect_.height()), paint);
}

} // namespace flutter
13 changes: 7 additions & 6 deletions flow/layers/shader_mask_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,18 @@ TEST_F(ShaderMaskLayerTest, OpacityInheritance) {
{
expected_builder.translate(offset.fX, offset.fY);
/* ShaderMaskLayer::Paint() */ {
expected_builder.setColor(opacity_alpha << 24);
expected_builder.saveLayer(&child_path.getBounds(), true);
DlPaint sl_paint;
sl_paint.setColor(opacity_alpha << 24);
expected_builder.saveLayer(&child_path.getBounds(), &sl_paint);
{
/* child layer paint */ {
expected_builder.setColor(0xFF000000);
expected_builder.drawPath(child_path);
expected_builder.drawPath(child_path,
DlPaint().setColor(0xFF000000));
}
expected_builder.translate(mask_rect.fLeft, mask_rect.fTop);
expected_builder.setBlendMode(DlBlendMode::kSrc);
expected_builder.drawRect(
SkRect::MakeWH(mask_rect.width(), mask_rect.height()));
SkRect::MakeWH(mask_rect.width(), mask_rect.height()),
DlPaint().setBlendMode(DlBlendMode::kSrc));
}
expected_builder.restore();
}
Expand Down