diff options
author | Matthew Waters <matthew@centricular.com> | 2015-07-16 00:37:58 +1000 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2015-07-18 15:34:55 +1000 |
commit | be9ad5eeb255c68b7ed07c6cb6d64b744c2076c7 (patch) | |
tree | d1b5716f247262a79751408c09480d3b6cff5d99 /tests | |
parent | b679cc2238942a77ecf64038aa0a89a83063e287 (diff) | |
download | gstreamer-plugins-bad-be9ad5eeb255c68b7ed07c6cb6d64b744c2076c7.tar.gz |
glcontext: track sharedness with a cookie
The previous approach of traversing the other_context weak ref tree was
1. Less performant
2. Incorrect for context destruction removing a link in the tree
Example of 2:
c1 = context_create (NULL)
c2 = context_create (c1)
c3 = context_create (c2)
context_can_share (c1, c3) == TRUE
context_destroy (c2)
unref (c2)
context_can_share (c1, c3) returns FALSE when it should be TRUE!
This does not remove the restriction that context sharedness can only
be tracked between GstGLContext's.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check/libs/gstglcontext.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/check/libs/gstglcontext.c b/tests/check/libs/gstglcontext.c index 601e67344..d83d41d01 100644 --- a/tests/check/libs/gstglcontext.c +++ b/tests/check/libs/gstglcontext.c @@ -442,6 +442,46 @@ GST_START_TEST (test_current_context) GST_END_TEST; +GST_START_TEST (test_context_can_share) +{ + GstGLContext *c1, *c2, *c3; + GError *error = NULL; + + c1 = gst_gl_context_new (display); + gst_gl_context_create (c1, NULL, &error); + fail_if (error != NULL, "Error creating context %s\n", + error ? error->message : "Unknown Error"); + + c2 = gst_gl_context_new (display); + gst_gl_context_create (c2, c1, &error); + fail_if (error != NULL, "Error creating context %s\n", + error ? error->message : "Unknown Error"); + + fail_unless (gst_gl_context_can_share (c1, c2)); + fail_unless (gst_gl_context_can_share (c2, c1)); + + c3 = gst_gl_context_new (display); + gst_gl_context_create (c3, c2, &error); + fail_if (error != NULL, "Error creating context %s\n", + error ? error->message : "Unknown Error"); + + fail_unless (gst_gl_context_can_share (c1, c3)); + fail_unless (gst_gl_context_can_share (c3, c1)); + fail_unless (gst_gl_context_can_share (c2, c3)); + fail_unless (gst_gl_context_can_share (c3, c2)); + + /* destroy the middle context */ + gst_object_unref (c2); + c2 = NULL; + + fail_unless (gst_gl_context_can_share (c1, c3)); + fail_unless (gst_gl_context_can_share (c3, c1)); + + gst_object_unref (c1); + gst_object_unref (c3); +} + +GST_END_TEST; static Suite * gst_gl_context_suite (void) @@ -454,6 +494,7 @@ gst_gl_context_suite (void) tcase_add_test (tc_chain, test_share); tcase_add_test (tc_chain, test_wrapped_context); tcase_add_test (tc_chain, test_current_context); + tcase_add_test (tc_chain, test_context_can_share); return s; } |