summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-19 11:56:19 +0100
committerwm4 <wm4@nowhere>2015-12-19 14:14:12 +0100
commit3394d37b4ea6876c0a4484c51ba23e6b8ed08e5a (patch)
tree95e646d22bb8ca0ffb28e9c5850a1241739da8ec /video
parentd2baaaa7df87eba9566fb935eeab5bd0af80fe1b (diff)
downloadmpv-3394d37b4ea6876c0a4484c51ba23e6b8ed08e5a.tar.bz2
mpv-3394d37b4ea6876c0a4484c51ba23e6b8ed08e5a.tar.xz
vo_opengl: refactor how framebuffer depth is passed from backends
Store the determined framebuffer depth in struct GL instead of MPGLContext. This means gl_video_set_output_depth() can be removed, and also justifies adding new fields describing framebuffer/backend properties to struct GL instead of having to add more functions just to shovel the information around. Keep in mind that mpgl_load_functions() will wipe struct GL, so the new fields must be set before calling it.
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/cocoa.c2
-rw-r--r--video/out/opengl/common.h4
-rw-r--r--video/out/opengl/dxinterop.c8
-rw-r--r--video/out/opengl/video.c12
-rw-r--r--video/out/opengl/w32.c15
-rw-r--r--video/out/opengl/x11.c9
-rw-r--r--video/out/vo_opengl.c2
7 files changed, 22 insertions, 30 deletions
diff --git a/video/out/opengl/cocoa.c b/video/out/opengl/cocoa.c
index 5e98fce8a1..8a3c3721fa 100644
--- a/video/out/opengl/cocoa.c
+++ b/video/out/opengl/cocoa.c
@@ -127,8 +127,8 @@ static bool create_gl_context(struct MPGLContext *ctx, int vo_flags)
if (vo_flags & VOFLAG_ALPHA)
CGLSetParameter(p->ctx, kCGLCPSurfaceOpacity, &(GLint){0});
- ctx->depth_r = ctx->depth_g = ctx->depth_b = cgl_color_size(ctx);
mpgl_load_functions(ctx->gl, (void *)cocoa_glgetaddr, NULL, ctx->vo->log);
+ ctx->gl->fb_r = ctx->gl->fb_g = ctx->gl->fb_b = cgl_color_size(ctx);
CGLReleasePixelFormat(p->pix);
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index 537e785e3b..f376a41f6a 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -119,9 +119,6 @@ typedef struct MPGLContext {
struct vo *vo;
const struct mpgl_driver *driver;
- // Bit size of each component in the created framebuffer. 0 if unknown.
- int depth_r, depth_g, depth_b;
-
// For hwdec_vaegl.c.
const char *native_display_type;
void *native_display;
@@ -164,6 +161,7 @@ struct GL {
char *extensions; // Equivalent to GL_EXTENSIONS
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
+ int fb_r, fb_g, fb_b; // frame buffer bit depth (0 if unknown)
void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY *Clear)(GLbitfield);
diff --git a/video/out/opengl/dxinterop.c b/video/out/opengl/dxinterop.c
index bc302629aa..093729351d 100644
--- a/video/out/opengl/dxinterop.c
+++ b/video/out/opengl/dxinterop.c
@@ -275,17 +275,17 @@ static int d3d_size_dependent_create(MPGLContext *ctx)
// work is needed.
switch (bb_desc.Format) {
case D3DFMT_X1R5G5B5: case D3DFMT_A1R5G5B5:
- ctx->depth_r = ctx->depth_g = ctx->depth_b = 5;
+ ctx->gl->fb_r = ctx->gl->fb_g = ctx->gl->fb_b = 5;
break;
case D3DFMT_R5G6B5:
- ctx->depth_r = 5; ctx->depth_g = 6; ctx->depth_b = 5;
+ ctx->gl->fb_r = 5; ctx->gl->fb_g = 6; ctx->gl->fb_b = 5;
break;
case D3DFMT_R8G8B8: case D3DFMT_A8R8G8B8: case D3DFMT_X8R8G8B8:
case D3DFMT_A8B8G8R8: case D3DFMT_X8B8G8R8: default:
- ctx->depth_r = ctx->depth_g = ctx->depth_b = 8;
+ ctx->gl->fb_r = ctx->gl->fb_g = ctx->gl->fb_b = 8;
break;
case D3DFMT_A2R10G10B10: case D3DFMT_A2B10G10R10:
- ctx->depth_r = ctx->depth_g = ctx->depth_b = 10;
+ ctx->gl->fb_r = ctx->gl->fb_g = ctx->gl->fb_b = 10;
break;
}
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index d2fb4ac38c..a96a95b5c7 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -137,7 +137,6 @@ struct gl_video {
struct gl_video_opts opts;
bool gl_debug;
- int depth_g;
int texture_16bit_depth; // actual bits available in 16 bit textures
struct gl_shader_cache *sc;
@@ -1703,7 +1702,7 @@ static void pass_dither(struct gl_video *p)
GL *gl = p->gl;
// Assume 8 bits per component if unknown.
- int dst_depth = p->depth_g ? p->depth_g : 8;
+ int dst_depth = gl->fb_g ? gl->fb_g : 8;
if (p->opts.dither_depth > 0)
dst_depth = p->opts.dither_depth;
@@ -2508,6 +2507,9 @@ static void init_gl(struct gl_video *p)
debug_check_gl(p, "before init_gl");
+ MP_VERBOSE(p, "Reported display depth: R=%d, G=%d, B=%d\n",
+ gl->fb_r, gl->fb_g, gl->fb_b);
+
gl->Disable(GL_DITHER);
gl_vao_init(&p->vao, gl, sizeof(struct vertex), vertex_vao);
@@ -2744,12 +2746,6 @@ void gl_video_config(struct gl_video *p, struct mp_image_params *params)
gl_video_reset_surfaces(p);
}
-void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b)
-{
- MP_VERBOSE(p, "Display depth: R=%d, G=%d, B=%d\n", r, g, b);
- p->depth_g = g;
-}
-
void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd)
{
mpgl_osd_destroy(p->osd);
diff --git a/video/out/opengl/w32.c b/video/out/opengl/w32.c
index ab6550a492..86f4414aa4 100644
--- a/video/out/opengl/w32.c
+++ b/video/out/opengl/w32.c
@@ -80,13 +80,6 @@ static bool create_dc(struct MPGLContext *ctx, int flags)
SetPixelFormat(hdc, pf, &pfd);
- int pfmt = GetPixelFormat(hdc);
- if (DescribePixelFormat(hdc, pfmt, sizeof(PIXELFORMATDESCRIPTOR), &pfd)) {
- ctx->depth_r = pfd.cRedBits;
- ctx->depth_g = pfd.cGreenBits;
- ctx->depth_b = pfd.cBlueBits;
- }
-
w32_ctx->hdc = hdc;
return true;
}
@@ -221,6 +214,14 @@ static void create_ctx(void *ptr)
if (!w32_ctx->context)
create_context_w32_old(ctx);
+ int pfmt = GetPixelFormat(w32_ctx->hdc);
+ PIXELFORMATDESCRIPTOR pfd;
+ if (DescribePixelFormat(w32_ctx->hdc, pfmt, sizeof(pfd), &pfd)) {
+ ctx->gl->fb_r = pfd.cRedBits;
+ ctx->gl->fb_g = pfd.cGreenBits;
+ ctx->gl->fb_b = pfd.cBlueBits;
+ }
+
wglMakeCurrent(w32_ctx->hdc, NULL);
}
diff --git a/video/out/opengl/x11.c b/video/out/opengl/x11.c
index 0a102e124f..1ef44ab604 100644
--- a/video/out/opengl/x11.c
+++ b/video/out/opengl/x11.c
@@ -253,11 +253,6 @@ static int glx_init(struct MPGLContext *ctx, int flags)
MP_WARN(vo, "Selected GLX FB config has no associated X visual\n");
}
-
- glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_RED_SIZE, &ctx->depth_r);
- glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_GREEN_SIZE, &ctx->depth_g);
- glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_BLUE_SIZE, &ctx->depth_b);
-
if (!vo_x11_create_vo_window(vo, glx_ctx->vinfo, "gl"))
goto uninit;
@@ -274,6 +269,10 @@ static int glx_init(struct MPGLContext *ctx, int flags)
if (!success)
goto uninit;
+ glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_RED_SIZE, &ctx->gl->fb_r);
+ glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_GREEN_SIZE, &ctx->gl->fb_g);
+ glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_BLUE_SIZE, &ctx->gl->fb_b);
+
return 0;
uninit:
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index ef6fe53e43..068b004e5d 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -423,8 +423,6 @@ static int preinit(struct vo *vo)
if (!p->renderer)
goto err_out;
gl_video_set_osd_source(p->renderer, vo->osd);
- gl_video_set_output_depth(p->renderer, p->glctx->depth_r, p->glctx->depth_g,
- p->glctx->depth_b);
gl_video_set_options(p->renderer, p->renderer_opts);
gl_video_configure_queue(p->renderer, vo);