コード例 #1
0
ファイル: video_mix.c プロジェクト: fluggo/Canvas
EXPORT void
video_mix_over_gl( rgba_frame_gl *out, rgba_frame_gl *a, rgba_frame_gl *b, float mix_b ) {
    // Really, this is almost exactly the same code as video_mix_cross_gl; the two
    // should probably be combined (difference is just the shader text)
    GQuark shader_quark = g_quark_from_static_string( "cprocess::video_mix::over_shader" );

    // Gather the mix factor
    mix_b = clampf(mix_b, 0.0f, 1.0f);

    void *context = getCurrentGLContext();
    gl_shader_state *shader = (gl_shader_state *) g_dataset_id_get_data( context, shader_quark );

    if( !shader ) {
        // Time to create the program for this context
        shader = g_new0( gl_shader_state, 1 );

        shader->program = video_create_filter_program( over_shader_text, "Video mix over shader" );
        shader->mix_b_uniform = glGetUniformLocation( shader->program->program, "mix_b" );

        g_dataset_id_set_data_full( context, shader_quark, shader, (GDestroyNotify) destroy_shader );
    }

    glUseProgram( shader->program->program );
    glUniform1f( shader->mix_b_uniform, mix_b );

    video_render_gl_frame_filter2( shader->program, out, a, b );
}
コード例 #2
0
ファイル: video_mix.c プロジェクト: fluggo/Canvas
EXPORT void
video_mix_cross_gl( rgba_frame_gl *out, rgba_frame_gl *a, rgba_frame_gl *b, float mix_b ) {
    GQuark shader_quark = g_quark_from_static_string( "cprocess::video_mix::crossfade_shader" );
    g_debug( "In video_mix_cross_gl, mix_b=%f", mix_b );

    // Gather the mix factor
    mix_b = clampf(mix_b, 0.0f, 1.0f);

    void *context = getCurrentGLContext();
    gl_shader_state *shader = (gl_shader_state *) g_dataset_id_get_data( context, shader_quark );

    if( !shader ) {
        // Time to create the program for this context
        shader = g_new0( gl_shader_state, 1 );

        shader->program = video_create_filter_program( crossfade_shader_text, "Video mix crossfade shader" );
        shader->mix_b_uniform = glGetUniformLocation( shader->program->program, "mix_b" );

        g_dataset_id_set_data_full( context, shader_quark, shader, (GDestroyNotify) destroy_shader );
    }

    glUseProgram( shader->program->program );
    glUniform1f( shader->mix_b_uniform, mix_b );

    video_render_gl_frame_filter2( shader->program, out, a, b );
}
コード例 #3
0
ファイル: source.c プロジェクト: B-Rich/amanda
amglue_Source *
amglue_source_get(
    GSource *gsrc,
    GSourceFunc callback)
{
    amglue_Source *src;
    g_assert(gsrc != NULL);

    src = (amglue_Source *)g_dataset_id_get_data(gsrc, AMGLUE_SOURCE_QUARK);

    if (!src)
	src = amglue_source_new(gsrc, callback);
    else
	amglue_source_ref(src);

    return src;
}
コード例 #4
0
ファイル: clutter-binding-pool.c プロジェクト: GNOME/clutter
/**
 * clutter_binding_pool_get_for_class:
 * @klass: a #GObjectClass pointer
 *
 * Retrieves the #ClutterBindingPool for the given #GObject class
 * and, eventually, creates it. This function is a wrapper around
 * clutter_binding_pool_new() and uses the class type name as the
 * unique name for the binding pool.
 *
 * Calling this function multiple times will return the same
 * #ClutterBindingPool.
 *
 * A binding pool for a class can also be retrieved using
 * clutter_binding_pool_find() with the class type name:
 *
 * |[
 *   pool = clutter_binding_pool_find (G_OBJECT_TYPE_NAME (instance));
 * ]|
 *
 * Return value: (transfer none): the binding pool for the given class.
 *   The returned #ClutterBindingPool is owned by Clutter and should not
 *   be freed directly
 *
 * Since: 1.0
 */
ClutterBindingPool *
clutter_binding_pool_get_for_class (gpointer klass)
{
  ClutterBindingPool *pool;

  g_return_val_if_fail (G_IS_OBJECT_CLASS (klass), NULL);

  if (G_UNLIKELY (key_class_bindings == 0))
    key_class_bindings = g_quark_from_static_string ("clutter-bindings-set");

  pool = g_dataset_id_get_data (klass, key_class_bindings);
  if (pool)
    return pool;

  pool = clutter_binding_pool_new (G_OBJECT_CLASS_NAME (klass));
  g_dataset_id_set_data_full (klass, key_class_bindings,
                              pool,
                              g_object_unref);

  return pool;
}