[Impeller] delete a bunch of dead filter code. (flutter/engine#55841)

All of these filter graph methods are not used or only used to test themselves in a limited unit test. Delete!
This commit is contained in:
Jonah Williams
2024-10-11 19:15:23 -07:00
committed by GitHub
parent 3214f65fa3
commit c9f0e8a458
18 changed files with 0 additions and 190 deletions

View File

@@ -138,10 +138,6 @@ std::optional<Color> Contents::AsBackgroundColor(const Entity& entity,
return {};
}
const FilterContents* Contents::AsFilter() const {
return nullptr;
}
bool Contents::ApplyColorFilter(
const Contents::ColorFilterProc& color_filter_proc) {
return false;

View File

@@ -157,12 +157,6 @@ class Contents {
virtual std::optional<Color> AsBackgroundColor(const Entity& entity,
ISize target_size) const;
//----------------------------------------------------------------------------
/// @brief Cast to a filter. Returns `nullptr` if this Contents is not a
/// filter.
///
virtual const FilterContents* AsFilter() const;
//----------------------------------------------------------------------------
/// @brief If possible, applies a color filter to this contents inputs on
/// the CPU.

View File

@@ -257,10 +257,6 @@ std::optional<Snapshot> FilterContents::RenderToSnapshot(
return std::nullopt;
}
const FilterContents* FilterContents::AsFilter() const {
return this;
}
Matrix FilterContents::GetLocalTransform(const Matrix& parent_transform) const {
return Matrix();
}
@@ -268,33 +264,6 @@ Matrix FilterContents::GetLocalTransform(const Matrix& parent_transform) const {
Matrix FilterContents::GetTransform(const Matrix& parent_transform) const {
return parent_transform * GetLocalTransform(parent_transform);
}
bool FilterContents::IsTranslationOnly() const {
for (auto& input : inputs_) {
if (!input->IsTranslationOnly()) {
return false;
}
}
return true;
}
bool FilterContents::IsLeaf() const {
for (auto& input : inputs_) {
if (!input->IsLeaf()) {
return false;
}
}
return true;
}
void FilterContents::SetLeafInputs(const FilterInput::Vector& inputs) {
if (IsLeaf()) {
inputs_ = inputs;
return;
}
for (auto& input : inputs_) {
input->SetLeafInputs(inputs);
}
}
void FilterContents::SetRenderingMode(Entity::RenderingMode rendering_mode) {
for (auto& input : inputs_) {

View File

@@ -120,9 +120,6 @@ class FilterContents : public Contents {
int32_t mip_count = 1,
const std::string& label = "Filter Snapshot") const override;
// |Contents|
const FilterContents* AsFilter() const override;
/// @brief Determines the coverage of source pixels that will be needed
/// to produce results for the specified |output_limit| under the
/// specified |effect_transform|. This is essentially a reverse of
@@ -160,25 +157,6 @@ class FilterContents : public Contents {
Matrix GetTransform(const Matrix& parent_transform) const;
/// @brief Returns true if this filter graph doesn't perform any basis
/// transforms to the filtered content. For example: Rotating,
/// scaling, and skewing are all basis transforms, but
/// translating is not.
///
/// This is useful for determining whether a filtered object's space
/// is compatible enough with the parent pass space to perform certain
/// subpass clipping optimizations.
virtual bool IsTranslationOnly() const;
/// @brief Returns `true` if this filter does not have any `FilterInput`
/// children.
bool IsLeaf() const;
/// @brief Replaces the set of all leaf `FilterContents` with a new set
/// of `FilterInput`s.
/// @see `FilterContents::IsLeaf`
void SetLeafInputs(const FilterInput::Vector& inputs);
/// @brief Marks this filter chain as applying in a subpass scenario.
///
/// Subpasses render in screenspace, and this setting informs filters

View File

@@ -17,10 +17,6 @@ ContentsFilterInput::ContentsFilterInput(std::shared_ptr<Contents> contents,
ContentsFilterInput::~ContentsFilterInput() = default;
FilterInput::Variant ContentsFilterInput::GetInput() const {
return contents_;
}
std::optional<Snapshot> ContentsFilterInput::GetSnapshot(
const std::string& label,
const ContentContext& renderer,

View File

@@ -13,9 +13,6 @@ class ContentsFilterInput final : public FilterInput {
public:
~ContentsFilterInput() override;
// |FilterInput|
Variant GetInput() const override;
// |FilterInput|
std::optional<Snapshot> GetSnapshot(const std::string& label,
const ContentContext& renderer,

View File

@@ -17,10 +17,6 @@ FilterContentsFilterInput::FilterContentsFilterInput(
FilterContentsFilterInput::~FilterContentsFilterInput() = default;
FilterInput::Variant FilterContentsFilterInput::GetInput() const {
return filter_;
}
std::optional<Snapshot> FilterContentsFilterInput::GetSnapshot(
const std::string& label,
const ContentContext& renderer,
@@ -60,19 +56,6 @@ Matrix FilterContentsFilterInput::GetTransform(const Entity& entity) const {
return filter_->GetTransform(entity.GetTransform());
}
bool FilterContentsFilterInput::IsTranslationOnly() const {
return filter_->IsTranslationOnly();
}
bool FilterContentsFilterInput::IsLeaf() const {
return false;
}
void FilterContentsFilterInput::SetLeafInputs(
const FilterInput::Vector& inputs) {
filter_->SetLeafInputs(inputs);
}
void FilterContentsFilterInput::SetEffectTransform(const Matrix& matrix) {
filter_->SetEffectTransform(matrix);
}

View File

@@ -13,9 +13,6 @@ class FilterContentsFilterInput final : public FilterInput {
public:
~FilterContentsFilterInput() override;
// |FilterInput|
Variant GetInput() const override;
// |FilterInput|
std::optional<Snapshot> GetSnapshot(const std::string& label,
const ContentContext& renderer,
@@ -37,15 +34,6 @@ class FilterContentsFilterInput final : public FilterInput {
// |FilterInput|
Matrix GetTransform(const Entity& entity) const override;
// |FilterInput|
bool IsTranslationOnly() const override;
// |FilterInput|
bool IsLeaf() const override;
// |FilterInput|
void SetLeafInputs(const FilterInput::Vector& inputs) override;
// |FilterInput|
virtual void SetEffectTransform(const Matrix& matrix) override;

View File

@@ -78,16 +78,6 @@ Matrix FilterInput::GetTransform(const Entity& entity) const {
FilterInput::~FilterInput() = default;
bool FilterInput::IsTranslationOnly() const {
return true;
}
bool FilterInput::IsLeaf() const {
return true;
}
void FilterInput::SetLeafInputs(const FilterInput::Vector& inputs) {}
void FilterInput::SetEffectTransform(const Matrix& matrix) {}
void FilterInput::SetRenderingMode(Entity::RenderingMode rendering_mode) {}

View File

@@ -45,8 +45,6 @@ class FilterInput {
static FilterInput::Vector Make(std::initializer_list<Variant> inputs);
virtual Variant GetInput() const = 0;
virtual std::optional<Snapshot> GetSnapshot(
const std::string& label,
const ContentContext& renderer,
@@ -69,18 +67,6 @@ class FilterInput {
/// calling `entity.GetTransform() * GetLocalTransform()`.
virtual Matrix GetTransform(const Entity& entity) const;
/// @see `FilterContents::HasBasisTransforms`
virtual bool IsTranslationOnly() const;
/// @brief Returns `true` unless this input is a `FilterInput`, which may
/// take other inputs.
virtual bool IsLeaf() const;
/// @brief Replaces the inputs of all leaf `FilterContents` with a new set
/// of `inputs`.
/// @see `FilterInput::IsLeaf`
virtual void SetLeafInputs(const FilterInput::Vector& inputs);
/// @brief Sets the effect transform of filter inputs.
virtual void SetEffectTransform(const Matrix& matrix);

View File

@@ -5,10 +5,8 @@
#include <memory>
#include "flutter/testing/testing.h"
#include "gtest/gtest.h"
#include "impeller/entity/contents/filters/color_filter_contents.h"
#include "impeller/entity/contents/filters/inputs/filter_input.h"
#include "impeller/entity/entity.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/geometry_asserts.h"
namespace impeller {
@@ -27,41 +25,5 @@ TEST(FilterInputTest, CanSetLocalTransformForTexture) {
Matrix::MakeTranslation({1.0, 2.0, 0.0}));
}
TEST(FilterInputTest, IsLeaf) {
std::shared_ptr<FilterContents> leaf =
ColorFilterContents::MakeBlend(BlendMode::kSource, {});
ASSERT_TRUE(leaf->IsLeaf());
auto base = ColorFilterContents::MakeMatrixFilter(FilterInput::Make(leaf),
Matrix(), {});
ASSERT_TRUE(leaf->IsLeaf());
ASSERT_FALSE(base->IsLeaf());
}
TEST(FilterInputTest, SetCoverageInputs) {
std::shared_ptr<FilterContents> leaf =
ColorFilterContents::MakeBlend(BlendMode::kSource, {});
ASSERT_TRUE(leaf->IsLeaf());
auto base = ColorFilterContents::MakeMatrixFilter(FilterInput::Make(leaf),
Matrix(), {});
{
auto result = base->GetCoverage({});
ASSERT_FALSE(result.has_value());
}
auto coverage_rect = Rect::MakeLTRB(100, 100, 200, 200);
base->SetLeafInputs(FilterInput::Make({coverage_rect}));
{
auto result = base->GetCoverage({});
ASSERT_TRUE(result.has_value());
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
ASSERT_RECT_NEAR(result.value(), coverage_rect);
}
}
} // namespace testing
} // namespace impeller

View File

@@ -5,9 +5,6 @@
#include "impeller/entity/contents/filters/inputs/placeholder_filter_input.h"
#include <optional>
#include <utility>
#include "impeller/base/strings.h"
namespace impeller {
@@ -16,10 +13,6 @@ PlaceholderFilterInput::PlaceholderFilterInput(Rect coverage_rect)
PlaceholderFilterInput::~PlaceholderFilterInput() = default;
FilterInput::Variant PlaceholderFilterInput::GetInput() const {
return coverage_rect_;
}
std::optional<Snapshot> PlaceholderFilterInput::GetSnapshot(
const std::string& label,
const ContentContext& renderer,

View File

@@ -15,9 +15,6 @@ class PlaceholderFilterInput final : public FilterInput {
~PlaceholderFilterInput() override;
// |FilterInput|
Variant GetInput() const override;
// |FilterInput|
std::optional<Snapshot> GetSnapshot(const std::string& label,
const ContentContext& renderer,

View File

@@ -16,10 +16,6 @@ TextureFilterInput::TextureFilterInput(std::shared_ptr<Texture> texture,
TextureFilterInput::~TextureFilterInput() = default;
FilterInput::Variant TextureFilterInput::GetInput() const {
return texture_;
}
std::optional<Snapshot> TextureFilterInput::GetSnapshot(
const std::string& label,
const ContentContext& renderer,

View File

@@ -15,9 +15,6 @@ class TextureFilterInput final : public FilterInput {
public:
~TextureFilterInput() override;
// |FilterInput|
Variant GetInput() const override;
// |FilterInput|
std::optional<Snapshot> GetSnapshot(const std::string& label,
const ContentContext& renderer,

View File

@@ -20,10 +20,6 @@ void MatrixFilterContents::SetRenderingMode(
FilterContents::SetRenderingMode(rendering_mode);
}
bool MatrixFilterContents::IsTranslationOnly() const {
return matrix_.Basis().IsIdentity() && FilterContents::IsTranslationOnly();
}
void MatrixFilterContents::SetSamplerDescriptor(SamplerDescriptor desc) {
sampler_descriptor_ = std::move(desc);
}

View File

@@ -21,9 +21,6 @@ class MatrixFilterContents final : public FilterContents {
// |FilterContents|
void SetRenderingMode(Entity::RenderingMode rendering_mode) override;
// |FilterContents|
bool IsTranslationOnly() const override;
void SetSamplerDescriptor(SamplerDescriptor desc);
// |FilterContents|

View File

@@ -42,11 +42,6 @@ class MatrixFilterContentsTest : public EntityPlayground {
INSTANTIATE_PLAYGROUND_SUITE(MatrixFilterContentsTest);
TEST(MatrixFilterContentsTest, Create) {
MatrixFilterContents contents;
EXPECT_TRUE(contents.IsTranslationOnly());
}
TEST(MatrixFilterContentsTest, CoverageEmpty) {
MatrixFilterContents contents;
FilterInput::Vector inputs = {};