Esempio n. 1
0
void
_cogl_path_fill_nodes (CoglPath *path, CoglDrawFlags flags)
{
  gboolean needs_fallback = FALSE;
  CoglPipeline *pipeline = cogl_get_source ();

  _cogl_pipeline_foreach_layer_internal (pipeline,
                                         validate_layer_cb, &needs_fallback);
  if (needs_fallback)
    {
      _cogl_path_fill_nodes_with_clipped_rectangle (path);
      return;
    }

  _cogl_path_build_fill_attribute_buffer (path);

  _cogl_framebuffer_draw_indexed_attributes (cogl_get_draw_framebuffer (),
                                             pipeline,
                                             COGL_VERTICES_MODE_TRIANGLES,
                                             0, /* first_vertex */
                                             path->data->fill_vbo_n_indices,
                                             path->data->fill_vbo_indices,
                                             path->data->fill_attributes,
                                             COGL_PATH_N_ATTRIBUTES,
                                             flags);
}
Esempio n. 2
0
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);
    }
}