diff options
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/swrast/swrast_span.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/mesa/drivers/dri/swrast/swrast_span.c b/src/mesa/drivers/dri/swrast/swrast_span.c index fd11f2866e..d11d1d36ae 100644 --- a/src/mesa/drivers/dri/swrast/swrast_span.c +++ b/src/mesa/drivers/dri/swrast/swrast_span.c @@ -32,52 +32,36 @@ #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; \ @@ -86,6 +70,42 @@ 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" @@ -119,20 +139,11 @@ 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" @@ -146,20 +157,9 @@ 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" |