20 std::optional<Entity> LinearToSrgbFilterContents::RenderFilter(
22 const ContentContext& renderer,
24 const Matrix& effect_transform,
26 const std::optional<Rect>& coverage_hint)
const {
35 inputs[0]->GetSnapshot(
"LinearToSrgb", renderer, entity);
36 if (!input_snapshot.has_value()) {
45 const ContentContext& renderer,
46 const Entity& entity, RenderPass& pass) ->
bool {
47 pass.SetCommandLabel(
"Linear to sRGB Filter");
48 pass.SetStencilReference(entity.GetClipDepth());
52 pass.SetPipeline(renderer.GetLinearToSrgbFilterPipeline(options));
54 auto size = input_snapshot->texture->GetSize();
56 VertexBufferBuilder<VS::PerVertexData> vtx_builder;
57 vtx_builder.AddVertices({
64 auto& host_buffer = renderer.GetTransientsBuffer();
65 pass.SetVertexBuffer(vtx_builder.CreateVertexBuffer(host_buffer));
67 VS::FrameInfo frame_info;
69 entity.GetShaderClipDepth(), pass,
70 entity.GetTransform() * input_snapshot->transform *
72 frame_info.texture_sampler_y_coord_scale =
73 input_snapshot->texture->GetYCoordScale();
75 FS::FragInfo frag_info;
76 frag_info.input_alpha =
78 ? input_snapshot->opacity
82 pass, input_snapshot->texture,
83 renderer.GetContext()->GetSamplerLibrary()->GetSampler({}));
84 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
85 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
87 return pass.Draw().ok();
91 [coverage](
const Entity& entity) -> std::optional<Rect> {
92 return coverage.TransformBounds(entity.GetTransform());
98 sub_entity.SetContents(std::move(contents));
99 sub_entity.SetClipDepth(entity.GetClipDepth());
100 sub_entity.SetBlendMode(entity.GetBlendMode());