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:
|
case GST_GL_BUFFER_RBO:
|
||||||
glDeleteRenderbuffersEXT (1, &buffer->rbo);
|
glDeleteRenderbuffersEXT (1, &buffer->rbo);
|
||||||
break;
|
break;
|
||||||
|
case GST_GL_BUFFER_TEXTURE:
|
||||||
|
glDeleteTextures (1, &buffer->texture);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
|
@ -88,14 +91,14 @@ gst_gl_buffer_new (GstGLDisplay * display, GstVideoFormat format,
|
||||||
GstGLBuffer *buffer;
|
GstGLBuffer *buffer;
|
||||||
XGCValues values = { 0 };
|
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 (width > 0, NULL);
|
||||||
g_return_val_if_fail (height > 0, NULL);
|
g_return_val_if_fail (height > 0, NULL);
|
||||||
|
|
||||||
buffer = (GstGLBuffer *) gst_mini_object_new (GST_TYPE_GL_BUFFER);
|
buffer = (GstGLBuffer *) gst_mini_object_new (GST_TYPE_GL_BUFFER);
|
||||||
|
|
||||||
buffer->display = g_object_ref (display);
|
buffer->display = g_object_ref (display);
|
||||||
buffer->type = GST_GL_BUFFER_RBO;
|
buffer->type = GST_GL_BUFFER_TEXTURE;
|
||||||
|
|
||||||
buffer->width = width;
|
buffer->width = width;
|
||||||
buffer->height = height;
|
buffer->height = height;
|
||||||
|
@ -147,6 +150,8 @@ gst_gl_buffer_new (GstGLDisplay * display, GstVideoFormat format,
|
||||||
gst_gl_display_unlock (buffer->display);
|
gst_gl_display_unlock (buffer->display);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GST_GL_BUFFER_TEXTURE:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
@ -236,6 +241,11 @@ gst_gl_buffer_upload (GstGLBuffer * buffer, void *data)
|
||||||
|
|
||||||
break;
|
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:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
@ -287,6 +297,29 @@ gst_gl_buffer_download (GstGLBuffer * buffer, void *data)
|
||||||
|
|
||||||
break;
|
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:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ typedef struct _GstGLBuffer GstGLBuffer;
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GST_GL_BUFFER_UNKNOWN,
|
GST_GL_BUFFER_UNKNOWN,
|
||||||
GST_GL_BUFFER_XIMAGE,
|
GST_GL_BUFFER_XIMAGE,
|
||||||
GST_GL_BUFFER_RBO
|
GST_GL_BUFFER_RBO,
|
||||||
|
GST_GL_BUFFER_TEXTURE
|
||||||
} GstGLBufferType;
|
} GstGLBufferType;
|
||||||
|
|
||||||
struct _GstGLBuffer {
|
struct _GstGLBuffer {
|
||||||
|
@ -31,6 +32,7 @@ struct _GstGLBuffer {
|
||||||
GC gc;
|
GC gc;
|
||||||
|
|
||||||
GLuint rbo;
|
GLuint rbo;
|
||||||
|
GLuint texture;
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
Loading…
Reference in a new issue