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_set_source (void *material_or_pipeline) { CoglSourceState *top; CoglPipeline *pipeline = COGL_PIPELINE (material_or_pipeline); _COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); _COGL_RETURN_IF_FAIL (ctx->source_stack); top = ctx->source_stack->data; if (top->pipeline == pipeline && top->enable_legacy) return; if (top->push_count == 1) { /* NB: top->pipeline may be only thing keeping pipeline * alive currently so ref pipeline first... */ cogl_object_ref (pipeline); cogl_object_unref (top->pipeline); top->pipeline = pipeline; top->enable_legacy = TRUE; } else { top->push_count--; cogl_push_source (pipeline); } }
void _cogl_buffer_immutable_unref (CoglBuffer *buffer) { _COGL_RETURN_IF_FAIL (cogl_is_buffer (buffer)); _COGL_RETURN_IF_FAIL (buffer->immutable_ref > 0); buffer->immutable_ref--; }
void cogl_xlib_renderer_request_reset_on_video_memory_purge (CoglRenderer *renderer, CoglBool enable) { _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->xlib_want_reset_on_video_memory_purge = enable; }
void _cogl_indices_immutable_unref (CoglIndices *indices) { _COGL_RETURN_IF_FAIL (cogl_is_indices (indices)); _COGL_RETURN_IF_FAIL (indices->immutable_ref > 0); indices->immutable_ref--; _cogl_buffer_immutable_unref (COGL_BUFFER (indices->buffer)); }
void cogl_wayland_renderer_set_event_dispatch_enabled (CoglRenderer *renderer, CoglBool enable) { _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); /* NB: Renderers are considered immutable once connected */ _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->wayland_enable_event_dispatch = enable; }
void cogl_xlib_renderer_set_event_retrieval_enabled (CoglRenderer *renderer, CoglBool enable) { _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); /* NB: Renderers are considered immutable once connected */ _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->xlib_enable_event_retrieval = enable; }
void cogl_wayland_renderer_set_foreign_compositor (CoglRenderer *renderer, struct wl_compositor *compositor) { _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); /* NB: Renderers are considered immutable once connected */ _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->foreign_wayland_compositor = compositor; }
/* XXX: deprecated */ void cogl_framebuffer_stroke_path (CoglFramebuffer *framebuffer, CoglPipeline *pipeline, CoglPath *path) { _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer)); _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); _COGL_RETURN_IF_FAIL (cogl_is_path (path)); _cogl_path_stroke_nodes (path, framebuffer, pipeline); }
void cogl_wayland_renderer_set_foreign_shell (CoglRenderer *renderer, struct wl_shell *shell) { _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); /* NB: Renderers are considered immutable once connected */ _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->foreign_wayland_shell = shell; }
void cogl_path_fill (CoglPath *path, CoglFramebuffer *framebuffer, CoglPipeline *pipeline) { _COGL_RETURN_IF_FAIL (cogl_is_path (path)); _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer)); _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); _cogl_path_fill_nodes (path, framebuffer, pipeline, 0 /* flags */); }
void cogl_wayland_renderer_set_foreign_display (CoglRenderer *renderer, struct wl_display *display) { _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); /* NB: Renderers are considered immutable once connected */ _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->foreign_wayland_display = display; }
void _cogl_buffer_fini (CoglBuffer *buffer) { _COGL_RETURN_IF_FAIL (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED)); _COGL_RETURN_IF_FAIL (buffer->immutable_ref == 0); if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) buffer->context->driver_vtable->buffer_destroy (buffer); else g_free (buffer->data); }
void _cogl_buffer_fini (CoglBuffer *buffer) { _COGL_RETURN_IF_FAIL (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED)); _COGL_RETURN_IF_FAIL (buffer->immutable_ref == 0); if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) GE( buffer->context, glDeleteBuffers (1, &buffer->gl_handle) ); else g_free (buffer->data); }
void cogl_primitive_set_attributes (CoglPrimitive *primitive, CoglAttribute **attributes, int n_attributes) { int i; _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive)); if (G_UNLIKELY (primitive->immutable_ref)) { warn_about_midscene_changes (); return; } /* NB: we don't unref the previous attributes before refing the new * in case we would end up releasing the last reference for an * attribute thats actually in the new list too. */ for (i = 0; i < n_attributes; i++) { _COGL_RETURN_IF_FAIL (cogl_is_attribute (attributes[i])); cogl_object_ref (attributes[i]); } for (i = 0; i < primitive->n_attributes; i++) cogl_object_unref (primitive->attributes[i]); /* First try to use the embedded storage assocated with the * primitive, else fallback to slice allocating separate storage for * the attribute pointers... */ if (n_attributes <= primitive->n_embedded_attributes) { if (primitive->attributes != &primitive->embedded_attribute) g_slice_free1 (sizeof (CoglAttribute *) * primitive->n_attributes, primitive->attributes); primitive->attributes = &primitive->embedded_attribute; } else { if (primitive->attributes != &primitive->embedded_attribute) g_slice_free1 (sizeof (CoglAttribute *) * primitive->n_attributes, primitive->attributes); primitive->attributes = g_slice_alloc (sizeof (CoglAttribute *) * n_attributes); } memcpy (primitive->attributes, attributes, sizeof (CoglAttribute *) * n_attributes); primitive->n_attributes = n_attributes; }
void cogl_renderer_foreach_output (CoglRenderer *renderer, CoglOutputCallback callback, void *user_data) { GList *l; _COGL_RETURN_IF_FAIL (renderer->connected); _COGL_RETURN_IF_FAIL (callback != NULL); for (l = renderer->outputs; l; l = l->next) callback (l->data, user_data); }
void _cogl_primitive_immutable_unref (CoglPrimitive *primitive) { int i; _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive)); _COGL_RETURN_IF_FAIL (primitive->immutable_ref > 0); primitive->immutable_ref--; for (i = 0; i < primitive->n_attributes; i++) _cogl_attribute_immutable_unref (primitive->attributes[i]); }
void cogl_path_stroke (CoglPath *path, CoglFramebuffer *framebuffer, CoglPipeline *pipeline) { CoglPathData *data; CoglPipeline *copy = NULL; unsigned int path_start; int path_num = 0; CoglPathNode *node; _COGL_RETURN_IF_FAIL (cogl_is_path (path)); _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer)); _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); data = path->data; if (data->path_nodes->len == 0) return; if (cogl_pipeline_get_n_layers (pipeline) != 0) { copy = cogl_pipeline_copy (pipeline); _cogl_pipeline_prune_to_n_layers (copy, 0); pipeline = copy; } _cogl_path_build_stroke_attribute_buffer (path); for (path_start = 0; path_start < data->path_nodes->len; path_start += node->path_size) { CoglPrimitive *primitive; node = &g_array_index (data->path_nodes, CoglPathNode, path_start); primitive = cogl_primitive_new_with_attributes (COGL_VERTICES_MODE_LINE_STRIP, node->path_size, &data->stroke_attributes[path_num], 1); cogl_primitive_draw (primitive, framebuffer, pipeline); cogl_object_unref (primitive); path_num++; } if (copy) cogl_object_unref (copy); }
void cogl_xlib_renderer_set_foreign_display (CoglRenderer *renderer, Display *xdisplay) { _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); /* NB: Renderers are considered immutable once connected */ _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->foreign_xdpy = xdisplay; /* If the application is using a foreign display then we can assume it will also do its own event retrieval */ cogl_xlib_renderer_set_event_retrieval_enabled (renderer, FALSE); }
void _cogl_buffer_unmap_for_fill_or_fallback (CoglBuffer *buffer) { CoglContext *ctx = buffer->context; _COGL_RETURN_IF_FAIL (ctx->buffer_map_fallback_in_use); ctx->buffer_map_fallback_in_use = FALSE; if ((buffer->flags & COGL_BUFFER_FLAG_MAPPED_FALLBACK)) { /* Note: don't try to catch OOM errors here since the use cases * we currently have for this api (the journal and path stroke * tesselator) don't have anything particularly sensible they * can do in response to a failure anyway so it seems better to * simply abort instead. * * If we find this is a problem for real world applications * then in the path tesselation case we could potentially add an * explicit cogl_path_tesselate_stroke() api that can throw an * error for the app to cache. For the journal we could * potentially flush the journal in smaller batches so we use * smaller buffers, though that would probably not help for * deferred renderers. */ cogl_buffer_set_data (buffer, ctx->buffer_map_fallback_offset, ctx->buffer_map_fallback_array->data, ctx->buffer_map_fallback_array->len, NULL); buffer->flags &= ~COGL_BUFFER_FLAG_MAPPED_FALLBACK; } else cogl_buffer_unmap (buffer); }
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); }
void cogl_depth_state_set_write_enabled (CoglDepthState *state, CoglBool enabled) { _COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC); state->write_enabled = enabled; }
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); }
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_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_depth_state_set_test_function (CoglDepthState *state, CoglDepthTestFunction function) { _COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC); state->test_function = function; }
void cogl_renderer_set_driver (CoglRenderer *renderer, CoglDriver driver) { _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->driver_override = driver; }
void cogl_path_curve_to (CoglPath *path, float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) { CoglBezCubic cubic; _COGL_RETURN_IF_FAIL (cogl_is_path (path)); /* Prepare cubic curve */ cubic.p1 = path->data->path_pen; cubic.p2.x = x_1; cubic.p2.y = y_1; cubic.p3.x = x_2; cubic.p3.y = y_2; cubic.p4.x = x_3; cubic.p4.y = y_3; /* Run subdivision */ _cogl_path_bezier3_sub (path, &cubic); /* Add last point */ _cogl_path_add_node (path, FALSE, cubic.p4.x, cubic.p4.y); path->data->path_pen = cubic.p4; }
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); }
void cogl_primitive_set_n_vertices (CoglPrimitive *primitive, int n_vertices) { _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive)); primitive->n_vertices = n_vertices; }