Example #1
0
/*
 * Copy the parameters (except GC of course) from one cache record to another.
 */
void
copyCgs(XtermWidget xw, VTwin *cgsWin, CgsEnum dstCgsId, CgsEnum srcCgsId)
{
    if (dstCgsId != srcCgsId) {
        CgsCache *me;

        if ((me = myCache(xw, cgsWin, srcCgsId)) != 0) {
            TRACE(("copyCgs from %s to %s\n",
                   traceCgsEnum(srcCgsId),
                   traceCgsEnum(dstCgsId)));
            TRACE2(("copyCgs from %s (me %p, fg %s, bg %s, cset %s) to %s {{\n",
                    traceCgsEnum(srcCgsId),
                    me,
                    tracePixel(xw, THIS(fg)),
                    tracePixel(xw, THIS(bg)),
                    traceCSet(THIS(cset)),
                    traceCgsEnum(dstCgsId)));
            setCgsCSet(xw, cgsWin, dstCgsId, THIS(cset));
            setCgsFore(xw, cgsWin, dstCgsId, THIS(fg));
            setCgsBack(xw, cgsWin, dstCgsId, THIS(bg));
            setCgsFont(xw, cgsWin, dstCgsId, THIS(font));
            TRACE2(("...copyCgs }}\n"));
        }
    }
}
Example #2
0
static GC
chgCache(XtermWidget xw, CgsEnum cgsId GCC_UNUSED, CgsCache * me, Bool both)
{
    XGCValues xgcv;
    XtGCMask mask = (GCForeground | GCBackground | GCFont);

    memset(&xgcv, 0, sizeof(xgcv));

    TRACE2(("chgCache(%s) old data fg=%s, bg=%s, font=%s cset %s\n",
            traceCgsEnum(cgsId),
            tracePixel(xw, THIS(fg)),
            tracePixel(xw, THIS(bg)),
            traceFont(THIS(font)),
            traceCSet(THIS(cset))));
#if OPT_TRACE > 1
    if (!SameFont(THIS(font), NEXT(font)))
        TRACE2(("...chgCache new font=%s\n", traceFont(NEXT(font))));
    if (!SameCSet(THIS(cset), NEXT(cset)))
        TRACE2(("...chgCache new cset=%s\n", traceCSet(NEXT(cset))));
    if (!SameColor(THIS(fg), NEXT(fg)))
        TRACE2(("...chgCache new fg=%s\n", tracePixel(xw, NEXT(fg))));
    if (!SameColor(THIS(bg), NEXT(bg)))
        TRACE2(("...chgCache new bg=%s\n", tracePixel(xw, NEXT(bg))));
#endif

    if (both) {
        THIS(font) = NEXT(font);
        THIS(cset) = NEXT(cset);
    }
    THIS(fg) = NEXT(fg);
    THIS(bg) = NEXT(bg);

    xgcv.font = THIS(font)->fs->fid;
    xgcv.foreground = THIS(fg);
    xgcv.background = THIS(bg);

    XChangeGC(myDisplay(xw), THIS(gc), mask, &xgcv);
    TRACE2(("...chgCache(%s) updated gc %p(%d)\n",
            traceCgsEnum(cgsId), THIS(gc), ITEM()));

    THIS(used) = 0;
    return THIS(gc);
}
Example #3
0
void RayTracer::traceLines( int start, int stop )
{
	vec3f col;
	if( !scene )
		return;

	if( stop > buffer_height )
		stop = buffer_height;

	for( int j = start; j < stop; ++j )
		for( int i = 0; i < buffer_width; ++i )
			tracePixel(i,j);
}
Example #4
0
/*
 * Return a GC associated with the given id, allocating if needed.
 */
GC
getCgsGC(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId)
{
    CgsCache *me;
    GC result = 0;
    int j, k;
    unsigned used = 0;

    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
        TRACE2(("getCgsGC(%s, %s)\n",
                traceVTwin(xw, cgsWin), traceCgsEnum(cgsId)));
        if (me->mask != 0) {

            /* fill in the unchanged fields */
            if (!(me->mask & GC_CSet))
                NEXT(cset) = 0;	/* OPT_DEC_CHRSET */
            if (!(me->mask & GCFont))
                NEXT(font) = THIS(font);
            if (!(me->mask & GCForeground))
                NEXT(fg) = THIS(fg);
            if (!(me->mask & GCBackground))
                NEXT(bg) = THIS(bg);

            if (NEXT(font) == 0) {
                setCgsFont(xw, cgsWin, cgsId, 0);
            }

            TRACE2(("...Cgs new data fg=%s, bg=%s, font=%s cset %s\n",
                    tracePixel(xw, NEXT(fg)),
                    tracePixel(xw, NEXT(bg)),
                    traceFont(NEXT(font)),
                    traceCSet(NEXT(cset))));

            /* try to find the given data in an already-created GC */
            for (j = 0; j < DEPTH; ++j) {
                if (LIST(j).gc != 0
                        && SameFont(LIST(j).font, NEXT(font))
                        && SameCSet(LIST(j).cset, NEXT(cset))
                        && SameColor(LIST(j).fg, NEXT(fg))
                        && SameColor(LIST(j).bg, NEXT(bg))) {
                    LINK(j);
                    result = THIS(gc);
                    TRACE2(("getCgsGC existing %p(%d)\n", result, ITEM()));
                    break;
                }
            }

            if (result == 0) {
                /* try to find an empty slot, to create a new GC */
                used = 0;
                for (j = 0; j < DEPTH; ++j) {
                    if (LIST(j).gc == 0) {
                        LINK(j);
                        result = newCache(xw, cgsWin, cgsId, me);
                        break;
                    }
                    if (used < LIST(j).used)
                        used = LIST(j).used;
                }
            }

            if (result == 0) {
                /* if none were empty, pick the least-used slot, to modify */
                for (j = 0, k = -1; j < DEPTH; ++j) {
                    if (used >= LIST(j).used) {
                        used = LIST(j).used;
                        k = j;
                    }
                }
                LINK(k);
                TRACE2(("...getCgsGC least-used(%d) was %d\n", k, THIS(used)));
                result = chgCache(xw, cgsId, me, True);
            }
            me->next = *(me->data);
        } else {
            result = THIS(gc);
        }
        me->mask = 0;
        THIS(used) += 1;
        TRACE2(("...getCgsGC(%s, %s) gc %p(%d), used %d\n",
                traceVTwin(xw, cgsWin),
                traceCgsEnum(cgsId), result, ITEM(), THIS(used)));
    }
    return result;
}