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_clip_push_rectangle (float x_1, float y_1, float x_2, float y_2) { CoglFramebuffer *framebuffer; CoglClipState *clip_state; CoglMatrix modelview_matrix; _COGL_GET_CONTEXT (ctx, NO_RETVAL); framebuffer = _cogl_get_draw_buffer (); clip_state = _cogl_framebuffer_get_clip_state (framebuffer); cogl_get_modelview_matrix (&modelview_matrix); clip_state->stacks->data = _cogl_clip_stack_push_rectangle (clip_state->stacks->data, x_1, y_1, x_2, y_2, &modelview_matrix); }