[cogl/wip/rib/cogl-1.12: 5/101] Add a context member to CoglPath



commit 9cda94bd7c75ec2b9c2ca3de0c9fe2ed7a18e8b8
Author: Neil Roberts <neil linux intel com>
Date:   Mon Apr 16 13:21:15 2012 +0100

    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

 cogl-pango/cogl-pango-display-list.c |    2 ++
 cogl/cogl-path-private.h             |    2 ++
 cogl/cogl-path.c                     |    1 -
 cogl/cogl2-path.c                    |   24 ++++++++++++------------
 4 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/cogl-pango/cogl-pango-display-list.c b/cogl-pango/cogl-pango-display-list.c
index 6800c6c..335ea12 100644
--- a/cogl-pango/cogl-pango-display-list.c
+++ b/cogl-pango/cogl-pango-display-list.c
@@ -440,6 +440,8 @@ _cogl_pango_display_list_render (CoglPangoDisplayList *dl,
             float points[8];
             CoglPath *path;
 
+            _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
             points[0] =  node->d.trapezoid.x_11;
             points[1] =  node->d.trapezoid.y_1;
             points[2] =  node->d.trapezoid.x_12;
diff --git a/cogl/cogl-path-private.h b/cogl/cogl-path-private.h
index fd2e1de..c64aa4b 100644
--- a/cogl/cogl-path-private.h
+++ b/cogl/cogl-path-private.h
@@ -70,6 +70,8 @@ struct _CoglPathData
 {
   unsigned int         ref_count;
 
+  CoglContext         *context;
+
   CoglPathFillRule     fill_rule;
 
   GArray              *path_nodes;
diff --git a/cogl/cogl-path.c b/cogl/cogl-path.c
index aab3dfb..d940b7a 100644
--- a/cogl/cogl-path.c
+++ b/cogl/cogl-path.c
@@ -303,4 +303,3 @@ cogl_set_path (CoglPath *path)
   cogl_object_unref (ctx->current_path);
   ctx->current_path = path;
 }
-
diff --git a/cogl/cogl2-path.c b/cogl/cogl2-path.c
index d9426ae..c2b8bbc 100644
--- a/cogl/cogl2-path.c
+++ b/cogl/cogl2-path.c
@@ -96,6 +96,8 @@ _cogl_path_data_unref (CoglPathData *data)
 
       g_array_free (data->path_nodes, TRUE);
 
+      cogl_object_unref (data->context);
+
       g_slice_free (CoglPathData, data);
     }
 }
@@ -122,6 +124,7 @@ _cogl_path_modify (CoglPath *path)
       path->data->fill_attribute_buffer = NULL;
       path->data->stroke_attribute_buffer = NULL;
       path->data->ref_count = 1;
+      cogl_object_ref (path->data->context);
 
       _cogl_path_data_unref (old_data);
     }
@@ -209,8 +212,6 @@ _cogl_path_stroke_nodes (CoglPath *path)
   int path_num = 0;
   CoglPathNode *node;
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   source = cogl_get_source ();
 
   if (cogl_pipeline_get_n_layers (source) != 0)
@@ -276,9 +277,8 @@ _cogl_path_fill_nodes_with_clipped_rectangle (CoglPath *path)
 {
   CoglFramebuffer *fb;
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_STENCIL_BUFFER))
+  if (!(path->data->context->private_feature_flags &
+        COGL_PRIVATE_FEATURE_STENCIL_BUFFER))
     {
       static gboolean seen_warning = FALSE;
 
@@ -873,10 +873,13 @@ cogl2_path_new (void)
   CoglPath *path;
   CoglPathData *data;
 
+  _COGL_GET_CONTEXT (ctx, NULL);
+
   path = g_slice_new (CoglPath);
   data = path->data = g_slice_new (CoglPathData);
 
   data->ref_count = 1;
+  data->context = cogl_object_ref (ctx);
   data->fill_rule = COGL_PATH_FILL_RULE_EVEN_ODD;
   data->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
   data->last_path = 0;
@@ -1267,8 +1270,6 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path)
   CoglPathData *data = path->data;
   int i;
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   /* If we've already got a vbo then we don't need to do anything */
   if (data->fill_attribute_buffer)
     return;
@@ -1354,7 +1355,7 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path)
   gluDeleteTess (tess.glu_tess);
 
   data->fill_attribute_buffer =
-    cogl_attribute_buffer_new (ctx,
+    cogl_attribute_buffer_new (data->context,
                                sizeof (CoglPathTesselatorVertex) *
                                tess.vertices->len,
                                tess.vertices->data);
@@ -1375,7 +1376,7 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path)
                         2, /* n_components */
                         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->data,
                                              tess.indices->len);
@@ -1394,14 +1395,13 @@ _cogl_path_build_stroke_attribute_buffer (CoglPath *path)
   floatVec2 *buffer_p;
   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 (data->stroke_attribute_buffer)
     return;
 
   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);
 
   buffer = COGL_BUFFER (data->stroke_attribute_buffer);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]