diff options
author | Robert Bragg <robert@linux.intel.com> | 2013-04-28 03:22:24 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2013-05-28 23:03:01 +0100 |
commit | cf07254e5ce1cac45ab5c626e7ec2de0b502dd7d (patch) | |
tree | c180b7883c329f096cb8d3ad17e8ddfb74a54f6f | |
parent | e6d37470da9294adc1554c0a8c91aa2af560ed9f (diff) | |
download | cogl-wip/split-cogl-path.tar.gz |
Separate out CoglPath api into sub-librarywip/split-cogl-path
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.
-rw-r--r-- | Makefile.am | 8 | ||||
-rw-r--r-- | cogl-pango/cogl-pango-display-list.c | 50 | ||||
-rw-r--r-- | cogl-pango/cogl-pango-pipeline-cache.c | 12 | ||||
-rw-r--r-- | cogl-pango/cogl-pango-pipeline-cache.h | 13 | ||||
-rw-r--r-- | cogl-pango/cogl-pango-render.c | 10 | ||||
-rw-r--r-- | cogl-path/Makefile.am | 87 | ||||
-rw-r--r-- | cogl-path/cogl-path-private.h (renamed from cogl/cogl-path-private.h) | 1 | ||||
-rw-r--r-- | cogl-path/cogl-path.c (renamed from cogl/cogl-path.c) | 136 | ||||
-rw-r--r-- | cogl-path/cogl-path.h (renamed from cogl/cogl-path.h) | 63 | ||||
-rw-r--r-- | cogl-path/cogl-path.pc.in | 13 | ||||
-rw-r--r-- | cogl-path/tesselator/GL/glu.h (renamed from cogl/tesselator/GL/glu.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/README (renamed from cogl/tesselator/README) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/dict-list.h (renamed from cogl/tesselator/dict-list.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/dict.c (renamed from cogl/tesselator/dict.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/dict.h (renamed from cogl/tesselator/dict.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/geom.c (renamed from cogl/tesselator/geom.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/geom.h (renamed from cogl/tesselator/geom.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/gluos.h (renamed from cogl/tesselator/gluos.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/memalloc.h (renamed from cogl/tesselator/memalloc.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/mesh.c (renamed from cogl/tesselator/mesh.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/mesh.h (renamed from cogl/tesselator/mesh.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/normal.c (renamed from cogl/tesselator/normal.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/normal.h (renamed from cogl/tesselator/normal.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/priorityq-heap.c (renamed from cogl/tesselator/priorityq-heap.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/priorityq-heap.h (renamed from cogl/tesselator/priorityq-heap.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/priorityq-sort.h (renamed from cogl/tesselator/priorityq-sort.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/priorityq.c (renamed from cogl/tesselator/priorityq.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/priorityq.h (renamed from cogl/tesselator/priorityq.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/render.c (renamed from cogl/tesselator/render.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/render.h (renamed from cogl/tesselator/render.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/sweep.c (renamed from cogl/tesselator/sweep.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/sweep.h (renamed from cogl/tesselator/sweep.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/tess.c (renamed from cogl/tesselator/tess.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/tess.h (renamed from cogl/tesselator/tess.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/tesselator.h (renamed from cogl/tesselator/tesselator.h) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/tessmono.c (renamed from cogl/tesselator/tessmono.c) | 0 | ||||
-rw-r--r-- | cogl-path/tesselator/tessmono.h (renamed from cogl/tesselator/tessmono.h) | 0 | ||||
-rw-r--r-- | cogl/Makefile.am | 41 | ||||
-rw-r--r-- | cogl/cogl-clip-stack.c | 61 | ||||
-rw-r--r-- | cogl/cogl-clip-stack.h | 24 | ||||
-rw-r--r-- | cogl/cogl-context.c | 1 | ||||
-rw-r--r-- | cogl/cogl-framebuffer.c | 55 | ||||
-rw-r--r-- | cogl/cogl-framebuffer.h | 59 | ||||
-rw-r--r-- | cogl/cogl.h | 1 | ||||
-rw-r--r-- | cogl/driver/gl/cogl-clip-stack-gl.c | 51 | ||||
-rw-r--r-- | configure.ac | 28 | ||||
-rw-r--r-- | tests/conform/Makefile.am | 8 | ||||
-rw-r--r-- | tests/conform/test-conform-main.c | 2 | ||||
-rw-r--r-- | tests/conform/test-path.c | 3 |
49 files changed, 359 insertions, 368 deletions
diff --git a/Makefile.am b/Makefile.am index 15fb5899..04707959 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = deps cogl tests +SUBDIRS = deps cogl if BUILD_COGL_PANGO SUBDIRS += cogl-pango @@ -12,7 +12,11 @@ if BUILD_COGL_GST SUBDIRS += cogl-gst endif -SUBDIRS += examples doc po build +if BUILD_COGL_PATH +SUBDIRS += cogl-path +endif + +SUBDIRS += tests examples doc po build ACLOCAL_AMFLAGS = -I build/autotools ${ACLOCAL_FLAGS} diff --git a/cogl-pango/cogl-pango-display-list.c b/cogl-pango/cogl-pango-display-list.c index 1be3f446..a2f2e27d 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); } @@ -452,25 +455,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 (ctx); - 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; } } @@ -487,6 +473,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 67bb77aa..1e702d0c 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 615eaf99..411650bc 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 e296b2d8..43fae500 100644 --- a/cogl-pango/cogl-pango-render.c +++ b/cogl-pango/cogl-pango-render.c @@ -778,19 +778,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, diff --git a/cogl-path/Makefile.am b/cogl-path/Makefile.am new file mode 100644 index 00000000..82d4f896 --- /dev/null +++ b/cogl-path/Makefile.am @@ -0,0 +1,87 @@ +include $(top_srcdir)/build/autotools/Makefile.am.silent + +NULL = + +CLEANFILES = +DISTCLEANFILES = + +EXTRA_DIST = + +# tesselator sources +cogl_tesselator_sources = \ + $(srcdir)/tesselator/dict-list.h \ + $(srcdir)/tesselator/dict.c \ + $(srcdir)/tesselator/dict.h \ + $(srcdir)/tesselator/geom.c \ + $(srcdir)/tesselator/geom.h \ + $(srcdir)/tesselator/gluos.h \ + $(srcdir)/tesselator/memalloc.h \ + $(srcdir)/tesselator/mesh.c \ + $(srcdir)/tesselator/mesh.h \ + $(srcdir)/tesselator/normal.c \ + $(srcdir)/tesselator/normal.h \ + $(srcdir)/tesselator/priorityq-heap.h \ + $(srcdir)/tesselator/priorityq-sort.h \ + $(srcdir)/tesselator/priorityq.c \ + $(srcdir)/tesselator/priorityq.h \ + $(srcdir)/tesselator/render.c \ + $(srcdir)/tesselator/render.h \ + $(srcdir)/tesselator/sweep.c \ + $(srcdir)/tesselator/sweep.h \ + $(srcdir)/tesselator/tess.c \ + $(srcdir)/tesselator/tess.h \ + $(srcdir)/tesselator/tesselator.h \ + $(srcdir)/tesselator/tessmono.c \ + $(srcdir)/tesselator/tessmono.h \ + $(srcdir)/tesselator/GL/glu.h \ + $(NULL) + +source_c = \ + $(cogl_tesselator_sources) \ + cogl-path-private.h \ + cogl-path.c \ + $(NULL) + +EXTRA_DIST += \ + $(srcdir)/tesselator/README \ + $(srcdir)/tesselator/priorityq-heap.c \ + $(NULL) + + +source_h = \ + cogl-path.h \ + $(NULL) + +lib_LTLIBRARIES = libcogl-path.la + +libcogl_path_la_SOURCES = $(source_c) $(source_h) +libcogl_path_la_CFLAGS = $(COGL_DEP_CFLAGS) $(COGL_GST_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS) $(MAINTAINER_CFLAGS) +libcogl_path_la_LIBADD = $(top_builddir)/cogl/libcogl2.la +libcogl_path_la_LIBADD += $(COGL_DEP_LIBS) $(COGL_GST_DEP_LIBS) $(COGL_EXTRA_LDFLAGS) +libcogl_path_la_LDFLAGS = \ + -export-dynamic \ + -export-symbols-regex "^cogl_path_.*" \ + -no-undefined \ + -version-info @COGL_LT_CURRENT@:@COGL_LT_REVISION@:@COGL_LT_AGE@ \ + -rpath $(libdir) + +AM_CPPFLAGS = \ + -DCOGL_COMPILATION \ + -DG_LOG_DOMAIN=\"CoglPath\" \ + -I$(srcdir)/tesselator \ + -I$(top_srcdir)/cogl \ + -I$(top_builddir)/cogl \ + -I$(top_srcdir)/cogl/winsys \ + -I$(top_srcdir) \ + -I$(top_builddir) + +cogl_pathheadersdir = $(includedir)/cogl2/cogl-path +cogl_pathheaders_HEADERS = $(source_h) + +pc_files = cogl-path.pc + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = $(pc_files) + +EXTRA_DIST += cogl-path.pc.in +DISTCLEANFILES += $(pc_files) diff --git a/cogl/cogl-path-private.h b/cogl-path/cogl-path-private.h index cc0b65c3..9b689203 100644 --- a/cogl/cogl-path-private.h +++ b/cogl-path/cogl-path-private.h @@ -86,6 +86,7 @@ struct _CoglPathData CoglIndices *fill_vbo_indices; unsigned int fill_vbo_n_indices; CoglAttribute *fill_attributes[COGL_PATH_N_ATTRIBUTES + 1]; + CoglPrimitive *fill_primitive; CoglAttributeBuffer *stroke_attribute_buffer; CoglAttribute **stroke_attributes; diff --git a/cogl/cogl-path.c b/cogl-path/cogl-path.c index 7cd66bd3..9a1d1df1 100644 --- a/cogl/cogl-path.c +++ b/cogl-path/cogl-path.c @@ -35,8 +35,8 @@ #include "cogl-context-private.h" #include "cogl-journal-private.h" #include "cogl-pipeline-private.h" -#include "cogl-pipeline-opengl-private.h" #include "cogl-framebuffer-private.h" +#include "cogl-path.h" #include "cogl-path-private.h" #include "cogl-texture-private.h" #include "cogl-primitives-private.h" @@ -52,6 +52,7 @@ static void _cogl_path_free (CoglPath *path); static void _cogl_path_build_fill_attribute_buffer (CoglPath *path); +static CoglPrimitive *_cogl_path_get_fill_primitive (CoglPath *path); static void _cogl_path_build_stroke_attribute_buffer (CoglPath *path); COGL_OBJECT_DEFINE (Path, path); @@ -72,6 +73,12 @@ _cogl_path_data_clear_vbos (CoglPathData *data) data->fill_attribute_buffer = NULL; } + if (data->fill_primitive) + { + cogl_object_unref (data->fill_primitive); + data->fill_primitive = NULL; + } + if (data->stroke_attribute_buffer) { cogl_object_unref (data->stroke_attribute_buffer); @@ -118,6 +125,7 @@ _cogl_path_modify (CoglPath *path) old_data->path_nodes->len); path->data->fill_attribute_buffer = NULL; + path->data->fill_primitive = NULL; path->data->stroke_attribute_buffer = NULL; path->data->ref_count = 1; @@ -198,16 +206,22 @@ _cogl_path_add_node (CoglPath *path, } void -_cogl_path_stroke_nodes (CoglPath *path, - CoglFramebuffer *framebuffer, - CoglPipeline *pipeline) +cogl_path_stroke (CoglPath *path, + CoglFramebuffer *framebuffer, + CoglPipeline *pipeline) { - CoglPathData *data = path->data; + CoglPathData *data; CoglPipeline *copy = NULL; unsigned int path_start; int path_num = 0; CoglPathNode *node; + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); + + data = path->data; + if (data->path_nodes->len == 0) return; @@ -340,6 +354,7 @@ _cogl_path_fill_nodes (CoglPath *path, else { CoglBool needs_fallback = FALSE; + CoglPrimitive *primitive; _cogl_pipeline_foreach_layer_internal (pipeline, validate_layer_cb, @@ -352,21 +367,28 @@ _cogl_path_fill_nodes (CoglPath *path, return; } - _cogl_path_build_fill_attribute_buffer (path); - - _cogl_framebuffer_draw_indexed_attributes (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); + primitive = _cogl_path_get_fill_primitive (path); + + _cogl_framebuffer_draw_primitive (framebuffer, + pipeline, + primitive, + flags); } } void +cogl_path_fill (CoglPath *path, + CoglFramebuffer *framebuffer, + CoglPipeline *pipeline) +{ + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); + + _cogl_path_fill_nodes (path, framebuffer, pipeline, 0 /* flags */); +} + +void cogl_path_move_to (CoglPath *path, float x, float y) @@ -1367,6 +1389,88 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path) g_array_free (tess.indices, TRUE); } +static CoglPrimitive * +_cogl_path_get_fill_primitive (CoglPath *path) +{ + if (path->data->fill_primitive) + return path->data->fill_primitive; + + _cogl_path_build_fill_attribute_buffer (path); + + path->data->fill_primitive = + cogl_primitive_new_with_attributes (COGL_VERTICES_MODE_TRIANGLES, + path->data->fill_vbo_n_indices, + path->data->fill_attributes, + COGL_PATH_N_ATTRIBUTES); + cogl_primitive_set_indices (path->data->fill_primitive, + path->data->fill_vbo_indices, + path->data->fill_vbo_n_indices); + + return path->data->fill_primitive; +} + +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 + { + return _cogl_clip_stack_push_primitive (stack, + path->data->fill_primitive, + x_1, y_1, x_2, y_2, + modelview_entry, + projection_entry, + viewport); + } +} + +void +cogl_framebuffer_push_path_clip (CoglFramebuffer *framebuffer, + CoglPath *path) +{ + CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer); + CoglMatrixEntry *modelview_entry = + _cogl_framebuffer_get_modelview_entry (framebuffer); + CoglMatrixEntry *projection_entry = + _cogl_framebuffer_get_projection_entry (framebuffer); + /* XXX: It would be nicer if we stored the private viewport as a + * vec4 so we could avoid this redundant copy. */ + float viewport[] = { + framebuffer->viewport_x, + framebuffer->viewport_y, + framebuffer->viewport_width, + framebuffer->viewport_height + }; + + clip_state->stacks->data = + _cogl_clip_stack_push_from_path (clip_state->stacks->data, + path, + modelview_entry, + projection_entry, + viewport); + + if (framebuffer->context->current_draw_buffer == framebuffer) + framebuffer->context->current_draw_buffer_changes |= + COGL_FRAMEBUFFER_STATE_CLIP; +} + static void _cogl_path_build_stroke_attribute_buffer (CoglPath *path) { diff --git a/cogl/cogl-path.h b/cogl-path/cogl-path.h index 35df19ad..bba53e36 100644 --- a/cogl/cogl-path.h +++ b/cogl-path/cogl-path.h @@ -463,6 +463,69 @@ cogl_path_set_fill_rule (CoglPath *path, CoglPathFillRule fill_rule); CoglPathFillRule cogl_path_get_fill_rule (CoglPath *path); +/** + * cogl_framebuffer_fill_path: + * @path: The #CoglPath to fill + * @framebuffer: A #CoglFramebuffer + * @pipeline: A #CoglPipeline to render with + * + * Draws a triangle tesselation of the given @path using the specified + * GPU @pipeline to the given @framebuffer. + * + * The tesselated interior of the path is determined using the fill + * rule of the path. See %CoglPathFillRule for details. + * + * <note>The result of referencing sliced textures in your current + * pipeline when filling a path are undefined. You should pass + * the %COGL_TEXTURE_NO_SLICING flag when loading any texture you will + * use while filling a path.</note> + * + * Since: 2.0 + */ +void +cogl_path_fill (CoglPath *path, + CoglFramebuffer *framebuffer, + CoglPipeline *pipeline); + +/** + * cogl_path_stroke: + * @path: The #CoglPath to stroke + * @framebuffer: A #CoglFramebuffer + * @pipeline: A #CoglPipeline to render with + * + * Draws a list of line primitives corresponding to the edge of the + * given @path using the specified GPU @pipeline to the given + * @framebuffer. + * + * <note>Cogl does not provide any sophisticated path stroking + * features for things like stroke width, dashes or caps. The stroke + * line will have a width of 1 pixel regardless of the current + * transformation matrix.</note> + * + * Since: 2.0 + */ +void +cogl_path_stroke (CoglPath *path, + CoglFramebuffer *framebuffer, + CoglPipeline *pipeline); + +/** + * cogl_framebuffer_push_path_clip: + * @framebuffer: A #CoglFramebuffer pointer + * @path: The path to clip with. + * + * Sets a new clipping area using the silhouette of the specified, + * filled @path. The clipping area is intersected with the previous + * clipping area. To restore the previous clipping area, call + * cogl_framebuffer_pop_clip(). + * + * Since: 1.0 + * Stability: unstable + */ +void +cogl_framebuffer_push_path_clip (CoglFramebuffer *framebuffer, + CoglPath *path); + COGL_END_DECLS #endif /* __COGL_PATH_H__ */ diff --git a/cogl-path/cogl-path.pc.in b/cogl-path/cogl-path.pc.in new file mode 100644 index 00000000..d8b3beb8 --- /dev/null +++ b/cogl-path/cogl-path.pc.in @@ -0,0 +1,13 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +apiversion=@COGL_API_VERSION@ +requires=@COGL_PKG_REQUIRES@ + +Name: Cogl +Description: A 2D path drawing library for Cogl +Version: @COGL_VERSION@ +Libs: -L${libdir} -lcogl-path +Cflags: -I${includedir}/cogl +Requires: ${requires} diff --git a/cogl/tesselator/GL/glu.h b/cogl-path/tesselator/GL/glu.h index 026ca5af..026ca5af 100644 --- a/cogl/tesselator/GL/glu.h +++ b/cogl-path/tesselator/GL/glu.h diff --git a/cogl/tesselator/README b/cogl-path/tesselator/README index 66a6011e..66a6011e 100644 --- a/cogl/tesselator/README +++ b/cogl-path/tesselator/README diff --git a/cogl/tesselator/dict-list.h b/cogl-path/tesselator/dict-list.h index 11331a76..11331a76 100644 --- a/cogl/tesselator/dict-list.h +++ b/cogl-path/tesselator/dict-list.h diff --git a/cogl/tesselator/dict.c b/cogl-path/tesselator/dict.c index 49d4f759..49d4f759 100644 --- a/cogl/tesselator/dict.c +++ b/cogl-path/tesselator/dict.c diff --git a/cogl/tesselator/dict.h b/cogl-path/tesselator/dict.h index 11331a76..11331a76 100644 --- a/cogl/tesselator/dict.h +++ b/cogl-path/tesselator/dict.h diff --git a/cogl/tesselator/geom.c b/cogl-path/tesselator/geom.c index 35b36a39..35b36a39 100644 --- a/cogl/tesselator/geom.c +++ b/cogl-path/tesselator/geom.c diff --git a/cogl/tesselator/geom.h b/cogl-path/tesselator/geom.h index 5cb76c7d..5cb76c7d 100644 --- a/cogl/tesselator/geom.h +++ b/cogl-path/tesselator/geom.h diff --git a/cogl/tesselator/gluos.h b/cogl-path/tesselator/gluos.h index d6c3ae99..d6c3ae99 100644 --- a/cogl/tesselator/gluos.h +++ b/cogl-path/tesselator/gluos.h diff --git a/cogl/tesselator/memalloc.h b/cogl-path/tesselator/memalloc.h index 0293e155..0293e155 100644 --- a/cogl/tesselator/memalloc.h +++ b/cogl-path/tesselator/memalloc.h diff --git a/cogl/tesselator/mesh.c b/cogl-path/tesselator/mesh.c index 36cb3a7b..36cb3a7b 100644 --- a/cogl/tesselator/mesh.c +++ b/cogl-path/tesselator/mesh.c diff --git a/cogl/tesselator/mesh.h b/cogl-path/tesselator/mesh.h index 690c5f2f..690c5f2f 100644 --- a/cogl/tesselator/mesh.h +++ b/cogl-path/tesselator/mesh.h diff --git a/cogl/tesselator/normal.c b/cogl-path/tesselator/normal.c index 9a3bd43d..9a3bd43d 100644 --- a/cogl/tesselator/normal.c +++ b/cogl-path/tesselator/normal.c diff --git a/cogl/tesselator/normal.h b/cogl-path/tesselator/normal.h index c376ca44..c376ca44 100644 --- a/cogl/tesselator/normal.h +++ b/cogl-path/tesselator/normal.h diff --git a/cogl/tesselator/priorityq-heap.c b/cogl-path/tesselator/priorityq-heap.c index 52698b59..52698b59 100644 --- a/cogl/tesselator/priorityq-heap.c +++ b/cogl-path/tesselator/priorityq-heap.c diff --git a/cogl/tesselator/priorityq-heap.h b/cogl-path/tesselator/priorityq-heap.h index dc9aaef8..dc9aaef8 100644 --- a/cogl/tesselator/priorityq-heap.h +++ b/cogl-path/tesselator/priorityq-heap.h diff --git a/cogl/tesselator/priorityq-sort.h b/cogl-path/tesselator/priorityq-sort.h index 746cf5fa..746cf5fa 100644 --- a/cogl/tesselator/priorityq-sort.h +++ b/cogl-path/tesselator/priorityq-sort.h diff --git a/cogl/tesselator/priorityq.c b/cogl-path/tesselator/priorityq.c index db7cd595..db7cd595 100644 --- a/cogl/tesselator/priorityq.c +++ b/cogl-path/tesselator/priorityq.c diff --git a/cogl/tesselator/priorityq.h b/cogl-path/tesselator/priorityq.h index 746cf5fa..746cf5fa 100644 --- a/cogl/tesselator/priorityq.h +++ b/cogl-path/tesselator/priorityq.h diff --git a/cogl/tesselator/render.c b/cogl-path/tesselator/render.c index bca836f0..bca836f0 100644 --- a/cogl/tesselator/render.c +++ b/cogl-path/tesselator/render.c diff --git a/cogl/tesselator/render.h b/cogl-path/tesselator/render.h index a298c9a9..a298c9a9 100644 --- a/cogl/tesselator/render.h +++ b/cogl-path/tesselator/render.h diff --git a/cogl/tesselator/sweep.c b/cogl-path/tesselator/sweep.c index eca828ff..eca828ff 100644 --- a/cogl/tesselator/sweep.c +++ b/cogl-path/tesselator/sweep.c diff --git a/cogl/tesselator/sweep.h b/cogl-path/tesselator/sweep.h index feb68b0f..feb68b0f 100644 --- a/cogl/tesselator/sweep.h +++ b/cogl-path/tesselator/sweep.h diff --git a/cogl/tesselator/tess.c b/cogl-path/tesselator/tess.c index 4a0e8dea..4a0e8dea 100644 --- a/cogl/tesselator/tess.c +++ b/cogl-path/tesselator/tess.c diff --git a/cogl/tesselator/tess.h b/cogl-path/tesselator/tess.h index 16249608..16249608 100644 --- a/cogl/tesselator/tess.h +++ b/cogl-path/tesselator/tess.h diff --git a/cogl/tesselator/tesselator.h b/cogl-path/tesselator/tesselator.h index 5b651be1..5b651be1 100644 --- a/cogl/tesselator/tesselator.h +++ b/cogl-path/tesselator/tesselator.h diff --git a/cogl/tesselator/tessmono.c b/cogl-path/tesselator/tessmono.c index 4d084400..4d084400 100644 --- a/cogl/tesselator/tessmono.c +++ b/cogl-path/tesselator/tessmono.c diff --git a/cogl/tesselator/tessmono.h b/cogl-path/tesselator/tessmono.h index 8ee1b2fe..8ee1b2fe 100644 --- a/cogl/tesselator/tessmono.h +++ b/cogl-path/tesselator/tessmono.h diff --git a/cogl/Makefile.am b/cogl/Makefile.am index d9a50569..637b0df7 100644 --- a/cogl/Makefile.am +++ b/cogl/Makefile.am @@ -18,7 +18,6 @@ lib_LTLIBRARIES = AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_builddir) \ - -I$(srcdir)/tesselator \ -I$(srcdir)/winsys \ -I$(srcdir)/driver/gl \ -I$(srcdir)/driver/gl/gl \ @@ -84,7 +83,6 @@ cogl_public_h = \ $(srcdir)/cogl-onscreen-template.h \ $(srcdir)/cogl-frame-info.h \ $(srcdir)/cogl-onscreen.h \ - $(srcdir)/cogl-path.h \ $(srcdir)/cogl-pipeline-layer-state.h \ $(srcdir)/cogl-pipeline-state.h \ $(srcdir)/cogl-pipeline.h \ @@ -197,45 +195,10 @@ cogl_winsys_common_sources = \ $(srcdir)/winsys/cogl-winsys.c \ $(NULL) -# tesselator sources -cogl_tesselator_sources = \ - $(srcdir)/tesselator/dict-list.h \ - $(srcdir)/tesselator/dict.c \ - $(srcdir)/tesselator/dict.h \ - $(srcdir)/tesselator/geom.c \ - $(srcdir)/tesselator/geom.h \ - $(srcdir)/tesselator/gluos.h \ - $(srcdir)/tesselator/memalloc.h \ - $(srcdir)/tesselator/mesh.c \ - $(srcdir)/tesselator/mesh.h \ - $(srcdir)/tesselator/normal.c \ - $(srcdir)/tesselator/normal.h \ - $(srcdir)/tesselator/priorityq-heap.h \ - $(srcdir)/tesselator/priorityq-sort.h \ - $(srcdir)/tesselator/priorityq.c \ - $(srcdir)/tesselator/priorityq.h \ - $(srcdir)/tesselator/render.c \ - $(srcdir)/tesselator/render.h \ - $(srcdir)/tesselator/sweep.c \ - $(srcdir)/tesselator/sweep.h \ - $(srcdir)/tesselator/tess.c \ - $(srcdir)/tesselator/tess.h \ - $(srcdir)/tesselator/tesselator.h \ - $(srcdir)/tesselator/tessmono.c \ - $(srcdir)/tesselator/tessmono.h \ - $(srcdir)/tesselator/GL/glu.h \ - $(NULL) - -EXTRA_DIST += \ - $(srcdir)/tesselator/README \ - $(srcdir)/tesselator/priorityq-heap.c \ - $(NULL) - # sources cogl_sources_c = \ $(cogl_driver_sources) \ $(cogl_winsys_common_sources) \ - $(cogl_tesselator_sources) \ $(srcdir)/cogl-private.h \ $(srcdir)/cogl-debug.h \ $(srcdir)/cogl-debug-options.h \ @@ -268,8 +231,6 @@ cogl_sources_c = \ $(srcdir)/cogl-bitmap-packing.h \ $(srcdir)/cogl-primitives-private.h \ $(srcdir)/cogl-primitives.c \ - $(srcdir)/cogl-path-private.h \ - $(srcdir)/cogl-path.c \ $(srcdir)/cogl-bitmap-pixbuf.c \ $(srcdir)/cogl-clip-stack.h \ $(srcdir)/cogl-clip-stack.c \ @@ -544,7 +505,7 @@ libcogl2_la_LDFLAGS = \ -no-undefined \ -version-info @COGL_LT_CURRENT@:@COGL_LT_REVISION@:@COGL_LT_AGE@ \ -export-dynamic \ - -export-symbols-regex "^(cogl|_cogl_debug_flags|_cogl_atlas_new|_cogl_atlas_add_reorganize_callback|_cogl_atlas_reserve_space|_cogl_callback|_cogl_util_get_eye_planes_for_screen_poly|_cogl_atlas_texture_remove_reorganize_callback|_cogl_atlas_texture_add_reorganize_callback|_cogl_texture_foreach_sub_texture_in_region|_cogl_atlas_texture_new_with_size|_cogl_profile_trace_message|_cogl_context_get_default).*" + -export-symbols-regex "^(cogl|_cogl_debug_flags|_cogl_atlas_new|_cogl_atlas_add_reorganize_callback|_cogl_atlas_reserve_space|_cogl_callback|_cogl_util_get_eye_planes_for_screen_poly|_cogl_atlas_texture_remove_reorganize_callback|_cogl_atlas_texture_add_reorganize_callback|_cogl_texture_foreach_sub_texture_in_region|_cogl_atlas_texture_new_with_size|_cogl_profile_trace_message|_cogl_context_get_default|_cogl_framebuffer_get_stencil_bits|_cogl_clip_stack_push_rectangle|_cogl_framebuffer_get_modelview_stack|_cogl_object_default_unref|_cogl_pipeline_foreach_layer_internal|_cogl_clip_stack_push_primitive|_cogl_buffer_unmap_for_fill_or_fallback|_cogl_framebuffer_draw_primitive|_cogl_debug_instances|_cogl_framebuffer_get_projection_stack|_cogl_pipeline_layer_get_texture|_cogl_buffer_map_for_fill_or_fallback|_cogl_framebuffer_get_clip_state|_cogl_texture_can_hardware_repeat|_cogl_pipeline_prune_to_n_layers).*" libcogl2_la_SOURCES = $(cogl_sources_c) nodist_libcogl2_la_SOURCES = $(BUILT_SOURCES) diff --git a/cogl/cogl-clip-stack.c b/cogl/cogl-clip-stack.c index 9db3b0ee..2e909aec 100644 --- a/cogl/cogl-clip-stack.c +++ b/cogl/cogl-clip-stack.c @@ -36,7 +36,6 @@ #include "cogl-framebuffer-private.h" #include "cogl-journal-private.h" #include "cogl-util.h" -#include "cogl-path-private.h" #include "cogl-matrix-private.h" #include "cogl-primitives-private.h" #include "cogl-private.h" @@ -248,57 +247,6 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack, } 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; - } -} - -CoglClipStack * _cogl_clip_stack_push_primitive (CoglClipStack *stack, CoglPrimitive *primitive, float bounds_x1, @@ -376,15 +324,6 @@ _cogl_clip_stack_unref (CoglClipStack *entry) case COGL_CLIP_STACK_WINDOW_RECT: g_slice_free1 (sizeof (CoglClipStackWindowRect), entry); break; - - case COGL_CLIP_STACK_PATH: - { - CoglClipStackPath *path_entry = (CoglClipStackPath *) entry; - cogl_matrix_entry_unref (path_entry->matrix_entry); - cogl_object_unref (path_entry->path); - g_slice_free1 (sizeof (CoglClipStackPath), entry); - break; - } case COGL_CLIP_STACK_PRIMITIVE: { CoglClipStackPrimitive *primitive_entry = diff --git a/cogl/cogl-clip-stack.h b/cogl/cogl-clip-stack.h index 7c2ee988..2e0bd891 100644 --- a/cogl/cogl-clip-stack.h +++ b/cogl/cogl-clip-stack.h @@ -24,7 +24,6 @@ #ifndef __COGL_CLIP_STACK_H #define __COGL_CLIP_STACK_H -#include "cogl-path.h" #include "cogl-matrix.h" #include "cogl-primitive.h" #include "cogl-framebuffer.h" @@ -41,14 +40,12 @@ typedef struct _CoglClipStack CoglClipStack; typedef struct _CoglClipStackRect CoglClipStackRect; typedef struct _CoglClipStackWindowRect CoglClipStackWindowRect; -typedef struct _CoglClipStackPath CoglClipStackPath; typedef struct _CoglClipStackPrimitive CoglClipStackPrimitive; typedef enum { COGL_CLIP_STACK_RECT, COGL_CLIP_STACK_WINDOW_RECT, - COGL_CLIP_STACK_PATH, COGL_CLIP_STACK_PRIMITIVE } CoglClipStackType; @@ -65,14 +62,14 @@ typedef enum * CoglClipStack *stack_a = NULL; * stack_a = _cogl_clip_stack_push_rectangle (stack_a, ...); * stack_a = _cogl_clip_stack_push_rectangle (stack_a, ...); - * stack_a = _cogl_clip_stack_push_from_path (stack_a, ...); + * stack_a = _cogl_clip_stack_push_primitive (stack_a, ...); * CoglClipStack *stack_b = NULL; * stack_b = cogl_clip_stack_push_window_rectangle (stack_b, ...); * * stack_a * \ holds a ref to * +-----------+ - * | path node | + * | prim node | * |ref count 1| * +-----------+ * \ @@ -143,16 +140,6 @@ struct _CoglClipStackWindowRect just adds to the scissor clip */ }; -struct _CoglClipStackPath -{ - CoglClipStack _parent_data; - - /* The matrix that was current when the clip was set */ - CoglMatrixEntry *matrix_entry; - - CoglPath *path; -}; - struct _CoglClipStackPrimitive { CoglClipStack _parent_data; @@ -186,13 +173,6 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack, const float *viewport); CoglClipStack * -_cogl_clip_stack_push_from_path (CoglClipStack *stack, - CoglPath *path, - CoglMatrixEntry *modelview_entry, - CoglMatrixEntry *projection_entry, - const float *viewport); - -CoglClipStack * _cogl_clip_stack_push_primitive (CoglClipStack *stack, CoglPrimitive *primitive, float bounds_x1, diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c index 461d0f37..f9f55de7 100644 --- a/cogl/cogl-context.c +++ b/cogl/cogl-context.c @@ -44,7 +44,6 @@ #include "cogl-pipeline-opengl-private.h" #include "cogl-framebuffer-private.h" #include "cogl-onscreen-private.h" -#include "cogl-path.h" #include "cogl-attribute-private.h" #include "cogl-gpu-info-private.h" #include "cogl-config-private.h" diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index 883b37b9..57199793 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -46,7 +46,6 @@ #include "cogl-offscreen.h" #include "cogl-private.h" #include "cogl-primitives-private.h" -#include "cogl-path-private.h" #include "cogl-error-private.h" #include "cogl-texture-gl-private.h" @@ -1640,36 +1639,6 @@ cogl_framebuffer_push_rectangle_clip (CoglFramebuffer *framebuffer, } void -cogl_framebuffer_push_path_clip (CoglFramebuffer *framebuffer, - CoglPath *path) -{ - CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer); - CoglMatrixEntry *modelview_entry = - _cogl_framebuffer_get_modelview_entry (framebuffer); - CoglMatrixEntry *projection_entry = - _cogl_framebuffer_get_projection_entry (framebuffer); - /* XXX: It would be nicer if we stored the private viewport as a - * vec4 so we could avoid this redundant copy. */ - float viewport[] = { - framebuffer->viewport_x, - framebuffer->viewport_y, - framebuffer->viewport_width, - framebuffer->viewport_height - }; - - clip_state->stacks->data = - _cogl_clip_stack_push_from_path (clip_state->stacks->data, - path, - modelview_entry, - projection_entry, - viewport); - - if (framebuffer->context->current_draw_buffer == framebuffer) - framebuffer->context->current_draw_buffer_changes |= - COGL_FRAMEBUFFER_STATE_CLIP; -} - -void cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer, CoglPrimitive *primitive, float bounds_x1, @@ -2422,27 +2391,3 @@ cogl_framebuffer_draw_textured_rectangles (CoglFramebuffer *framebuffer, rects, n_rectangles); } - -void -cogl_framebuffer_fill_path (CoglFramebuffer *framebuffer, - CoglPipeline *pipeline, - CoglPath *path) -{ - _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer)); - _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); - _COGL_RETURN_IF_FAIL (cogl_is_path (path)); - - _cogl_path_fill_nodes (path, framebuffer, pipeline, 0 /* flags */); -} - -void -cogl_framebuffer_stroke_path (CoglFramebuffer *framebuffer, - CoglPipeline *pipeline, - CoglPath *path) -{ - _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer)); - _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); - _COGL_RETURN_IF_FAIL (cogl_is_path (path)); - - _cogl_path_stroke_nodes (path, framebuffer, pipeline); -} diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h index 918a36dd..fde5c359 100644 --- a/cogl/cogl-framebuffer.h +++ b/cogl/cogl-framebuffer.h @@ -37,7 +37,6 @@ */ typedef struct _CoglFramebuffer CoglFramebuffer; -#include <cogl/cogl-path.h> #include <cogl/cogl-pipeline.h> #include <cogl/cogl-indices.h> #include <cogl/cogl-bitmap.h> @@ -586,23 +585,6 @@ cogl_framebuffer_push_rectangle_clip (CoglFramebuffer *framebuffer, float y_2); /** - * cogl_framebuffer_push_path_clip: - * @framebuffer: A #CoglFramebuffer pointer - * @path: The path to clip with. - * - * Sets a new clipping area using the silhouette of the specified, - * filled @path. The clipping area is intersected with the previous - * clipping area. To restore the previous clipping area, call - * cogl_framebuffer_pop_clip(). - * - * Since: 1.0 - * Stability: unstable - */ -void -cogl_framebuffer_push_path_clip (CoglFramebuffer *framebuffer, - CoglPath *path); - -/** * cogl_framebuffer_push_primitive_clip: * @framebuffer: A #CoglFramebuffer pointer * @primitive: A #CoglPrimitive describing a flat 2D shape @@ -1573,47 +1555,6 @@ cogl_framebuffer_draw_textured_rectangles (CoglFramebuffer *framebuffer, const float *coordinates, unsigned int n_rectangles); -/** - * cogl_framebuffer_fill_path: - * @framebuffer: A #CoglFramebuffer - * @pipeline: A #CoglPipeline to render with - * @path: The #CoglPath to fill - * - * Fills the interior of the path using the fragment operations - * defined by the pipeline. - * - * The interior of the shape is determined using the fill rule of the - * path. See %CoglPathFillRule for details. - * - * <note>The result of referencing sliced textures in your current - * pipeline when filling a path are undefined. You should pass - * the %COGL_TEXTURE_NO_SLICING flag when loading any texture you will - * use while filling a path.</note> - * - * Since: 2.0 - */ -void -cogl_framebuffer_fill_path (CoglFramebuffer *framebuffer, - CoglPipeline *pipeline, - CoglPath *path); - -/** - * cogl_framebuffer_stroke_path: - * @framebuffer: A #CoglFramebuffer - * @pipeline: A #CoglPipeline to render with - * @path: The #CoglPath to stroke - * - * Strokes the edge of the path using the fragment operations defined - * by the pipeline. The stroke line will have a width of 1 pixel - * regardless of the current transformation matrix. - * - * Since: 2.0 - */ -void -cogl_framebuffer_stroke_path (CoglFramebuffer *framebuffer, - CoglPipeline *pipeline, - CoglPath *path); - /* XXX: Should we take an n_buffers + buffer id array instead of using * the CoglBufferBits type which doesn't seem future proof? */ /** diff --git a/cogl/cogl.h b/cogl/cogl.h index 790dcd96..e515af49 100644 --- a/cogl/cogl.h +++ b/cogl/cogl.h @@ -38,7 +38,6 @@ #include <cogl/cogl-offscreen.h> #include <cogl/cogl-texture.h> #include <cogl/cogl-types.h> -#include <cogl/cogl-path.h> #include <cogl/cogl-version.h> #ifdef COGL_HAS_GTYPE_SUPPORT diff --git a/cogl/driver/gl/cogl-clip-stack-gl.c b/cogl/driver/gl/cogl-clip-stack-gl.c index 6fcd4c17..54c4c0ba 100644 --- a/cogl/driver/gl/cogl-clip-stack-gl.c +++ b/cogl/driver/gl/cogl-clip-stack-gl.c @@ -33,7 +33,6 @@ #include "cogl-util-gl-private.h" #include "cogl-primitives-private.h" #include "cogl-pipeline-opengl-private.h" -#include "cogl-path-private.h" #include "cogl-clip-stack-gl-private.h" #ifndef GL_CLIP_PLANE0 @@ -360,41 +359,6 @@ add_stencil_clip_silhouette (CoglFramebuffer *framebuffer, } static void -paint_path_silhouette (CoglFramebuffer *framebuffer, - CoglPipeline *pipeline, - void *user_data) -{ - CoglPath *path = user_data; - if (path->data->path_nodes->len >= 3) - _cogl_path_fill_nodes (path, - framebuffer, - pipeline, - COGL_DRAW_SKIP_JOURNAL_FLUSH | - COGL_DRAW_SKIP_PIPELINE_VALIDATION | - COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH); -} - -static void -add_stencil_clip_path (CoglFramebuffer *framebuffer, - CoglMatrixEntry *modelview_entry, - CoglPath *path, - CoglBool merge, - CoglBool need_clear) -{ - CoglPathData *data = path->data; - add_stencil_clip_silhouette (framebuffer, - paint_path_silhouette, - modelview_entry, - data->path_nodes_min.x, - data->path_nodes_min.y, - data->path_nodes_max.x, - data->path_nodes_max.y, - merge, - need_clear, - path); -} - -static void paint_primitive_silhouette (CoglFramebuffer *framebuffer, CoglPipeline *pipeline, void *user_data) @@ -574,21 +538,6 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack, { switch (entry->type) { - case COGL_CLIP_STACK_PATH: - { - CoglClipStackPath *path_entry = (CoglClipStackPath *) entry; - - COGL_NOTE (CLIPPING, "Adding stencil clip for path"); - - add_stencil_clip_path (framebuffer, - path_entry->matrix_entry, - path_entry->path, - using_stencil_buffer, - TRUE); - - using_stencil_buffer = TRUE; - break; - } case COGL_CLIP_STACK_PRIMITIVE: { CoglClipStackPrimitive *primitive_entry = diff --git a/configure.ac b/configure.ac index f0bb0967..fb4b1a7d 100644 --- a/configure.ac +++ b/configure.ac @@ -472,6 +472,21 @@ AS_IF([test "x$enable_cogl_gst" = "xyes"], ] ) +dnl ============================================================ +dnl Should cogl-path be built? +dnl ============================================================ + +AC_ARG_ENABLE( + [cogl-path], + [AC_HELP_STRING([--enable-cogl-path=@<:@no/yes@:>@], [Enable 2D path support @<:@default=no@:>@])], + [], + enable_cogl_path=yes +) +AS_IF([test "x$enable_cogl_path" = "xyes"], + [ + COGL_DEFINES_SYMBOLS="$COGL_DEFINES_SYMBOLS COGL_HAS_COGL_PATH_SUPPORT" + ] +) dnl ============================================================ dnl Choose image loading backend @@ -1170,6 +1185,8 @@ AS_IF([test "x$enable_cogl_pango" = "xyes"], ) AM_CONDITIONAL([BUILD_COGL_PANGO], [test "x$enable_cogl_pango" = "xyes"]) +AM_CONDITIONAL([BUILD_COGL_PATH], [test "x$enable_cogl_path" = "xyes"]) + AC_SUBST(COGL_GST_PKG_REQUIRES) AS_IF([test "x$enable_cogl_gst" = "xyes"], @@ -1325,6 +1342,8 @@ cogl/cogl.rc cogl-pango/Makefile cogl-pango/cogl-pango2.pc cogl-pango/cogl-pango.rc +cogl-path/Makefile +cogl-path/cogl-path.pc cogl-gst/Makefile cogl-gst/cogl-gst.pc cogl-gles2/Makefile @@ -1380,13 +1399,14 @@ fi echo " Build libcogl-gles2 GLES 2.0 frontend api: ${enable_cogl_gles2}" echo " Image backend: ${COGL_IMAGE_BACKEND}" echo " Cogl Pango: ${enable_cogl_pango}" -echo " Profiling: ${enable_profile}" -echo " CoglGst: ${enable_cogl_gst}" +echo " Cogl Gstreamer: ${enable_cogl_gst}" +echo " Cogl Path: ${enable_cogl_path}" # Compiler/Debug related flags echo "" -echo " • Compiler options:" -echo " Cogl debug: ${enable_debug}" +echo " • Build options:" +echo " Debugging: ${enable_debug}" +echo " Profiling: ${enable_profile}" echo " Enable deprecated symbols: ${enable_deprecated}" echo " Compiler flags: ${CFLAGS} ${COGL_EXTRA_CFLAGS}" echo " Linker flags: ${LDFLAGS} ${COGL_EXTRA_LDFLAGS}" diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am index 61c2e83a..91e5767d 100644 --- a/tests/conform/Makefile.am +++ b/tests/conform/Makefile.am @@ -33,7 +33,6 @@ test_sources = \ test-color-mask.c \ test-backface-culling.c \ test-just-vertex-shader.c \ - test-path.c \ test-pipeline-uniforms.c \ test-pixel-buffer.c \ test-premult.c \ @@ -68,6 +67,10 @@ test_sources = \ test-fence.c \ $(NULL) +if BUILD_COGL_PATH +test_sources += test-path.c +endif + test_conformance_SOURCES = $(common_sources) $(test_sources) if OS_WIN32 @@ -138,6 +141,9 @@ test_conformance_LDADD = \ if !USE_GLIB test_conformance_LDADD += $(top_builddir)/deps/glib/libglib.la endif +if BUILD_COGL_PATH +test_conformance_LDADD += $(top_builddir)/cogl-path/libcogl-path.la +endif test_conformance_LDFLAGS = -export-dynamic test: wrappers diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index 569985f0..037db990 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -55,7 +55,9 @@ main (int argc, char **argv) ADD_TEST (test_blend_strings, 0, 0); ADD_TEST (test_premult, 0, 0); UNPORTED_TEST (test_readpixels); +#ifdef COGL_HAS_COGL_PATH_SUPPORT ADD_TEST (test_path, 0, 0); +#endif ADD_TEST (test_depth_test, 0, 0); ADD_TEST (test_color_mask, 0, 0); ADD_TEST (test_backface_culling, 0, 0); diff --git a/tests/conform/test-path.c b/tests/conform/test-path.c index bf1e2679..01cee551 100644 --- a/tests/conform/test-path.c +++ b/tests/conform/test-path.c @@ -1,4 +1,5 @@ #include <cogl/cogl.h> +#include <cogl-path/cogl-path.h> #include <string.h> @@ -20,7 +21,7 @@ draw_path_at (CoglPath *path, CoglPipeline *pipeline, int x, int y) cogl_framebuffer_push_matrix (test_fb); cogl_framebuffer_translate (test_fb, x * BLOCK_SIZE, y * BLOCK_SIZE, 0.0f); - cogl_framebuffer_fill_path (test_fb, pipeline, path); + cogl_path_fill (path, test_fb, pipeline); cogl_framebuffer_pop_matrix (test_fb); } |