[Impeller] dont print format strings for blend filter and snapshots. (flutter/engine#57105)
We can use a macro to distinguish between all of the blend modes. We don't need to distinguish between porter duff/ advanced /pipeline as the pipeline is already labeled with the shader used. For all snapshots the additional label on the texture isn't useful since we can just look at the command.
This commit is contained in:
parent
d9cdbeebea
commit
84931c12d7
@ -60,7 +60,7 @@ std::optional<Snapshot> Contents::RenderToSnapshot(
|
||||
const std::optional<SamplerDescriptor>& 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;
|
||||
|
@ -95,7 +95,7 @@ class Contents {
|
||||
const std::optional<SamplerDescriptor>& 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.
|
||||
|
@ -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<std::underlying_type_t<BlendMode>>(
|
||||
blend_mode)];
|
||||
}
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
} // namespace
|
||||
|
||||
std::optional<BlendMode> InvertPorterDuffBlend(BlendMode blend_mode) {
|
||||
switch (blend_mode) {
|
||||
case BlendMode::kClear:
|
||||
@ -173,8 +191,7 @@ static std::optional<Entity> 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<Entity> 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<Entity> 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<Entity> 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;
|
||||
|
@ -253,7 +253,7 @@ std::optional<Snapshot> FilterContents::RenderToSnapshot(
|
||||
const std::optional<SamplerDescriptor>& 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<Entity> result =
|
||||
@ -266,7 +266,8 @@ std::optional<Snapshot> FilterContents::RenderToSnapshot(
|
||||
std::nullopt, // sampler_descriptor
|
||||
true, // msaa_enabled
|
||||
/*mip_count=*/mip_count,
|
||||
label); // label
|
||||
label // label
|
||||
);
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
|
@ -126,7 +126,7 @@ class FilterContents : public Contents {
|
||||
const std::optional<SamplerDescriptor>& 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
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
#include "impeller/base/strings.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ContentsFilterInput::ContentsFilterInput(std::shared_ptr<Contents> contents,
|
||||
@ -18,7 +16,7 @@ ContentsFilterInput::ContentsFilterInput(std::shared_ptr<Contents> contents,
|
||||
ContentsFilterInput::~ContentsFilterInput() = default;
|
||||
|
||||
std::optional<Snapshot> ContentsFilterInput::GetSnapshot(
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
std::optional<Rect> coverage_limit,
|
||||
@ -27,14 +25,14 @@ std::optional<Snapshot> 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_;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class ContentsFilterInput final : public FilterInput {
|
||||
~ContentsFilterInput() override;
|
||||
|
||||
// |FilterInput|
|
||||
std::optional<Snapshot> GetSnapshot(const std::string& label,
|
||||
std::optional<Snapshot> GetSnapshot(std::string_view label,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
std::optional<Rect> coverage_limit,
|
||||
|
@ -18,20 +18,19 @@ FilterContentsFilterInput::FilterContentsFilterInput(
|
||||
FilterContentsFilterInput::~FilterContentsFilterInput() = default;
|
||||
|
||||
std::optional<Snapshot> FilterContentsFilterInput::GetSnapshot(
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
std::optional<Rect> 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_;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class FilterContentsFilterInput final : public FilterInput {
|
||||
~FilterContentsFilterInput() override;
|
||||
|
||||
// |FilterInput|
|
||||
std::optional<Snapshot> GetSnapshot(const std::string& label,
|
||||
std::optional<Snapshot> GetSnapshot(std::string_view label,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
std::optional<Rect> coverage_limit,
|
||||
|
@ -46,7 +46,7 @@ class FilterInput {
|
||||
static FilterInput::Vector Make(std::initializer_list<Variant> inputs);
|
||||
|
||||
virtual std::optional<Snapshot> GetSnapshot(
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
std::optional<Rect> coverage_limit = std::nullopt,
|
||||
|
@ -14,7 +14,7 @@ PlaceholderFilterInput::PlaceholderFilterInput(Rect coverage_rect)
|
||||
PlaceholderFilterInput::~PlaceholderFilterInput() = default;
|
||||
|
||||
std::optional<Snapshot> PlaceholderFilterInput::GetSnapshot(
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
std::optional<Rect> coverage_limit,
|
||||
|
@ -16,7 +16,7 @@ class PlaceholderFilterInput final : public FilterInput {
|
||||
~PlaceholderFilterInput() override;
|
||||
|
||||
// |FilterInput|
|
||||
std::optional<Snapshot> GetSnapshot(const std::string& label,
|
||||
std::optional<Snapshot> GetSnapshot(std::string_view label,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
std::optional<Rect> coverage_limit,
|
||||
|
@ -17,7 +17,7 @@ TextureFilterInput::TextureFilterInput(std::shared_ptr<Texture> texture,
|
||||
TextureFilterInput::~TextureFilterInput() = default;
|
||||
|
||||
std::optional<Snapshot> TextureFilterInput::GetSnapshot(
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
std::optional<Rect> coverage_limit,
|
||||
|
@ -16,7 +16,7 @@ class TextureFilterInput final : public FilterInput {
|
||||
~TextureFilterInput() override;
|
||||
|
||||
// |FilterInput|
|
||||
std::optional<Snapshot> GetSnapshot(const std::string& label,
|
||||
std::optional<Snapshot> GetSnapshot(std::string_view label,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
std::optional<Rect> coverage_limit,
|
||||
|
@ -77,7 +77,7 @@ std::optional<Snapshot> TextureContents::RenderToSnapshot(
|
||||
const std::optional<SamplerDescriptor>& 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_;
|
||||
|
@ -62,7 +62,7 @@ class TextureContents final : public Contents {
|
||||
const std::optional<SamplerDescriptor>& 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,
|
||||
|
@ -175,7 +175,7 @@ std::optional<Snapshot> TiledTextureContents::RenderToSnapshot(
|
||||
const std::optional<SamplerDescriptor>& sampler_descriptor,
|
||||
bool msaa_enabled,
|
||||
int32_t mip_count,
|
||||
const std::string& label) const {
|
||||
std::string_view label) const {
|
||||
std::optional<Rect> geometry_coverage = GetGeometry()->GetCoverage({});
|
||||
if (GetInverseEffectTransform().IsIdentity() &&
|
||||
GetGeometry()->IsAxisAlignedRect() &&
|
||||
|
@ -59,7 +59,7 @@ class TiledTextureContents final : public ColorSourceContents {
|
||||
const std::optional<SamplerDescriptor>& 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<Texture> CreateFilterTexture(
|
||||
|
Loading…
x
Reference in New Issue
Block a user