aboutsummaryrefslogtreecommitdiff
path: root/generic/Item.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/Item.c')
-rw-r--r--generic/Item.c226
1 files changed, 199 insertions, 27 deletions
diff --git a/generic/Item.c b/generic/Item.c
index 3c9f651..e67eb1e 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -8,7 +8,7 @@
*/
/*
- * Copyright (c) 1993 - 1999 CENA, Patrick Lecoanet --
+ * Copyright (c) 1993 - 2000 CENA, Patrick Lecoanet --
*
* This code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -43,6 +43,7 @@
#include "Image.h"
#include "Color.h"
#include "tkZinc.h"
+#include "OverlapMan.h"
static const char rcsid[] = "$Id$";
@@ -4224,7 +4225,22 @@ DrawFields(FieldSet field_set)
}
}
}
-
+
+
+/*
+ **********************************************************************************
+ *
+ * RenderFields --
+ *
+ **********************************************************************************
+ */
+static void
+RenderFields(FieldSet field_set)
+{
+ /* WidgetInfo *wi = field_set->wi;*/
+
+}
+
/*
**********************************************************************************
@@ -4407,8 +4423,8 @@ Damage(WidgetInfo *wi,
if (wi->damaged_area.corner.x > wi->width) {
wi->damaged_area.corner.x = wi->width;
}
- if (wi->damaged_area.orig.y > wi->height) {
- wi->damaged_area.orig.y = wi->height;
+ if (wi->damaged_area.corner.y > wi->height) {
+ wi->damaged_area.corner.y = wi->height;
}
/*printf("damaged area: %g %g %g %g\n", wi->damaged_area.orig.x,
wi->damaged_area.orig.y, wi->damaged_area.corner.x,
@@ -4419,6 +4435,22 @@ Damage(WidgetInfo *wi,
static void
Update(WidgetInfo *wi)
{
+ /*
+ * Give the overlap manager a chance to do its work.
+ */
+#ifdef OM
+ if ((wi->om_group != ZN_NO_ITEM) &&
+ ((GroupItem) wi->om_group)->call_om) {
+ ZnPoint scale={1.0,1.0};
+ if (wi->om_group->transfo) {
+ ZnTransfoDecompose(wi->om_group->transfo, &scale,
+ NULL, NULL, NULL);
+ }
+ OmProcessOverlap((void *) wi, wi->width, wi->height, scale.x);
+ ((GroupItem) wi->om_group)->call_om = False;
+ }
+#endif
+
if (ISSET(wi->top_group->inv_flags, ZN_COORDS_FLAG) ||
ISSET(wi->top_group->inv_flags, ZN_TRANSFO_FLAG)) {
wi->top_group->class->ComputeCoordinates(wi->top_group, False);
@@ -4426,6 +4458,130 @@ Update(WidgetInfo *wi)
}
+#ifdef SHM
+static void
+EnsureRGBBuf(WidgetInfo *wi,
+ int r,
+ int g,
+ int b)
+{
+ unsigned char *ptr;
+ int y;
+
+ ptr = wi->buf.buf;
+ for (y = wi->buf.oy; y < wi->buf.cy; y++) {
+ art_rgb_fill_run(ptr, r, g, b, wi->buf.cx - wi->buf.ox);
+ ptr += wi->buf.rowstride;
+ }
+}
+
+static void
+RenderSVP(WidgetInfo *wi,
+ ArtSVP *svp,
+ int r,
+ int g,
+ int b,
+ int alpha,
+ int tile_x,
+ int tile_y,
+ ArtPixBuf *tile)
+{
+ if (tile) {
+ tile_svp_alpha(svp, wi->buf.ox, wi->buf.oy,
+ wi->buf.cx, wi->buf.cy,
+ tile_x, tile_y, tile, alpha,
+ wi->buf.buf, wi->buf.rowstride);
+ }
+ else {
+ art_rgb_svp_alpha(svp,
+ wi->buf.ox, wi->buf.oy,
+ wi->buf.cx, wi->buf.cy,
+ ((r & 0xff00) << 16) | ((g & 0xff00) << 8) |
+ (b & 0xff00) | (alpha & 0xff),
+ wi->buf.buf, wi->buf.rowstride, NULL);
+ }
+}
+
+
+/*
+ * Working only for 16 bits displays with 5r6g5b mask.
+ */
+static void
+RGBToXImage(WidgetInfo *wi,
+ int x0,
+ int y0,
+ int width,
+ int height)
+{
+ int x, y;
+ int rowstride;
+ art_u8 *obuf, *obptr;
+ int bpl;
+ art_u8 *bptr, *bp2;
+ art_u8 r, g, b;
+
+ /*printf("RGBToXImage: x0 %d, y0 %d, width %d, height %d, wwidth %d, wheight %d\n",
+ x0, y0, width, height, wi->width, wi->height);*/
+ rowstride = wi->buf.rowstride;
+ bptr = wi->buf.buf/* + y0 * rowstride + x0 * 3*/;
+ bpl = wi->draw_buffer_im->bytes_per_line;
+ obuf = ((art_u8 *) wi->draw_buffer_im->data) + y0 * bpl + x0 * 2;
+ for (y = 0; y < height; y++) {
+ bp2 = bptr;
+ obptr = obuf;
+ if (((unsigned long) obuf | (unsigned long) bp2) & 3) {
+ for (x = 0; x < width; x++) {
+ r = *bp2++;
+ g = *bp2++;
+ b = *bp2++;
+ ((art_u16 *)obptr)[0] = ((r & 0xf8) << 8) |
+ ((g & 0xfc) << 3) |
+ (b >> 3);
+ obptr += 2;
+ }
+ }
+ else {
+ for (x = 0; x < width - 3; x += 4) {
+ art_u32 r1b0g0r0;
+ art_u32 g2r2b1g1;
+ art_u32 b3g3r3b2;
+
+ r1b0g0r0 = ((art_u32 *)bp2)[0];
+ g2r2b1g1 = ((art_u32 *)bp2)[1];
+ b3g3r3b2 = ((art_u32 *)bp2)[2];
+ ((art_u32 *)obptr)[0] =
+ ((r1b0g0r0 & 0xf8) << 8) |
+ ((r1b0g0r0 & 0xfc00) >> 5) |
+ ((r1b0g0r0 & 0xf80000) >> 19) |
+ (r1b0g0r0 & 0xf8000000) |
+ ((g2r2b1g1 & 0xfc) << 19) |
+ ((g2r2b1g1 & 0xf800) << 5);
+ ((art_u32 *)obptr)[1] =
+ ((g2r2b1g1 & 0xf80000) >> 8) |
+ ((g2r2b1g1 & 0xfc000000) >> 21) |
+ ((b3g3r3b2 & 0xf8) >> 3) |
+ ((b3g3r3b2 & 0xf800) << 16) |
+ ((b3g3r3b2 & 0xfc0000) << 3) |
+ ((b3g3r3b2 & 0xf8000000) >> 11);
+ bp2 += 12;
+ obptr += 8;
+ }
+ for (; x < width; x++) {
+ r = *bp2++;
+ g = *bp2++;
+ b = *bp2++;
+ ((art_u16 *)obptr)[0] = ((r & 0xf8) << 8) |
+ ((g & 0xfc) << 3) |
+ (b >> 3);
+ obptr += 2;
+ }
+ }
+ bptr += rowstride;
+ obuf += bpl;
+ }
+}
+#endif
+
static void
Repair(WidgetInfo *wi)
{
@@ -4439,10 +4595,6 @@ Repair(WidgetInfo *wi)
if (wi->realized && !IsEmptyBBox(&wi->damaged_area)) {
/* Set the whole damaged area as clip rect. */
- /*printf("damaged area %g %g %g %g\n",
- wi->damaged_area.orig.x, wi->damaged_area.orig.y,
- wi->damaged_area.corner.x, wi->damaged_area.corner.y);*/
-
wi->damaged_area.orig.x = r.x = REAL_TO_INT(wi->damaged_area.orig.x);
wi->damaged_area.orig.y = r.y = REAL_TO_INT(wi->damaged_area.orig.y);
wi->damaged_area.corner.x = REAL_TO_INT(wi->damaged_area.corner.x);
@@ -4458,27 +4610,45 @@ Repair(WidgetInfo *wi)
XStartChrono(draw_time, wi->dpy, wi->draw_buffer);
/*StartChrono(int_draw_time);*/
#endif
- /* Fill the background */
- if (wi->tile == ZnUnspecifiedImage) {
- values.foreground = ZnPixel(wi->back_color);
- values.fill_style = FillSolid;
- XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCForeground, &values);
+ if (wi->local_render) {
+ /* if (wi->tile == ZnUnspecifiedImage) {
+ * }
+ * else {
+ * }*/
+
+ wi->buf.ox = (int) wi->damaged_area.orig.x;
+ wi->buf.oy = (int) wi->damaged_area.orig.y;
+ wi->buf.cx = (int) wi->damaged_area.corner.x;
+ wi->buf.cy = (int) wi->damaged_area.corner.y;
+ EnsureRGBBuf(wi,
+ wi->back_color->red >> 8,
+ wi->back_color->green >> 8,
+ wi->back_color->blue >> 8);
+ wi->top_group->class->Render(wi->top_group);
+ RGBToXImage(wi, r.x, r.y, r.width, r.height);
}
else {
- values.fill_style = FillTiled;
- values.tile = GetImagePixmap(wi->win, wi->tile_name, wi->tile, NULL);
- values.ts_x_origin = values.ts_y_origin = 0;
- XChangeGC(wi->dpy, wi->gc,
- GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin,
- &values);
+ /* Fill the background of the double buffer pixmap. */
+ if (wi->tile == ZnUnspecifiedImage) {
+ values.foreground = ZnPixel(wi->back_color);
+ values.fill_style = FillSolid;
+ XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCForeground, &values);
+ }
+ else {
+ values.fill_style = FillTiled;
+ values.tile = GetImagePixmap(wi->win, wi->tile_name, wi->tile, NULL);
+ values.ts_x_origin = values.ts_y_origin = 0;
+ XChangeGC(wi->dpy, wi->gc,
+ GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin,
+ &values);
+ }
+ /*printf("Repair : filling rectangle: %d %d %d %d\n", r.x, r.y, r.width, r.height);*/
+ XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, r.x, r.y, r.width, r.height);
+
+ /* Draw the items */
+ /*printf("Drawing\n");*/
+ wi->top_group->class->Draw(wi->top_group);
}
- /*printf("Repair : filling rectangle: %d %d %d %d\n", r.x, r.y, r.width, r.height);*/
- XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, r.x, r.y, r.width, r.height);
-
- /* Draw the items */
- /*printf("Drawing\n");*/
- wi->top_group->class->Draw(wi->top_group);
-
#ifdef PERFOS
/*StopChrono(int_draw_time);*/
XStopChrono(draw_time, wi->dpy, wi->draw_buffer);
@@ -4511,6 +4681,7 @@ struct _ITEM_P ITEM_P = {
CloneFields,
FreeFields,
DrawFields,
+ RenderFields,
FieldsToArea,
IsFieldSensitive,
FieldsPick,
@@ -4527,7 +4698,8 @@ struct _ITEM_P ITEM_P = {
ResetClipStack,
PushClip,
PopClip,
- CurrentClip
+ CurrentClip,
+ RenderSVP
};
struct _ITEM ITEM = {