summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2012-05-14 16:33:06 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2012-05-15 10:37:58 +0200
commit43337db0a49029da316157d9bc57e9c44e846e69 (patch)
tree4644c331af38cab4fa8de6a1f5468ec648c43afa
parent4a2bd440dd71faf6852d3653de02fc512ce8244f (diff)
downloadmpv-43337db0a49029da316157d9bc57e9c44e846e69.tar.bz2
mpv-43337db0a49029da316157d9bc57e9c44e846e69.tar.xz
cocoa: gl3: support querying of colors bit depth
Add support for querying the bit depth of the colors from the OpenGL context. This allows to perform dithering correctly.
-rw-r--r--libvo/cocoa_common.h2
-rw-r--r--libvo/cocoa_common.m16
-rw-r--r--libvo/gl_common.c3
3 files changed, 21 insertions, 0 deletions
diff --git a/libvo/cocoa_common.h b/libvo/cocoa_common.h
index 1a2ec7bd75..943a5fb8ba 100644
--- a/libvo/cocoa_common.h
+++ b/libvo/cocoa_common.h
@@ -46,4 +46,6 @@ int vo_cocoa_swap_interval(int enabled);
void *vo_cocoa_cgl_context(void);
void *vo_cocoa_cgl_pixel_format(void);
+int vo_cocoa_cgl_color_size(void);
+
#endif /* MPLAYER_COCOA_COMMON_H */
diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m
index 04b325405b..5b2bc9ab4e 100644
--- a/libvo/cocoa_common.m
+++ b/libvo/cocoa_common.m
@@ -405,6 +405,22 @@ void *vo_cocoa_cgl_pixel_format(void)
return [s->pixelFormat CGLPixelFormatObj];
}
+int vo_cocoa_cgl_color_size(void)
+{
+ GLint value;
+ CGLDescribePixelFormat(vo_cocoa_cgl_pixel_format(), 0,
+ kCGLPFAColorSize, &value);
+ switch (value) {
+ case 32:
+ case 24:
+ return 8;
+ case 16:
+ return 5;
+ }
+
+ return 8;
+}
+
void create_menu()
{
NSMenu *menu;
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index cd618b443c..621bfa39a8 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -1727,6 +1727,9 @@ static int create_window_cocoa_gl3(struct MPGLContext *ctx, int gl_flags,
{
int rv = vo_cocoa_create_window(ctx->vo, d_width, d_height, flags, 1);
getFunctions(ctx->gl, (void *)vo_cocoa_glgetaddr, NULL, true);
+ ctx->depth_r = vo_cocoa_cgl_color_size();
+ ctx->depth_g = vo_cocoa_cgl_color_size();
+ ctx->depth_b = vo_cocoa_cgl_color_size();
return rv;
}