From fb188f65b156389c5728e0927dbcf7a063ef57ee Mon Sep 17 00:00:00 2001 From: lecoanet Date: Mon, 16 Jun 2003 14:48:45 +0000 Subject: Simplified the grdient prep/drawing interface. Use of the new ZnGetGradientPixel function in X. Added an optimized case for tile filed rectangles when they are aligned with the pixel matrix (openGL). This can dramatically boost performances on some applications. --- generic/Rectangle.c | 55 ++++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'generic') diff --git a/generic/Rectangle.c b/generic/Rectangle.c index bcb7db5..ea0bb7b 100644 --- a/generic/Rectangle.c +++ b/generic/Rectangle.c @@ -356,49 +356,39 @@ ComputeCoordinates(ZnItem item, delta = ABS(delta); aligned |= delta < X_PRECISION_LIMIT; ASSIGN(rect->flags, ALIGNED_BIT, aligned); - + #ifdef GL /* * Compute the gradient geometry */ if (!ZnGradientFlat(rect->fill_color)) { ZnPoly shape; - - if (rect->fill_color->type == ZN_AXIAL_GRADIENT) { - int angle = rect->fill_color->g.angle; - + + if (rect->fill_color->type == ZN_AXIAL_GRADIENT) { + int angle = rect->fill_color->angle; + if ((angle != 0) && (angle != 90) && (angle != 180) && (angle != 270)) { if (!rect->grad_geo) { rect->grad_geo = ZnMalloc(6*sizeof(ZnPoint)); } ZnPolyContour1(&shape, p, 4, False); - ZnComputeAxialGradient(wi, &shape, (ZnReal) angle, rect->grad_geo); + ZnComputeGradient(rect->fill_color, wi, &shape, rect->grad_geo); } else { goto free_ggeo; } - } - else if (rect->fill_color->type == ZN_RADIAL_GRADIENT) { - ZnPoint pp[4]; + else { if (!rect->grad_geo) { rect->grad_geo = ZnMalloc(6*sizeof(ZnPoint)); } - pp[0] = rect->coords[0]; - pp[2] = rect->coords[1]; - pp[1].x = pp[2].x; - pp[1].y = pp[0].y; - pp[3].x = pp[0].x; - pp[3].y = pp[2].y; - ZnPolyContour1(&shape, pp, 4, False); - ZnComputeRadialGradient(wi, &shape, False, &rect->fill_color->g.p, rect->grad_geo); - } - else if (rect->fill_color->type == ZN_PATH_GRADIENT) { - if (!rect->grad_geo) { - rect->grad_geo = ZnMalloc(6*sizeof(ZnPoint)); + if (rect->fill_color->type == ZN_PATH_GRADIENT) { + ZnPolyContour1(&shape, rect->coords, 2, False); } - ZnPolyContour1(&shape, rect->coords, 2, False); - ZnComputePathGradient(wi, &shape, &rect->fill_color->g.p, rect->grad_geo); + else { + ZnPolyContour1(&shape, p, 4, False); + } + ZnComputeGradient(rect->fill_color, wi, &shape, rect->grad_geo); } } else { @@ -497,7 +487,7 @@ Draw(ZnItem item) * Fill if requested. */ if (ISSET(rect->flags, FILLED_BIT)) { - values.foreground = ZnPixel(ZnGetGradientColor(rect->fill_color, 0.0, NULL)); + values.foreground = ZnGetGradientPixel(rect->fill_color, 0.0); if (rect->tile != ZnUnspecifiedImage) { if (!ZnImageIsBitmap(rect->tile)) { /* Fill tiled */ values.fill_style = FillTiled; @@ -563,7 +553,7 @@ Draw(ZnItem item) else { ZnSetLineStyle(wi, rect->line_style); gc_mask = GCFillStyle|GCLineWidth|GCForeground|GCJoinStyle; - values.foreground = ZnPixel(ZnGetGradientColor(rect->line_color, 0.0, NULL)); + values.foreground = ZnGetGradientPixel(rect->line_color, 0.0); values.line_width = (rect->line_width == 1) ? 0 : (int) rect->line_width; values.join_style = JoinMiter; if (ISCLEAR(rect->flags, ALIGNED_BIT)) { @@ -621,8 +611,6 @@ Render(ZnItem item) ZnWInfo *wi = item->wi; RectangleItem rect = (RectangleItem) item; int i; - XColor *color; - unsigned short alpha; #ifdef GL_LIST if (!item->gl_list) { @@ -642,11 +630,18 @@ Render(ZnItem item) fast ? rect->dev : rect->grad_geo, &poly); } else if (rect->tile != ZnUnspecifiedImage) { /* Fill tiled/patterned */ - ZnRenderTile(wi, rect->tile, rect->fill_color, RectRenderCB, - rect, (ZnPoint *) &item->item_bounding_box); + if (ISSET(rect->flags, ALIGNED_BIT)) { + ZnRenderTile(wi, rect->tile, rect->fill_color, NULL, NULL, + (ZnPoint *) &item->item_bounding_box); + } + else { + ZnRenderTile(wi, rect->tile, rect->fill_color, RectRenderCB, + rect, (ZnPoint *) &item->item_bounding_box); + } } else { - color = ZnGetGradientColor(rect->fill_color, 0.0, &alpha); + unsigned short alpha; + XColor *color = ZnGetGradientColor(rect->fill_color, 0.0, &alpha); alpha = ZnComposeAlpha(alpha, wi->alpha); glColor4us(color->red, color->green, color->blue, alpha); RectRenderCB(rect); -- cgit v1.1