diff --git a/engine/src/flutter/impeller/entity/contents/contents.cc b/engine/src/flutter/impeller/entity/contents/contents.cc index 60998616fe..21d7ebf75d 100644 --- a/engine/src/flutter/impeller/entity/contents/contents.cc +++ b/engine/src/flutter/impeller/entity/contents/contents.cc @@ -60,7 +60,7 @@ std::optional Contents::RenderToSnapshot( const std::optional& sampler_descriptor, bool msaa_enabled, int32_t mip_count, - const std::string& label) const { + std::string_view label) const { auto coverage = GetCoverage(entity); if (!coverage.has_value()) { return std::nullopt; diff --git a/engine/src/flutter/impeller/entity/contents/contents.h b/engine/src/flutter/impeller/entity/contents/contents.h index 31a8aed38f..2672136c52 100644 --- a/engine/src/flutter/impeller/entity/contents/contents.h +++ b/engine/src/flutter/impeller/entity/contents/contents.h @@ -95,7 +95,7 @@ class Contents { const std::optional& sampler_descriptor = std::nullopt, bool msaa_enabled = true, int32_t mip_count = 1, - const std::string& label = "Snapshot") const; + std::string_view label = "Snapshot") const; //---------------------------------------------------------------------------- /// @brief Return the color source's intrinsic size, if available. diff --git a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc index 3f07150c3d..e749be2b73 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc @@ -30,6 +30,24 @@ namespace impeller { +namespace { + +#ifdef IMPELLER_DEBUG + +#define _IMPELLER_BLEND_MODE_FILTER_NAME_LIST(blend_mode) \ + "Blend Filter " #blend_mode, + +static constexpr const char* kBlendModeFilterNames[] = { + IMPELLER_FOR_EACH_BLEND_MODE(_IMPELLER_BLEND_MODE_FILTER_NAME_LIST)}; + +const std::string_view BlendModeToFilterString(BlendMode blend_mode) { + return kBlendModeFilterNames[static_cast>( + blend_mode)]; +} +#endif // IMPELLER_DEBUG + +} // namespace + std::optional InvertPorterDuffBlend(BlendMode blend_mode) { switch (blend_mode) { case BlendMode::kClear: @@ -173,8 +191,7 @@ static std::optional AdvancedBlend( PipelineRef pipeline = std::invoke(pipeline_proc, renderer, options); #ifdef IMPELLER_DEBUG - pass.SetCommandLabel( - SPrintF("Advanced Blend Filter (%s)", BlendModeToString(blend_mode))); + pass.SetCommandLabel(BlendModeToFilterString(blend_mode)); #endif // IMPELLER_DEBUG pass.SetVertexBuffer(std::move(vtx_buffer)); pass.SetPipeline(pipeline); @@ -296,8 +313,7 @@ std::optional BlendFilterContents::CreateForegroundAdvancedBlend( CreateVertexBuffer(vertices, renderer.GetTransientsBuffer()); #ifdef IMPELLER_DEBUG - pass.SetCommandLabel(SPrintF("Foreground Advanced Blend Filter (%s)", - BlendModeToString(blend_mode))); + pass.SetCommandLabel(BlendModeToFilterString(blend_mode)); #endif // IMPELLER_DEBUG pass.SetVertexBuffer(std::move(vtx_buffer)); auto options = OptionsFromPassAndEntity(pass, entity); @@ -449,8 +465,7 @@ std::optional BlendFilterContents::CreateForegroundPorterDuffBlend( CreateVertexBuffer(vertices, renderer.GetTransientsBuffer()); #ifdef IMPELLER_DEBUG - pass.SetCommandLabel(SPrintF("Foreground PorterDuff Blend Filter (%s)", - BlendModeToString(blend_mode))); + pass.SetCommandLabel(BlendModeToFilterString(blend_mode)); #endif // IMPELLER_DEBUG pass.SetVertexBuffer(std::move(vtx_buffer)); auto options = OptionsFromPassAndEntity(pass, entity); @@ -548,8 +563,7 @@ static std::optional PipelineBlend( auto& host_buffer = renderer.GetTransientsBuffer(); #ifdef IMPELLER_DEBUG - pass.SetCommandLabel( - SPrintF("Pipeline Blend Filter (%s)", BlendModeToString(blend_mode))); + pass.SetCommandLabel(BlendModeToFilterString(blend_mode)); #endif // IMPELLER_DEBUG auto options = OptionsFromPass(pass); options.primitive_type = PrimitiveType::kTriangleStrip; diff --git a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc index ddfaa2c638..9d42ad104d 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc @@ -253,7 +253,7 @@ std::optional FilterContents::RenderToSnapshot( const std::optional& sampler_descriptor, bool msaa_enabled, int32_t mip_count, - const std::string& label) const { + std::string_view label) const { // Resolve the render instruction (entity) from the filter and render it to a // snapshot. if (std::optional result = @@ -266,7 +266,8 @@ std::optional FilterContents::RenderToSnapshot( std::nullopt, // sampler_descriptor true, // msaa_enabled /*mip_count=*/mip_count, - label); // label + label // label + ); } return std::nullopt; diff --git a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.h b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.h index 3177cf7518..baa168f167 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.h +++ b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.h @@ -126,7 +126,7 @@ class FilterContents : public Contents { const std::optional& sampler_descriptor = std::nullopt, bool msaa_enabled = true, int32_t mip_count = 1, - const std::string& label = "Filter Snapshot") const override; + std::string_view label = "Filter Snapshot") const override; /// @brief Determines the coverage of source pixels that will be needed /// to produce results for the specified |output_limit| under the diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.cc b/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.cc index 57a68747e9..9be12186d4 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.cc @@ -7,8 +7,6 @@ #include #include -#include "impeller/base/strings.h" - namespace impeller { ContentsFilterInput::ContentsFilterInput(std::shared_ptr contents, @@ -18,7 +16,7 @@ ContentsFilterInput::ContentsFilterInput(std::shared_ptr contents, ContentsFilterInput::~ContentsFilterInput() = default; std::optional ContentsFilterInput::GetSnapshot( - const std::string& label, + std::string_view label, const ContentContext& renderer, const Entity& entity, std::optional coverage_limit, @@ -27,14 +25,14 @@ std::optional ContentsFilterInput::GetSnapshot( coverage_limit = entity.GetContents()->GetCoverageHint(); } if (!snapshot_.has_value()) { - snapshot_ = contents_->RenderToSnapshot( - renderer, // renderer - entity, // entity - coverage_limit, // coverage_limit - std::nullopt, // sampler_descriptor - msaa_enabled_, // msaa_enabled - /*mip_count=*/mip_count, - SPrintF("Contents to %s Filter Snapshot", label.c_str())); // label + snapshot_ = contents_->RenderToSnapshot(renderer, // renderer + entity, // entity + coverage_limit, // coverage_limit + std::nullopt, // sampler_descriptor + msaa_enabled_, // msaa_enabled + /*mip_count=*/mip_count, // + label // + ); } return snapshot_; } diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.h b/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.h index 0a43968f9f..42258f3d3a 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.h +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.h @@ -14,7 +14,7 @@ class ContentsFilterInput final : public FilterInput { ~ContentsFilterInput() override; // |FilterInput| - std::optional GetSnapshot(const std::string& label, + std::optional GetSnapshot(std::string_view label, const ContentContext& renderer, const Entity& entity, std::optional coverage_limit, diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc index 9eb01a7437..10000909a7 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc @@ -18,20 +18,19 @@ FilterContentsFilterInput::FilterContentsFilterInput( FilterContentsFilterInput::~FilterContentsFilterInput() = default; std::optional FilterContentsFilterInput::GetSnapshot( - const std::string& label, + std::string_view label, const ContentContext& renderer, const Entity& entity, std::optional coverage_limit, int32_t mip_count) const { if (!snapshot_.has_value()) { - snapshot_ = filter_->RenderToSnapshot( - renderer, // renderer - entity, // entity - coverage_limit, // coverage_limit - std::nullopt, // sampler_descriptor - true, // msaa_enabled - /*mip_count=*/mip_count, - SPrintF("Filter to %s Filter Snapshot", label.c_str())); // label + snapshot_ = filter_->RenderToSnapshot(renderer, // renderer + entity, // entity + coverage_limit, // coverage_limit + std::nullopt, // sampler_descriptor + true, // msaa_enabled + /*mip_count=*/mip_count, // + label); // label } return snapshot_; } diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.h b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.h index d1f42f32ea..9bcac002b6 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.h +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.h @@ -14,7 +14,7 @@ class FilterContentsFilterInput final : public FilterInput { ~FilterContentsFilterInput() override; // |FilterInput| - std::optional GetSnapshot(const std::string& label, + std::optional GetSnapshot(std::string_view label, const ContentContext& renderer, const Entity& entity, std::optional coverage_limit, diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.h b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.h index e8edd041c7..7888ac6ef9 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.h +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.h @@ -46,7 +46,7 @@ class FilterInput { static FilterInput::Vector Make(std::initializer_list inputs); virtual std::optional GetSnapshot( - const std::string& label, + std::string_view label, const ContentContext& renderer, const Entity& entity, std::optional coverage_limit = std::nullopt, diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/placeholder_filter_input.cc b/engine/src/flutter/impeller/entity/contents/filters/inputs/placeholder_filter_input.cc index 2742340d40..0201645f40 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/placeholder_filter_input.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/placeholder_filter_input.cc @@ -14,7 +14,7 @@ PlaceholderFilterInput::PlaceholderFilterInput(Rect coverage_rect) PlaceholderFilterInput::~PlaceholderFilterInput() = default; std::optional PlaceholderFilterInput::GetSnapshot( - const std::string& label, + std::string_view label, const ContentContext& renderer, const Entity& entity, std::optional coverage_limit, diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/placeholder_filter_input.h b/engine/src/flutter/impeller/entity/contents/filters/inputs/placeholder_filter_input.h index 1096d57246..e64688c030 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/placeholder_filter_input.h +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/placeholder_filter_input.h @@ -16,7 +16,7 @@ class PlaceholderFilterInput final : public FilterInput { ~PlaceholderFilterInput() override; // |FilterInput| - std::optional GetSnapshot(const std::string& label, + std::optional GetSnapshot(std::string_view label, const ContentContext& renderer, const Entity& entity, std::optional coverage_limit, diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.cc b/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.cc index 0e84e74037..38ee99a5b7 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.cc @@ -17,7 +17,7 @@ TextureFilterInput::TextureFilterInput(std::shared_ptr texture, TextureFilterInput::~TextureFilterInput() = default; std::optional TextureFilterInput::GetSnapshot( - const std::string& label, + std::string_view label, const ContentContext& renderer, const Entity& entity, std::optional coverage_limit, diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.h b/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.h index 218659b28e..817dcb3077 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.h +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.h @@ -16,7 +16,7 @@ class TextureFilterInput final : public FilterInput { ~TextureFilterInput() override; // |FilterInput| - std::optional GetSnapshot(const std::string& label, + std::optional GetSnapshot(std::string_view label, const ContentContext& renderer, const Entity& entity, std::optional coverage_limit, diff --git a/engine/src/flutter/impeller/entity/contents/texture_contents.cc b/engine/src/flutter/impeller/entity/contents/texture_contents.cc index f443558dd1..9e6274c33c 100644 --- a/engine/src/flutter/impeller/entity/contents/texture_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/texture_contents.cc @@ -77,7 +77,7 @@ std::optional TextureContents::RenderToSnapshot( const std::optional& sampler_descriptor, bool msaa_enabled, int32_t mip_count, - const std::string& label) const { + std::string_view label) const { // Passthrough textures that have simple rectangle paths and complete source // rects. auto bounds = destination_rect_; diff --git a/engine/src/flutter/impeller/entity/contents/texture_contents.h b/engine/src/flutter/impeller/entity/contents/texture_contents.h index 34657ff54d..92cb29a234 100644 --- a/engine/src/flutter/impeller/entity/contents/texture_contents.h +++ b/engine/src/flutter/impeller/entity/contents/texture_contents.h @@ -62,7 +62,7 @@ class TextureContents final : public Contents { const std::optional& sampler_descriptor = std::nullopt, bool msaa_enabled = true, int32_t mip_count = 1, - const std::string& label = "Texture Snapshot") const override; + std::string_view label = "Texture Snapshot") const override; // |Contents| bool Render(const ContentContext& renderer, diff --git a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.cc b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.cc index 549abf32ff..c082155cd7 100644 --- a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.cc @@ -175,7 +175,7 @@ std::optional TiledTextureContents::RenderToSnapshot( const std::optional& sampler_descriptor, bool msaa_enabled, int32_t mip_count, - const std::string& label) const { + std::string_view label) const { std::optional geometry_coverage = GetGeometry()->GetCoverage({}); if (GetInverseEffectTransform().IsIdentity() && GetGeometry()->IsAxisAlignedRect() && diff --git a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.h b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.h index 3c883aabab..c10d74f412 100644 --- a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.h +++ b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.h @@ -59,7 +59,7 @@ class TiledTextureContents final : public ColorSourceContents { const std::optional& sampler_descriptor = std::nullopt, bool msaa_enabled = true, int32_t mip_count = 1, - const std::string& label = "Tiled Texture Snapshot") const override; + std::string_view label = "Tiled Texture Snapshot") const override; private: std::shared_ptr CreateFilterTexture(