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.
This commit is contained in:
Robert Bragg 2013-04-28 03:22:24 +01:00
parent dab054200c
commit 7365c3aa77
61 changed files with 735 additions and 708 deletions

View File

@ -1,4 +1,13 @@
SUBDIRS = deps test-fixtures cogl tests SUBDIRS = deps test-fixtures
# Until we can bump the cogl soname cogl-path is built as
# a noinst_LTLIBRARY and linked into libcogl.so so it needs
# to be built before cogl...
if BUILD_COGL_PATH
SUBDIRS += cogl-path
endif
SUBDIRS += cogl
if BUILD_COGL_PANGO if BUILD_COGL_PANGO
SUBDIRS += cogl-pango SUBDIRS += cogl-pango
@ -12,7 +21,7 @@ if BUILD_COGL_GST
SUBDIRS += cogl-gst SUBDIRS += cogl-gst
endif endif
SUBDIRS += examples doc po build SUBDIRS += tests examples doc po build
ACLOCAL_AMFLAGS = -I build/autotools ${ACLOCAL_FLAGS} ACLOCAL_AMFLAGS = -I build/autotools ${ACLOCAL_FLAGS}

View File

@ -30,6 +30,7 @@
#include <string.h> #include <string.h>
#include "cogl-pango-display-list.h" #include "cogl-pango-display-list.h"
#include "cogl-pango-pipeline-cache.h"
#include "cogl/cogl-context-private.h" #include "cogl/cogl-context-private.h"
typedef enum typedef enum
@ -88,12 +89,7 @@ struct _CoglPangoDisplayListNode
struct struct
{ {
float y_1; CoglPrimitive *primitive;
float x_11;
float x_21;
float y_2;
float x_12;
float x_22;
} trapezoid; } trapezoid;
} d; } d;
}; };
@ -219,19 +215,26 @@ _cogl_pango_display_list_add_trapezoid (CoglPangoDisplayList *dl,
float x_12, float x_12,
float x_22) float x_22)
{ {
CoglContext *ctx = dl->pipeline_cache->ctx;
CoglPangoDisplayListNode *node = g_slice_new (CoglPangoDisplayListNode); 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->type = COGL_PANGO_DISPLAY_LIST_TRAPEZOID;
node->color_override = dl->color_override; node->color_override = dl->color_override;
node->color = dl->color; 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->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); _cogl_pango_display_list_append_node (dl, node);
} }
@ -448,25 +451,8 @@ _cogl_pango_display_list_render (CoglFramebuffer *fb,
break; break;
case COGL_PANGO_DISPLAY_LIST_TRAPEZOID: case COGL_PANGO_DISPLAY_LIST_TRAPEZOID:
{ cogl_framebuffer_draw_primitive (fb, node->pipeline,
float points[8]; node->d.trapezoid.primitive);
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);
}
break; break;
} }
} }
@ -483,6 +469,8 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node)
if (node->d.texture.primitive != NULL) if (node->d.texture.primitive != NULL)
cogl_object_unref (node->d.texture.primitive); 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) if (node->pipeline)
cogl_object_unref (node->pipeline); cogl_object_unref (node->pipeline);

View File

@ -37,18 +37,6 @@
typedef struct _CoglPangoPipelineCacheEntry CoglPangoPipelineCacheEntry; 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 struct _CoglPangoPipelineCacheEntry
{ {
/* This will take a reference or it can be NULL to represent the /* This will take a reference or it can be NULL to represent the

View File

@ -33,7 +33,18 @@
COGL_BEGIN_DECLS 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 * CoglPangoPipelineCache *
_cogl_pango_pipeline_cache_new (CoglContext *ctx, _cogl_pango_pipeline_cache_new (CoglContext *ctx,

View File

@ -825,19 +825,9 @@ cogl_pango_renderer_draw_trapezoid (PangoRenderer *renderer,
double x22) double x22)
{ {
CoglPangoRenderer *priv = COGL_PANGO_RENDERER (renderer); CoglPangoRenderer *priv = COGL_PANGO_RENDERER (renderer);
float points[8];
_COGL_RETURN_IF_FAIL (priv->display_list != NULL); _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_renderer_set_color_for_part (renderer, part);
_cogl_pango_display_list_add_trapezoid (priv->display_list, _cogl_pango_display_list_add_trapezoid (priv->display_list,

92
cogl-path/Makefile.am Normal file
View File

@ -0,0 +1,92 @@
include $(top_srcdir)/build/autotools/Makefile.am.silent
NULL =
BUILT_SOURCES =
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 \
cogl1-path.c \
cogl-path.c \
$(NULL)
EXTRA_DIST += \
$(srcdir)/tesselator/README \
$(srcdir)/tesselator/priorityq-heap.c \
$(NULL)
source_1_x_h = \
$(srcdir)/cogl-path-types.h \
$(srcdir)/cogl1-path-functions.h \
$(NULL)
source_h = \
cogl-path.h \
$(source_1_x_h) \
cogl2-path-functions.h \
$(NULL)
if USE_GLIB
# glib-mkenums rules
glib_enum_h = cogl-path-enum-types.h
glib_enum_c = cogl-path-enum-types.c
glib_enum_headers = $(source_1_x_h)
include $(top_srcdir)/build/autotools/Makefile.am.enums
endif
noinst_LTLIBRARIES = libcogl-path.la
libcogl_path_la_SOURCES = $(source_c) $(source_h)
nodist_libcogl_path_la_SOURCES = $(BUILT_SOURCES)
libcogl_path_la_CFLAGS = $(COGL_DEP_CFLAGS) $(COGL_GST_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS) $(MAINTAINER_CFLAGS)
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)/cogl/cogl-path
cogl_pathheaders_HEADERS = $(source_h)
if USE_GLIB
nodist_cogl_pathheaders_HEADERS = cogl-path-enum-types.h
endif

View File

@ -0,0 +1,13 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
apiversion=1.0
requires=@COGL_PKG_REQUIRES@ cogl-1.0
Name: Cogl
Description: A 2D path drawing library for Cogl
Version: @COGL_1_VERSION@
Libs: -L${libdir} -lcogl-path
Cflags: -I${includedir}/cogl
Requires: ${requires}

View File

@ -0,0 +1,50 @@
/*** BEGIN file-header ***/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* We need to undefine this so that we will be sure to include
* cogl-path.h instead of cogl2-path.h when we include the framebuffer
* header. Otherwise it will include both headers and it won't
* compile. */
#undef COGL_ENABLE_EXPERIMENTAL_2_0_API
#include "cogl-path-enum-types.h"
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
#include "@filename@"
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type (void)
{
static volatile gsize g_enum_type_id__volatile = 0;
if (g_once_init_enter (&g_enum_type_id__volatile))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_enum_type_id;
g_enum_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id);
}
return g_enum_type_id__volatile;
}
/*** END value-tail ***/

View File

@ -0,0 +1,25 @@
/*** BEGIN file-header ***/
#ifndef __COGL_PATH_ENUM_TYPES_H__
#define __COGL_PATH_ENUM_TYPES_H__
#include <glib-object.h>
G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN file-tail ***/
G_END_DECLS
#endif /* __COGL_PATH_ENUM_TYPES_H__ */
/*** END file-tail ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
#define COGL_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
/*** END value-header ***/

View File

@ -86,6 +86,7 @@ struct _CoglPathData
CoglIndices *fill_vbo_indices; CoglIndices *fill_vbo_indices;
unsigned int fill_vbo_n_indices; unsigned int fill_vbo_n_indices;
CoglAttribute *fill_attributes[COGL_PATH_N_ATTRIBUTES + 1]; CoglAttribute *fill_attributes[COGL_PATH_N_ATTRIBUTES + 1];
CoglPrimitive *fill_primitive;
CoglAttributeBuffer *stroke_attribute_buffer; CoglAttributeBuffer *stroke_attribute_buffer;
CoglAttribute **stroke_attributes; CoglAttribute **stroke_attributes;
@ -115,15 +116,4 @@ _cogl_path_get_bounds (CoglPath *path,
CoglBool CoglBool
_cogl_path_is_rectangle (CoglPath *path); _cogl_path_is_rectangle (CoglPath *path);
void
_cogl_path_stroke_nodes (CoglPath *path,
CoglFramebuffer *framebuffer,
CoglPipeline *pipeline);
void
_cogl_path_fill_nodes (CoglPath *path,
CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
CoglDrawFlags flags);
#endif /* __COGL_PATH_PRIVATE_H */ #endif /* __COGL_PATH_PRIVATE_H */

View File

@ -3,7 +3,7 @@
* *
* An object oriented GL/GLES Abstraction/Utility Layer * An object oriented GL/GLES Abstraction/Utility Layer
* *
* Copyright (C) 2008,2009 Intel Corporation. * Copyright (C) 2008,2009,2013 Intel Corporation.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -16,7 +16,8 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
* *
* *
*/ */
@ -25,32 +26,13 @@
#error "Only <cogl/cogl.h> can be included directly." #error "Only <cogl/cogl.h> can be included directly."
#endif #endif
#ifndef __COGL_PATH_H__ #ifndef __COGL_PATH_TYPES_H__
#define __COGL_PATH_H__ #define __COGL_PATH_TYPES_H__
#include <cogl/cogl-types.h> #include <cogl/cogl-types.h>
COGL_BEGIN_DECLS COGL_BEGIN_DECLS
/**
* SECTION:cogl-paths
* @short_description: Functions for constructing and drawing 2D paths.
*
* There are two levels on which drawing with cogl-paths can be used.
* The highest level functions construct various simple primitive
* shapes to be either filled or stroked. Using a lower-level set of
* functions more complex and arbitrary paths can be constructed by
* concatenating straight line, bezier curve and arc segments.
*
* When constructing arbitrary paths, the current pen location is
* initialized using the move_to command. The subsequent path segments
* implicitly use the last pen location as their first vertex and move
* the pen location to the last vertex they produce at the end. Also
* there are special versions of functions that allow specifying the
* vertices of the path segments relative to the last pen location
* rather then in the absolute coordinates.
*/
typedef struct _CoglPath CoglPath; typedef struct _CoglPath CoglPath;
#define COGL_PATH(obj) ((CoglPath *)(obj)) #define COGL_PATH(obj) ((CoglPath *)(obj))
@ -96,7 +78,4 @@ typedef enum {
COGL_END_DECLS COGL_END_DECLS
#include "cogl-path-functions.h" #endif /* __COGL_PATH_TYPES_H__ */
#endif /* __COGL_PATH_H__ */

View File

@ -3,7 +3,7 @@
* *
* An object oriented GL/GLES Abstraction/Utility Layer * An object oriented GL/GLES Abstraction/Utility Layer
* *
* Copyright (C) 2007,2008,2009,2010 Intel Corporation. * Copyright (C) 2007,2008,2009,2010,2013 Intel Corporation.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -35,9 +35,8 @@
#include "cogl-context-private.h" #include "cogl-context-private.h"
#include "cogl-journal-private.h" #include "cogl-journal-private.h"
#include "cogl-pipeline-private.h" #include "cogl-pipeline-private.h"
#include "cogl-pipeline-opengl-private.h"
#include "cogl-framebuffer-private.h" #include "cogl-framebuffer-private.h"
#include "cogl-path-private.h" #include "cogl-primitive-private.h"
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-primitives-private.h" #include "cogl-primitives-private.h"
#include "cogl-private.h" #include "cogl-private.h"
@ -45,6 +44,9 @@
#include "cogl1-context.h" #include "cogl1-context.h"
#include "tesselator/tesselator.h" #include "tesselator/tesselator.h"
#include "cogl-path/cogl-path.h"
#include "cogl-path-private.h"
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -53,6 +55,7 @@
static void _cogl_path_free (CoglPath *path); static void _cogl_path_free (CoglPath *path);
static void _cogl_path_build_fill_attribute_buffer (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); static void _cogl_path_build_stroke_attribute_buffer (CoglPath *path);
COGL_OBJECT_DEFINE (Path, path); COGL_OBJECT_DEFINE (Path, path);
@ -73,6 +76,12 @@ _cogl_path_data_clear_vbos (CoglPathData *data)
data->fill_attribute_buffer = NULL; data->fill_attribute_buffer = NULL;
} }
if (data->fill_primitive)
{
cogl_object_unref (data->fill_primitive);
data->fill_primitive = NULL;
}
if (data->stroke_attribute_buffer) if (data->stroke_attribute_buffer)
{ {
cogl_object_unref (data->stroke_attribute_buffer); cogl_object_unref (data->stroke_attribute_buffer);
@ -119,6 +128,7 @@ _cogl_path_modify (CoglPath *path)
old_data->path_nodes->len); old_data->path_nodes->len);
path->data->fill_attribute_buffer = NULL; path->data->fill_attribute_buffer = NULL;
path->data->fill_primitive = NULL;
path->data->stroke_attribute_buffer = NULL; path->data->stroke_attribute_buffer = NULL;
path->data->ref_count = 1; path->data->ref_count = 1;
@ -198,17 +208,23 @@ _cogl_path_add_node (CoglPath *path,
data->is_rectangle = FALSE; data->is_rectangle = FALSE;
} }
void static void
_cogl_path_stroke_nodes (CoglPath *path, _cogl_path_stroke_nodes (CoglPath *path,
CoglFramebuffer *framebuffer, CoglFramebuffer *framebuffer,
CoglPipeline *pipeline) CoglPipeline *pipeline)
{ {
CoglPathData *data = path->data; CoglPathData *data;
CoglPipeline *copy = NULL; CoglPipeline *copy = NULL;
unsigned int path_start; unsigned int path_start;
int path_num = 0; int path_num = 0;
CoglPathNode *node; 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) if (data->path_nodes->len == 0)
return; return;
@ -318,7 +334,7 @@ validate_layer_cb (CoglPipelineLayer *layer, void *user_data)
return !*needs_fallback; return !*needs_fallback;
} }
void static void
_cogl_path_fill_nodes (CoglPath *path, _cogl_path_fill_nodes (CoglPath *path,
CoglFramebuffer *framebuffer, CoglFramebuffer *framebuffer,
CoglPipeline *pipeline, CoglPipeline *pipeline,
@ -344,6 +360,7 @@ _cogl_path_fill_nodes (CoglPath *path,
else else
{ {
CoglBool needs_fallback = FALSE; CoglBool needs_fallback = FALSE;
CoglPrimitive *primitive;
_cogl_pipeline_foreach_layer_internal (pipeline, _cogl_pipeline_foreach_layer_internal (pipeline,
validate_layer_cb, validate_layer_cb,
@ -356,46 +373,31 @@ _cogl_path_fill_nodes (CoglPath *path,
return; return;
} }
_cogl_path_build_fill_attribute_buffer (path); primitive = _cogl_path_get_fill_primitive (path);
_cogl_framebuffer_draw_indexed_attributes (framebuffer, _cogl_primitive_draw (primitive, framebuffer, pipeline, flags);
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);
} }
} }
/* TODO: Update to the protoype used in the Cogl master branch.
* This is experimental API but not in sync with the cogl_path_fill()
* api in Cogl master which takes explicit framebuffer and pipeline
* arguments */
void void
cogl2_path_fill (CoglPath *path) cogl2_path_fill (CoglPath *path)
{ {
_COGL_RETURN_IF_FAIL (cogl_is_path (path)); _COGL_RETURN_IF_FAIL (cogl_is_path (path));
if (path->data->path_nodes->len == 0)
return;
/* If the path is a simple rectangle then we can divert to using
cogl_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)
{
float x_1, y_1, x_2, y_2;
_cogl_path_get_bounds (path, &x_1, &y_1, &x_2, &y_2);
cogl_rectangle (x_1, y_1, x_2, y_2);
}
else
_cogl_path_fill_nodes (path, _cogl_path_fill_nodes (path,
cogl_get_draw_framebuffer (), cogl_get_draw_framebuffer (),
cogl_get_source (), cogl_get_source (),
0); 0 /* flags */);
} }
/* TODO: Update to the protoype used in the Cogl master branch.
* This is experimental API but not in sync with the cogl_path_fill()
* api in Cogl master which takes explicit framebuffer and pipeline
* arguments */
void void
cogl2_path_stroke (CoglPath *path) cogl2_path_stroke (CoglPath *path)
{ {
@ -1412,6 +1414,95 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path)
g_array_free (tess.indices, TRUE); 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;
}
/* XXX: deprecated */
void
cogl_clip_push_from_path (CoglPath *path)
{
cogl_framebuffer_push_path_clip (cogl_get_draw_framebuffer (), path);
}
static void static void
_cogl_path_build_stroke_attribute_buffer (CoglPath *path) _cogl_path_build_stroke_attribute_buffer (CoglPath *path)
{ {
@ -1475,3 +1566,29 @@ _cogl_path_build_stroke_attribute_buffer (CoglPath *path)
data->stroke_n_attributes = n_attributes; data->stroke_n_attributes = n_attributes;
} }
/* XXX: deprecated */
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 */);
}
/* XXX: deprecated */
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);
}

58
cogl-path/cogl-path.h Normal file
View File

@ -0,0 +1,58 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009,2013 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
*
*/
#ifndef __COGL_PATH_H__
#define __COGL_PATH_H__
/**
* SECTION:cogl-paths
* @short_description: Functions for constructing and drawing 2D paths.
*
* There are two levels on which drawing with cogl-paths can be used.
* The highest level functions construct various simple primitive
* shapes to be either filled or stroked. Using a lower-level set of
* functions more complex and arbitrary paths can be constructed by
* concatenating straight line, bezier curve and arc segments.
*
* When constructing arbitrary paths, the current pen location is
* initialized using the move_to command. The subsequent path segments
* implicitly use the last pen location as their first vertex and move
* the pen location to the last vertex they produce at the end. Also
* there are special versions of functions that allow specifying the
* vertices of the path segments relative to the last pen location
* rather then in the absolute coordinates.
*/
#include <cogl-path/cogl-path-enum-types.h>
#include <cogl-path/cogl-path-types.h>
#ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API
#include <cogl-path/cogl2-path-functions.h>
#else
#include <cogl-path/cogl1-path-functions.h>
#endif
#endif /* __COGL_PATH_H__ */

View File

@ -424,6 +424,36 @@ cogl_set_path (CoglPath *path);
CoglPath * CoglPath *
cogl_path_copy (CoglPath *path); cogl_path_copy (CoglPath *path);
/**
* cogl_clip_push_from_path_preserve:
*
* Sets a new clipping area using the current path. The current path
* is then cleared. The clipping area is intersected with the previous
* clipping area. To restore the previous clipping area, call
* cogl_clip_pop().
*
* Since: 1.0
* Deprecated: 1.16: Use cogl_framebuffer_push_path_clip() instead
*/
void
cogl_clip_push_from_path_preserve (void)
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_path_clip);
/**
* cogl_clip_push_from_path:
*
* Sets a new clipping area using the current path. The current path
* is then cleared. The clipping area is intersected with the previous
* clipping area. To restore the previous clipping area, call
* cogl_clip_pop().
*
* Since: 1.0
* Deprecated: 1.16: Use cogl_framebuffer_push_path_clip() instead
*/
void
cogl_clip_push_from_path (void)
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_path_clip);
COGL_END_DECLS COGL_END_DECLS
#endif /* __COGL_PATH_FUNCTIONS_H__ */ #endif /* __COGL_PATH_FUNCTIONS_H__ */

View File

@ -3,7 +3,7 @@
* *
* An object oriented GL/GLES Abstraction/Utility Layer * An object oriented GL/GLES Abstraction/Utility Layer
* *
* Copyright (C) 2010 Intel Corporation. * Copyright (C) 2010,2013 Intel Corporation.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -30,10 +30,10 @@
#include "cogl-util.h" #include "cogl-util.h"
#include "cogl-object.h" #include "cogl-object.h"
#include "cogl-context-private.h" #include "cogl-context-private.h"
#include "cogl2-path.h"
#include <string.h> #include "cogl-path-types.h"
#include <math.h>
#include "cogl2-path-functions.h"
#undef cogl_path_set_fill_rule #undef cogl_path_set_fill_rule
#undef cogl_path_get_fill_rule #undef cogl_path_get_fill_rule
@ -56,15 +56,33 @@
#undef cogl_path_round_rectangle #undef cogl_path_round_rectangle
#undef cogl_path_curve_to #undef cogl_path_curve_to
#undef cogl_path_rel_curve_to #undef cogl_path_rel_curve_to
#undef cogl_clip_push_from_path
#include "cogl-path-functions.h" #include "cogl1-path-functions.h"
#include <string.h>
#include <math.h>
static void
ensure_current_path (CoglContext *ctx)
{
if (ctx->current_path == NULL)
ctx->current_path = cogl2_path_new ();
}
static CoglPath *
get_current_path (CoglContext *ctx)
{
ensure_current_path (ctx);
return ctx->current_path;
}
void void
cogl_path_set_fill_rule (CoglPathFillRule fill_rule) cogl_path_set_fill_rule (CoglPathFillRule fill_rule)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_set_fill_rule (ctx->current_path, fill_rule); cogl2_path_set_fill_rule (get_current_path (ctx), fill_rule);
} }
CoglPathFillRule CoglPathFillRule
@ -72,7 +90,7 @@ cogl_path_get_fill_rule (void)
{ {
_COGL_GET_CONTEXT (ctx, COGL_PATH_FILL_RULE_EVEN_ODD); _COGL_GET_CONTEXT (ctx, COGL_PATH_FILL_RULE_EVEN_ODD);
return cogl2_path_get_fill_rule (ctx->current_path); return cogl2_path_get_fill_rule (get_current_path (ctx));
} }
void void
@ -80,8 +98,9 @@ cogl_path_fill (void)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_fill (ctx->current_path); cogl2_path_fill (get_current_path (ctx));
if (ctx->current_path)
cogl_object_unref (ctx->current_path); cogl_object_unref (ctx->current_path);
ctx->current_path = cogl2_path_new (); ctx->current_path = cogl2_path_new ();
} }
@ -91,7 +110,7 @@ cogl_path_fill_preserve (void)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_fill (ctx->current_path); cogl2_path_fill (get_current_path (ctx));
} }
void void
@ -99,8 +118,9 @@ cogl_path_stroke (void)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_stroke (ctx->current_path); cogl2_path_stroke (get_current_path (ctx));
if (ctx->current_path)
cogl_object_unref (ctx->current_path); cogl_object_unref (ctx->current_path);
ctx->current_path = cogl2_path_new (); ctx->current_path = cogl2_path_new ();
} }
@ -110,7 +130,7 @@ cogl_path_stroke_preserve (void)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_stroke (ctx->current_path); cogl2_path_stroke (get_current_path (ctx));
} }
void void
@ -119,7 +139,7 @@ cogl_path_move_to (float x,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_move_to (ctx->current_path, x, y); cogl2_path_move_to (get_current_path (ctx), x, y);
} }
void void
@ -128,7 +148,7 @@ cogl_path_rel_move_to (float x,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_rel_move_to (ctx->current_path, x, y); cogl2_path_rel_move_to (get_current_path (ctx), x, y);
} }
void void
@ -137,7 +157,7 @@ cogl_path_line_to (float x,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_line_to (ctx->current_path, x, y); cogl2_path_line_to (get_current_path (ctx), x, y);
} }
void void
@ -146,7 +166,7 @@ cogl_path_rel_line_to (float x,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_rel_line_to (ctx->current_path, x, y); cogl2_path_rel_line_to (get_current_path (ctx), x, y);
} }
void void
@ -154,7 +174,7 @@ cogl_path_close (void)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_close (ctx->current_path); cogl2_path_close (get_current_path (ctx));
} }
void void
@ -162,6 +182,7 @@ cogl_path_new (void)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (ctx->current_path)
cogl_object_unref (ctx->current_path); cogl_object_unref (ctx->current_path);
ctx->current_path = cogl2_path_new (); ctx->current_path = cogl2_path_new ();
} }
@ -174,7 +195,7 @@ cogl_path_line (float x_1,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_line (ctx->current_path, x_1, y_1, x_2, y_2); cogl2_path_line (get_current_path (ctx), x_1, y_1, x_2, y_2);
} }
void void
@ -183,7 +204,7 @@ cogl_path_polyline (const float *coords,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_polyline (ctx->current_path, coords, num_points); cogl2_path_polyline (get_current_path (ctx), coords, num_points);
} }
void void
@ -192,7 +213,7 @@ cogl_path_polygon (const float *coords,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_polygon (ctx->current_path, coords, num_points); cogl2_path_polygon (get_current_path (ctx), coords, num_points);
} }
void void
@ -203,7 +224,7 @@ cogl_path_rectangle (float x_1,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_rectangle (ctx->current_path, x_1, y_1, x_2, y_2); cogl2_path_rectangle (get_current_path (ctx), x_1, y_1, x_2, y_2);
} }
void void
@ -216,7 +237,7 @@ cogl_path_arc (float center_x,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_arc (ctx->current_path, cogl2_path_arc (get_current_path (ctx),
center_x, center_x,
center_y, center_y,
radius_x, radius_x,
@ -233,7 +254,7 @@ cogl_path_ellipse (float center_x,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_ellipse (ctx->current_path, cogl2_path_ellipse (get_current_path (ctx),
center_x, center_x,
center_y, center_y,
radius_x, radius_x,
@ -250,7 +271,7 @@ cogl_path_round_rectangle (float x_1,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_round_rectangle (ctx->current_path, cogl2_path_round_rectangle (get_current_path (ctx),
x_1, y_1, x_2, y_2, radius, arc_step); x_1, y_1, x_2, y_2, radius, arc_step);
} }
@ -264,7 +285,7 @@ cogl_path_curve_to (float x_1,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_curve_to (ctx->current_path, cogl2_path_curve_to (get_current_path (ctx),
x_1, y_1, x_2, y_2, x_3, y_3); x_1, y_1, x_2, y_2, x_3, y_3);
} }
@ -278,7 +299,7 @@ cogl_path_rel_curve_to (float x_1,
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl2_path_rel_curve_to (ctx->current_path, cogl2_path_rel_curve_to (get_current_path (ctx),
x_1, y_1, x_2, y_2, x_3, y_3); x_1, y_1, x_2, y_2, x_3, y_3);
} }
@ -287,7 +308,7 @@ cogl_get_path (void)
{ {
_COGL_GET_CONTEXT (ctx, NULL); _COGL_GET_CONTEXT (ctx, NULL);
return ctx->current_path; return get_current_path (ctx);
} }
void void
@ -300,6 +321,27 @@ cogl_set_path (CoglPath *path)
/* Reference the new object first in case it is the same as the old /* Reference the new object first in case it is the same as the old
object */ object */
cogl_object_ref (path); cogl_object_ref (path);
if (ctx->current_path)
cogl_object_unref (ctx->current_path); cogl_object_unref (ctx->current_path);
ctx->current_path = path; ctx->current_path = path;
} }
void
cogl_clip_push_from_path_preserve (void)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_framebuffer_push_path_clip (cogl_get_draw_framebuffer (),
get_current_path (ctx));
}
void
cogl_clip_push_from_path (void)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_clip_push_from_path_preserve ();
if (ctx->current_path)
cogl_object_unref (ctx->current_path);
ctx->current_path = cogl2_path_new ();
}

View File

@ -3,7 +3,7 @@
* *
* An object oriented GL/GLES Abstraction/Utility Layer * An object oriented GL/GLES Abstraction/Utility Layer
* *
* Copyright (C) 2008,2009 Intel Corporation. * Copyright (C) 2008,2009,2013 Intel Corporation.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -16,7 +16,8 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
* *
* *
*/ */
@ -25,36 +26,14 @@
#error "Only <cogl/cogl.h> can be included directly." #error "Only <cogl/cogl.h> can be included directly."
#endif #endif
#ifndef __COGL2_PATH_H__ #ifndef __COGL2_PATH_FUNCTIONS_H__
#define __COGL2_PATH_H__ #define __COGL2_PATH_FUNCTIONS_H__
#include <cogl/cogl-types.h> #include <cogl/cogl-types.h>
#include <cogl/cogl.h>
COGL_BEGIN_DECLS COGL_BEGIN_DECLS
/**
* SECTION:cogl-paths
* @short_description: Functions for constructing and drawing 2D paths.
*
* There are two levels on which drawing with cogl-paths can be used.
* The highest level functions construct various simple primitive
* shapes to be either filled or stroked. Using a lower-level set of
* functions more complex and arbitrary paths can be constructed by
* concatenating straight line, bezier curve and arc segments.
*
* When constructing arbitrary paths, the current pen location is
* initialized using the move_to command. The subsequent path segments
* implicitly use the last pen location as their first vertex and move
* the pen location to the last vertex they produce at the end. Also
* there are special versions of functions that allow specifying the
* vertices of the path segments relative to the last pen location
* rather then in the absolute coordinates.
*/
typedef struct _CoglPath CoglPath;
#define COGL_PATH(obj) ((CoglPath *)(obj))
#define cogl_path_new cogl2_path_new #define cogl_path_new cogl2_path_new
/** /**
* cogl_path_new: * cogl_path_new:
@ -396,48 +375,6 @@ cogl_path_round_rectangle (CoglPath *path,
float radius, float radius,
float arc_step); float arc_step);
/**
* CoglPathFillRule:
* @COGL_PATH_FILL_RULE_NON_ZERO: Each time the line crosses an edge of
* the path from left to right one is added to a counter and each time
* it crosses from right to left the counter is decremented. If the
* counter is non-zero then the point will be filled. See <xref
* linkend="fill-rule-non-zero"/>.
* @COGL_PATH_FILL_RULE_EVEN_ODD: If the line crosses an edge of the
* path an odd number of times then the point will filled, otherwise
* it won't. See <xref linkend="fill-rule-even-odd"/>.
*
* #CoglPathFillRule is used to determine how a path is filled. There
* are two options - 'non-zero' and 'even-odd'. To work out whether any
* point will be filled imagine drawing an infinetely long line in any
* direction from that point. The number of times and the direction
* that the edges of the path crosses this line determines whether the
* line is filled as described below. Any open sub paths are treated
* as if there was an extra line joining the first point and the last
* point.
*
* The default fill rule is %COGL_PATH_FILL_RULE_EVEN_ODD. The fill
* rule is attached to the current path so preserving a path with
* cogl_get_path() also preserves the fill rule. Calling
* cogl_path_new() resets the current fill rule to the default.
*
* <figure id="fill-rule-non-zero">
* <title>Example of filling various paths using the non-zero rule</title>
* <graphic fileref="fill-rule-non-zero.png" format="PNG"/>
* </figure>
*
* <figure id="fill-rule-even-odd">
* <title>Example of filling various paths using the even-odd rule</title>
* <graphic fileref="fill-rule-even-odd.png" format="PNG"/>
* </figure>
*
* Since: 1.4
*/
typedef enum {
COGL_PATH_FILL_RULE_NON_ZERO,
COGL_PATH_FILL_RULE_EVEN_ODD
} CoglPathFillRule;
#define cogl_path_set_fill_rule cogl2_path_set_fill_rule #define cogl_path_set_fill_rule cogl2_path_set_fill_rule
/** /**
* cogl_path_set_fill_rule: * cogl_path_set_fill_rule:
@ -487,6 +424,32 @@ cogl_path_get_fill_rule (CoglPath *path);
void void
cogl_path_fill (CoglPath *path); cogl_path_fill (CoglPath *path);
/**
* 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>
*
* Stability: unstable
* Deprecated: 1.16: Use cogl_path_fill() instead
*/
void
cogl_framebuffer_fill_path (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
CoglPath *path)
COGL_DEPRECATED_IN_1_16_FOR (cogl_path_fill);
#define cogl_path_stroke cogl2_path_stroke #define cogl_path_stroke cogl2_path_stroke
/** /**
* cogl_path_stroke: * cogl_path_stroke:
@ -500,7 +463,61 @@ cogl_path_fill (CoglPath *path);
void void
cogl_path_stroke (CoglPath *path); cogl_path_stroke (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.
*
* Stability: unstable
* Deprecated: 1.16: Use cogl_path_stroke() instead
*/
void
cogl_framebuffer_stroke_path (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
CoglPath *path)
COGL_DEPRECATED_IN_1_16_FOR (cogl_path_stroke);
/**
* 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);
#define cogl_clip_push_from_path cogl2_clip_push_from_path
/**
* cogl_clip_push_from_path:
* @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
* call cogl_clip_pop().
*
* Since: 1.8
* Stability: Unstable
* Deprecated: 1.16: Use cogl_framebuffer_push_path_clip() instead
*/
void
cogl_clip_push_from_path (CoglPath *path)
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_path_clip);
COGL_END_DECLS COGL_END_DECLS
#endif /* __COGL2_PATH_H__ */ #endif /* __COGL2_PATH_FUNCTIONS_H__ */

View File

@ -18,7 +18,6 @@ lib_LTLIBRARIES =
AM_CPPFLAGS = \ AM_CPPFLAGS = \
-I$(top_srcdir) \ -I$(top_srcdir) \
-I$(top_builddir) \ -I$(top_builddir) \
-I$(srcdir)/tesselator \
-I$(srcdir)/winsys \ -I$(srcdir)/winsys \
-I$(srcdir)/driver/gl \ -I$(srcdir)/driver/gl \
-I$(srcdir)/driver/gl/gl \ -I$(srcdir)/driver/gl/gl \
@ -78,8 +77,6 @@ cogl_1_public_h = \
$(srcdir)/cogl-matrix.h \ $(srcdir)/cogl-matrix.h \
$(srcdir)/cogl-offscreen.h \ $(srcdir)/cogl-offscreen.h \
$(srcdir)/cogl-primitives.h \ $(srcdir)/cogl-primitives.h \
$(srcdir)/cogl-path.h \
$(srcdir)/cogl-path-functions.h \
$(srcdir)/cogl-shader.h \ $(srcdir)/cogl-shader.h \
$(srcdir)/cogl-texture.h \ $(srcdir)/cogl-texture.h \
$(srcdir)/cogl-types.h \ $(srcdir)/cogl-types.h \
@ -101,7 +98,6 @@ cogl_experimental_h = \
$(srcdir)/cogl-pipeline-state.h \ $(srcdir)/cogl-pipeline-state.h \
$(srcdir)/cogl-pipeline-layer-state.h \ $(srcdir)/cogl-pipeline-layer-state.h \
$(srcdir)/cogl-snippet.h \ $(srcdir)/cogl-snippet.h \
$(srcdir)/cogl2-path.h \
$(srcdir)/cogl-gles2.h \ $(srcdir)/cogl-gles2.h \
$(srcdir)/cogl-gles2-types.h \ $(srcdir)/cogl-gles2-types.h \
$(srcdir)/cogl-index-buffer.h \ $(srcdir)/cogl-index-buffer.h \
@ -132,7 +128,6 @@ cogl_experimental_h = \
$(srcdir)/cogl-buffer.h \ $(srcdir)/cogl-buffer.h \
$(srcdir)/cogl-pixel-buffer.h \ $(srcdir)/cogl-pixel-buffer.h \
$(srcdir)/cogl2-experimental.h \ $(srcdir)/cogl2-experimental.h \
$(srcdir)/cogl2-compatibility.h \
$(srcdir)/cogl-macros.h \ $(srcdir)/cogl-macros.h \
$(srcdir)/cogl-fence.h \ $(srcdir)/cogl-fence.h \
$(srcdir)/cogl-version.h \ $(srcdir)/cogl-version.h \
@ -219,45 +214,10 @@ cogl_winsys_common_sources = \
$(srcdir)/winsys/cogl-winsys.c \ $(srcdir)/winsys/cogl-winsys.c \
$(NULL) $(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 # sources
cogl_sources_c = \ cogl_sources_c = \
$(cogl_driver_sources) \ $(cogl_driver_sources) \
$(cogl_winsys_common_sources) \ $(cogl_winsys_common_sources) \
$(cogl_tesselator_sources) \
$(srcdir)/cogl-private.h \ $(srcdir)/cogl-private.h \
$(srcdir)/cogl-i18n-private.h \ $(srcdir)/cogl-i18n-private.h \
$(srcdir)/cogl-debug.h \ $(srcdir)/cogl-debug.h \
@ -292,11 +252,6 @@ cogl_sources_c = \
$(srcdir)/cogl-primitives-private.h \ $(srcdir)/cogl-primitives-private.h \
$(srcdir)/cogl-primitives.h \ $(srcdir)/cogl-primitives.h \
$(srcdir)/cogl-primitives.c \ $(srcdir)/cogl-primitives.c \
$(srcdir)/cogl-path-private.h \
$(srcdir)/cogl-path.h \
$(srcdir)/cogl-path.c \
$(srcdir)/cogl2-path.h \
$(srcdir)/cogl2-path.c \
$(srcdir)/cogl-bitmap-pixbuf.c \ $(srcdir)/cogl-bitmap-pixbuf.c \
$(srcdir)/cogl-clip-stack.h \ $(srcdir)/cogl-clip-stack.h \
$(srcdir)/cogl-clip-stack.c \ $(srcdir)/cogl-clip-stack.c \
@ -572,13 +527,16 @@ endif
if UNIT_TESTS if UNIT_TESTS
libcogl_la_LIBADD += $(top_builddir)/test-fixtures/libtest-fixtures.la libcogl_la_LIBADD += $(top_builddir)/test-fixtures/libtest-fixtures.la
endif endif
if BUILD_COGL_PATH
libcogl_la_LIBADD += $(top_builddir)/cogl-path/libcogl-path.la
endif
# XXX: The aim is to eventually get rid of all private API exports # XXX: The aim is to eventually get rid of all private API exports
# for cogl-pango. # for cogl-pango.
libcogl_la_LDFLAGS = \ libcogl_la_LDFLAGS = \
-no-undefined \ -no-undefined \
-version-info @COGL_LT_CURRENT@:@COGL_LT_REVISION@:@COGL_LT_AGE@ \ -version-info @COGL_LT_CURRENT@:@COGL_LT_REVISION@:@COGL_LT_AGE@ \
-export-dynamic \ -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_profile_trace_message|_cogl_context_get_default|test_|unit_test_).*" -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_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|_cogl_primitive_draw|test_|unit_test_).*"
libcogl_la_SOURCES = $(cogl_sources_c) libcogl_la_SOURCES = $(cogl_sources_c)
nodist_libcogl_la_SOURCES = $(BUILT_SOURCES) nodist_libcogl_la_SOURCES = $(BUILT_SOURCES)
@ -699,6 +657,12 @@ if UNIT_TESTS
Cogl_1_0_gir_LIBS += $(top_builddir)/test-fixtures/libtest-fixtures.la Cogl_1_0_gir_LIBS += $(top_builddir)/test-fixtures/libtest-fixtures.la
endif endif
Cogl_1_0_gir_FILES = $(cogl_1_public_h) cogl-enum-types.h Cogl_1_0_gir_FILES = $(cogl_1_public_h) cogl-enum-types.h
if BUILD_COGL_PATH
Cogl_1_0_gir_FILES += \
$(top_builddir)/cogl-path/cogl-path-enum-types.h \
$(top_srcdir)/cogl-path/cogl-path-types.h \
$(top_srcdir)/cogl-path/cogl1-path-functions.h
endif
Cogl_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_DEP_CFLAGS) -UCOGL_ENABLE_EXPERIMENTAL_API -UCOGL_ENABLE_EXPERIMENTAL_2_0_API Cogl_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_DEP_CFLAGS) -UCOGL_ENABLE_EXPERIMENTAL_API -UCOGL_ENABLE_EXPERIMENTAL_2_0_API
Cogl_1_0_gir_INCLUDES = GL-1.0 GObject-2.0 Cogl_1_0_gir_INCLUDES = GL-1.0 GObject-2.0
Cogl_1_0_gir_EXPORT_PACKAGES = cogl-1.0 Cogl_1_0_gir_EXPORT_PACKAGES = cogl-1.0

View File

@ -37,7 +37,6 @@
#include "cogl-framebuffer-private.h" #include "cogl-framebuffer-private.h"
#include "cogl-journal-private.h" #include "cogl-journal-private.h"
#include "cogl-util.h" #include "cogl-util.h"
#include "cogl-path-private.h"
#include "cogl-matrix-private.h" #include "cogl-matrix-private.h"
#include "cogl-primitives-private.h" #include "cogl-primitives-private.h"
#include "cogl-private.h" #include "cogl-private.h"
@ -249,57 +248,6 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack,
return (CoglClipStack *) entry; return (CoglClipStack *) entry;
} }
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 * CoglClipStack *
_cogl_clip_stack_push_primitive (CoglClipStack *stack, _cogl_clip_stack_push_primitive (CoglClipStack *stack,
CoglPrimitive *primitive, CoglPrimitive *primitive,
@ -378,15 +326,6 @@ _cogl_clip_stack_unref (CoglClipStack *entry)
case COGL_CLIP_STACK_WINDOW_RECT: case COGL_CLIP_STACK_WINDOW_RECT:
g_slice_free1 (sizeof (CoglClipStackWindowRect), entry); g_slice_free1 (sizeof (CoglClipStackWindowRect), entry);
break; 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: case COGL_CLIP_STACK_PRIMITIVE:
{ {
CoglClipStackPrimitive *primitive_entry = CoglClipStackPrimitive *primitive_entry =

View File

@ -24,7 +24,6 @@
#ifndef __COGL_CLIP_STACK_H #ifndef __COGL_CLIP_STACK_H
#define __COGL_CLIP_STACK_H #define __COGL_CLIP_STACK_H
#include "cogl2-path.h"
#include "cogl-matrix.h" #include "cogl-matrix.h"
#include "cogl-primitive.h" #include "cogl-primitive.h"
#include "cogl-framebuffer.h" #include "cogl-framebuffer.h"
@ -41,14 +40,12 @@
typedef struct _CoglClipStack CoglClipStack; typedef struct _CoglClipStack CoglClipStack;
typedef struct _CoglClipStackRect CoglClipStackRect; typedef struct _CoglClipStackRect CoglClipStackRect;
typedef struct _CoglClipStackWindowRect CoglClipStackWindowRect; typedef struct _CoglClipStackWindowRect CoglClipStackWindowRect;
typedef struct _CoglClipStackPath CoglClipStackPath;
typedef struct _CoglClipStackPrimitive CoglClipStackPrimitive; typedef struct _CoglClipStackPrimitive CoglClipStackPrimitive;
typedef enum typedef enum
{ {
COGL_CLIP_STACK_RECT, COGL_CLIP_STACK_RECT,
COGL_CLIP_STACK_WINDOW_RECT, COGL_CLIP_STACK_WINDOW_RECT,
COGL_CLIP_STACK_PATH,
COGL_CLIP_STACK_PRIMITIVE COGL_CLIP_STACK_PRIMITIVE
} CoglClipStackType; } CoglClipStackType;
@ -65,14 +62,14 @@ typedef enum
* CoglClipStack *stack_a = NULL; * 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_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; * CoglClipStack *stack_b = NULL;
* stack_b = cogl_clip_stack_push_window_rectangle (stack_b, ...); * stack_b = cogl_clip_stack_push_window_rectangle (stack_b, ...);
* *
* stack_a * stack_a
* \ holds a ref to * \ holds a ref to
* +-----------+ * +-----------+
* | path node | * | prim node |
* |ref count 1| * |ref count 1|
* +-----------+ * +-----------+
* \ * \
@ -143,16 +140,6 @@ struct _CoglClipStackWindowRect
just adds to the scissor clip */ 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 struct _CoglClipStackPrimitive
{ {
CoglClipStack _parent_data; CoglClipStack _parent_data;
@ -185,13 +172,6 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack,
CoglMatrixEntry *projection_entry, CoglMatrixEntry *projection_entry,
const float *viewport); const float *viewport);
CoglClipStack *
_cogl_clip_stack_push_from_path (CoglClipStack *stack,
CoglPath *path,
CoglMatrixEntry *modelview_entry,
CoglMatrixEntry *projection_entry,
const float *viewport);
CoglClipStack * CoglClipStack *
_cogl_clip_stack_push_primitive (CoglClipStack *stack, _cogl_clip_stack_push_primitive (CoglClipStack *stack,
CoglPrimitive *primitive, CoglPrimitive *primitive,

View File

@ -39,6 +39,7 @@
#include "cogl-matrix-private.h" #include "cogl-matrix-private.h"
#include "cogl-clip-state.h" #include "cogl-clip-state.h"
#include "cogl1-context.h" #include "cogl1-context.h"
#include "cogl-path/cogl-path.h"
void void
cogl_clip_push_window_rectangle (int x_offset, cogl_clip_push_window_rectangle (int x_offset,
@ -83,26 +84,6 @@ cogl_clip_push (float x_offset,
y_offset + height); y_offset + height);
} }
void
cogl_clip_push_from_path_preserve (void)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_framebuffer_push_path_clip (cogl_get_draw_framebuffer (),
ctx->current_path);
}
#undef cogl_clip_push_from_path
void
cogl_clip_push_from_path (void)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_clip_push_from_path_preserve ();
cogl_object_unref (ctx->current_path);
ctx->current_path = cogl2_path_new ();
}
void void
cogl_clip_push_primitive (CoglPrimitive *primitive, cogl_clip_push_primitive (CoglPrimitive *primitive,
float bounds_x1, float bounds_x1,

View File

@ -32,19 +32,6 @@
COGL_BEGIN_DECLS COGL_BEGIN_DECLS
/**
* cogl_clip_push_from_path:
*
* Sets a new clipping area using the current path. The current path
* is then cleared. The clipping area is intersected with the previous
* clipping area. To restore the previous clipping area, call
* cogl_clip_pop().
*
* Since: 1.0
*/
void
cogl_clip_push_from_path (void);
COGL_END_DECLS COGL_END_DECLS
#endif /* __COGL_CLIP_STATE_H */ #endif /* __COGL_CLIP_STATE_H */

View File

@ -53,6 +53,7 @@
#include "cogl-onscreen-private.h" #include "cogl-onscreen-private.h"
#include "cogl-fence-private.h" #include "cogl-fence-private.h"
#include "cogl-poll-private.h" #include "cogl-poll-private.h"
#include "cogl-path/cogl-path-types.h"
typedef struct typedef struct
{ {

View File

@ -44,7 +44,6 @@
#include "cogl-pipeline-opengl-private.h" #include "cogl-pipeline-opengl-private.h"
#include "cogl-framebuffer-private.h" #include "cogl-framebuffer-private.h"
#include "cogl-onscreen-private.h" #include "cogl-onscreen-private.h"
#include "cogl2-path.h"
#include "cogl-attribute-private.h" #include "cogl-attribute-private.h"
#include "cogl1-context.h" #include "cogl1-context.h"
#include "cogl-gpu-info-private.h" #include "cogl-gpu-info-private.h"
@ -378,7 +377,7 @@ cogl_context_new (CoglDisplay *display,
cogl_object_unref (COGL_FRAMEBUFFER (window)); cogl_object_unref (COGL_FRAMEBUFFER (window));
} }
context->current_path = cogl2_path_new (); context->current_path = NULL;
context->stencil_pipeline = cogl_pipeline_new (context); context->stencil_pipeline = cogl_pipeline_new (context);
context->in_begin_gl_block = FALSE; context->in_begin_gl_block = FALSE;

View File

@ -47,7 +47,6 @@
#include "cogl1-context.h" #include "cogl1-context.h"
#include "cogl-private.h" #include "cogl-private.h"
#include "cogl-primitives-private.h" #include "cogl-primitives-private.h"
#include "cogl-path-private.h"
#include "cogl-error-private.h" #include "cogl-error-private.h"
#include "cogl-texture-gl-private.h" #include "cogl-texture-gl-private.h"
@ -1948,36 +1947,6 @@ cogl_framebuffer_push_rectangle_clip (CoglFramebuffer *framebuffer,
COGL_FRAMEBUFFER_STATE_CLIP; COGL_FRAMEBUFFER_STATE_CLIP;
} }
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 void
cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer, cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer,
CoglPrimitive *primitive, CoglPrimitive *primitive,
@ -2603,27 +2572,3 @@ cogl_framebuffer_draw_textured_rectangles (CoglFramebuffer *framebuffer,
n_rectangles, n_rectangles,
TRUE); TRUE);
} }
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);
}

View File

@ -37,12 +37,6 @@
*/ */
typedef struct _CoglFramebuffer CoglFramebuffer; typedef struct _CoglFramebuffer CoglFramebuffer;
#ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API
#include <cogl/cogl2-path.h>
#else
#include <cogl/cogl-path.h>
#endif
#include <cogl/cogl-pipeline.h> #include <cogl/cogl-pipeline.h>
#include <cogl/cogl-indices.h> #include <cogl/cogl-indices.h>
#include <cogl/cogl-bitmap.h> #include <cogl/cogl-bitmap.h>
@ -598,23 +592,6 @@ cogl_framebuffer_push_rectangle_clip (CoglFramebuffer *framebuffer,
float x_2, float x_2,
float y_2); 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: * cogl_framebuffer_push_primitive_clip:
* @framebuffer: A #CoglFramebuffer pointer * @framebuffer: A #CoglFramebuffer pointer
@ -1387,47 +1364,6 @@ cogl_framebuffer_draw_textured_rectangles (CoglFramebuffer *framebuffer,
const float *coordinates, const float *coordinates,
unsigned int n_rectangles); 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 /* XXX: Should we take an n_buffers + buffer id array instead of using
* the CoglBufferBits type which doesn't seem future proof? */ * the CoglBufferBits type which doesn't seem future proof? */
/** /**

View File

@ -64,7 +64,6 @@
* 1.x only api... * 1.x only api...
*/ */
#ifndef COGL_ENABLE_EXPERIMENTAL_2_0_API #ifndef COGL_ENABLE_EXPERIMENTAL_2_0_API
#include <cogl/cogl-path.h>
#include <cogl/cogl-clip-state.h> #include <cogl/cogl-clip-state.h>
#include <cogl/cogl-vertex-buffer.h> #include <cogl/cogl-vertex-buffer.h>
#include <cogl/cogl-enum-types.h> #include <cogl/cogl-enum-types.h>
@ -129,20 +128,22 @@
#include <cogl/cogl-sdl.h> #include <cogl/cogl-sdl.h>
#endif #endif
/*
* 2.0 only api...
*/
#ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API
#include <cogl/cogl2-path.h>
/* This header will be removed in Cogl 1.12 */
#include <cogl/cogl2-compatibility.h>
#endif
/* /*
* API deprecations * API deprecations
*/ */
#include <cogl/cogl-deprecated.h> #include <cogl/cogl-deprecated.h>
/*
* Cogl Path api compatability
*
* The cogl_path_ api used to be part of the core Cogl api so for
* compatability we include cogl-path.h via cogl.h
*/
#if defined (COGL_ENABLE_EXPERIMENTAL_2_0_API) && \
defined (COGL_HAS_COGL_PATH_SUPPORT)
#include <cogl-path/cogl-path.h>
#endif
/** /**
* SECTION:cogl * SECTION:cogl
* @short_description: General purpose API * @short_description: General purpose API

View File

@ -838,21 +838,6 @@ cogl_clip_push_rectangle (float x0,
float y1) float y1)
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_rectangle_clip); COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_rectangle_clip);
/**
* cogl_clip_push_from_path_preserve:
*
* Sets a new clipping area using the current path. The current path
* is then cleared. The clipping area is intersected with the previous
* clipping area. To restore the previous clipping area, call
* cogl_clip_pop().
*
* Since: 1.0
* Deprecated: 1.16: Use cogl_framebuffer_push_path_clip() instead
*/
void
cogl_clip_push_from_path_preserve (void)
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_path_clip);
/** /**
* cogl_clip_push_primitive: * cogl_clip_push_primitive:
* @primitive: A #CoglPrimitive describing a flat 2D shape * @primitive: A #CoglPrimitive describing a flat 2D shape

View File

@ -29,18 +29,11 @@
to maintain ABI compatibility. They will be removed again to maintain ABI compatibility. They will be removed again
immediately once the branch for 1.12.x is created */ immediately once the branch for 1.12.x is created */
#include "cogl2-compatibility.h"
#include "cogl-framebuffer.h" #include "cogl-framebuffer.h"
#include "cogl-framebuffer-private.h" #include "cogl-framebuffer-private.h"
#include "cogl-index-buffer.h" #include "cogl-index-buffer.h"
#include "cogl-pipeline.h" #include "cogl-pipeline.h"
void
cogl_clip_push_from_path (CoglPath *path)
{
cogl_framebuffer_push_path_clip (cogl_get_draw_framebuffer (), path);
}
/* These were never declared in a public header so we might as well /* These were never declared in a public header so we might as well
keep it that way. The declarations here are just to avoid a keep it that way. The declarations here are just to avoid a
warning */ warning */

View File

@ -1,58 +0,0 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2012 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef __COGL2_COMPATIBILITY_H__
#define __COGL2_COMPATIBILITY_H__
#include <cogl/cogl-types.h>
#include <cogl/cogl2-path.h>
#include <cogl/cogl-macros.h>
COGL_BEGIN_DECLS
#define cogl_clip_push_from_path cogl2_clip_push_from_path
/**
* cogl_clip_push_from_path:
* @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
* call cogl_clip_pop().
*
* Since: 1.8
* Stability: Unstable
* Deprecated: 1.16: Use cogl_framebuffer_push_path_clip() instead
*/
void
cogl_clip_push_from_path (CoglPath *path)
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_path_clip);
COGL_END_DECLS
#endif /* __COGL2_COMPATIBILITY_H__ */

View File

@ -33,7 +33,6 @@
#include "cogl-util-gl-private.h" #include "cogl-util-gl-private.h"
#include "cogl-primitives-private.h" #include "cogl-primitives-private.h"
#include "cogl-pipeline-opengl-private.h" #include "cogl-pipeline-opengl-private.h"
#include "cogl-path-private.h"
#include "cogl-clip-stack-gl-private.h" #include "cogl-clip-stack-gl-private.h"
#include "cogl-primitive-private.h" #include "cogl-primitive-private.h"
@ -361,41 +360,6 @@ add_stencil_clip_silhouette (CoglFramebuffer *framebuffer,
GE (ctx, glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP)); GE (ctx, glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP));
} }
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 static void
paint_primitive_silhouette (CoglFramebuffer *framebuffer, paint_primitive_silhouette (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline, CoglPipeline *pipeline,
@ -578,21 +542,6 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack,
{ {
switch (entry->type) 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: case COGL_CLIP_STACK_PRIMITIVE:
{ {
CoglClipStackPrimitive *primitive_entry = CoglClipStackPrimitive *primitive_entry =

View File

@ -536,6 +536,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 ============================================================
dnl Choose image loading backend dnl Choose image loading backend
@ -1273,6 +1288,8 @@ AS_IF([test "x$enable_cogl_pango" = "xyes"],
) )
AM_CONDITIONAL([BUILD_COGL_PANGO], [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) AC_SUBST(COGL_GST_PKG_REQUIRES)
AS_IF([test "x$enable_cogl_gst" = "xyes"], AS_IF([test "x$enable_cogl_gst" = "xyes"],
@ -1451,6 +1468,7 @@ cogl-pango/Makefile
cogl-pango/cogl-pango-1.0.pc cogl-pango/cogl-pango-1.0.pc
cogl-pango/cogl-pango-2.0-experimental.pc cogl-pango/cogl-pango-2.0-experimental.pc
cogl-pango/cogl-pango.rc cogl-pango/cogl-pango.rc
cogl-path/Makefile
cogl-gst/Makefile cogl-gst/Makefile
cogl-gst/cogl-gst.pc cogl-gst/cogl-gst.pc
cogl-gles2/Makefile cogl-gles2/Makefile
@ -1509,13 +1527,14 @@ echo " Building for emscripten environment: $enable_emscripten"
echo " Build libcogl-gles2 GLES 2.0 frontend api: ${enable_cogl_gles2}" echo " Build libcogl-gles2 GLES 2.0 frontend api: ${enable_cogl_gles2}"
echo " Image backend: ${COGL_IMAGE_BACKEND}" echo " Image backend: ${COGL_IMAGE_BACKEND}"
echo " Cogl Pango: ${enable_cogl_pango}" echo " Cogl Pango: ${enable_cogl_pango}"
echo " Profiling: ${enable_profile}" echo " Cogl Gstreamer: ${enable_cogl_gst}"
echo " CoglGst: ${enable_cogl_gst}" echo " Cogl Path: ${enable_cogl_path}"
# Compiler/Debug related flags # Compiler/Debug related flags
echo "" echo ""
echo " • Compiler options:" echo " • Build options:"
echo " Cogl debug: ${enable_debug}" echo " Debugging: ${enable_debug}"
echo " Profiling: ${enable_profile}"
echo " Enable deprecated symbols: ${enable_deprecated}" echo " Enable deprecated symbols: ${enable_deprecated}"
echo " Compiler flags: ${CFLAGS} ${COGL_EXTRA_CFLAGS}" echo " Compiler flags: ${CFLAGS} ${COGL_EXTRA_CFLAGS}"
echo " Linker flags: ${LDFLAGS} ${COGL_EXTRA_LDFLAGS}" echo " Linker flags: ${LDFLAGS} ${COGL_EXTRA_LDFLAGS}"

View File

@ -33,7 +33,6 @@ test_sources = \
test-color-mask.c \ test-color-mask.c \
test-backface-culling.c \ test-backface-culling.c \
test-just-vertex-shader.c \ test-just-vertex-shader.c \
test-path.c \
test-pipeline-user-matrix.c \ test-pipeline-user-matrix.c \
test-pipeline-uniforms.c \ test-pipeline-uniforms.c \
test-pixel-buffer.c \ test-pixel-buffer.c \
@ -75,6 +74,10 @@ if !USING_EMSCRIPTEN
test_sources += test-fence.c test_sources += test-fence.c
endif endif
if BUILD_COGL_PATH
test_sources += test-path.c
endif
test_conformance_SOURCES = $(common_sources) $(test_sources) test_conformance_SOURCES = $(common_sources) $(test_sources)
if OS_WIN32 if OS_WIN32
@ -145,6 +148,9 @@ test_conformance_LDADD = \
if !USE_GLIB if !USE_GLIB
test_conformance_LDADD += $(top_builddir)/deps/glib/libglib.la test_conformance_LDADD += $(top_builddir)/deps/glib/libglib.la
endif endif
if BUILD_COGL_PATH
test_conformance_LDADD += $(top_builddir)/cogl-path/libcogl-path.la
endif
test_conformance_LDFLAGS = -export-dynamic test_conformance_LDFLAGS = -export-dynamic
test: wrappers test: wrappers

View File

@ -57,7 +57,9 @@ main (int argc, char **argv)
ADD_TEST (test_blend, 0, 0); ADD_TEST (test_blend, 0, 0);
ADD_TEST (test_premult, 0, 0); ADD_TEST (test_premult, 0, 0);
UNPORTED_TEST (test_readpixels); UNPORTED_TEST (test_readpixels);
#ifdef COGL_HAS_COGL_PATH_SUPPORT
ADD_TEST (test_path, 0, 0); ADD_TEST (test_path, 0, 0);
#endif
ADD_TEST (test_depth_test, 0, 0); ADD_TEST (test_depth_test, 0, 0);
ADD_TEST (test_color_mask, 0, 0); ADD_TEST (test_color_mask, 0, 0);
ADD_TEST (test_backface_culling, 0, TEST_REQUIREMENT_NPOT); ADD_TEST (test_backface_culling, 0, TEST_REQUIREMENT_NPOT);

View File

@ -1,4 +1,6 @@
#define COGL_ENABLE_EXPERIMENTAL_2_0_API
#include <cogl/cogl.h> #include <cogl/cogl.h>
#include <cogl-path/cogl-path.h>
#include <string.h> #include <string.h>
@ -20,7 +22,9 @@ draw_path_at (CoglPath *path, CoglPipeline *pipeline, int x, int y)
cogl_framebuffer_push_matrix (test_fb); cogl_framebuffer_push_matrix (test_fb);
cogl_framebuffer_translate (test_fb, x * BLOCK_SIZE, y * BLOCK_SIZE, 0.0f); cogl_framebuffer_translate (test_fb, x * BLOCK_SIZE, y * BLOCK_SIZE, 0.0f);
cogl_framebuffer_fill_path (test_fb, pipeline, path); cogl_set_framebuffer (test_fb);
cogl_set_source (pipeline);
cogl_path_fill (path);
cogl_framebuffer_pop_matrix (test_fb); cogl_framebuffer_pop_matrix (test_fb);
} }
@ -73,18 +77,18 @@ paint (TestState *state)
/* Create a path filling just a quarter of a block. It will use two /* Create a path filling just a quarter of a block. It will use two
rectangles so that we have a sub path in the path */ rectangles so that we have a sub path in the path */
cogl_path_new (); path_a = cogl_path_new ();
cogl_path_rectangle (BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2, cogl_path_rectangle (path_a,
BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2,
BLOCK_SIZE, BLOCK_SIZE); BLOCK_SIZE, BLOCK_SIZE);
cogl_path_rectangle (BLOCK_SIZE / 2, BLOCK_SIZE / 2, cogl_path_rectangle (path_a,
BLOCK_SIZE / 2, BLOCK_SIZE / 2,
BLOCK_SIZE * 3 / 4, BLOCK_SIZE); BLOCK_SIZE * 3 / 4, BLOCK_SIZE);
path_a = cogl_object_ref (cogl_get_path ());
draw_path_at (path_a, white, 0, 0); draw_path_at (path_a, white, 0, 0);
/* Create another path filling the whole block */ /* Create another path filling the whole block */
cogl_path_new (); path_b = cogl_path_new ();
cogl_path_rectangle (0, 0, BLOCK_SIZE, BLOCK_SIZE); cogl_path_rectangle (path_b, 0, 0, BLOCK_SIZE, BLOCK_SIZE);
path_b = cogl_object_ref (cogl_get_path ());
draw_path_at (path_b, white, 1, 0); draw_path_at (path_b, white, 1, 0);
/* Draw the first path again */ /* Draw the first path again */
@ -97,11 +101,10 @@ paint (TestState *state)
/* Add another rectangle to path a. We'll use line_to's instead of /* Add another rectangle to path a. We'll use line_to's instead of
cogl_rectangle so that we don't create another sub-path because cogl_rectangle so that we don't create another sub-path because
that is more likely to break the copy */ that is more likely to break the copy */
cogl_set_path (path_a); cogl_path_line_to (path_a, 0, BLOCK_SIZE / 2);
cogl_path_line_to (0, BLOCK_SIZE / 2); cogl_path_line_to (path_a, 0, 0);
cogl_path_line_to (0, 0); cogl_path_line_to (path_a, BLOCK_SIZE / 2, 0);
cogl_path_line_to (BLOCK_SIZE / 2, 0); cogl_path_line_to (path_a, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2);
draw_path_at (path_a, white, 4, 0); draw_path_at (path_a, white, 4, 0);
/* Draw the copy again. It should not have changed */ /* Draw the copy again. It should not have changed */
@ -110,16 +113,15 @@ paint (TestState *state)
/* Add another rectangle to path c. It will be added in two halves, /* Add another rectangle to path c. It will be added in two halves,
one as an extension of the previous path and the other as a new one as an extension of the previous path and the other as a new
sub path */ sub path */
cogl_set_path (path_c); cogl_path_line_to (path_c, BLOCK_SIZE / 2, 0);
cogl_path_line_to (BLOCK_SIZE / 2, 0); cogl_path_line_to (path_c, BLOCK_SIZE * 3 / 4, 0);
cogl_path_line_to (BLOCK_SIZE * 3 / 4, 0); cogl_path_line_to (path_c, BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2);
cogl_path_line_to (BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2); cogl_path_line_to (path_c, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2); cogl_path_rectangle (path_c,
cogl_path_rectangle (BLOCK_SIZE * 3 / 4, 0, BLOCK_SIZE, BLOCK_SIZE / 2); BLOCK_SIZE * 3 / 4, 0, BLOCK_SIZE, BLOCK_SIZE / 2);
draw_path_at (path_c, white, 6, 0); draw_path_at (path_c, white, 6, 0);
/* Draw the original path again. It should not have changed */ /* Draw the original path again. It should not have changed */
cogl_set_path (path_a);
draw_path_at (path_a, white, 7, 0); draw_path_at (path_a, white, 7, 0);
cogl_object_unref (path_a); cogl_object_unref (path_a);
@ -128,51 +130,48 @@ paint (TestState *state)
/* Draw a self-intersecting path. The part that intersects should be /* Draw a self-intersecting path. The part that intersects should be
inverted */ inverted */
cogl_path_new (); path_a = cogl_path_new ();
cogl_path_rectangle (0, 0, BLOCK_SIZE, BLOCK_SIZE); cogl_path_rectangle (path_a, 0, 0, BLOCK_SIZE, BLOCK_SIZE);
cogl_path_line_to (0, BLOCK_SIZE / 2); cogl_path_line_to (path_a, 0, BLOCK_SIZE / 2);
cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2); cogl_path_line_to (path_a, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
cogl_path_line_to (BLOCK_SIZE / 2, 0); cogl_path_line_to (path_a, BLOCK_SIZE / 2, 0);
cogl_path_close (); cogl_path_close (path_a);
path_a = cogl_object_ref (cogl_get_path ());
draw_path_at (path_a, white, 8, 0); draw_path_at (path_a, white, 8, 0);
cogl_object_unref (path_a); cogl_object_unref (path_a);
/* Draw two sub paths. Where the paths intersect it should be /* Draw two sub paths. Where the paths intersect it should be
inverted */ inverted */
cogl_path_new (); path_a = cogl_path_new ();
cogl_path_rectangle (0, 0, BLOCK_SIZE, BLOCK_SIZE); cogl_path_rectangle (path_a, 0, 0, BLOCK_SIZE, BLOCK_SIZE);
cogl_path_rectangle (BLOCK_SIZE / 2, BLOCK_SIZE / 2, BLOCK_SIZE, BLOCK_SIZE); cogl_path_rectangle (path_a,
path_a = cogl_object_ref (cogl_get_path ()); BLOCK_SIZE / 2, BLOCK_SIZE / 2, BLOCK_SIZE, BLOCK_SIZE);
draw_path_at (path_a, white, 9, 0); draw_path_at (path_a, white, 9, 0);
cogl_object_unref (path_a); cogl_object_unref (path_a);
/* Draw a clockwise outer path */ /* Draw a clockwise outer path */
cogl_path_new (); path_a = cogl_path_new ();
cogl_path_move_to (0, 0); cogl_path_move_to (path_a, 0, 0);
cogl_path_line_to (BLOCK_SIZE, 0); cogl_path_line_to (path_a, BLOCK_SIZE, 0);
cogl_path_line_to (BLOCK_SIZE, BLOCK_SIZE); cogl_path_line_to (path_a, BLOCK_SIZE, BLOCK_SIZE);
cogl_path_line_to (0, BLOCK_SIZE); cogl_path_line_to (path_a, 0, BLOCK_SIZE);
cogl_path_close (); cogl_path_close (path_a);
/* Add a clockwise sub path in the upper left quadrant */ /* Add a clockwise sub path in the upper left quadrant */
cogl_path_move_to (0, 0); cogl_path_move_to (path_a, 0, 0);
cogl_path_line_to (BLOCK_SIZE / 2, 0); cogl_path_line_to (path_a, BLOCK_SIZE / 2, 0);
cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2); cogl_path_line_to (path_a, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
cogl_path_line_to (0, BLOCK_SIZE / 2); cogl_path_line_to (path_a, 0, BLOCK_SIZE / 2);
cogl_path_close (); cogl_path_close (path_a);
/* Add a counter-clockwise sub path in the upper right quadrant */ /* Add a counter-clockwise sub path in the upper right quadrant */
cogl_path_move_to (BLOCK_SIZE / 2, 0); cogl_path_move_to (path_a, BLOCK_SIZE / 2, 0);
cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2); cogl_path_line_to (path_a, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
cogl_path_line_to (BLOCK_SIZE, BLOCK_SIZE / 2); cogl_path_line_to (path_a, BLOCK_SIZE, BLOCK_SIZE / 2);
cogl_path_line_to (BLOCK_SIZE, 0); cogl_path_line_to (path_a, BLOCK_SIZE, 0);
cogl_path_close (); cogl_path_close (path_a);
/* Retain the path for the next test */ /* Retain the path for the next test */
path_a = cogl_object_ref (cogl_get_path ());
draw_path_at (path_a, white, 10, 0); draw_path_at (path_a, white, 10, 0);
/* Draw the same path again with the other fill rule */ /* Draw the same path again with the other fill rule */
cogl_set_path (path_a); cogl_path_set_fill_rule (path_a, COGL_PATH_FILL_RULE_NON_ZERO);
cogl_path_set_fill_rule (COGL_PATH_FILL_RULE_NON_ZERO);
draw_path_at (path_a, white, 11, 0); draw_path_at (path_a, white, 11, 0);
cogl_object_unref (path_a); cogl_object_unref (path_a);