Add a context member to CoglPath
cogl_path_new now takes a CoglContext pointer which it keeps a pointer to instead of relying on the global context. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit afc63f8211c230f8fd1f7801f9085627c46a8661) Since we can't change the api on this branch this just applies the internal cleanups so we depend less on _COGL_GET_CONTEXT
This commit is contained in:
parent
6400b455b8
commit
d2a5d6f361
@ -440,6 +440,8 @@ _cogl_pango_display_list_render (CoglPangoDisplayList *dl,
|
|||||||
float points[8];
|
float points[8];
|
||||||
CoglPath *path;
|
CoglPath *path;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
points[0] = node->d.trapezoid.x_11;
|
points[0] = node->d.trapezoid.x_11;
|
||||||
points[1] = node->d.trapezoid.y_1;
|
points[1] = node->d.trapezoid.y_1;
|
||||||
points[2] = node->d.trapezoid.x_12;
|
points[2] = node->d.trapezoid.x_12;
|
||||||
|
@ -70,6 +70,8 @@ struct _CoglPathData
|
|||||||
{
|
{
|
||||||
unsigned int ref_count;
|
unsigned int ref_count;
|
||||||
|
|
||||||
|
CoglContext *context;
|
||||||
|
|
||||||
CoglPathFillRule fill_rule;
|
CoglPathFillRule fill_rule;
|
||||||
|
|
||||||
GArray *path_nodes;
|
GArray *path_nodes;
|
||||||
|
@ -303,4 +303,3 @@ cogl_set_path (CoglPath *path)
|
|||||||
cogl_object_unref (ctx->current_path);
|
cogl_object_unref (ctx->current_path);
|
||||||
ctx->current_path = path;
|
ctx->current_path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,8 @@ _cogl_path_data_unref (CoglPathData *data)
|
|||||||
|
|
||||||
g_array_free (data->path_nodes, TRUE);
|
g_array_free (data->path_nodes, TRUE);
|
||||||
|
|
||||||
|
cogl_object_unref (data->context);
|
||||||
|
|
||||||
g_slice_free (CoglPathData, data);
|
g_slice_free (CoglPathData, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,6 +124,7 @@ _cogl_path_modify (CoglPath *path)
|
|||||||
path->data->fill_attribute_buffer = NULL;
|
path->data->fill_attribute_buffer = NULL;
|
||||||
path->data->stroke_attribute_buffer = NULL;
|
path->data->stroke_attribute_buffer = NULL;
|
||||||
path->data->ref_count = 1;
|
path->data->ref_count = 1;
|
||||||
|
cogl_object_ref (path->data->context);
|
||||||
|
|
||||||
_cogl_path_data_unref (old_data);
|
_cogl_path_data_unref (old_data);
|
||||||
}
|
}
|
||||||
@ -209,8 +212,6 @@ _cogl_path_stroke_nodes (CoglPath *path)
|
|||||||
int path_num = 0;
|
int path_num = 0;
|
||||||
CoglPathNode *node;
|
CoglPathNode *node;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
source = cogl_get_source ();
|
source = cogl_get_source ();
|
||||||
|
|
||||||
if (cogl_pipeline_get_n_layers (source) != 0)
|
if (cogl_pipeline_get_n_layers (source) != 0)
|
||||||
@ -276,9 +277,8 @@ _cogl_path_fill_nodes_with_clipped_rectangle (CoglPath *path)
|
|||||||
{
|
{
|
||||||
CoglFramebuffer *fb;
|
CoglFramebuffer *fb;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
if (!(path->data->context->private_feature_flags &
|
||||||
|
COGL_PRIVATE_FEATURE_STENCIL_BUFFER))
|
||||||
if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_STENCIL_BUFFER))
|
|
||||||
{
|
{
|
||||||
static gboolean seen_warning = FALSE;
|
static gboolean seen_warning = FALSE;
|
||||||
|
|
||||||
@ -873,10 +873,13 @@ cogl2_path_new (void)
|
|||||||
CoglPath *path;
|
CoglPath *path;
|
||||||
CoglPathData *data;
|
CoglPathData *data;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NULL);
|
||||||
|
|
||||||
path = g_slice_new (CoglPath);
|
path = g_slice_new (CoglPath);
|
||||||
data = path->data = g_slice_new (CoglPathData);
|
data = path->data = g_slice_new (CoglPathData);
|
||||||
|
|
||||||
data->ref_count = 1;
|
data->ref_count = 1;
|
||||||
|
data->context = cogl_object_ref (ctx);
|
||||||
data->fill_rule = COGL_PATH_FILL_RULE_EVEN_ODD;
|
data->fill_rule = COGL_PATH_FILL_RULE_EVEN_ODD;
|
||||||
data->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
|
data->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
|
||||||
data->last_path = 0;
|
data->last_path = 0;
|
||||||
@ -1267,8 +1270,6 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path)
|
|||||||
CoglPathData *data = path->data;
|
CoglPathData *data = path->data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* If we've already got a vbo then we don't need to do anything */
|
/* If we've already got a vbo then we don't need to do anything */
|
||||||
if (data->fill_attribute_buffer)
|
if (data->fill_attribute_buffer)
|
||||||
return;
|
return;
|
||||||
@ -1354,7 +1355,7 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path)
|
|||||||
gluDeleteTess (tess.glu_tess);
|
gluDeleteTess (tess.glu_tess);
|
||||||
|
|
||||||
data->fill_attribute_buffer =
|
data->fill_attribute_buffer =
|
||||||
cogl_attribute_buffer_new (ctx,
|
cogl_attribute_buffer_new (data->context,
|
||||||
sizeof (CoglPathTesselatorVertex) *
|
sizeof (CoglPathTesselatorVertex) *
|
||||||
tess.vertices->len,
|
tess.vertices->len,
|
||||||
tess.vertices->data);
|
tess.vertices->data);
|
||||||
@ -1375,7 +1376,7 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path)
|
|||||||
2, /* n_components */
|
2, /* n_components */
|
||||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
|
|
||||||
data->fill_vbo_indices = cogl_indices_new (ctx,
|
data->fill_vbo_indices = cogl_indices_new (data->context,
|
||||||
tess.indices_type,
|
tess.indices_type,
|
||||||
tess.indices->data,
|
tess.indices->data,
|
||||||
tess.indices->len);
|
tess.indices->len);
|
||||||
@ -1394,14 +1395,13 @@ _cogl_path_build_stroke_attribute_buffer (CoglPath *path)
|
|||||||
floatVec2 *buffer_p;
|
floatVec2 *buffer_p;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* If we've already got a cached vbo then we don't need to do anything */
|
/* If we've already got a cached vbo then we don't need to do anything */
|
||||||
if (data->stroke_attribute_buffer)
|
if (data->stroke_attribute_buffer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
data->stroke_attribute_buffer =
|
data->stroke_attribute_buffer =
|
||||||
cogl_attribute_buffer_new (ctx, data->path_nodes->len * sizeof (floatVec2),
|
cogl_attribute_buffer_new (data->context,
|
||||||
|
data->path_nodes->len * sizeof (floatVec2),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
buffer = COGL_BUFFER (data->stroke_attribute_buffer);
|
buffer = COGL_BUFFER (data->stroke_attribute_buffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user