From 1cbd273449a0272cf3e554c9fa2103e313becf85 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Tue, 3 Oct 2023 23:27:23 -0700 Subject: [PATCH] [Impeller] Clarify coverage space. (flutter/engine#46524) Update the coverage docstrings to clarify which space the coordinates are given in. Up until now, I've been using the phrase "screen space" to convey that coverage is counted in framebuffer pixels and is unaffected by the subpass transform basis. But a more accurate way to describe this would be "pass space", since it counts pixels relative to the top left corner of the framebuffer that the Entity is being drawn to during rendering. --- .../flutter/impeller/entity/contents/contents.h | 14 ++++++++++++-- engine/src/flutter/impeller/entity/entity.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/impeller/entity/contents/contents.h b/engine/src/flutter/impeller/entity/contents/contents.h index e06af8a2a0..6a25261ac0 100644 --- a/engine/src/flutter/impeller/entity/contents/contents.h +++ b/engine/src/flutter/impeller/entity/contents/contents.h @@ -66,7 +66,14 @@ class Contents { RenderPass& pass) const = 0; //---------------------------------------------------------------------------- - /// @brief Get the screen space bounding rectangle that this contents affects. + /// @brief Get the area of the render pass that will be affected when this + /// contents is rendered. + /// + /// During rendering, coverage coordinates count pixels from the top + /// left corner of the framebuffer. + /// + /// @return The coverage rectangle. An `std::nullopt` result means that + /// rendering this contents has no effect on the output color. /// virtual std::optional GetCoverage(const Entity& entity) const = 0; @@ -89,11 +96,14 @@ class Contents { virtual bool IsOpaque() const; //---------------------------------------------------------------------------- - /// @brief Given the current screen space bounding rectangle of the clip + /// @brief Given the current pass space bounding rectangle of the clip /// buffer, return the expected clip coverage after this draw call. /// This should only be implemented for contents that may write to the /// clip buffer. /// + /// During rendering, coverage coordinates count pixels from the top + /// left corner of the framebuffer. + /// virtual ClipCoverage GetClipCoverage( const Entity& entity, const std::optional& current_clip_coverage) const; diff --git a/engine/src/flutter/impeller/entity/entity.h b/engine/src/flutter/impeller/entity/entity.h index 9b210d0c19..26fa0b3974 100644 --- a/engine/src/flutter/impeller/entity/entity.h +++ b/engine/src/flutter/impeller/entity/entity.h @@ -71,8 +71,10 @@ class Entity { ~Entity(); + /// @brief Get the global transformation matrix for this Entity. const Matrix& GetTransformation() const; + /// @brief Set the global transformation matrix for this Entity. void SetTransformation(const Matrix& transformation); std::optional GetCoverage() const;