From 8f07676db7e61313ab560249a957fad293f0c333 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 9 May 2003 15:02:11 +0000 Subject: * (Render): Fixed the pattern filling under openGL. Stippling can't be used to fill patterns. Now texture mapping is used instead. As a side effect -fillpattern and -tile use the same internal variable reducing memory requirements. --- generic/Rectangle.c | 89 ++++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 53 deletions(-) (limited to 'generic/Rectangle.c') diff --git a/generic/Rectangle.c b/generic/Rectangle.c index 9aa98cb..d15356d 100644 --- a/generic/Rectangle.c +++ b/generic/Rectangle.c @@ -65,7 +65,6 @@ typedef struct _RectangleItemStruct { ZnLineStyle line_style; ZnDim line_width; ZnGradient *line_color; - ZnImage fill_pattern; ZnImage line_pattern; ZnGradient *fill_color; ZnImage tile; @@ -93,7 +92,7 @@ static ZnAttrConfig rect_attrs[] = { { ZN_CONFIG_BOOL, "-filled", NULL, Tk_Offset(RectangleItemStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False }, { ZN_CONFIG_BITMAP, "-fillpattern", NULL, - Tk_Offset(RectangleItemStruct, fill_pattern), 0, ZN_DRAW_FLAG, False }, + Tk_Offset(RectangleItemStruct, tile), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_GRADIENT, "-linecolor", NULL, Tk_Offset(RectangleItemStruct, line_color), 0, ZN_DRAW_FLAG, False }, @@ -175,7 +174,6 @@ Init(ZnItem item, rect->line_width = 1; rect->line_pattern = ZnUnspecifiedImage; rect->tile = ZnUnspecifiedImage; - rect->fill_pattern = ZnUnspecifiedImage; rect->line_color = ZnGetGradientByValue(wi->fore_color); rect->fill_color = ZnGetGradientByValue(wi->fore_color); @@ -204,9 +202,6 @@ Clone(ZnItem item) if (rect->line_pattern != ZnUnspecifiedImage) { rect->line_pattern = ZnGetImageByValue(rect->line_pattern); } - if (rect->fill_pattern != ZnUnspecifiedImage) { - rect->fill_pattern = ZnGetImageByValue(rect->fill_pattern); - } rect->line_color = ZnGetGradientByValue(rect->line_color); rect->fill_color = ZnGetGradientByValue(rect->fill_color); rect->grad_geo = NULL; @@ -236,10 +231,6 @@ Destroy(ZnItem item) ZnFreeImage(rect->line_pattern); rect->line_pattern = ZnUnspecifiedImage; } - if (rect->fill_pattern != ZnUnspecifiedImage) { - ZnFreeImage(rect->fill_pattern); - rect->fill_pattern = ZnUnspecifiedImage; - } if (rect->grad_geo) { ZnFree(rect->grad_geo); } @@ -509,34 +500,36 @@ Draw(ZnItem item) */ if (ISSET(rect->flags, FILLED_BIT)) { values.foreground = ZnPixel(ZnGetGradientColor(rect->fill_color, 0.0, NULL)); - if (rect->tile != ZnUnspecifiedImage) { /* Fill tiled */ - values.fill_style = FillTiled; - values.tile = ZnImagePixmap(rect->tile); - if (ISSET(rect->flags, ALIGNED_BIT)) { - values.ts_x_origin = (int) r.x; - values.ts_y_origin = (int) r.y; + if (rect->tile != ZnUnspecifiedImage) { + if (!ZnImageIsBitmap(rect->tile)) { /* Fill tiled */ + values.fill_style = FillTiled; + values.tile = ZnImagePixmap(rect->tile); + if (ISSET(rect->flags, ALIGNED_BIT)) { + values.ts_x_origin = (int) r.x; + values.ts_y_origin = (int) r.y; + } + else { + values.ts_x_origin = (int) item->item_bounding_box.orig.x; + values.ts_y_origin = (int) item->item_bounding_box.orig.y; + } + XChangeGC(wi->dpy, wi->gc, + GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCTile, &values); } else { - values.ts_x_origin = (int) item->item_bounding_box.orig.x; - values.ts_y_origin = (int) item->item_bounding_box.orig.y; - } - XChangeGC(wi->dpy, wi->gc, - GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCTile, &values); - } - else if (rect->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */ - values.fill_style = FillStippled; - values.stipple = ZnImagePixmap(rect->fill_pattern); - if (ISSET(rect->flags, ALIGNED_BIT)) { - values.ts_x_origin = (int) r.x; - values.ts_y_origin = (int) r.y; + values.fill_style = FillStippled; + values.stipple = ZnImagePixmap(rect->tile); + if (ISSET(rect->flags, ALIGNED_BIT)) { + values.ts_x_origin = (int) r.x; + values.ts_y_origin = (int) r.y; } - else { - values.ts_x_origin = (int) item->item_bounding_box.orig.x; - values.ts_y_origin = (int) item->item_bounding_box.orig.y; + else { + values.ts_x_origin = (int) item->item_bounding_box.orig.x; + values.ts_y_origin = (int) item->item_bounding_box.orig.y; + } + XChangeGC(wi->dpy, wi->gc, + GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCStipple|GCForeground, + &values); } - XChangeGC(wi->dpy, wi->gc, - GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCStipple|GCForeground, - &values); } else { /* Fill solid */ values.fill_style = FillSolid; @@ -629,8 +622,8 @@ Render(ZnItem item) { ZnWInfo *wi = item->wi; RectangleItem rect = (RectangleItem) item; - XColor *color; int i; + XColor *color; unsigned short alpha; #ifdef GL_LIST @@ -650,25 +643,15 @@ Render(ZnItem item) fast ? NULL: RectRenderCB, rect, 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); + } else { - if (rect->tile != ZnUnspecifiedImage) { /* Fill tiled */ - ZnRenderTile(wi, rect->tile, rect->fill_color, RectRenderCB, - rect, (ZnPoint *) &item->item_bounding_box); - } - else { - if (rect->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */ - /* - * Setup polygon stippling. - */ - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(ZnImageMask(rect->fill_pattern, NULL)); - } - color = ZnGetGradientColor(rect->fill_color, 0.0, &alpha); - alpha = ZnComposeAlpha(alpha, wi->alpha); - glColor4us(color->red, color->green, color->blue, alpha); - RectRenderCB(rect); - glDisable(GL_POLYGON_STIPPLE); - } + 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