shithub: dav1d

Download patch

ref: a1e7a329b2f87154f97630403a2708030447b6ae
parent: df40d36d84fbdd3aae827b36d1a15739efb9225b
author: Niklas Haas <git@haasn.xyz>
date: Mon May 25 07:51:51 EDT 2020

dav1dplay: allow resizing the window

libplacebo v66 got helper functions that make preserving the aspect
ratio in this case trivial. But we still need to make sure to clear the
FBO to black if the image doesn't cover it fully.

--- a/examples/dp_renderer_placebo.c
+++ b/examples/dp_renderer_placebo.c
@@ -80,7 +80,7 @@
     placebo_renderer_create_common(int window_flags)
 {
     // Create Window
-    SDL_Window *sdlwin = dp_create_sdl_window(window_flags);
+    SDL_Window *sdlwin = dp_create_sdl_window(window_flags | SDL_WINDOW_RESIZABLE);
     if (sdlwin == NULL)
         return NULL;
 
@@ -326,6 +326,12 @@
         .len = 0,
     };
 
+#if PL_API_VER >= 66
+    pl_rect2df_aspect_copy(&target.dst_rect, &rd_priv_ctx->image.src_rect, 0.0);
+    if (pl_render_target_partial(&target))
+        pl_tex_clear(rd_priv_ctx->gpu, target.fbo, (float[4]){ 0.0 });
+#endif
+
     if (!pl_render_image(rd_priv_ctx->renderer, &rd_priv_ctx->image, &target, &render_params)) {
         fprintf(stderr, "Failed rendering frame!\n");
         pl_tex_clear(rd_priv_ctx->gpu, target.fbo, (float[4]){ 1.0 });
@@ -366,6 +372,7 @@
         .num_planes = 3,
         .width      = width,
         .height     = height,
+        .src_rect   = {0, 0, width, height},
 
         .repr = {
             .bits = {