 |
Flutter Impeller
|
|
Go to the documentation of this file.
8 #include "fml/logging.h"
48 const std::optional<Rect>& current_clip_coverage)
const {
49 if (!current_clip_coverage.has_value()) {
50 return {.
type = ClipCoverage::Type::kAppend, .coverage = std::nullopt};
56 return {.type = ClipCoverage::Type::kAppend,
57 .coverage = current_clip_coverage};
60 return {.type = ClipCoverage::Type::kAppend, .coverage = std::nullopt};
62 auto coverage = geometry_->GetCoverage(entity.
GetTransform());
63 if (!coverage.has_value() || !current_clip_coverage.has_value()) {
64 return {.type = ClipCoverage::Type::kAppend, .coverage = std::nullopt};
67 .type = ClipCoverage::Type::kAppend,
68 .coverage = current_clip_coverage->Intersection(coverage.value()),
75 const std::optional<Rect> clip_coverage)
const {
95 geometry_->IsAxisAlignedRect() &&
97 std::optional<Rect> coverage =
99 if (coverage.has_value() &&
110 auto geometry_result = geometry_->GetPositionBuffer(renderer, entity, pass);
118 options.depth_write_enabled =
false;
119 options.primitive_type = geometry_result.type;
121 switch (geometry_result.mode) {
124 options.stencil_mode =
129 options.stencil_mode =
135 options.stencil_mode =
141 info.mvp = geometry_result.transform;
144 if (!pass.
Draw().ok()) {
150 options.depth_write_enabled =
true;
156 options.stencil_mode =
163 std::optional<Rect> maybe_cover_area =
165 if (!maybe_cover_area.has_value()) {
168 cover_area = maybe_cover_area.value();
174 .
AddVertices({{points[0]}, {points[1]}, {points[2]}, {points[3]}})
183 return pass.
Draw().ok();
195 restore_height_ = clip_height;
199 return restore_height_;
203 std::optional<Rect> restore_coverage) {
204 restore_coverage_ = restore_coverage;
208 const Entity& entity)
const {
214 const std::optional<Rect>& current_clip_coverage)
const {
215 return {.
type = ClipCoverage::Type::kRestore, .coverage = std::nullopt};
220 const std::optional<Rect> clip_coverage)
const {
238 options.stencil_mode =
251 {
Point(ltrb[0], ltrb[1])},
252 {
Point(ltrb[2], ltrb[1])},
253 {
Point(ltrb[0], ltrb[3])},
254 {
Point(ltrb[2], ltrb[3])},
264 return pass.
Draw().ok();
@ kNormal
The geometry has no overlapping triangles.
ContentContextOptions OptionsFromPass(const RenderPass &pass)
float GetShaderClipDepth() const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
@ kOverdrawPreventionIncrement
bool CanInheritOpacity(const Entity &entity) const override
Whether or not this contents can accept the opacity peephole optimization.
std::shared_ptr< Pipeline< PipelineDescriptor > > GetClipPipeline(ContentContextOptions opts) const
void SetClipOperation(Entity::ClipOperation clip_op)
virtual bool SetVertexBuffer(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
void SetRestoreCoverage(std::optional< Rect > coverage)
The area on the pass texture where this clip restore will be applied. If unset, the entire pass textu...
VertexBufferBuilder & AddVertices(std::initializer_list< VertexType_ > vertices)
size_t GetRestoreHeight() const
virtual void SetCommandLabel(std::string_view label)
The debugging label to use for the command.
const Matrix & GetOrthographicTransform() const
bool ShouldRender(const Entity &entity, const std::optional< Rect > clip_coverage) const override
constexpr std::array< TPoint< T >, 4 > GetPoints() const
Get the points that represent the 4 corners of this rectangle in a Z order that is compatible with tr...
ClipCoverage GetClipCoverage(const Entity &entity, const std::optional< Rect > ¤t_clip_coverage) const override
Given the current pass space bounding rectangle of the clip buffer, return the expected clip coverage...
virtual fml::Status Draw()
Record the currently pending command.
static Scalar GetShaderClipDepth(const Entity &entity)
ISize GetRenderTargetSize() const
void SetGeometry(const std::shared_ptr< Geometry > &geometry)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
constexpr bool IsTranslationScaleOnly() const
Returns true if the matrix has a scale-only basis and is non-projective. Note that an identity matrix...
VertexShader_ VertexShader
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
virtual void SetStencilReference(uint32_t value)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
VertexBuffer CreateVertexBuffer(HostBuffer &host_buffer) const
Render passes encode render commands directed as one specific render target into an underlying comman...
uint32_t GetClipDepth() const
bool ShouldRender(const Entity &entity, const std::optional< Rect > clip_coverage) const override
constexpr static TRect MakeSize(const TSize< U > &size)
ClipCoverage GetClipCoverage(const Entity &entity, const std::optional< Rect > ¤t_clip_coverage) const override
Given the current pass space bounding rectangle of the clip buffer, return the expected clip coverage...
BufferView EmplaceUniform(const UniformType &uniform)
Emplace uniform data onto the host buffer. Ensure that backend specific uniform alignment requirement...
bool CanInheritOpacity(const Entity &entity) const override
Whether or not this contents can accept the opacity peephole optimization.
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
void SetRestoreHeight(size_t clip_height)
@ kOverdrawPreventionRestore
virtual void SetPipeline(const std::shared_ptr< Pipeline< PipelineDescriptor >> &pipeline)
The pipeline to use for this command.
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.