18 1.164, 1.164, 1.164, 0.0,
19 0.0, -0.392, 2.017, 0.0,
20 1.596, -0.813, 0.0, 0.0,
26 0.0, -0.344, 1.772, 0.0,
27 1.402, -0.714, 0.0, 0.0,
37 yuv_color_space_ = yuv_color_space;
40 std::optional<Entity> YUVToRGBFilterContents::RenderFilter(
44 const Matrix& effect_transform,
46 const std::optional<Rect>& coverage_hint)
const {
47 if (inputs.size() < 2) {
54 auto y_input_snapshot =
55 inputs[0]->GetSnapshot(
"YUVToRGB(Y)", renderer, entity);
56 auto uv_input_snapshot =
57 inputs[1]->GetSnapshot(
"YUVToRGB(UV)", renderer, entity);
58 if (!y_input_snapshot.has_value() || !uv_input_snapshot.has_value()) {
62 if (y_input_snapshot->texture->GetTextureDescriptor().format !=
64 uv_input_snapshot->texture->GetTextureDescriptor().format !=
72 RenderProc render_proc = [y_input_snapshot, uv_input_snapshot,
73 yuv_color_space = yuv_color_space_](
74 const ContentContext& renderer,
75 const Entity& entity, RenderPass& pass) ->
bool {
78 cmd.stencil_reference = entity.GetClipDepth();
82 cmd.pipeline = renderer.GetYUVToRGBFilterPipeline(options);
84 auto size = y_input_snapshot->texture->GetSize();
86 VertexBufferBuilder<VS::PerVertexData> vtx_builder;
87 vtx_builder.AddVertices({
94 auto& host_buffer = pass.GetTransientsBuffer();
95 cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer));
97 VS::FrameInfo frame_info;
98 frame_info.mvp = pass.GetOrthographicTransform() * entity.GetTransform() *
99 y_input_snapshot->transform *
101 frame_info.texture_sampler_y_coord_scale =
102 y_input_snapshot->texture->GetYCoordScale();
104 FS::FragInfo frag_info;
105 frag_info.yuv_color_space =
static_cast<Scalar>(yuv_color_space);
106 switch (yuv_color_space) {
115 auto sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler({});
116 FS::BindYTexture(cmd, y_input_snapshot->texture, sampler);
117 FS::BindUvTexture(cmd, uv_input_snapshot->texture, sampler);
119 FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info));
120 VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info));
122 return pass.AddCommand(std::move(cmd));
126 [coverage](
const Entity& entity) -> std::optional<Rect> {
133 sub_entity.SetContents(std::move(contents));
134 sub_entity.SetClipDepth(entity.GetClipDepth());
135 sub_entity.SetBlendMode(entity.GetBlendMode());
139 std::optional<Rect> YUVToRGBFilterContents::GetFilterSourceCoverage(
140 const Matrix& effect_transform,
141 const Rect& output_limit)
const {