static CoglClipStack * _cogl_clip_stack_push_from_path (CoglClipStack *stack, CoglPath *path, CoglMatrixEntry *modelview_entry, CoglMatrixEntry *projection_entry, const float *viewport) { float x_1, y_1, x_2, y_2; _cogl_path_get_bounds (path, &x_1, &y_1, &x_2, &y_2); /* If the path is a simple rectangle then we can divert to pushing a rectangle clip instead which usually won't involve the stencil buffer */ if (_cogl_path_is_rectangle (path)) return _cogl_clip_stack_push_rectangle (stack, x_1, y_1, x_2, y_2, modelview_entry, projection_entry, viewport); else { CoglPrimitive *primitive = _cogl_path_get_fill_primitive (path); return _cogl_clip_stack_push_primitive (stack, primitive, x_1, y_1, x_2, y_2, modelview_entry, projection_entry, viewport); } }
CoglClipStack * _cogl_clip_stack_push_from_path (CoglClipStack *stack, CoglPath *path, CoglMatrixEntry *modelview_entry, CoglMatrixEntry *projection_entry, const float *viewport) { float x_1, y_1, x_2, y_2; _cogl_path_get_bounds (path, &x_1, &y_1, &x_2, &y_2); /* If the path is a simple rectangle then we can divert to pushing a rectangle clip instead which usually won't involve the stencil buffer */ if (_cogl_path_is_rectangle (path)) return _cogl_clip_stack_push_rectangle (stack, x_1, y_1, x_2, y_2, modelview_entry, projection_entry, viewport); else { CoglClipStackPath *entry; CoglMatrix modelview; CoglMatrix projection; float transformed_corners[8]; entry = _cogl_clip_stack_push_entry (stack, sizeof (CoglClipStackPath), COGL_CLIP_STACK_PATH); entry->path = cogl_path_copy (path); entry->matrix_entry = _cogl_matrix_entry_ref (modelview_entry); _cogl_matrix_entry_get (modelview_entry, &modelview); _cogl_matrix_entry_get (projection_entry, &projection); get_transformed_corners (x_1, y_1, x_2, y_2, &modelview, &projection, viewport, transformed_corners); _cogl_clip_stack_entry_set_bounds ((CoglClipStack *) entry, transformed_corners); return (CoglClipStack *) entry; } }
void _cogl_path_fill_nodes (CoglPath *path, CoglFramebuffer *framebuffer, CoglPipeline *pipeline, CoglDrawFlags flags) { if (path->data->path_nodes->len == 0) return; /* If the path is a simple rectangle then we can divert to using cogl_framebuffer_draw_rectangle which should be faster because it can go through the journal instead of uploading the geometry just for two triangles */ if (path->data->is_rectangle && flags == 0) { float x_1, y_1, x_2, y_2; _cogl_path_get_bounds (path, &x_1, &y_1, &x_2, &y_2); cogl_framebuffer_draw_rectangle (framebuffer, pipeline, x_1, y_1, x_2, y_2); } else { CoglBool needs_fallback = FALSE; CoglPrimitive *primitive; _cogl_pipeline_foreach_layer_internal (pipeline, validate_layer_cb, &needs_fallback); if (needs_fallback) { _cogl_path_fill_nodes_with_clipped_rectangle (path, framebuffer, pipeline); return; } primitive = _cogl_path_get_fill_primitive (path); _cogl_primitive_draw (primitive, framebuffer, pipeline, flags); } }
void cogl2_path_fill (CoglPath *path) { _COGL_RETURN_IF_FAIL (cogl_is_path (path)); if (path->data->path_nodes->len == 0) return; /* If the path is a simple rectangle then we can divert to using cogl_rectangle which should be faster because it can go through the journal instead of uploading the geometry just for two triangles */ if (path->data->is_rectangle) { float x_1, y_1, x_2, y_2; _cogl_path_get_bounds (path, &x_1, &y_1, &x_2, &y_2); cogl_rectangle (x_1, y_1, x_2, y_2); } else _cogl_path_fill_nodes (path, 0); }