 |
Flutter Impeller
|
|
Go to the documentation of this file.
8 #include "fml/logging.h"
39 std::move(coverage_proc));
52 const std::optional<Rect>& current_clip_coverage)
const {
54 .coverage = current_clip_coverage};
60 std::optional<Rect> coverage_limit,
61 const std::optional<SamplerDescriptor>& sampler_descriptor,
63 const std::string& label)
const {
65 if (!coverage.has_value()) {
73 coverage = coverage->Expand(1);
75 if (coverage_limit.has_value()) {
76 coverage = coverage->Intersection(*coverage_limit);
77 if (!coverage.has_value()) {
82 fml::StatusOr<RenderTarget> render_target = renderer.
MakeSubpass(
84 [&contents = *
this, &entity, &coverage](
const ContentContext& renderer,
87 sub_entity.SetBlendMode(BlendMode::kSourceOver);
88 sub_entity.SetTransform(
89 Matrix::MakeTranslation(Vector3(-coverage->GetOrigin())) *
90 entity.GetTransform());
91 return contents.Render(renderer, sub_entity, pass);
95 if (!render_target.ok()) {
100 .
texture = render_target.value().GetRenderTargetTexture(),
103 if (sampler_descriptor.has_value()) {
104 snapshot.sampler_descriptor = sampler_descriptor.value();
115 VALIDATION_LOG <<
"Contents::SetInheritedOpacity should never be called when "
116 "Contents::CanAcceptOpacity returns false.";
120 ISize target_size)
const {
134 const std::optional<Rect> clip_coverage)
const {
135 if (!clip_coverage.has_value()) {
139 if (!coverage.has_value()) {
145 return clip_coverage->IntersectsWithRect(coverage.value());
149 coverage_hint_ = coverage_hint;
153 return coverage_hint_;
157 return color_source_size_;
161 color_source_size_ = size;
std::optional< Size > GetColorSourceSize() const
Return the color source's intrinsic size, if available.
ContentContextOptions OptionsFromPass(const RenderPass &pass)
void SetCoverageHint(std::optional< Rect > coverage_hint)
Hint that specifies the coverage area of this Contents that will actually be used during rendering....
virtual std::optional< Color > AsBackgroundColor(const Entity &entity, ISize target_size) const
Returns a color if this Contents will flood the given target_size with a color. This output color is ...
void SetColorSourceSize(Size size)
virtual bool CanInheritOpacity(const Entity &entity) const
Whether or not this contents can accept the opacity peephole optimization.
fml::StatusOr< RenderTarget > MakeSubpass(const std::string &label, ISize texture_size, const SubpassCallback &subpass_callback, bool msaa_enabled=true) const
Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing t...
virtual std::optional< Rect > GetCoverage(const Entity &entity) const =0
Get the area of the render pass that will be affected when this contents is rendered.
constexpr TSize Ceil() const
static constexpr Matrix MakeTranslation(const Vector3 &t)
virtual ClipCoverage GetClipCoverage(const Entity &entity, const std::optional< Rect > ¤t_clip_coverage) const
Given the current pass space bounding rectangle of the clip buffer, return the expected clip coverage...
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
const std::optional< Rect > & GetCoverageHint() const
PixelFormat color_attachment_pixel_format
std::function< Color(Color)> ColorFilterProc
Represents a texture and its intended draw transform/sampler configuration.
SampleCount GetSampleCount() const
The sample count of the attached render target.
virtual bool ShouldRender(const Entity &entity, const std::optional< Rect > clip_coverage) const
bool has_stencil_attachment
BlendMode GetBlendMode() const
Render passes encode render commands directed as one specific render target into an underlying comman...
std::function< bool(const ContentContext &renderer, const Entity &entity, RenderPass &pass)> RenderProc
constexpr static TRect MakeMaximum()
virtual void SetInheritedOpacity(Scalar opacity)
Inherit the provided opacity.
bool HasStencilAttachment() const
Whether the render target has an stencil attachment.
static std::shared_ptr< Contents > MakeAnonymous(RenderProc render_proc, CoverageProc coverage_proc)
virtual bool ApplyColorFilter(const ColorFilterProc &color_filter_proc)
If possible, applies a color filter to this contents inputs on the CPU.
std::function< std::optional< Rect >(const Entity &entity)> CoverageProc
std::shared_ptr< Texture > texture
virtual bool IsOpaque() const
Whether this Contents only emits opaque source colors from the fragment stage. This value does not ac...
virtual const FilterContents * AsFilter() const
Cast to a filter. Returns nullptr if this Contents is not a filter.
static std::shared_ptr< Contents > Make(RenderProc render_proc, CoverageProc coverage_proc)
virtual std::optional< Snapshot > RenderToSnapshot(const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit=std::nullopt, const std::optional< SamplerDescriptor > &sampler_descriptor=std::nullopt, bool msaa_enabled=true, const std::string &label="Snapshot") const
Render this contents to a snapshot, respecting the entity's transform, path, clip depth,...
PixelFormat GetRenderTargetPixelFormat() const
The pixel format of the attached render target.