#define YFLIP(_xrb, Y) ((_xrb)->Base.Height - (Y) - 1)
/*
- * Generate code for image span functions.
+ * Pixel macros shared across front/back buffer span functions.
*/
/* 32-bit BGRA */
-#define NAME(FUNC) FUNC##_A8R8G8B8
-#define RB_TYPE GLubyte
-#define SPAN_VARS \
- struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
-#define INIT_PIXEL_PTR(P, X, Y) \
- GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 4;
-#define INC_PIXEL_PTR(P) P += 4
-#define STORE_PIXEL(DST, X, Y, VALUE) \
+#define STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE) \
DST[3] = VALUE[ACOMP]; \
DST[2] = VALUE[RCOMP]; \
DST[1] = VALUE[GCOMP]; \
DST[0] = VALUE[BCOMP]
-#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+#define STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE) \
DST[3] = 0xff; \
DST[2] = VALUE[RCOMP]; \
DST[1] = VALUE[GCOMP]; \
DST[0] = VALUE[BCOMP]
-#define FETCH_PIXEL(DST, SRC) \
+#define FETCH_PIXEL_A8R8G8B8(DST, SRC) \
DST[ACOMP] = SRC[3]; \
DST[RCOMP] = SRC[2]; \
DST[GCOMP] = SRC[1]; \
DST[BCOMP] = SRC[0]
-#include "swrast/s_spantemp.h"
-
/* 16-bit BGR */
-#define NAME(FUNC) FUNC##_R5G6B5
-#define RB_TYPE GLubyte
-#define SPAN_VARS \
- struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
-#define INIT_PIXEL_PTR(P, X, Y) \
- GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 2;
-#define INC_PIXEL_PTR(P) P += 2
-#define STORE_PIXEL(DST, X, Y, VALUE) \
+#define STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) \
do { \
GLushort *p = (GLushort *)DST; \
*p = ( (((VALUE[RCOMP]) & 0xf8) << 8) | \
(((VALUE[GCOMP]) & 0xfc) << 3) | \
(((VALUE[BCOMP]) & 0xf8) >> 3) ); \
} while(0)
-#define FETCH_PIXEL(DST, SRC) \
+#define FETCH_PIXEL_R5G6B5(DST, SRC) \
do { \
GLushort p = *(GLushort *)SRC; \
DST[ACOMP] = 0xff; \
DST[BCOMP] = ((p << 3) & 0xf8) * 255 / 0xf8; \
} while(0)
+
+/*
+ * Generate code for image span functions.
+ */
+
+/* 32-bit BGRA */
+#define NAME(FUNC) FUNC##_A8R8G8B8
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+ struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 4;
+#define INC_PIXEL_PTR(P) P += 4
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE)
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+ STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+ FETCH_PIXEL_A8R8G8B8(DST, SRC)
+
+#include "swrast/s_spantemp.h"
+
+
+/* 16-bit BGR */
+#define NAME(FUNC) FUNC##_R5G6B5
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+ struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 2;
+#define INC_PIXEL_PTR(P) P += 2
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ STORE_PIXEL_R5G6B5(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+ FETCH_PIXEL_R5G6B5(DST, SRC)
+
#include "swrast/s_spantemp.h"
GLubyte *P = (GLubyte *)row;
#define INC_PIXEL_PTR(P) P += 4
#define STORE_PIXEL(DST, X, Y, VALUE) \
- DST[3] = VALUE[ACOMP]; \
- DST[2] = VALUE[RCOMP]; \
- DST[1] = VALUE[GCOMP]; \
- DST[0] = VALUE[BCOMP]
+ STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE)
#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
- DST[3] = 0xff; \
- DST[2] = VALUE[RCOMP]; \
- DST[1] = VALUE[GCOMP]; \
- DST[0] = VALUE[BCOMP]
+ STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE)
#define FETCH_PIXEL(DST, SRC) \
- DST[ACOMP] = SRC[3]; \
- DST[RCOMP] = SRC[2]; \
- DST[GCOMP] = SRC[1]; \
- DST[BCOMP] = SRC[0]
+ FETCH_PIXEL_A8R8G8B8(DST, SRC)
#include "swrast_spantemp.h"
GLubyte *P = (GLubyte *)row;
#define INC_PIXEL_PTR(P) P += 2
#define STORE_PIXEL(DST, X, Y, VALUE) \
- do { \
- GLushort *p = (GLushort *)DST; \
- *p = ( (((VALUE[RCOMP]) & 0xf8) << 8) | \
- (((VALUE[GCOMP]) & 0xfc) << 3) | \
- (((VALUE[BCOMP]) & 0xf8) >> 3) ); \
- } while(0)
+ STORE_PIXEL_R5G6B5(DST, X, Y, VALUE)
#define FETCH_PIXEL(DST, SRC) \
- do { \
- GLushort p = *(GLushort *)SRC; \
- DST[ACOMP] = 0xff; \
- DST[RCOMP] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
- DST[GCOMP] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
- DST[BCOMP] = ((p << 3) & 0xf8) * 255 / 0xf8; \
- } while(0)
+ FETCH_PIXEL_R5G6B5(DST, SRC)
#include "swrast_spantemp.h"