Ejemplo n.º 1
0
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);
    }
}
Ejemplo n.º 2
0
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;
    }
}