summaryrefslogtreecommitdiff
path: root/cogl-pango
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2013-04-28 03:22:24 +0100
committerRobert Bragg <robert@linux.intel.com>2013-08-19 22:44:35 +0100
commit7365c3aa77fe2efc4f5a71c009bc18c043d8dc4e (patch)
tree6642ee8eeccbd18f2d06488c56918baa589d8b07 /cogl-pango
parentdab054200cb2135da2303ed0909a906da3c05083 (diff)
downloadmutter-7365c3aa77fe2efc4f5a71c009bc18c043d8dc4e.tar.gz
Separate out CoglPath api into sub-library
This splits out the cogl_path_ api into a separate cogl-path sub-library like cogl-pango and cogl-gst. This enables developers to build Cogl with this sub-library disabled if they don't need it which can be useful when its important to keep the size of an application and its dependencies down to a minimum. The functions cogl_framebuffer_{fill,stroke}_path have been renamed to cogl_path_{fill,stroke}. There were a few places in core cogl and cogl-gst that referenced the CoglPath api and these have been decoupled by using the CoglPrimitive api instead. In the case of cogl_framebuffer_push_path_clip() the core clip stack no longer accepts path clips directly but it's now possible to get a CoglPrimitive for the fill of a path and so the implementation of cogl_framebuffer_push_path_clip() now lives in cogl-path and works as a shim that first gets a CoglPrimitive and uses cogl_framebuffer_push_primitive_clip instead. We may want to consider renaming cogl_framebuffer_push_path_clip to put it in the cogl_path_ namespace. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit 8aadfd829239534fb4ec8255cdea813d698c5a3f) So as to avoid breaking the 1.x API or even the ABI since we are quite late in the 1.16 development cycle the patch was modified to build cogl-path as a noinst_LTLIBRARY before building cogl and link the code directly into libcogl.so as it was previously. This way we can wait until the start of the 1.18 cycle before splitting the code into a separate libcogl-path.so. This also adds shims for cogl_framebuffer_fill/stroke_path() to avoid breaking the 1.x API/ABI.
Diffstat (limited to 'cogl-pango')
-rw-r--r--cogl-pango/cogl-pango-display-list.c50
-rw-r--r--cogl-pango/cogl-pango-pipeline-cache.c12
-rw-r--r--cogl-pango/cogl-pango-pipeline-cache.h13
-rw-r--r--cogl-pango/cogl-pango-render.c10
4 files changed, 31 insertions, 54 deletions
diff --git a/cogl-pango/cogl-pango-display-list.c b/cogl-pango/cogl-pango-display-list.c
index e9bb684f3..2b8c6ab25 100644
--- a/cogl-pango/cogl-pango-display-list.c
+++ b/cogl-pango/cogl-pango-display-list.c
@@ -30,6 +30,7 @@
#include <string.h>
#include "cogl-pango-display-list.h"
+#include "cogl-pango-pipeline-cache.h"
#include "cogl/cogl-context-private.h"
typedef enum
@@ -88,12 +89,7 @@ struct _CoglPangoDisplayListNode
struct
{
- float y_1;
- float x_11;
- float x_21;
- float y_2;
- float x_12;
- float x_22;
+ CoglPrimitive *primitive;
} trapezoid;
} d;
};
@@ -219,19 +215,26 @@ _cogl_pango_display_list_add_trapezoid (CoglPangoDisplayList *dl,
float x_12,
float x_22)
{
+ CoglContext *ctx = dl->pipeline_cache->ctx;
CoglPangoDisplayListNode *node = g_slice_new (CoglPangoDisplayListNode);
+ CoglVertexP2 vertices[4] = {
+ { x_11, y_1 },
+ { x_12, y_2 },
+ { x_22, y_2 },
+ { x_21, y_1 }
+ };
node->type = COGL_PANGO_DISPLAY_LIST_TRAPEZOID;
node->color_override = dl->color_override;
node->color = dl->color;
- node->d.trapezoid.y_1 = y_1;
- node->d.trapezoid.x_11 = x_11;
- node->d.trapezoid.x_21 = x_21;
- node->d.trapezoid.y_2 = y_2;
- node->d.trapezoid.x_12 = x_12;
- node->d.trapezoid.x_22 = x_22;
node->pipeline = NULL;
+ node->d.trapezoid.primitive =
+ cogl_primitive_new_p2 (ctx,
+ COGL_VERTICES_MODE_TRIANGLE_FAN,
+ 4,
+ vertices);
+
_cogl_pango_display_list_append_node (dl, node);
}
@@ -448,25 +451,8 @@ _cogl_pango_display_list_render (CoglFramebuffer *fb,
break;
case COGL_PANGO_DISPLAY_LIST_TRAPEZOID:
- {
- float points[8];
- CoglPath *path;
- CoglContext *ctx = fb->context;
-
- points[0] = node->d.trapezoid.x_11;
- points[1] = node->d.trapezoid.y_1;
- points[2] = node->d.trapezoid.x_12;
- points[3] = node->d.trapezoid.y_2;
- points[4] = node->d.trapezoid.x_22;
- points[5] = node->d.trapezoid.y_2;
- points[6] = node->d.trapezoid.x_21;
- points[7] = node->d.trapezoid.y_1;
-
- path = cogl_path_new ();
- cogl_path_polygon (path, points, 4);
- cogl_framebuffer_fill_path (fb, node->pipeline, path);
- cogl_object_unref (path);
- }
+ cogl_framebuffer_draw_primitive (fb, node->pipeline,
+ node->d.trapezoid.primitive);
break;
}
}
@@ -483,6 +469,8 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node)
if (node->d.texture.primitive != NULL)
cogl_object_unref (node->d.texture.primitive);
}
+ else if (node->type == COGL_PANGO_DISPLAY_LIST_TRAPEZOID)
+ cogl_object_unref (node->d.trapezoid.primitive);
if (node->pipeline)
cogl_object_unref (node->pipeline);
diff --git a/cogl-pango/cogl-pango-pipeline-cache.c b/cogl-pango/cogl-pango-pipeline-cache.c
index 11cbb64aa..9aa32ad0f 100644
--- a/cogl-pango/cogl-pango-pipeline-cache.c
+++ b/cogl-pango/cogl-pango-pipeline-cache.c
@@ -37,18 +37,6 @@
typedef struct _CoglPangoPipelineCacheEntry CoglPangoPipelineCacheEntry;
-struct _CoglPangoPipelineCache
-{
- CoglContext *ctx;
-
- GHashTable *hash_table;
-
- CoglPipeline *base_texture_alpha_pipeline;
- CoglPipeline *base_texture_rgba_pipeline;
-
- CoglBool use_mipmapping;
-};
-
struct _CoglPangoPipelineCacheEntry
{
/* This will take a reference or it can be NULL to represent the
diff --git a/cogl-pango/cogl-pango-pipeline-cache.h b/cogl-pango/cogl-pango-pipeline-cache.h
index 615eaf991..411650bca 100644
--- a/cogl-pango/cogl-pango-pipeline-cache.h
+++ b/cogl-pango/cogl-pango-pipeline-cache.h
@@ -33,7 +33,18 @@
COGL_BEGIN_DECLS
-typedef struct _CoglPangoPipelineCache CoglPangoPipelineCache;
+typedef struct _CoglPangoPipelineCache
+{
+ CoglContext *ctx;
+
+ GHashTable *hash_table;
+
+ CoglPipeline *base_texture_alpha_pipeline;
+ CoglPipeline *base_texture_rgba_pipeline;
+
+ CoglBool use_mipmapping;
+} CoglPangoPipelineCache;
+
CoglPangoPipelineCache *
_cogl_pango_pipeline_cache_new (CoglContext *ctx,
diff --git a/cogl-pango/cogl-pango-render.c b/cogl-pango/cogl-pango-render.c
index a5abaa646..082114dc8 100644
--- a/cogl-pango/cogl-pango-render.c
+++ b/cogl-pango/cogl-pango-render.c
@@ -825,19 +825,9 @@ cogl_pango_renderer_draw_trapezoid (PangoRenderer *renderer,
double x22)
{
CoglPangoRenderer *priv = COGL_PANGO_RENDERER (renderer);
- float points[8];
_COGL_RETURN_IF_FAIL (priv->display_list != NULL);
- points[0] = (x11);
- points[1] = (y1);
- points[2] = (x12);
- points[3] = (y2);
- points[4] = (x22);
- points[5] = points[3];
- points[6] = (x21);
- points[7] = points[1];
-
cogl_pango_renderer_set_color_for_part (renderer, part);
_cogl_pango_display_list_add_trapezoid (priv->display_list,