mirror of
https://github.com/mpv-player/mpv
synced 2025-02-18 13:47:04 +00:00
vda: make independent from cocoa backend
Basically, don't access the vo field. There's also no reason anymore to access MPGLContext. We still need to access loaded GL functions though, so add a field for that to gl_hwdec. Untested.
This commit is contained in:
parent
82afc0f343
commit
bfa7893fe9
@ -171,6 +171,7 @@ struct mp_hwdec_info;
|
|||||||
struct gl_hwdec {
|
struct gl_hwdec {
|
||||||
const struct gl_hwdec_driver *driver;
|
const struct gl_hwdec_driver *driver;
|
||||||
struct mp_log *log;
|
struct mp_log *log;
|
||||||
|
GL *gl;
|
||||||
struct MPGLContext *mpgl;
|
struct MPGLContext *mpgl;
|
||||||
struct mp_hwdec_info *info;
|
struct mp_hwdec_info *info;
|
||||||
// For free use by hwdec driver
|
// For free use by hwdec driver
|
||||||
|
@ -32,14 +32,12 @@ struct priv {
|
|||||||
|
|
||||||
static bool check_hwdec(struct gl_hwdec *hw)
|
static bool check_hwdec(struct gl_hwdec *hw)
|
||||||
{
|
{
|
||||||
struct vo *vo = hw->mpgl->vo;
|
|
||||||
|
|
||||||
if (hw->gl_texture_target != GL_TEXTURE_RECTANGLE) {
|
if (hw->gl_texture_target != GL_TEXTURE_RECTANGLE) {
|
||||||
MP_ERR(hw, "must use rectangle video textures with VDA\n");
|
MP_ERR(hw, "must use rectangle video textures with VDA\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vo->cocoa) {
|
if (!CGLGetCurrentContext()) {
|
||||||
MP_ERR(hw, "need cocoa opengl backend to be active");
|
MP_ERR(hw, "need cocoa opengl backend to be active");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -57,7 +55,7 @@ static int create(struct gl_hwdec *hw)
|
|||||||
if (!check_hwdec(hw))
|
if (!check_hwdec(hw))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
GL *gl = hw->mpgl->gl;
|
GL *gl = hw->gl;
|
||||||
gl->GenTextures(1, &p->gl_texture);
|
gl->GenTextures(1, &p->gl_texture);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -75,8 +73,7 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
struct priv *p = hw->priv;
|
struct priv *p = hw->priv;
|
||||||
struct vo *vo = hw->mpgl->vo;
|
GL *gl = hw->gl;
|
||||||
GL *gl = hw->mpgl->gl;
|
|
||||||
|
|
||||||
CVPixelBufferRelease(p->pbuf);
|
CVPixelBufferRelease(p->pbuf);
|
||||||
p->pbuf = (CVPixelBufferRef)hw_image->planes[3];
|
p->pbuf = (CVPixelBufferRef)hw_image->planes[3];
|
||||||
@ -91,7 +88,7 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image,
|
|||||||
GL_RGB_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, surface, 0);
|
GL_RGB_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, surface, 0);
|
||||||
|
|
||||||
if (err != kCGLNoError)
|
if (err != kCGLNoError)
|
||||||
MP_ERR(vo, "error creating IOSurface texture: %s (%x)\n",
|
MP_ERR(hw, "error creating IOSurface texture: %s (%x)\n",
|
||||||
CGLErrorString(err), gl->GetError());
|
CGLErrorString(err), gl->GetError());
|
||||||
|
|
||||||
gl->BindTexture(hw->gl_texture_target, 0);
|
gl->BindTexture(hw->gl_texture_target, 0);
|
||||||
@ -127,7 +124,7 @@ static struct mp_image *download_image(struct gl_hwdec *hw,
|
|||||||
static void destroy(struct gl_hwdec *hw)
|
static void destroy(struct gl_hwdec *hw)
|
||||||
{
|
{
|
||||||
struct priv *p = hw->priv;
|
struct priv *p = hw->priv;
|
||||||
GL *gl = hw->mpgl->gl;
|
GL *gl = hw->gl;
|
||||||
|
|
||||||
CVPixelBufferRelease(p->pbuf);
|
CVPixelBufferRelease(p->pbuf);
|
||||||
gl->DeleteTextures(1, &p->gl_texture);
|
gl->DeleteTextures(1, &p->gl_texture);
|
||||||
|
@ -228,6 +228,7 @@ static void load_hwdec_driver(struct gl_priv *p,
|
|||||||
.driver = drv,
|
.driver = drv,
|
||||||
.log = mp_log_new(hwdec, p->vo->log, drv->api_name),
|
.log = mp_log_new(hwdec, p->vo->log, drv->api_name),
|
||||||
.mpgl = p->glctx,
|
.mpgl = p->glctx,
|
||||||
|
.gl = p->glctx->gl,
|
||||||
.info = &p->hwdec_info,
|
.info = &p->hwdec_info,
|
||||||
.gl_texture_target = GL_TEXTURE_2D,
|
.gl_texture_target = GL_TEXTURE_2D,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user