[Impeller] EntityPass::Clone needs to clone harder (flutter/engine#45313)
Fixes https://github.com/flutter/flutter/issues/133731
This commit is contained in:
@@ -3119,6 +3119,42 @@ TEST_P(AiksTest, CanCanvasDrawPicture) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, CanCanvasDrawPictureWithAdvancedBlend) {
|
||||
Canvas subcanvas;
|
||||
subcanvas.DrawRect(
|
||||
Rect::MakeLTRB(-100, -50, 100, 50),
|
||||
{.color = Color::CornflowerBlue(), .blend_mode = BlendMode::kColorDodge});
|
||||
auto picture = subcanvas.EndRecordingAsPicture();
|
||||
|
||||
Canvas canvas;
|
||||
canvas.Translate({200, 200});
|
||||
canvas.DrawPicture(picture);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, CanCanvasDrawPictureWithBackdropFilter) {
|
||||
Canvas subcanvas;
|
||||
subcanvas.SaveLayer({}, {},
|
||||
[](const FilterInput::Ref& input,
|
||||
const Matrix& effect_transform, bool is_subpass) {
|
||||
return FilterContents::MakeGaussianBlur(
|
||||
input, Sigma(20.0), Sigma(20.0));
|
||||
});
|
||||
auto image = std::make_shared<Image>(CreateTextureForFixture("kalimba.jpg"));
|
||||
Paint paint;
|
||||
paint.color = Color::Red();
|
||||
subcanvas.DrawImage(image, Point::MakeXY(100.0, 100.0), paint);
|
||||
|
||||
auto picture = subcanvas.EndRecordingAsPicture();
|
||||
|
||||
Canvas canvas;
|
||||
canvas.Translate({200, 200});
|
||||
canvas.DrawPicture(picture);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DrawPictureWithText) {
|
||||
Canvas subcanvas;
|
||||
ASSERT_TRUE(RenderTextInCanvasSkia(
|
||||
|
||||
@@ -527,9 +527,9 @@ void Canvas::SaveLayer(const Paint& paint,
|
||||
// Only apply opacity peephole on default blending.
|
||||
if (paint.blend_mode == BlendMode::kSourceOver) {
|
||||
new_layer_pass.SetDelegate(
|
||||
std::make_unique<OpacityPeepholePassDelegate>(paint));
|
||||
std::make_shared<OpacityPeepholePassDelegate>(paint));
|
||||
} else {
|
||||
new_layer_pass.SetDelegate(std::make_unique<PaintPassDelegate>(paint));
|
||||
new_layer_pass.SetDelegate(std::make_shared<PaintPassDelegate>(paint));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ EntityPass::EntityPass() = default;
|
||||
|
||||
EntityPass::~EntityPass() = default;
|
||||
|
||||
void EntityPass::SetDelegate(std::unique_ptr<EntityPassDelegate> delegate) {
|
||||
void EntityPass::SetDelegate(std::shared_ptr<EntityPassDelegate> delegate) {
|
||||
if (!delegate) {
|
||||
return;
|
||||
}
|
||||
@@ -1020,6 +1020,16 @@ std::unique_ptr<EntityPass> EntityPass::Clone() const {
|
||||
|
||||
auto pass = std::make_unique<EntityPass>();
|
||||
pass->SetElements(std::move(new_elements));
|
||||
pass->backdrop_filter_reads_from_pass_texture_ =
|
||||
backdrop_filter_reads_from_pass_texture_;
|
||||
pass->advanced_blend_reads_from_pass_texture_ =
|
||||
advanced_blend_reads_from_pass_texture_;
|
||||
pass->backdrop_filter_proc_ = backdrop_filter_proc_;
|
||||
pass->blend_mode_ = blend_mode_;
|
||||
pass->delegate_ = delegate_;
|
||||
// Note: I tried also adding flood clip and bounds limit but one of the
|
||||
// two caused rendering in wonderous to break. It's 10:51 PM, and I'm
|
||||
// ready to move on.
|
||||
return pass;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class EntityPass {
|
||||
|
||||
~EntityPass();
|
||||
|
||||
void SetDelegate(std::unique_ptr<EntityPassDelegate> delgate);
|
||||
void SetDelegate(std::shared_ptr<EntityPassDelegate> delgate);
|
||||
|
||||
/// @brief Set the bounds limit, which is provided by the user when creating
|
||||
/// a SaveLayer. This is a hint that allows the user to communicate
|
||||
@@ -279,7 +279,7 @@ class EntityPass {
|
||||
|
||||
BackdropFilterProc backdrop_filter_proc_ = nullptr;
|
||||
|
||||
std::unique_ptr<EntityPassDelegate> delegate_ =
|
||||
std::shared_ptr<EntityPassDelegate> delegate_ =
|
||||
EntityPassDelegate::MakeDefault();
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EntityPass);
|
||||
|
||||
Reference in New Issue
Block a user