diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 5858719b6c8cd..33ee6347b3976 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -1203,6 +1203,15 @@ TEST_P(AiksTest, CanDrawPaintMultipleTimes) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +TEST_P(AiksTest, CanDrawPaintWithAdvancedBlend) { + Canvas canvas; + canvas.Scale(Vector2(0.2, 0.2)); + canvas.DrawPaint({.color = Color::MediumTurquoise()}); + canvas.DrawPaint({.color = Color::Color::OrangeRed().WithAlpha(0.5), + .blend_mode = BlendMode::kHue}); + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + TEST_P(AiksTest, PaintBlendModeIsRespected) { Paint paint; Canvas canvas; diff --git a/impeller/display_list/dl_image_impeller.cc b/impeller/display_list/dl_image_impeller.cc index 4a4933b58e0bf..9ba43538e9f87 100644 --- a/impeller/display_list/dl_image_impeller.cc +++ b/impeller/display_list/dl_image_impeller.cc @@ -31,8 +31,12 @@ sk_sp DlImageImpeller::MakeFromYUVTextures( impeller::Entity entity; entity.SetBlendMode(impeller::BlendMode::kSource); auto snapshot = yuv_to_rgb_filter_contents->RenderToSnapshot( - aiks_context->GetContentContext(), entity, std::nullopt, true, - "MakeYUVToRGBFilter Snapshot"); + aiks_context->GetContentContext(), // renderer + entity, // entity + std::nullopt, // coverage_limit + std::nullopt, // sampler_descriptor + true, // msaa_enabled + "MakeYUVToRGBFilter Snapshot"); // label return impeller::DlImageImpeller::Make(snapshot->texture); } diff --git a/impeller/entity/contents/atlas_contents.cc b/impeller/entity/contents/atlas_contents.cc index 4b49fd050e77e..38d187f26a58b 100644 --- a/impeller/entity/contents/atlas_contents.cc +++ b/impeller/entity/contents/atlas_contents.cc @@ -248,8 +248,13 @@ bool AtlasContents::Render(const ContentContext& renderer, auto contents = ColorFilterContents::MakeBlend( blend_mode_, {FilterInput::Make(dst_contents), FilterInput::Make(src_contents)}); - auto snapshot = contents->RenderToSnapshot(renderer, entity, std::nullopt, - true, "AtlasContents Snapshot"); + auto snapshot = + contents->RenderToSnapshot(renderer, // renderer + entity, // entity + std::nullopt, // coverage_limit + std::nullopt, // sampler_descriptor + true, // msaa_enabled + "AtlasContents Snapshot"); // label if (!snapshot.has_value()) { return false; } diff --git a/impeller/entity/contents/contents.cc b/impeller/entity/contents/contents.cc index 8eaf5ccc63da4..e81ace0d18646 100644 --- a/impeller/entity/contents/contents.cc +++ b/impeller/entity/contents/contents.cc @@ -59,10 +59,14 @@ Contents::StencilCoverage Contents::GetStencilCoverage( std::optional Contents::RenderToSnapshot( const ContentContext& renderer, const Entity& entity, + std::optional coverage_limit, const std::optional& sampler_descriptor, bool msaa_enabled, const std::string& label) const { auto coverage = GetCoverage(entity); + if (coverage_limit.has_value()) { + coverage = coverage->Intersection(*coverage_limit); + } if (!coverage.has_value()) { return std::nullopt; } diff --git a/impeller/entity/contents/contents.h b/impeller/entity/contents/contents.h index b4d6289add92e..42f52925a4a98 100644 --- a/impeller/entity/contents/contents.h +++ b/impeller/entity/contents/contents.h @@ -77,6 +77,7 @@ class Contents { virtual std::optional RenderToSnapshot( const ContentContext& renderer, const Entity& entity, + std::optional coverage_limit = std::nullopt, const std::optional& sampler_descriptor = std::nullopt, bool msaa_enabled = true, const std::string& label = "Snapshot") const; diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc index f88f580fbd5cc..3c6f2cc059d71 100644 --- a/impeller/entity/contents/filters/filter_contents.cc +++ b/impeller/entity/contents/filters/filter_contents.cc @@ -241,6 +241,7 @@ std::optional FilterContents::GetEntity(const ContentContext& renderer, std::optional FilterContents::RenderToSnapshot( const ContentContext& renderer, const Entity& entity, + std::optional coverage_limit, const std::optional& sampler_descriptor, bool msaa_enabled, const std::string& label) const { @@ -248,8 +249,13 @@ std::optional FilterContents::RenderToSnapshot( // snapshot. if (std::optional result = GetEntity(renderer, entity); result.has_value()) { - return result->GetContents()->RenderToSnapshot(renderer, result.value(), - std::nullopt, true, label); + return result->GetContents()->RenderToSnapshot( + renderer, // renderer + result.value(), // entity + std::nullopt, // coverage_limit + std::nullopt, // sampler_descriptor + true, // msaa_enabled + label); // label } return std::nullopt; diff --git a/impeller/entity/contents/filters/filter_contents.h b/impeller/entity/contents/filters/filter_contents.h index 645e928fc59ef..90605b7aee571 100644 --- a/impeller/entity/contents/filters/filter_contents.h +++ b/impeller/entity/contents/filters/filter_contents.h @@ -125,6 +125,7 @@ class FilterContents : public Contents { std::optional RenderToSnapshot( const ContentContext& renderer, const Entity& entity, + std::optional coverage_limit = std::nullopt, const std::optional& sampler_descriptor = std::nullopt, bool msaa_enabled = true, const std::string& label = "Filter Snapshot") const override; diff --git a/impeller/entity/contents/filters/inputs/contents_filter_input.cc b/impeller/entity/contents/filters/inputs/contents_filter_input.cc index 9af4882eadf60..b2babf4cd23fd 100644 --- a/impeller/entity/contents/filters/inputs/contents_filter_input.cc +++ b/impeller/entity/contents/filters/inputs/contents_filter_input.cc @@ -27,8 +27,12 @@ std::optional ContentsFilterInput::GetSnapshot( const Entity& entity) const { if (!snapshot_.has_value()) { snapshot_ = contents_->RenderToSnapshot( - renderer, entity, std::nullopt, msaa_enabled_, - SPrintF("Contents to %s Filter Snapshot", label.c_str())); + renderer, // renderer + entity, // entity + std::nullopt, // coverage_limit + std::nullopt, // sampler_descriptor + msaa_enabled_, // msaa_enabled + SPrintF("Contents to %s Filter Snapshot", label.c_str())); // label } return snapshot_; } diff --git a/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc b/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc index 03e37839cd6b2..d92e7a0ed9cbd 100644 --- a/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc +++ b/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc @@ -27,8 +27,12 @@ std::optional FilterContentsFilterInput::GetSnapshot( const Entity& entity) const { if (!snapshot_.has_value()) { snapshot_ = filter_->RenderToSnapshot( - renderer, entity, std::nullopt, true, - SPrintF("Filter to %s Filter Snapshot", label.c_str())); + renderer, // renderer + entity, // entity + std::nullopt, // coverage_limit + std::nullopt, // sampler_descriptor + true, // msaa_enabled + SPrintF("Filter to %s Filter Snapshot", label.c_str())); // label } return snapshot_; } diff --git a/impeller/entity/contents/framebuffer_blend_contents.cc b/impeller/entity/contents/framebuffer_blend_contents.cc index 2e5595c824006..e405eb399783a 100644 --- a/impeller/entity/contents/framebuffer_blend_contents.cc +++ b/impeller/entity/contents/framebuffer_blend_contents.cc @@ -41,9 +41,13 @@ bool FramebufferBlendContents::Render(const ContentContext& renderer, auto& host_buffer = pass.GetTransientsBuffer(); - auto src_snapshot = - child_contents_->RenderToSnapshot(renderer, entity, std::nullopt, true, - "FramebufferBlendContents Snapshot"); + auto src_snapshot = child_contents_->RenderToSnapshot( + renderer, // renderer + entity, // entity + Rect::MakeSize(pass.GetRenderTargetSize()), // coverage_limit + std::nullopt, // sampler_descriptor + true, // msaa_enabled + "FramebufferBlendContents Snapshot"); // label if (!src_snapshot.has_value()) { return true; } diff --git a/impeller/entity/contents/texture_contents.cc b/impeller/entity/contents/texture_contents.cc index 149b9b66b784d..575ed1f83d3e9 100644 --- a/impeller/entity/contents/texture_contents.cc +++ b/impeller/entity/contents/texture_contents.cc @@ -76,6 +76,7 @@ std::optional TextureContents::GetCoverage(const Entity& entity) const { std::optional TextureContents::RenderToSnapshot( const ContentContext& renderer, const Entity& entity, + std::optional coverage_limit, const std::optional& sampler_descriptor, bool msaa_enabled, const std::string& label) const { @@ -95,8 +96,12 @@ std::optional TextureContents::RenderToSnapshot( .opacity = opacity}; } return Contents::RenderToSnapshot( - renderer, entity, sampler_descriptor.value_or(sampler_descriptor_), true, - label); + renderer, // renderer + entity, // entity + std::nullopt, // coverage_limit + sampler_descriptor.value_or(sampler_descriptor_), // sampler_descriptor + true, // msaa_enabled + label); // label } static TextureFillVertexShader::PerVertexData ComputeVertexData( diff --git a/impeller/entity/contents/texture_contents.h b/impeller/entity/contents/texture_contents.h index 0de6d290b0777..567e95a3c4818 100644 --- a/impeller/entity/contents/texture_contents.h +++ b/impeller/entity/contents/texture_contents.h @@ -57,6 +57,7 @@ class TextureContents final : public Contents { std::optional RenderToSnapshot( const ContentContext& renderer, const Entity& entity, + std::optional coverage_limit = std::nullopt, const std::optional& sampler_descriptor = std::nullopt, bool msaa_enabled = true, const std::string& label = "Texture Snapshot") const override; diff --git a/impeller/entity/contents/tiled_texture_contents.cc b/impeller/entity/contents/tiled_texture_contents.cc index ce485480eb666..27326cbbb2af0 100644 --- a/impeller/entity/contents/tiled_texture_contents.cc +++ b/impeller/entity/contents/tiled_texture_contents.cc @@ -66,7 +66,12 @@ TiledTextureContents::CreateFilterTexture( const ColorFilterProc& filter = color_filter_.value(); auto color_filter_contents = filter(FilterInput::Make(texture_)); auto snapshot = color_filter_contents->RenderToSnapshot( - renderer, Entity(), std::nullopt, true, "TiledTextureContents Snapshot"); + renderer, // renderer + Entity(), // entity + std::nullopt, // coverage_limit + std::nullopt, // sampler_descriptor + true, // msaa_enabled + "TiledTextureContents Snapshot"); // label if (snapshot.has_value()) { return snapshot.value().texture; } diff --git a/impeller/entity/contents/vertices_contents.cc b/impeller/entity/contents/vertices_contents.cc index 14563ca77201b..8b0dab9e6f252 100644 --- a/impeller/entity/contents/vertices_contents.cc +++ b/impeller/entity/contents/vertices_contents.cc @@ -108,7 +108,12 @@ bool VerticesUVContents::Render(const ContentContext& renderer, auto src_contents = parent_.GetSourceContents(); auto snapshot = src_contents->RenderToSnapshot( - renderer, entity, std::nullopt, true, "VerticesUVContents Snapshot"); + renderer, // renderer + entity, // entity + Rect::MakeSize(pass.GetRenderTargetSize()), // coverage_limit + std::nullopt, // sampler_descriptor + true, // msaa_enabled + "VerticesUVContents Snapshot"); // label if (!snapshot.has_value()) { return false; }