aboutsummaryrefslogtreecommitdiff
path: root/generic/Arc.c
diff options
context:
space:
mode:
authorlecoanet2002-12-09 14:27:35 +0000
committerlecoanet2002-12-09 14:27:35 +0000
commit5de4aad21f265022dd3cf9352eca9c6cc40a16ad (patch)
tree772c076794c8ddb10bc786b7906609f7e8c5e69f /generic/Arc.c
parentfe6df269930a79ef5deea1bd3cc42104ab5b715b (diff)
downloadtkzinc-5de4aad21f265022dd3cf9352eca9c6cc40a16ad.zip
tkzinc-5de4aad21f265022dd3cf9352eca9c6cc40a16ad.tar.gz
tkzinc-5de4aad21f265022dd3cf9352eca9c6cc40a16ad.tar.bz2
tkzinc-5de4aad21f265022dd3cf9352eca9c6cc40a16ad.tar.xz
* Utilisation de la routine ZnParseCoordList pour initialiser
Les coordonn�es (incompatibilit�s). * Remaniement du code des gradients (incompatibilit�s). * Utilisation des display lists pour am�liorer les perfs en GL. * Adaptation pour g�rer la nouvelle fa�on de traiter les contours.
Diffstat (limited to 'generic/Arc.c')
-rw-r--r--generic/Arc.c142
1 files changed, 74 insertions, 68 deletions
diff --git a/generic/Arc.c b/generic/Arc.c
index 155bc06..080d57f 100644
--- a/generic/Arc.c
+++ b/generic/Arc.c
@@ -33,8 +33,9 @@
#include "Geo.h"
#include "Draw.h"
#include "Types.h"
-#include "WidgetInfo.h"
#include "Image.h"
+#include "WidgetInfo.h"
+#include "tkZinc.h"
static const char rcsid[] = "$Id$";
@@ -160,8 +161,8 @@ Init(Item item,
{
WidgetInfo *wi = item->wi;
ArcItem arc = (ArcItem) item;
- Tcl_Obj **elems;
- int num_elems;
+ int num_points;
+ ZnPoint *points;
/* Init attributes */
SET(item->flags, VISIBLE_BIT);
@@ -190,15 +191,15 @@ Init(Item item,
Tcl_AppendResult(wi->interp, " arc coords expected", NULL);
return ZN_ERROR;
}
- if ((Tcl_ListObjGetElements(wi->interp, (*args)[0], &num_elems, &elems) == ZN_ERROR) ||
- (num_elems != 4) ||
- (Tcl_GetDoubleFromObj(wi->interp, elems[0], &arc->coords[0].x) == ZN_ERROR) ||
- (Tcl_GetDoubleFromObj(wi->interp, elems[1], &arc->coords[0].y) == ZN_ERROR) ||
- (Tcl_GetDoubleFromObj(wi->interp, elems[2], &arc->coords[1].x) == ZN_ERROR) ||
- (Tcl_GetDoubleFromObj(wi->interp, elems[3], &arc->coords[1].y) == ZN_ERROR)) {
+ if (ZnParseCoordList(wi, (*args)[0], &points, NULL, &num_points) == ZN_ERROR) {
+ return ZN_ERROR;
+ }
+ if (num_points != 2) {
Tcl_AppendResult(wi->interp, " malformed arc coords", NULL);
return ZN_ERROR;
};
+ arc->coords[0] = points[0];
+ arc->coords[1] = points[1];
(*args)++;
(*argc)--;
@@ -538,11 +539,12 @@ ComputeCoordinates(Item item,
AddPointsToBBox(&item->item_bounding_box, end_points, LINE_END_POINTS);
}
+#ifdef GLX
if (!ZnGradientFlat(arc->fill_color)) {
ZnPoly shape;
if (!arc->grad_geo) {
- arc->grad_geo = ZnMalloc(4*sizeof(ZnPoint));
+ arc->grad_geo = ZnMalloc(6*sizeof(ZnPoint));
}
if (arc->fill_color->type == ZN_AXIAL_GRADIENT) {
ZnPoint p[4];
@@ -553,19 +555,16 @@ ComputeCoordinates(Item item,
p[1].y = p[0].y;
p[3].x = p[0].x;
p[3].y = p[2].y;
- POLY_CONTOUR1(&shape, p, 4);
- ZnComputeAxialGradient(wi, &shape, arc->fill_color->g.angle,
- arc->grad_geo);
+ POLY_CONTOUR1(&shape, p, 4, False);
+ ZnComputeAxialGradient(wi, &shape, arc->fill_color->g.angle, arc->grad_geo);
}
else if (arc->fill_color->type == ZN_RADIAL_GRADIENT) {
- POLY_CONTOUR1(&shape, ZnListArray(arc->render_shape),
- ZnListSize(arc->render_shape));
- ZnComputeRadialGradient(wi, &shape, &item->item_bounding_box,
- &arc->fill_color->g.p, arc->grad_geo);
+ POLY_CONTOUR1(&shape, arc->coords, 2, False);
+ ZnComputeRadialGradient(wi, &shape, True, &arc->fill_color->g.p, arc->grad_geo);
}
else if (arc->fill_color->type == ZN_PATH_GRADIENT) {
- ZnTransformPoint(wi->current_transfo, &arc->fill_color->g.p,
- &arc->grad_geo[0]);
+ POLY_CONTOUR1(&shape, arc->coords, 2, False);
+ ZnComputePathGradient(wi, &shape, &arc->fill_color->g.p, arc->grad_geo);
}
}
else {
@@ -574,7 +573,7 @@ ComputeCoordinates(Item item,
arc->grad_geo = NULL;
}
}
-
+#endif
return;
}
@@ -1208,60 +1207,68 @@ Render(Item item)
return;
}
- /* Fill if requested */
- if (ISSET(arc->flags, FILLED_BIT)) {
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-
- if (!ZnGradientFlat(arc->fill_color)) {
- ZnPoly poly;
-
- POLY_CONTOUR1(&poly, ZnListArray(arc->render_shape),
- ZnListSize(arc->render_shape));
- ZnRenderGradient(wi, arc->fill_color,ArcRenderCB, arc,
- arc->grad_geo, &poly);
- }
- else if (arc->tile != ZnUnspecifiedImage) { /* Fill tiled */
- ZnRenderTile(wi, arc->tile, arc->fill_color, ArcRenderCB, arc,
- (ZnPoint *) &item->item_bounding_box);
- }
- else {
- if (arc->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
- /*
- * Setup polygon stippling.
- */
- glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(ZnImagePattern(arc->fill_pattern, NULL));
+ if (!item->gl_list) {
+ item->gl_list = glGenLists(1);
+ glNewList(item->gl_list, GL_COMPILE);
+
+ /* Fill if requested */
+ if (ISSET(arc->flags, FILLED_BIT)) {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+ if (!ZnGradientFlat(arc->fill_color)) {
+ ZnPoly poly;
+
+ POLY_CONTOUR1(&poly, ZnListArray(arc->render_shape),
+ ZnListSize(arc->render_shape), False);
+ ZnRenderGradient(wi, arc->fill_color, ArcRenderCB, arc,
+ arc->grad_geo, &poly);
+ }
+ else if (arc->tile != ZnUnspecifiedImage) { /* Fill tiled */
+ ZnRenderTile(wi, arc->tile, arc->fill_color, ArcRenderCB, arc,
+ (ZnPoint *) &item->item_bounding_box);
+ }
+ else {
+ if (arc->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
+ /*
+ * Setup polygon stippling.
+ */
+ glEnable(GL_POLYGON_STIPPLE);
+ glPolygonStipple(ZnImagePattern(arc->fill_pattern, NULL));
+ }
+ color = ZnGetGradientColor(arc->fill_color, 0.0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
+ ArcRenderCB(arc);
+ glDisable(GL_POLYGON_STIPPLE);
}
- color = ZnGetGradientColor(arc->fill_color, 0.0, &alpha);
- alpha = ZnComposeAlpha(alpha, wi->alpha);
- glColor4us(color->red, color->green, color->blue, alpha);
- ArcRenderCB(arc);
- glDisable(GL_POLYGON_STIPPLE);
}
- }
-
- /*
- * Draw the arc.
- */
- if (arc->line_width) {
- ZnLineEnd first = ISSET(arc->flags, FIRST_END_OK) ? arc->first_end : NULL;
- ZnLineEnd last = ISSET(arc->flags, LAST_END_OK) ? arc->last_end : NULL;
- ZnBool closed = ISSET(arc->flags, CLOSED_BIT);
- p = ZnListArray(arc->render_shape);
- num_points = ZnListSize(arc->render_shape);
- if (!closed) {
- if (arc->angle_extent != 360) {
- num_points--;
- if (ISSET(arc->flags, PIE_SLICE_BIT)) {
+ /*
+ * Draw the arc.
+ */
+ if (arc->line_width) {
+ ZnLineEnd first = ISSET(arc->flags, FIRST_END_OK) ? arc->first_end : NULL;
+ ZnLineEnd last = ISSET(arc->flags, LAST_END_OK) ? arc->last_end : NULL;
+ ZnBool closed = ISSET(arc->flags, CLOSED_BIT);
+
+ p = ZnListArray(arc->render_shape);
+ num_points = ZnListSize(arc->render_shape);
+ if (!closed) {
+ if (arc->angle_extent != 360) {
num_points--;
+ if (ISSET(arc->flags, PIE_SLICE_BIT)) {
+ num_points--;
+ }
}
}
+ ZnRenderPolyline(wi, p, num_points, arc->line_width,
+ arc->line_style, CapRound, JoinRound, first, last,
+ arc->line_color);
}
- ZnRenderPolyline(wi, p, num_points, arc->line_width,
- arc->line_style, CapRound, JoinRound, first, last,
- arc->line_color);
+ glEndList();
}
+
+ glCallList(item->gl_list);
#endif
}
@@ -1639,8 +1646,7 @@ GetContours(Item item,
}
POLY_CONTOUR1(poly, ZnListArray(arc->render_shape),
- ZnListSize(arc->render_shape));
- poly->contour1.cw = 1;
+ ZnListSize(arc->render_shape), True);
poly->contour1.controls = NULL;
return False;