21 std::optional<Entity> LinearToSrgbFilterContents::RenderFilter(
23 const ContentContext& renderer,
25 const Matrix& effect_transform,
27 const std::optional<Rect>& coverage_hint)
const {
36 inputs[0]->GetSnapshot(
"LinearToSrgb", renderer, entity);
37 if (!input_snapshot.has_value()) {
46 const ContentContext& renderer,
47 const Entity& entity, RenderPass& pass) ->
bool {
50 cmd.stencil_reference = entity.GetStencilDepth();
53 cmd.pipeline = renderer.GetLinearToSrgbFilterPipeline(options);
55 auto size = input_snapshot->texture->GetSize();
57 VertexBufferBuilder<VS::PerVertexData> vtx_builder;
58 vtx_builder.AddVertices({
67 auto& host_buffer = pass.GetTransientsBuffer();
68 auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer);
69 cmd.BindVertices(vtx_buffer);
71 VS::FrameInfo frame_info;
73 entity.GetTransformation() * input_snapshot->transform *
75 frame_info.texture_sampler_y_coord_scale =
76 input_snapshot->texture->GetYCoordScale();
78 FS::FragInfo frag_info;
79 frag_info.input_alpha =
81 ? input_snapshot->opacity
84 auto sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler({});
85 FS::BindInputTexture(cmd, input_snapshot->texture, sampler);
86 FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info));
87 VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info));
89 return pass.AddCommand(std::move(cmd));
93 [coverage](
const Entity& entity) -> std::optional<Rect> {
94 return coverage.TransformBounds(entity.GetTransformation());
100 sub_entity.SetContents(std::move(contents));
101 sub_entity.SetStencilDepth(entity.GetStencilDepth());
102 sub_entity.SetBlendMode(entity.GetBlendMode());