All pastes #459394 Raw Edit

Anonymous

public text v1 · immutable
#459394 ·published 2007-04-26 12:50 UTC
rendered paste body
/* Slow */
#define DECLARE_STRETCHER(type, size, put, get) \
		int xc = _al_stretch.xcstart; \
		uintptr_t dend = dptr + _al_stretch.linesize; \
		ASSERT(dptr); \
		ASSERT(sptr); \
		for (; dptr < dend; sptr += _al_stretch.sxinc, dptr += size) { \
			put(dptr, get((type*)sptr)); \
			if (xc <= 0) { \
      			sptr += size; \
				xc += _al_stretch.xcinc; \
			} \
			else \
				xc -= _al_stretch.xcdec; \
		}

/* Fast */
#define DECLARE_STRETCHER(type, size, set, get)                           \
int dd = _al_stretch.dd;                                                  \
type *s = (type*) sptr;                                                   \
uintptr_t d = dptr;							  \
uintptr_t dend = d + _al_stretch.dw;					  \
ASSERT(s);                                                                \
ASSERT(d);                                                                \
for (; d < dend; d += (size), s = (type *)                                \
   ((unsigned char*)s + _al_stretch.sinc)) {                              \
   set(d, get(s));                                                        \
   if (dd >= 0) {                                                         \
      s = (type *) ((unsigned char*)s + (size));                          \
      dd += _al_stretch.i2;                                               \
   }                                                                      \
   else                                                                   \
      dd += _al_stretch.i1;                                               \
}