void cogl_pipeline_set_front_face_winding (CoglPipeline *pipeline, CoglWinding front_winding) { CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE; CoglPipeline *authority; CoglPipelineCullFaceState *cull_face_state; _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); cull_face_state = &authority->big_state->cull_face_state; if (cull_face_state->front_winding == front_winding) return; /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); pipeline->big_state->cull_face_state.front_winding = front_winding; _cogl_pipeline_update_authority (pipeline, authority, state, _cogl_pipeline_cull_face_state_equal); }
void cogl_pipeline_set_color_mask (CoglPipeline *pipeline, CoglColorMask color_mask) { CoglPipelineState state = COGL_PIPELINE_STATE_LOGIC_OPS; CoglPipeline *authority; CoglPipelineLogicOpsState *logic_ops_state; _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); logic_ops_state = &authority->big_state->logic_ops_state; if (logic_ops_state->color_mask == color_mask) return; /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); logic_ops_state = &pipeline->big_state->logic_ops_state; logic_ops_state->color_mask = color_mask; _cogl_pipeline_update_authority (pipeline, authority, state, _cogl_pipeline_logic_ops_state_equal); }
void _cogl_pipeline_set_blend_enabled (CoglPipeline *pipeline, CoglPipelineBlendEnable enable) { CoglPipelineState state = COGL_PIPELINE_STATE_BLEND_ENABLE; CoglPipeline *authority; _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); _COGL_RETURN_IF_FAIL (enable > 1 && "don't pass TRUE or FALSE to _set_blend_enabled!"); authority = _cogl_pipeline_get_authority (pipeline, state); if (authority->blend_enable == enable) return; /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); pipeline->blend_enable = enable; _cogl_pipeline_update_authority (pipeline, authority, state, _cogl_pipeline_blend_enable_equal); _cogl_pipeline_update_blend_enable (pipeline, state); }
void cogl_pipeline_set_point_size (CoglPipeline *pipeline, float point_size) { CoglPipelineState state = COGL_PIPELINE_STATE_POINT_SIZE; CoglPipeline *authority; _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); if (authority->big_state->point_size == point_size) return; /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); pipeline->big_state->point_size = point_size; _cogl_pipeline_update_authority (pipeline, authority, state, _cogl_pipeline_point_size_equal); }
static void _cogl_pipeline_set_alpha_test_function_reference (CoglPipeline *pipeline, float alpha_reference) { CoglPipelineState state = COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE; CoglPipeline *authority; CoglPipelineAlphaFuncState *alpha_state; _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); alpha_state = &authority->big_state->alpha_state; if (alpha_state->alpha_func_reference == alpha_reference) return; /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); alpha_state = &pipeline->big_state->alpha_state; alpha_state->alpha_func_reference = alpha_reference; _cogl_pipeline_update_authority (pipeline, authority, state, _cogl_pipeline_alpha_func_reference_state_equal); }
void cogl_pipeline_set_color (CoglPipeline *pipeline, const CoglColor *color) { CoglPipelineState state = COGL_PIPELINE_STATE_COLOR; CoglPipeline *authority; _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); if (cogl_color_equal (color, &authority->color)) return; /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ _cogl_pipeline_pre_change_notify (pipeline, state, color, FALSE); pipeline->color = *color; _cogl_pipeline_update_authority (pipeline, authority, state, _cogl_pipeline_color_equal); _cogl_pipeline_update_blend_enable (pipeline, state); }
static CoglPipelineSnippetList * get_vertex_snippets (CoglPipeline *pipeline) { pipeline = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_VERTEX_SNIPPETS); return &pipeline->big_state->vertex_snippets; }
CoglBool _cogl_pipeline_has_non_layer_fragment_snippets (CoglPipeline *pipeline) { CoglPipeline *authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS); return !COGL_LIST_EMPTY (&authority->big_state->fragment_snippets); }
CoglBool _cogl_pipeline_has_non_layer_vertex_snippets (CoglPipeline *pipeline) { CoglPipeline *authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_VERTEX_SNIPPETS); return !COGL_LIST_EMPTY (&authority->big_state->vertex_snippets); }
CoglPipelineBlendEnable _cogl_pipeline_get_blend_enabled (CoglPipeline *pipeline) { CoglPipeline *authority; _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_BLEND_ENABLE); return authority->blend_enable; }
CoglPipelineAlphaFunc cogl_pipeline_get_alpha_test_function (CoglPipeline *pipeline) { CoglPipeline *authority; _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_ALPHA_FUNC); return authority->big_state->alpha_state.alpha_func; }
void cogl_pipeline_get_depth_state (CoglPipeline *pipeline, CoglDepthState *state) { CoglPipeline *authority; _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH); *state = authority->big_state->depth_state; }
CoglColorMask cogl_pipeline_get_color_mask (CoglPipeline *pipeline) { CoglPipeline *authority; _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LOGIC_OPS); return authority->big_state->logic_ops_state.color_mask; }
float cogl_pipeline_get_point_size (CoglPipeline *pipeline) { CoglPipeline *authority; _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE); return authority->big_state->point_size; }
void cogl_pipeline_get_color (CoglPipeline *pipeline, CoglColor *color) { CoglPipeline *authority; _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR); *color = authority->color; }
float cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline) { CoglPipeline *authority; _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0.0f); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE); return authority->big_state->alpha_state.alpha_func_reference; }
CoglWinding cogl_pipeline_get_front_face_winding (CoglPipeline *pipeline) { CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE; CoglPipeline *authority; _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), COGL_PIPELINE_CULL_FACE_MODE_NONE); authority = _cogl_pipeline_get_authority (pipeline, state); return authority->big_state->cull_face_state.front_winding; }
CoglPipelineCullFaceMode cogl_pipeline_get_cull_face_mode (CoglPipeline *pipeline) { CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE; CoglPipeline *authority; _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), COGL_PIPELINE_CULL_FACE_MODE_NONE); authority = _cogl_pipeline_get_authority (pipeline, state); return authority->big_state->cull_face_state.mode; }
CoglBool cogl_pipeline_set_depth_state (CoglPipeline *pipeline, const CoglDepthState *depth_state, CoglError **error) { CoglPipelineState state = COGL_PIPELINE_STATE_DEPTH; CoglPipeline *authority; CoglDepthState *orig_state; _COGL_GET_CONTEXT (ctx, FALSE); _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); _COGL_RETURN_VAL_IF_FAIL (depth_state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); authority = _cogl_pipeline_get_authority (pipeline, state); orig_state = &authority->big_state->depth_state; if (orig_state->test_enabled == depth_state->test_enabled && orig_state->write_enabled == depth_state->write_enabled && orig_state->test_function == depth_state->test_function && orig_state->range_near == depth_state->range_near && orig_state->range_far == depth_state->range_far) return TRUE; if (ctx->driver == COGL_DRIVER_GLES1 && (depth_state->range_near != 0 || depth_state->range_far != 1)) { _cogl_set_error (error, COGL_SYSTEM_ERROR, COGL_SYSTEM_ERROR_UNSUPPORTED, "glDepthRange not available on GLES 1"); return FALSE; } /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); pipeline->big_state->depth_state = *depth_state; _cogl_pipeline_update_authority (pipeline, authority, state, _cogl_pipeline_depth_state_equal); return TRUE; }
static CoglBool _cogl_pipeline_vertend_fixed_end (CoglPipeline *pipeline, unsigned long pipelines_difference) { _COGL_GET_CONTEXT (ctx, FALSE); if (pipelines_difference & COGL_PIPELINE_STATE_POINT_SIZE) { CoglPipeline *authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE); if (authority->big_state->point_size > 0.0f) GE( ctx, glPointSize (authority->big_state->point_size) ); } return TRUE; }
void cogl_pipeline_set_blend_constant (CoglPipeline *pipeline, const CoglColor *constant_color) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_BLEND_CONSTANT)) return; #if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) { CoglPipelineState state = COGL_PIPELINE_STATE_BLEND; CoglPipeline *authority; CoglPipelineBlendState *blend_state; authority = _cogl_pipeline_get_authority (pipeline, state); blend_state = &authority->big_state->blend_state; if (cogl_color_equal (constant_color, &blend_state->blend_constant)) return; /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); blend_state = &pipeline->big_state->blend_state; blend_state->blend_constant = *constant_color; _cogl_pipeline_update_authority (pipeline, authority, state, _cogl_pipeline_blend_state_equal); _cogl_pipeline_update_blend_enable (pipeline, state); } #endif }
static gboolean _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline, int n_layers, unsigned long pipelines_difference) { CoglPipelineShaderState *shader_state; CoglPipeline *template_pipeline = NULL; CoglProgram *user_program; _COGL_GET_CONTEXT (ctx, FALSE); if (!cogl_features_available (COGL_FEATURE_SHADERS_GLSL)) return FALSE; user_program = cogl_pipeline_get_user_program (pipeline); /* If the user program has a vertex shader that isn't GLSL then the appropriate vertend for that language should handle it */ if (user_program && _cogl_program_has_vertex_shader (user_program) && _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_GLSL) return FALSE; /* Now lookup our glsl backend private state (allocating if * necessary) */ shader_state = get_shader_state (pipeline); if (shader_state == NULL) { CoglPipeline *authority; /* Get the authority for anything affecting vertex shader state */ authority = _cogl_pipeline_find_equivalent_parent (pipeline, COGL_PIPELINE_STATE_AFFECTS_VERTEX_CODEGEN & ~COGL_PIPELINE_STATE_LAYERS, COGL_PIPELINE_LAYER_STATE_AFFECTS_VERTEX_CODEGEN); shader_state = get_shader_state (authority); if (shader_state == NULL) { /* Check if there is already a similar cached pipeline whose shader state we can share */ if (G_LIKELY (!(COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_PROGRAM_CACHES)))) { template_pipeline = _cogl_pipeline_cache_get_vertex_template (ctx->pipeline_cache, authority); shader_state = get_shader_state (template_pipeline); } if (shader_state) shader_state->ref_count++; else shader_state = shader_state_new (); set_shader_state (authority, shader_state); if (template_pipeline) { shader_state->ref_count++; set_shader_state (template_pipeline, shader_state); } } if (authority != pipeline) { shader_state->ref_count++; set_shader_state (pipeline, shader_state); } } if (shader_state->gl_shader) { /* If we already have a valid GLSL shader then we don't need to generate a new one. However if there's a user program and it has changed since the last link then we do need a new shader */ if (user_program == NULL || shader_state->user_program_age == user_program->age) return TRUE; /* We need to recreate the shader so destroy the existing one */ GE( ctx, glDeleteShader (shader_state->gl_shader) ); shader_state->gl_shader = 0; } /* If we make it here then we have a shader_state struct without a gl_shader either because this is the first time we've encountered it or because the user program has changed */ if (user_program) shader_state->user_program_age = user_program->age; /* If the user program contains a vertex shader then we don't need to generate one */ if (user_program && _cogl_program_has_vertex_shader (user_program)) return TRUE; /* We reuse two grow-only GStrings for code-gen. One string contains the uniform and attribute declarations while the other contains the main function. We need two strings because we need to dynamically declare attributes as the add_layer callback is invoked */ g_string_set_size (ctx->codegen_header_buffer, 0); g_string_set_size (ctx->codegen_source_buffer, 0); shader_state->header = ctx->codegen_header_buffer; shader_state->source = ctx->codegen_source_buffer; g_string_append (shader_state->source, "void\n" "main ()\n" "{\n"); if (ctx->driver == COGL_DRIVER_GLES2) /* There is no builtin uniform for the pointsize on GLES2 so we need to copy it from the custom uniform in the vertex shader */ g_string_append (shader_state->source, " cogl_point_size_out = cogl_point_size_in;\n"); /* On regular OpenGL we'll just flush the point size builtin */ else if (pipelines_difference & COGL_PIPELINE_STATE_POINT_SIZE) { CoglPipeline *authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE); if (ctx->point_size_cache != authority->big_state->point_size) { GE( ctx, glPointSize (authority->big_state->point_size) ); ctx->point_size_cache = authority->big_state->point_size; } } return TRUE; }
static CoglBool _cogl_pipeline_vertend_glsl_end (CoglPipeline *pipeline, unsigned long pipelines_difference) { CoglPipelineShaderState *shader_state; _COGL_GET_CONTEXT (ctx, FALSE); shader_state = get_shader_state (pipeline); if (shader_state->source) { const char *source_strings[2]; GLint lengths[2]; GLint compile_status; GLuint shader; CoglPipelineSnippetData snippet_data; CoglPipelineSnippetList *vertex_snippets; COGL_STATIC_COUNTER (vertend_glsl_compile_counter, "glsl vertex compile counter", "Increments each time a new GLSL " "vertex shader is compiled", 0 /* no application private data */); COGL_COUNTER_INC (_cogl_uprof_context, vertend_glsl_compile_counter); g_string_append (shader_state->header, "void\n" "cogl_real_vertex_transform ()\n" "{\n" " cogl_position_out = " "cogl_modelview_projection_matrix * " "cogl_position_in;\n" "}\n"); g_string_append (shader_state->source, " cogl_vertex_transform ();\n" " cogl_color_out = cogl_color_in;\n" "}\n"); vertex_snippets = get_vertex_snippets (pipeline); /* Add hooks for the vertex transform part */ memset (&snippet_data, 0, sizeof (snippet_data)); snippet_data.snippets = vertex_snippets; snippet_data.hook = COGL_SNIPPET_HOOK_VERTEX_TRANSFORM; snippet_data.chain_function = "cogl_real_vertex_transform"; snippet_data.final_name = "cogl_vertex_transform"; snippet_data.function_prefix = "cogl_vertex_transform"; snippet_data.source_buf = shader_state->header; _cogl_pipeline_snippet_generate_code (&snippet_data); /* Add all of the hooks for vertex processing */ memset (&snippet_data, 0, sizeof (snippet_data)); snippet_data.snippets = vertex_snippets; snippet_data.hook = COGL_SNIPPET_HOOK_VERTEX; snippet_data.chain_function = "cogl_generated_source"; snippet_data.final_name = "cogl_vertex_hook"; snippet_data.function_prefix = "cogl_vertex_hook"; snippet_data.source_buf = shader_state->source; _cogl_pipeline_snippet_generate_code (&snippet_data); g_string_append (shader_state->source, "void\n" "main ()\n" "{\n" " cogl_vertex_hook ();\n"); /* If there are any snippets then we can't rely on the projection matrix to flip the rendering for offscreen buffers so we'll need to flip it using an extra statement and a uniform */ if (_cogl_pipeline_has_vertex_snippets (pipeline)) { g_string_append (shader_state->header, "uniform vec4 _cogl_flip_vector;\n"); g_string_append (shader_state->source, " cogl_position_out *= _cogl_flip_vector;\n"); } g_string_append (shader_state->source, "}\n"); GE_RET( shader, ctx, glCreateShader (GL_VERTEX_SHADER) ); lengths[0] = shader_state->header->len; source_strings[0] = shader_state->header->str; lengths[1] = shader_state->source->len; source_strings[1] = shader_state->source->str; _cogl_glsl_shader_set_source_with_boilerplate (ctx, NULL, shader, GL_VERTEX_SHADER, 2, /* count */ source_strings, lengths); GE( ctx, glCompileShader (shader) ); GE( ctx, glGetShaderiv (shader, GL_COMPILE_STATUS, &compile_status) ); if (!compile_status) { GLint len = 0; char *shader_log; GE( ctx, glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &len) ); shader_log = g_alloca (len); GE( ctx, glGetShaderInfoLog (shader, len, &len, shader_log) ); g_warning ("Shader compilation failed:\n%s", shader_log); } shader_state->header = NULL; shader_state->source = NULL; shader_state->gl_shader = shader; } if ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM) && (pipelines_difference & COGL_PIPELINE_STATE_POINT_SIZE)) { CoglPipeline *authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE); GE( ctx, glPointSize (authority->big_state->point_size) ); } return TRUE; }
static gboolean _cogl_pipeline_fragend_fixed_end (CoglPipeline *pipeline, unsigned long pipelines_difference) { int highest_unit_index = -1; int i; _COGL_GET_CONTEXT (ctx, FALSE); _cogl_pipeline_foreach_layer_internal (pipeline, get_highest_unit_index_cb, &highest_unit_index); /* Disable additional texture units that may have previously been in use.. */ for (i = highest_unit_index + 1; i < ctx->texture_units->len; i++) _cogl_disable_texture_unit (i); if (pipelines_difference & COGL_PIPELINE_STATE_FOG) { CoglPipeline *authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_FOG); CoglPipelineFogState *fog_state = &authority->big_state->fog_state; if (fog_state->enabled) { GLfloat fogColor[4]; GLenum gl_mode = GL_LINEAR; fogColor[0] = cogl_color_get_red_float (&fog_state->color); fogColor[1] = cogl_color_get_green_float (&fog_state->color); fogColor[2] = cogl_color_get_blue_float (&fog_state->color); fogColor[3] = cogl_color_get_alpha_float (&fog_state->color); GE (ctx, glEnable (GL_FOG)); GE (ctx, glFogfv (GL_FOG_COLOR, fogColor)); if (ctx->driver == COGL_DRIVER_GLES1) switch (fog_state->mode) { case COGL_FOG_MODE_LINEAR: gl_mode = GL_LINEAR; break; case COGL_FOG_MODE_EXPONENTIAL: gl_mode = GL_EXP; break; case COGL_FOG_MODE_EXPONENTIAL_SQUARED: gl_mode = GL_EXP2; break; } /* TODO: support other modes for GLES2 */ /* NB: GLES doesn't have glFogi */ GE (ctx, glFogf (GL_FOG_MODE, gl_mode)); GE (ctx, glHint (GL_FOG_HINT, GL_NICEST)); GE (ctx, glFogf (GL_FOG_DENSITY, fog_state->density)); GE (ctx, glFogf (GL_FOG_START, fog_state->z_near)); GE (ctx, glFogf (GL_FOG_END, fog_state->z_far)); } else GE (ctx, glDisable (GL_FOG)); } return TRUE; }
CoglBool cogl_pipeline_set_blend (CoglPipeline *pipeline, const char *blend_description, CoglError **error) { CoglPipelineState state = COGL_PIPELINE_STATE_BLEND; CoglPipeline *authority; CoglBlendStringStatement statements[2]; CoglBlendStringStatement *rgb; CoglBlendStringStatement *a; int count; CoglPipelineBlendState *blend_state; _COGL_GET_CONTEXT (ctx, FALSE); _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); count = _cogl_blend_string_compile (blend_description, COGL_BLEND_STRING_CONTEXT_BLENDING, statements, error); if (!count) return FALSE; if (count == 1) rgb = a = statements; else { rgb = &statements[0]; a = &statements[1]; } authority = _cogl_pipeline_get_authority (pipeline, state); /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); blend_state = &pipeline->big_state->blend_state; #if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2) if (ctx->driver != COGL_DRIVER_GLES1) { setup_blend_state (rgb, &blend_state->blend_equation_rgb, &blend_state->blend_src_factor_rgb, &blend_state->blend_dst_factor_rgb); setup_blend_state (a, &blend_state->blend_equation_alpha, &blend_state->blend_src_factor_alpha, &blend_state->blend_dst_factor_alpha); } else #endif { setup_blend_state (rgb, NULL, &blend_state->blend_src_factor_rgb, &blend_state->blend_dst_factor_rgb); } /* If we are the current authority see if we can revert to one of our * ancestors being the authority */ if (pipeline == authority && _cogl_pipeline_get_parent (authority) != NULL) { CoglPipeline *parent = _cogl_pipeline_get_parent (authority); CoglPipeline *old_authority = _cogl_pipeline_get_authority (parent, state); if (_cogl_pipeline_blend_state_equal (authority, old_authority)) pipeline->differences &= ~state; } /* If we weren't previously the authority on this state then we need * to extended our differences mask and so it's possible that some * of our ancestry will now become redundant, so we aim to reparent * ourselves if that's true... */ if (pipeline != authority) { pipeline->differences |= state; _cogl_pipeline_prune_redundant_ancestry (pipeline); } _cogl_pipeline_update_blend_enable (pipeline, state); return TRUE; }