libgstgl: eagl: handle CALayer resize

This commit is contained in:
Alessandro Decina 2015-02-24 14:23:49 +11:00 committed by Tim-Philipp Müller
parent e10a2f8922
commit 464b9e7680
3 changed files with 26 additions and 6 deletions

View file

@ -59,6 +59,7 @@ GType gst_gl_context_eagl_get_type (void);
GstGLContextEagl * gst_gl_context_eagl_new (void);
void gst_gl_context_eagl_resize (GstGLContextEagl * eagl_context);
void gst_gl_context_eagl_prepare_draw (GstGLContextEagl * context);
void gst_gl_context_eagl_finish_draw (GstGLContextEagl * context);
guintptr gst_gl_context_eagl_get_current_context (void);

View file

@ -99,6 +99,22 @@ gst_gl_context_eagl_new (void)
return context;
}
void
gst_gl_context_eagl_resize (GstGLContextEagl * eagl_context)
{
int width, height;
glBindRenderbuffer (GL_RENDERBUFFER, eagl_context->priv->color_renderbuffer);
[eagl_context->priv->eagl_context renderbufferStorage:GL_RENDERBUFFER fromDrawable:eagl_context->priv->eagl_layer];
glGetRenderbufferParameteriv (GL_RENDERBUFFER,
GL_RENDERBUFFER_WIDTH, &width);
glGetRenderbufferParameteriv (GL_RENDERBUFFER,
GL_RENDERBUFFER_HEIGHT, &height);
glBindRenderbuffer (GL_RENDERBUFFER, eagl_context->priv->depth_renderbuffer);
glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width,
height);
}
static gboolean
gst_gl_context_eagl_create_context (GstGLContext * context, GstGLAPI gl_api,
GstGLContext * other_context, GError ** error)

View file

@ -244,14 +244,17 @@ draw_cb (gpointer data)
eagl_layer = (CAEAGLLayer *)[window_eagl->priv->view layer];
size = eagl_layer.frame.size;
if (window_eagl->priv->window_width != window_eagl->priv->preferred_width ||
window_eagl->priv->window_height != window_eagl->priv->preferred_height) {
window_eagl->priv->window_width = window_eagl->priv->preferred_width;
window_eagl->priv->window_height = window_eagl->priv->preferred_height;
if (window_eagl->priv->window_width != size.width ||
window_eagl->priv->window_height != size.height) {
window_eagl->priv->window_width = size.width;
window_eagl->priv->window_height = size.height;
gst_gl_context_eagl_resize (eagl_context);
if (window->resize)
window->resize (window->resize_data, window_eagl->priv->preferred_width,
window_eagl->priv->preferred_height);
window->resize (window->resize_data, window_eagl->priv->window_width,
window_eagl->priv->window_height);
}
}