19 std::shared_ptr<RuntimeStage> runtime_stage) {
20 runtime_stage_ = std::move(runtime_stage);
24 std::shared_ptr<std::vector<uint8_t>> uniforms) {
25 uniforms_ = std::move(uniforms);
29 std::vector<RuntimeEffectContents::TextureInput> texture_inputs) {
30 texture_inputs_ = std::move(texture_inputs);
34std::optional<Entity> RuntimeEffectFilterContents::RenderFilter(
38 const Matrix& effect_transform,
40 const std::optional<Rect>& coverage_hint)
const {
45 std::optional<Snapshot> input_snapshot =
46 inputs[0]->GetSnapshot(
"RuntimeEffectContents", renderer, entity);
47 if (!input_snapshot.has_value()) {
51 std::optional<Rect> maybe_input_coverage = input_snapshot->GetCoverage();
52 if (!maybe_input_coverage.has_value()) {
69 if (!input_snapshot->transform.IsIdentity()) {
70 Matrix inverse = input_snapshot->transform.Invert();
77 TextureContents texture_contents;
78 texture_contents.SetTexture(input_snapshot->texture);
79 std::optional<Rect> bounds =
81 if (bounds.has_value()) {
82 texture_contents.SetSourceRect(bounds.value());
83 texture_contents.SetDestinationRect(coverage);
84 texture_contents.SetStencilEnabled(
false);
85 texture_contents.SetSamplerDescriptor(input_snapshot->sampler_descriptor);
90 input_snapshot = texture_contents.RenderToSnapshot(
91 renderer, entity, {.coverage_expansion = 0});
92 if (!input_snapshot.has_value()) {
102 if (texture_inputs_.size() < 1 || uniforms_->size() < 8) {
104 <<
"Invalid fragment shader in RuntimeEffectFilterContents. "
105 <<
"Shader must have at least one sampler and a vec2 size uniform.";
110 std::vector<RuntimeEffectContents::TextureInput> texture_input_copy =
112 texture_input_copy[0].texture = input_snapshot->texture;
115 memcpy(uniforms_->data(), &size,
sizeof(
Size));
117 Matrix snapshot_transform = input_snapshot->transform;
122 [snapshot_transform, input_snapshot, runtime_stage = runtime_stage_,
123 uniforms = uniforms_, texture_inputs = texture_input_copy](
124 const ContentContext& renderer,
const Entity& entity,
125 RenderPass& pass) ->
bool {
126 RuntimeEffectContents contents;
127 FillRectGeometry geom(
Rect::MakeSize(input_snapshot->texture->GetSize()));
128 contents.SetRuntimeStage(runtime_stage);
129 contents.SetUniformData(uniforms);
130 contents.SetTextureInputs(texture_inputs);
131 contents.SetGeometry(&geom);
132 Entity offset_entity = entity.Clone();
133 offset_entity.SetTransform(entity.GetTransform() * snapshot_transform);
134 return contents.Render(renderer, offset_entity, pass);
138 [coverage](
const Entity& entity) -> std::optional<Rect> {
145 sub_entity.SetContents(std::move(contents));
146 sub_entity.SetBlendMode(entity.GetBlendMode());
147 sub_entity.SetTransform(input_snapshot->transform *
148 snapshot_transform.Invert());
154std::optional<Rect> RuntimeEffectFilterContents::GetFilterSourceCoverage(
155 const Matrix& effect_transform,
156 const Rect& output_limit)
const {
static std::shared_ptr< Contents > Make(RenderProc render_proc, CoverageProc coverage_proc)
std::function< std::optional< Rect >(const Entity &entity)> CoverageProc
std::function< bool(const ContentContext &renderer, const Entity &entity, RenderPass &pass)> RenderProc
void SetUniforms(std::shared_ptr< std::vector< uint8_t > > uniforms)
void SetTextureInputs(std::vector< RuntimeEffectContents::TextureInput > texture_inputs)
void SetRuntimeStage(std::shared_ptr< RuntimeStage > runtime_stage)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::array< Point, 4 > Quad
A 4x4 matrix using column-major storage.
constexpr TPoint< T > GetLeftTop() const
constexpr TPoint< T > GetRightBottom() const
constexpr TPoint< T > GetLeftBottom() const
static constexpr TRect MakeSize(const TSize< U > &size)
constexpr TPoint< T > GetRightTop() const
static constexpr std::optional< TRect > MakePointBounds(const U &value)