mirror of https://github.com/mpv-player/mpv
vo_gpu: remove old window screenshot glue code and GL implementation
There is now a better way. Reading the font framebuffer was always a hack. The new code via VOCTRL_SCREENSHOT renders it into a FBO, which does not come with the disadvantages of reading the front buffer (like not being supported by GLES, possibly black regions due to overlapping windows on some systems). For now keep VOCTRL_SCREENSHOT_WIN on the VO level, because there are still some lesser VOs and backends that use it.
This commit is contained in:
parent
ceca1602e9
commit
f17246fec1
|
@ -69,9 +69,6 @@ struct ra_swapchain_fns {
|
|||
// Gets the current framebuffer depth in bits (0 if unknown). Optional.
|
||||
int (*color_depth)(struct ra_swapchain *sw);
|
||||
|
||||
// Retrieves a screenshot of the framebuffer. Optional.
|
||||
struct mp_image *(*screenshot)(struct ra_swapchain *sw);
|
||||
|
||||
// Called when rendering starts. Returns NULL on failure. This must be
|
||||
// followed by submit_frame, to submit the rendered frame. This function
|
||||
// can also fail sporadically, and such errors should be ignored unless
|
||||
|
|
|
@ -173,8 +173,6 @@ bool ra_gl_ctx_init(struct ra_ctx *ctx, GL *gl, struct ra_gl_ctx_params params)
|
|||
if (ext) {
|
||||
if (ext->color_depth)
|
||||
p->fns.color_depth = ext->color_depth;
|
||||
if (ext->screenshot)
|
||||
p->fns.screenshot = ext->screenshot;
|
||||
if (ext->start_frame)
|
||||
p->fns.start_frame = ext->start_frame;
|
||||
if (ext->submit_frame)
|
||||
|
@ -247,29 +245,6 @@ int ra_gl_ctx_color_depth(struct ra_swapchain *sw)
|
|||
return depth_g;
|
||||
}
|
||||
|
||||
struct mp_image *ra_gl_ctx_screenshot(struct ra_swapchain *sw)
|
||||
{
|
||||
struct priv *p = sw->priv;
|
||||
|
||||
struct mp_image *screen = mp_image_alloc(IMGFMT_RGB24, p->wrapped_fb->params.w,
|
||||
p->wrapped_fb->params.h);
|
||||
if (!screen)
|
||||
return NULL;
|
||||
|
||||
int dir = p->params.flipped ? 1 : -1;
|
||||
|
||||
assert(p->wrapped_fb);
|
||||
if (!gl_read_fbo_contents(p->gl, p->main_fb, dir, GL_RGB, GL_UNSIGNED_BYTE,
|
||||
p->wrapped_fb->params.w, p->wrapped_fb->params.h,
|
||||
screen->planes[0], screen->stride[0]))
|
||||
{
|
||||
talloc_free(screen);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return screen;
|
||||
}
|
||||
|
||||
bool ra_gl_ctx_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo)
|
||||
{
|
||||
struct priv *p = sw->priv;
|
||||
|
@ -353,7 +328,6 @@ void ra_gl_ctx_swap_buffers(struct ra_swapchain *sw)
|
|||
|
||||
static const struct ra_swapchain_fns ra_gl_swapchain_fns = {
|
||||
.color_depth = ra_gl_ctx_color_depth,
|
||||
.screenshot = ra_gl_ctx_screenshot,
|
||||
.start_frame = ra_gl_ctx_start_frame,
|
||||
.submit_frame = ra_gl_ctx_submit_frame,
|
||||
.swap_buffers = ra_gl_ctx_swap_buffers,
|
||||
|
|
|
@ -168,7 +168,6 @@ static void get_and_update_ambient_lighting(struct gpu_priv *p)
|
|||
static int control(struct vo *vo, uint32_t request, void *data)
|
||||
{
|
||||
struct gpu_priv *p = vo->priv;
|
||||
struct ra_swapchain *sw = p->ctx->swapchain;
|
||||
|
||||
switch (request) {
|
||||
case VOCTRL_SET_PANSCAN:
|
||||
|
@ -177,17 +176,6 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
|||
case VOCTRL_SET_EQUALIZER:
|
||||
vo->want_redraw = true;
|
||||
return VO_TRUE;
|
||||
case VOCTRL_SCREENSHOT_WIN: {
|
||||
struct mp_image *screen = NULL;
|
||||
if (sw->fns->screenshot)
|
||||
screen = sw->fns->screenshot(sw);
|
||||
if (!screen)
|
||||
break; // redirect to backend
|
||||
// set image parameters according to the display, if possible
|
||||
screen->params.color = gl_video_get_output_colorspace(p->renderer);
|
||||
*(struct mp_image **)data = screen;
|
||||
return true;
|
||||
}
|
||||
case VOCTRL_SCREENSHOT: {
|
||||
struct vo_frame *frame = vo_get_current_vo_frame(vo);
|
||||
if (frame) {
|
||||
|
|
|
@ -565,7 +565,6 @@ static void swap_buffers(struct ra_swapchain *sw)
|
|||
}
|
||||
|
||||
static const struct ra_swapchain_fns vulkan_swapchain = {
|
||||
// .screenshot is not currently supported
|
||||
.color_depth = color_depth,
|
||||
.start_frame = start_frame,
|
||||
.submit_frame = submit_frame,
|
||||
|
|
Loading…
Reference in New Issue