mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 02:00:33 +00:00
[878/906] tests: update for glmem api change
This commit is contained in:
parent
b6f6d585c3
commit
54d70702cc
3 changed files with 153 additions and 141 deletions
|
@ -89,6 +89,7 @@ init (gpointer data)
|
|||
fail_if (tex == 0, "failed to create texture");
|
||||
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) {
|
||||
shader = gst_gl_shader_new (context);
|
||||
fail_if (shader == NULL, "failed to create shader object");
|
||||
|
||||
|
@ -104,6 +105,7 @@ init (gpointer data)
|
|||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
shader_attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -151,6 +153,7 @@ draw_render (gpointer data)
|
|||
/* redraw the texture into the system provided framebuffer */
|
||||
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
|
||||
GLfloat verts[8] = { 1.0f, 1.0f,
|
||||
-1.0f, 1.0f,
|
||||
-1.0f, -1.0f,
|
||||
|
@ -183,8 +186,10 @@ draw_render (gpointer data)
|
|||
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
}
|
||||
#endif
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) {
|
||||
const GLfloat vVertices[] = { 1.0f, 1.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
-1.0f, 1.0f, 0.0f,
|
||||
|
@ -217,6 +222,7 @@ draw_render (gpointer data)
|
|||
gst_gl_shader_set_uniform_1i (shader, "s_texture", 0);
|
||||
|
||||
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
}
|
||||
#endif
|
||||
|
||||
context_class->swap_buffers (context);
|
||||
|
|
|
@ -73,14 +73,14 @@ GST_START_TEST (test_basic)
|
|||
|
||||
/* test allocator creation */
|
||||
ASSERT_WARNING (mem = gst_allocator_alloc (gl_allocator, 0, NULL););
|
||||
mem = gst_gl_memory_alloc (context, formats[i], width, height);
|
||||
mem = gst_gl_memory_alloc (context, vinfo);
|
||||
fail_if (mem == NULL);
|
||||
gl_mem = (GstGLMemory *) mem;
|
||||
|
||||
/* test init params */
|
||||
fail_if (gl_mem->width != width);
|
||||
fail_if (gl_mem->height != height);
|
||||
fail_if (gl_mem->v_format != formats[i]);
|
||||
fail_if (GST_VIDEO_INFO_WIDTH (&gl_mem->v_info) != width);
|
||||
fail_if (GST_VIDEO_INFO_HEIGHT (&gl_mem->v_info) != height);
|
||||
fail_if (GST_VIDEO_INFO_FORMAT (&gl_mem->v_info) != formats[i]);
|
||||
fail_if (gl_mem->context != context);
|
||||
fail_if (gl_mem->tex_id == 0);
|
||||
|
||||
|
@ -91,9 +91,12 @@ GST_START_TEST (test_basic)
|
|||
|
||||
/* test params */
|
||||
fail_if (gl_mem->tex_id == gl_mem2->tex_id);
|
||||
fail_if (gl_mem->width != gl_mem->width);
|
||||
fail_if (gl_mem->height != gl_mem->height);
|
||||
fail_if (gl_mem->v_format != gl_mem->v_format);
|
||||
fail_if (GST_VIDEO_INFO_FORMAT (&gl_mem->v_info) !=
|
||||
GST_VIDEO_INFO_FORMAT (&gl_mem2->v_info));
|
||||
fail_if (GST_VIDEO_INFO_WIDTH (&gl_mem->v_info) !=
|
||||
GST_VIDEO_INFO_WIDTH (&gl_mem2->v_info));
|
||||
fail_if (GST_VIDEO_INFO_HEIGHT (&gl_mem->v_info) !=
|
||||
GST_VIDEO_INFO_HEIGHT (&gl_mem2->v_info));
|
||||
fail_if (gl_mem->gl_format != gl_mem->gl_format);
|
||||
fail_if (gl_mem->context != gl_mem->context);
|
||||
fail_if (gl_mem->tex_id == 0);
|
||||
|
|
|
@ -119,6 +119,7 @@ void
|
|||
init (gpointer data)
|
||||
{
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) {
|
||||
shader = gst_gl_shader_new (context);
|
||||
fail_if (shader == NULL, "failed to create shader object");
|
||||
|
||||
|
@ -134,6 +135,7 @@ init (gpointer data)
|
|||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
shader_attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -147,6 +149,7 @@ draw_render (gpointer data)
|
|||
/* redraw the texture into the system provided framebuffer */
|
||||
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
|
||||
GLfloat verts[8] = { 1.0f, 1.0f,
|
||||
-1.0f, 1.0f,
|
||||
-1.0f, -1.0f,
|
||||
|
@ -158,7 +161,7 @@ draw_render (gpointer data)
|
|||
1.0f, 1.0f
|
||||
};
|
||||
|
||||
gl->Viewport (0, 0, WIDTH, HEIGHT);
|
||||
gl->Viewport (0, 0, 320, 240);
|
||||
|
||||
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
@ -179,8 +182,10 @@ draw_render (gpointer data)
|
|||
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
}
|
||||
#endif
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) {
|
||||
const GLfloat vVertices[] = { 1.0f, 1.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
-1.0f, 1.0f, 0.0f,
|
||||
|
@ -213,6 +218,7 @@ draw_render (gpointer data)
|
|||
gst_gl_shader_set_uniform_1i (shader, "s_texture", 0);
|
||||
|
||||
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
}
|
||||
#endif
|
||||
|
||||
context_class->swap_buffers (context);
|
||||
|
@ -288,12 +294,11 @@ GST_START_TEST (test_upload_memory)
|
|||
gboolean res;
|
||||
gint i = 0;
|
||||
|
||||
gl_mem = gst_gl_memory_wrapped (context, FORMAT, WIDTH, HEIGHT, rgba_data,
|
||||
NULL, NULL);
|
||||
|
||||
gst_video_info_set_format (&in_info, FORMAT, WIDTH, HEIGHT);
|
||||
gst_video_info_set_format (&out_info, FORMAT, WIDTH, HEIGHT);
|
||||
|
||||
gl_mem = gst_gl_memory_wrapped (context, in_info, rgba_data, NULL, NULL);
|
||||
|
||||
gst_gl_upload_init_format (upload, in_info, out_info);
|
||||
|
||||
res = gst_gl_upload_perform_with_memory (upload, gl_mem);
|
||||
|
@ -323,15 +328,14 @@ GST_START_TEST (test_upload_buffer)
|
|||
gint i = 0;
|
||||
gboolean res;
|
||||
|
||||
/* create GL buffer */
|
||||
buffer = gst_buffer_new ();
|
||||
gl_mem = gst_gl_memory_wrapped (context, FORMAT, WIDTH, HEIGHT, rgba_data,
|
||||
NULL, NULL);
|
||||
gst_buffer_append_memory (buffer, (GstMemory *) gl_mem);
|
||||
|
||||
gst_video_info_set_format (&in_info, FORMAT, WIDTH, HEIGHT);
|
||||
gst_video_info_set_format (&out_info, FORMAT, WIDTH, HEIGHT);
|
||||
|
||||
/* create GL buffer */
|
||||
buffer = gst_buffer_new ();
|
||||
gl_mem = gst_gl_memory_wrapped (context, in_info, rgba_data, NULL, NULL);
|
||||
gst_buffer_append_memory (buffer, (GstMemory *) gl_mem);
|
||||
|
||||
gst_gl_upload_init_format (upload, in_info, out_info);
|
||||
|
||||
res = gst_gl_upload_perform_with_buffer (upload, buffer, &tex_id);
|
||||
|
@ -363,17 +367,16 @@ GST_START_TEST (test_upload_meta_producer)
|
|||
gboolean res;
|
||||
gint i = 0;
|
||||
|
||||
gst_video_info_set_format (&in_info, FORMAT, WIDTH, HEIGHT);
|
||||
gst_video_info_set_format (&out_info, FORMAT, WIDTH, HEIGHT);
|
||||
|
||||
/* create GL buffer */
|
||||
buffer = gst_buffer_new ();
|
||||
gl_mem = gst_gl_memory_wrapped (context, FORMAT, WIDTH, HEIGHT, rgba_data,
|
||||
NULL, NULL);
|
||||
gl_mem = gst_gl_memory_wrapped (context, in_info, rgba_data, NULL, NULL);
|
||||
gst_buffer_append_memory (buffer, (GstMemory *) gl_mem);
|
||||
|
||||
gst_gl_context_gen_texture (context, &tex_ids[0], FORMAT, WIDTH, HEIGHT);
|
||||
|
||||
gst_video_info_set_format (&in_info, FORMAT, WIDTH, HEIGHT);
|
||||
gst_video_info_set_format (&out_info, FORMAT, WIDTH, HEIGHT);
|
||||
|
||||
gst_gl_upload_init_format (upload, in_info, out_info);
|
||||
gst_gl_upload_add_video_gl_texture_upload_meta (upload, buffer);
|
||||
|
||||
|
|
Loading…
Reference in a new issue