mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
[042/906] * sys/glsink/glimagesink.c: * sys/glsink/glimagesink.h: * sys/glsink/glvideo.c: * sys/glsink/glvideo.h: * sys/glsink/gstglbuffer.c: * sys/glsink/gstglbuffer.h: * sys/glsink/gstgldownload.c: * sys/glsink/gstglfilter.c: * sys/glsink/gstglupload.c: Rewrite a bunch of code to use textures as the intermediate instead of renderbuffers. upload, download, filtering all work.
This commit is contained in:
parent
c4a58e40e1
commit
7e42503811
2 changed files with 38 additions and 3 deletions
|
@ -27,6 +27,9 @@ gst_gl_buffer_finalize (GstGLBuffer * buffer)
|
|||
case GST_GL_BUFFER_RBO:
|
||||
glDeleteRenderbuffersEXT (1, &buffer->rbo);
|
||||
break;
|
||||
case GST_GL_BUFFER_TEXTURE:
|
||||
glDeleteTextures (1, &buffer->texture);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
|
@ -88,14 +91,14 @@ gst_gl_buffer_new (GstGLDisplay * display, GstVideoFormat format,
|
|||
GstGLBuffer *buffer;
|
||||
XGCValues values = { 0 };
|
||||
|
||||
g_return_val_if_fail (format == GST_VIDEO_FORMAT_RGB, NULL);
|
||||
g_return_val_if_fail (format == GST_VIDEO_FORMAT_RGBx, NULL);
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
|
||||
buffer = (GstGLBuffer *) gst_mini_object_new (GST_TYPE_GL_BUFFER);
|
||||
|
||||
buffer->display = g_object_ref (display);
|
||||
buffer->type = GST_GL_BUFFER_RBO;
|
||||
buffer->type = GST_GL_BUFFER_TEXTURE;
|
||||
|
||||
buffer->width = width;
|
||||
buffer->height = height;
|
||||
|
@ -147,6 +150,8 @@ gst_gl_buffer_new (GstGLDisplay * display, GstVideoFormat format,
|
|||
gst_gl_display_unlock (buffer->display);
|
||||
break;
|
||||
}
|
||||
case GST_GL_BUFFER_TEXTURE:
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
@ -236,6 +241,11 @@ gst_gl_buffer_upload (GstGLBuffer * buffer, void *data)
|
|||
|
||||
break;
|
||||
}
|
||||
case GST_GL_BUFFER_TEXTURE:
|
||||
buffer->texture =
|
||||
gst_gl_display_upload_texture_rectangle (buffer->display,
|
||||
GST_VIDEO_FORMAT_RGBx, data, buffer->width, buffer->height);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
@ -287,6 +297,29 @@ gst_gl_buffer_download (GstGLBuffer * buffer, void *data)
|
|||
|
||||
break;
|
||||
}
|
||||
case GST_GL_BUFFER_TEXTURE:
|
||||
{
|
||||
unsigned int fbo;
|
||||
|
||||
glGenFramebuffersEXT (1, &fbo);
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo);
|
||||
|
||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
|
||||
GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB,
|
||||
buffer->texture, 0);
|
||||
|
||||
glDrawBuffer (GL_COLOR_ATTACHMENT1_EXT);
|
||||
glReadBuffer (GL_COLOR_ATTACHMENT1_EXT);
|
||||
|
||||
g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
|
||||
GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||
|
||||
glReadPixels (0, 0, buffer->width, buffer->height, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
|
||||
glDeleteFramebuffersEXT (1, &fbo);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@ typedef struct _GstGLBuffer GstGLBuffer;
|
|||
typedef enum {
|
||||
GST_GL_BUFFER_UNKNOWN,
|
||||
GST_GL_BUFFER_XIMAGE,
|
||||
GST_GL_BUFFER_RBO
|
||||
GST_GL_BUFFER_RBO,
|
||||
GST_GL_BUFFER_TEXTURE
|
||||
} GstGLBufferType;
|
||||
|
||||
struct _GstGLBuffer {
|
||||
|
@ -31,6 +32,7 @@ struct _GstGLBuffer {
|
|||
GC gc;
|
||||
|
||||
GLuint rbo;
|
||||
GLuint texture;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
|
Loading…
Reference in a new issue