Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some important comments to some of the FilteContents methods #47567

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 41 additions & 10 deletions impeller/entity/contents/filters/filter_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,36 @@ class FilterContents : public Contents {
// |Contents|
const FilterContents* AsFilter() const override;

/// @brief Determines the coverage of source pixels that will be needed
/// to apply this filter under the given transform and produce
/// results anywhere within the indicated coverage limit.
/// @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
/// the |GetCoverage| method computing a source coverage from
/// an intended |output_limit| coverage.
///
/// This is useful for subpass rendering scenarios where a filter
/// will be applied to the output of the subpass and we need to
/// determine how large of a render target to allocate in order
/// to collect all pixels that might affect the supplied output
/// coverage limit. While we might clip the rendering of the subpass,
/// we want to avoid clipping out any pixels that contribute to
/// the output limit via the filtering operation.
/// Both the |output_limit| and the return value are in the
/// transformed coordinate space, and so do not need to be
/// transformed or inverse transformed by the |effect_transform|
/// but individual parameters on the filter might be in the
/// untransformed space and should be transformed by the
/// |effect_transform| before applying them to the coverages.
///
/// The method computes a result such that if the filter is applied
/// to a set of pixels filling the computed source coverage, it
/// should produce an output that covers the entire specified
/// |output_limit|.
///
/// This is useful for subpass rendering scenarios where a filter
/// will be applied to the output of the subpass and we need to
/// determine how large of a render target to allocate in order
/// to collect all pixels that might affect the supplied output
/// coverage limit. While we might end up clipping the rendering
/// of the subpass to its destination, we want to avoid clipping
/// out any pixels that contribute to the output limit via the
/// filtering operation.
///
/// @return The coverage bounds in the transformed space of any source pixel
/// that may be needed to produce output for the indicated filter
/// that covers the indicated |output_limit|.
std::optional<Rect> GetSourceCoverage(const Matrix& effect_transform,
const Rect& output_limit) const;

Expand Down Expand Up @@ -178,11 +197,18 @@ class FilterContents : public Contents {
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode);

private:
/// @brief Internal utility method for |GetLocalCoverage| that computes
/// the output coverage of this filter across the specified inputs,
/// ignoring the coverage hint.
virtual std::optional<Rect> GetFilterCoverage(
const FilterInput::Vector& inputs,
const Entity& entity,
const Matrix& effect_transform) const;

/// @brief Internal utility method for |GetSourceCoverage| that computes
/// the inverse effect of this transform on the specified output
/// coverage, ignoring the inputs which will be accommodated by
/// the caller.
virtual std::optional<Rect> GetFilterSourceCoverage(
const Matrix& effect_transform,
const Rect& output_limit) const = 0;
Expand All @@ -196,6 +222,11 @@ class FilterContents : public Contents {
const Rect& coverage,
const std::optional<Rect>& coverage_hint) const = 0;

/// @brief Internal utility method to compute the coverage of this
/// filter across its internally specified inputs and subject
/// to the coverage hint.
///
/// Uses |GetFilterCoverage|.
std::optional<Rect> GetLocalCoverage(const Entity& local_entity) const;

FilterInput::Vector inputs_;
Expand Down