Please find along with this email the patch. It does not provide gles routines.
Regards
Rno
On Tue, Oct 21, 2008 at 1:51 PM, Arnaud VALLAT <[EMAIL PROTECTED]> wrote:
> By the way, why Cogl Path does not handle line width?
>
> Rno
> --
>
> "Given enough eyeballs, all bugs are shallow"
> Eric Steven Raymond
>
--
"Given enough eyeballs, all bugs are shallow"
Eric Steven Raymond
Index: clutter/cogl/gl/cogl-primitives.c
===================================================================
--- clutter/cogl/gl/cogl-primitives.c (revision 3376)
+++ clutter/cogl/gl/cogl-primitives.c (working copy)
@@ -30,11 +30,14 @@
#include "cogl.h"
#include "cogl-internal.h"
#include "cogl-context.h"
+#include "cogl-texture.h"
#include "cogl-clip-stack.h"
#include <string.h>
#include <gmodule.h>
+#include <stdio.h>
+
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16
void
@@ -155,6 +158,7 @@
| (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0));
GE( glVertexPointer (2, GL_FLOAT, 0, ctx->path_nodes) );
+
GE( glDrawArrays (GL_TRIANGLE_FAN, 0, ctx->path_nodes_size) );
GE( glStencilMask (~(GLuint) 0) );
@@ -175,3 +179,99 @@
/* Rebuild the stencil clip */
_cogl_clip_stack_rebuild (TRUE);
}
+
+static void
+_cogl_path_nodes_build_tex_coords (CoglFloatVec2 **tex_coords)
+{
+ guint count;
+ guint w;
+ guint h;
+ gfloat min_x;
+ gfloat min_y;
+
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+ w = CLUTTER_FIXED_FLOOR (ctx->path_nodes_max.x - ctx->path_nodes_min.x);
+ h = CLUTTER_FIXED_FLOOR (ctx->path_nodes_max.y - ctx->path_nodes_min.y);
+
+ *tex_coords = (CoglFloatVec2 *)g_malloc (sizeof(CoglFloatVec2) * ctx->path_nodes_size);
+ if (!*tex_coords)
+ return;
+
+ min_x = CLUTTER_FIXED_TO_FLOAT(ctx->path_nodes_min.x);
+ min_y = CLUTTER_FIXED_TO_FLOAT(ctx->path_nodes_min.y);
+
+ for (count = 0; count < ctx->path_nodes_size; ++count)
+ {
+ (*tex_coords)[count].x = (ctx->path_nodes[count].x - min_x) / w;
+ (*tex_coords)[count].y = (ctx->path_nodes[count].y - min_y) / h;
+ }
+}
+
+void
+_cogl_path_stroke_nodes_with_texture (CoglTexture *tex)
+{
+ GLuint gl_handle;
+ CoglFloatVec2 *tex_coords;
+
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+ cogl_enable (COGL_ENABLE_VERTEX_ARRAY |
+ COGL_ENABLE_TEXTURE_2D |
+ COGL_ENABLE_TEXCOORD_ARRAY |
+ COGL_ENABLE_BLEND);
+
+ _cogl_path_nodes_build_tex_coords (&tex_coords);
+ if (!tex_coords)
+ return;
+
+ GE( glActiveTextureARB (GL_TEXTURE0_ARB) );
+ gl_handle = g_array_index (tex->slice_gl_handles, GLuint, 0);
+ GE( glBindTexture (tex->gl_target, gl_handle) );
+ GE( glTexCoordPointer (2, GL_FLOAT, 0, tex_coords) );
+
+ GE( glVertexPointer (2, GL_FLOAT, 0, ctx->path_nodes) );
+ GE( glDrawArrays (GL_LINE_STRIP, 0, ctx->path_nodes_size) );
+
+ g_free (tex_coords);
+}
+
+void
+_cogl_path_fill_nodes_with_texture (CoglTexture *tex)
+{
+ GLuint gl_handle;
+ CoglFloatVec2 *tex_coords;
+
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+ cogl_enable (COGL_ENABLE_VERTEX_ARRAY |
+ COGL_ENABLE_TEXTURE_2D |
+ COGL_ENABLE_TEXCOORD_ARRAY |
+ COGL_ENABLE_BLEND);
+
+ _cogl_path_nodes_build_tex_coords (&tex_coords);
+ if (!tex_coords)
+ return;
+
+ GE( glActiveTextureARB (GL_TEXTURE0_ARB) );
+ gl_handle = g_array_index (tex->slice_gl_handles, GLuint, 0);
+ GE( glBindTexture (tex->gl_target, gl_handle) );
+ GE( glTexCoordPointer (2, GL_FLOAT, 0, tex_coords) );
+
+ GE( glVertexPointer (2, GL_FLOAT, 0, ctx->path_nodes) );
+ GE( glDrawArrays (GL_TRIANGLE_FAN, 0, ctx->path_nodes_size) );
+
+ g_free (tex_coords);
+}
+
+void
+_cogl_path_fill_nodes2 (int mode)
+{
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+ cogl_enable (COGL_ENABLE_VERTEX_ARRAY |
+ (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0));
+
+ GE( glVertexPointer (2, GL_FLOAT, 0, ctx->path_nodes) );
+ GE( glDrawArrays (mode, 0, ctx->path_nodes_size) );
+}
Index: clutter/cogl/common/cogl-primitives.c
===================================================================
--- clutter/cogl/common/cogl-primitives.c (revision 3376)
+++ clutter/cogl/common/cogl-primitives.c (working copy)
@@ -30,6 +30,7 @@
#include "cogl.h"
#include "cogl-internal.h"
#include "cogl-context.h"
+#include "cogl-texture.h"
#include <string.h>
#include <gmodule.h>
@@ -42,6 +43,8 @@
ClutterFixed y);
void _cogl_path_fill_nodes ();
void _cogl_path_stroke_nodes ();
+void _cogl_path_fill_nodes_with_texture ();
+void _cogl_path_stroke_nodes_with_texture ();
void _cogl_rectangle (gint x,
gint y,
guint width,
@@ -92,6 +95,40 @@
}
void
+cogl_path_fill_with_texture (CoglHandle *tex)
+{
+ CoglTexture *internal_tex;
+
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+ if (ctx->path_nodes_size == 0 || tex == NULL)
+ return;
+
+ internal_tex = _cogl_texture_pointer_from_handle (tex);
+ if (internal_tex == NULL)
+ return;
+
+ _cogl_path_fill_nodes_with_texture (internal_tex);
+}
+
+void
+cogl_path_stroke_with_texture (CoglHandle *tex)
+{
+ CoglTexture *internal_tex;
+
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+ if (ctx->path_nodes_size == 0 || tex == NULL)
+ return;
+
+ internal_tex = _cogl_texture_pointer_from_handle (tex);
+ if (internal_tex == NULL)
+ return;
+
+ _cogl_path_stroke_nodes_with_texture (internal_tex);
+}
+
+void
cogl_path_move_to (ClutterFixed x,
ClutterFixed y)
{