summaryrefslogtreecommitdiffstats
path: root/video/out/dr_helper.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-04-20 17:48:44 +0200
committerJan Ekström <jeebjp@gmail.com>2018-04-29 02:21:32 +0300
commit76844c9c519f4366463a70c8c2366a3d5dc9046c (patch)
treeb62cb8753dea8fc16e35dc0f20679d1db95f1491 /video/out/dr_helper.h
parent65f08253158ba9cb4c164a6cfd6da39b39d38e55 (diff)
downloadmpv-76844c9c519f4366463a70c8c2366a3d5dc9046c.tar.bz2
mpv-76844c9c519f4366463a70c8c2366a3d5dc9046c.tar.xz
vo: move DR helper code to a separate source file
So it can be reused by vo_libmpv.c, which needs to use it in a slightly different way.
Diffstat (limited to 'video/out/dr_helper.h')
-rw-r--r--video/out/dr_helper.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/video/out/dr_helper.h b/video/out/dr_helper.h
new file mode 100644
index 0000000000..cf37c570e2
--- /dev/null
+++ b/video/out/dr_helper.h
@@ -0,0 +1,20 @@
+#pragma once
+
+// This is a helper for implementing thread-safety for DR callbacks. These need
+// to allocate GPU buffers on the GPU thread (e.g. OpenGL with its forced TLS),
+// and the buffers also need to be freed on the GPU thread.
+struct dr_helper;
+
+struct mp_image;
+struct mp_dispatch_queue;
+
+// This MUST be called on the "target" thread (it will call pthread_self()).
+// dr_helper_get_image() calls will use the dispatch queue to run get_image on
+// the target thread too.
+struct dr_helper *dr_helper_create(struct mp_dispatch_queue *dispatch,
+ struct mp_image *(*get_image)(void *ctx, int imgfmt, int w, int h,
+ int stride_align),
+ void *get_image_ctx);
+
+struct mp_image *dr_helper_get_image(struct dr_helper *dr, int imgfmt,
+ int w, int h, int stride_align);