Skip to content

Commit

Permalink
gl_common: split into platform specific files
Browse files Browse the repository at this point in the history
Do this instead of stuffing all x11/cocoa/win32/wayland specific code
into gl_common.c. The cocoa specific parts could probably go directly
into cocoa_common.m, possibly same with wayland.

Also redo how the list of backends is managed. Get rid of the GLTYPE_
constants. Instead of having a big switch() on GLTYPE_, each backend
entry has a function pointer to setup the MPGLContext callback (e.g.
mpgl_set_backend_x11()).
  • Loading branch information
wm4 committed Mar 28, 2013
1 parent 3374a43 commit 16e951c
Show file tree
Hide file tree
Showing 11 changed files with 897 additions and 808 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ SOURCES-$(GL) += video/out/gl_common.c video/out/gl_osd.c \

SOURCES-$(ENCODING) += video/out/vo_lavc.c audio/out/ao_lavc.c \
core/encode_lavc.c
SOURCES-$(GL_WIN32) += video/out/w32_common.c
SOURCES-$(GL_X11) += video/out/x11_common.c
SOURCES-$(GL_WAYLAND) += video/out/wayland_common.c

SOURCES-$(GL_WIN32) += video/out/w32_common.c video/out/gl_w32.c
SOURCES-$(GL_X11) += video/out/x11_common.c video/out/gl_x11.c
SOURCES-$(GL_COCOA) += video/out/gl_cocoa.c
SOURCES-$(GL_WAYLAND) += video/out/wayland_common.c \
video/out/gl_wayland.c

SOURCES-$(JACK) += audio/out/ao_jack.c
SOURCES-$(JOYSTICK) += core/input/joystick.c
Expand Down
67 changes: 67 additions & 0 deletions video/out/gl_cocoa.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* You can alternatively redistribute this file and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*/

#include "cocoa_common.h"
#include "gl_common.h"

static bool config_window_cocoa(struct MPGLContext *ctx, uint32_t d_width,
uint32_t d_height, uint32_t flags)
{
int rv = vo_cocoa_config_window(ctx->vo, d_width, d_height, flags,
ctx->requested_gl_version >= MPGL_VER(3, 0));
if (rv != 0)
return false;

mpgl_load_functions(ctx->gl, (void *)vo_cocoa_glgetaddr, NULL);

ctx->depth_r = vo_cocoa_cgl_color_size(ctx->vo);
ctx->depth_g = vo_cocoa_cgl_color_size(ctx->vo);
ctx->depth_b = vo_cocoa_cgl_color_size(ctx->vo);

if (!ctx->gl->SwapInterval)
ctx->gl->SwapInterval = vo_cocoa_swap_interval;

return true;
}

static void releaseGlContext_cocoa(MPGLContext *ctx)
{
}

static void swapGlBuffers_cocoa(MPGLContext *ctx)
{
vo_cocoa_swap_buffers(ctx->vo);
}

void mpgl_set_backend_cocoa(MPGLContext *ctx)
{
ctx->config_window = config_window_cocoa;
ctx->releaseGlContext = releaseGlContext_cocoa;
ctx->swapGlBuffers = swapGlBuffers_cocoa;
ctx->check_events = vo_cocoa_check_events;
ctx->update_xinerama_info = vo_cocoa_update_xinerama_info;
ctx->fullscreen = vo_cocoa_fullscreen;
ctx->ontop = vo_cocoa_ontop;
ctx->vo_init = vo_cocoa_init;
ctx->pause = vo_cocoa_pause;
ctx->resume = vo_cocoa_resume;
ctx->vo_uninit = vo_cocoa_uninit;
}
Loading

0 comments on commit 16e951c

Please sign in to comment.