diff options
author | Brian Paul <[email protected]> | 2002-06-10 15:16:44 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-06-10 15:16:44 +0000 |
commit | b58c5ad7b0a2c3ed3ecf189f284e23118091fa68 (patch) | |
tree | 65f0df21580a254758afe61094c51d436118ec54 /src/mesa/drivers/ggi/default/linear.c | |
parent | dd41748f63b819c36c4234a525e5609660ceb395 (diff) |
GGI driver updates (Filip Spacek)
Diffstat (limited to 'src/mesa/drivers/ggi/default/linear.c')
-rw-r--r-- | src/mesa/drivers/ggi/default/linear.c | 347 |
1 files changed, 213 insertions, 134 deletions
diff --git a/src/mesa/drivers/ggi/default/linear.c b/src/mesa/drivers/ggi/default/linear.c index e105cd0e592..4c74497e009 100644 --- a/src/mesa/drivers/ggi/default/linear.c +++ b/src/mesa/drivers/ggi/default/linear.c @@ -24,6 +24,8 @@ #include <ggi/mesa/ggimesa.h> #include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/debug.h> +#include "swrast/swrast.h" #define RMASK ((1<<R)-1) #define GMASK ((1<<G)-1) @@ -33,21 +35,30 @@ #define GS (8-G) #define BS (8-B) +#define PACK(color) (((color[RCOMP]>>RS) << (G+B)) | \ + ((color[GCOMP]>>GS) << B) | \ + ((color[BCOMP]>>BS))) + +#define FLIP(coord) (LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y-(coord) - 1) + /**********************************************************************/ /***** Write spans of pixels *****/ /**********************************************************************/ -void GGIwrite_ci32_span(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLuint ci[], - const GLubyte mask[]) +void GGIwrite_ci32_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLuint ci[], const GLubyte mask[]) { - FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + if (mask) { while (n--) { - if (*mask++) *fb=*ci; + if (*mask++) + *fb = *ci; fb++; ci++; } @@ -58,17 +69,19 @@ void GGIwrite_ci32_span(const GLcontext *ctx, } } -void GGIwrite_ci8_span(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte ci[], - const GLubyte mask[] ) +void GGIwrite_ci8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte ci[], const GLubyte mask[]) { - FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; if (mask) { while (n--) { - if (*mask++) *fb=*ci; + if (*mask++) + *fb = *ci; fb++; ci++; } @@ -80,21 +93,19 @@ void GGIwrite_ci8_span(const GLcontext *ctx, } -void GGIwrite_rgba_span(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte rgba[][4], - const GLubyte mask[]) +void GGIwrite_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLchan rgba[][4], const GLubyte mask[]) { - FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; if (mask) { while (n--) { - if (*mask++) { - *fb= ((rgba[0][RCOMP]>>RS) << (G+B)) | - ((rgba[0][GCOMP]>>GS) << B) | - ((rgba[0][BCOMP]>>BS)); - } + if (*mask++) + *fb = PACK(rgba[0]); fb++; rgba++; } @@ -102,28 +113,25 @@ void GGIwrite_rgba_span(const GLcontext *ctx, else { while (n--) { - *fb++= ((rgba[0][RCOMP]>>RS) << (G+B)) | - ((rgba[0][GCOMP]>>GS) << B)| - ((rgba[0][BCOMP]>>BS)); + *fb++ = PACK(rgba[0]); rgba++; } } } -void GGIwrite_rgb_span( const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte rgba[][3], - const GLubyte mask[] ) +void GGIwrite_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLchan rgba[][3], const GLubyte mask[]) { - FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + if (mask) { while (n--) { - if (*mask++) { - *fb= ((rgba[0][RCOMP]>>RS) << (G+B)) | - ((rgba[0][GCOMP]>>GS) << B) | - ((rgba[0][BCOMP]>>BS)); - } + if (*mask++) + *fb = PACK(rgba[0]); fb++; rgba++; } @@ -131,36 +139,62 @@ void GGIwrite_rgb_span( const GLcontext *ctx, else { while (n--) { - *fb++= ((rgba[0][RCOMP]>>RS) << (G+B)) | - ((rgba[0][GCOMP]>>GS) << B) | - ((rgba[0][BCOMP]>>BS)); + *fb++ = PACK(rgba[0]); rgba++; } } } -void GGIwrite_mono_span( const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte mask[]) +void GGIwrite_mono_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLchan color[4], const GLubyte mask[]) { + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; FB_TYPE *fb; - FB_TYPE color; + fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + if (mask){ + while (n--){ + if (*mask++) + *fb = PACK(color); + ++fb; + } + } + else { + while (n--) + *fb++ = PACK(color); - if (mask) - { - fb=LFB(FB_TYPE,x,FLIP(y)); - color=(FB_TYPE) GGICTX->color; + /* Alternatively we could write a potentialy faster HLine + ggiSetGCForeground(ggi_ctx->ggi_visual, color); + ggiDrawHLine(ggi_ctx->ggi_visual,x,FLIP(y),n); + */ + } +} - while (n--) - { - if (*mask++) *fb=color; - fb++; +void GGIwrite_mono_ci_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLuint ci, const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + if (mask){ + while (n--){ + if (*mask++) + *fb = ci; + ++fb; } } - else - { - ggiDrawHLine(VIS,x,FLIP(y),n); + else { + while (n--) + *fb++ = ci; + + /* Alternatively we could write a potentialy faster HLine + ggiSetGCForeground(ggi_ctx->ggi_visual, ci); + ggiDrawHLine(ggi_ctx->ggi_visual, x, FLIP(y), n); + */ } } @@ -171,27 +205,33 @@ void GGIwrite_mono_span( const GLcontext *ctx, void GGIread_ci32_span(const GLcontext *ctx, - GLuint n, GLint x, GLint y, GLuint ci[]) + GLuint n, GLint x, GLint y, GLuint ci[]) { - FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + while (n--) - *ci++=(GLuint)*fb++; + *ci++ = (GLuint)*fb++; } void GGIread_rgba_span(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - GLubyte rgba[][4]) + GLuint n, GLint x, GLint y, GLchan rgba[][4]) { - FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; FB_TYPE color; - + FB_TYPE *fb; + fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + while (n--) { - color=*fb++; + color = *fb++; rgba[0][RCOMP] = (GLubyte) (color>>(G+B))<<RS; rgba[0][GCOMP] = (GLubyte) ((color>>B)& ((1<<G)-1))<<GS; rgba[0][BCOMP] = (GLubyte) (color & ((1<<B)-1))<<BS; - rgba[0][ACOMP] =0; + rgba[0][ACOMP] = 0; rgba++; } } @@ -201,68 +241,97 @@ void GGIread_rgba_span(const GLcontext *ctx, /**********************************************************************/ void GGIwrite_ci32_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLuint ci[], const GLubyte mask[] ) + GLuint n, const GLint x[], const GLint y[], + const GLuint ci[], const GLubyte mask[]) { - FB_TYPE *fb=LFB(FB_TYPE,0,0); + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual); while (n--) { - if (*mask++) *(fb+ *x + FLIP(*y)*GGICTX->width)=*ci; + if (*mask++){ + FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *dst = *ci; + } ci++; x++; y++; } } -void GGIwrite_mono_pixels(const GLcontext *ctx, - GLuint n, - const GLint x[], const GLint y[], - const GLubyte mask[] ) +void GGIwrite_mono_ci_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint ci, const GLubyte mask[]) { - FB_TYPE *fb=LFB(FB_TYPE,0,0); - FB_TYPE color=(FB_TYPE) GGICTX->color; + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual); while (n--) { - if (*mask++) *(fb+ *x + FLIP(*y)*GGICTX->width)=color; + if (*mask++){ + FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *dst = ci; + } x++; y++; } } void GGIwrite_rgba_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLubyte rgba[][4], - const GLubyte mask[] ) + GLuint n, const GLint x[], const GLint y[], + const GLchan rgba[][4], const GLubyte mask[]) { - FB_TYPE *fb=LFB(FB_TYPE,0,0); - FB_TYPE color; + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual); while (n--) { - if (*mask++) { - color= ((rgba[0][RCOMP]>>RS) << (G+B)) | - ((rgba[0][GCOMP]>>GS) << B) | - ((rgba[0][BCOMP]>>BS)); - *(fb+ *x + FLIP(*y)*GGICTX->width)=color; + if (*mask++){ + FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *dst = PACK(rgba[0]); } - x++;y++; + x++; + y++; rgba++; } } +void GGIwrite_mono_rgba_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLchan rgba[4], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual); + + while (n--) { + if (*mask++){ + FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *dst = PACK(rgba); + } + + x++; + y++; + } +} /**********************************************************************/ /***** Read arrays of pixels *****/ /**********************************************************************/ void GGIread_ci32_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLuint ci[], const GLubyte mask[]) + GLuint n, const GLint x[], const GLint y[], + GLuint ci[], const GLubyte mask[]) { - FB_TYPE *fb=LFB(FB_TYPE,0,0); + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual); while (n--) { - if (*mask++) - *ci=*(fb+ *x + FLIP(*y)*GGICTX->width); + if (*mask++){ + FB_TYPE *src = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *ci = *src; + } ci++; x++; y++; @@ -270,60 +339,70 @@ void GGIread_ci32_pixels(const GLcontext *ctx, } void GGIread_rgba_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], - const GLubyte mask[] ) + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[]) { - FB_TYPE *fb=LFB(FB_TYPE,0,0); + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual); FB_TYPE color; while (n--) { if (*mask++) - { - color=*(fb+ *x + FLIP(*y)*GGICTX->width); - rgba[0][RCOMP] =(GLubyte)(color>>(G+B))<<RS; - rgba[0][GCOMP] =(GLubyte)((color>>B)& ((1<<G)-1))<<GS; - rgba[0][BCOMP] =(GLubyte) (color & ((1<<B)-1))<<BS; - rgba[0][ACOMP] =0; + { + FB_TYPE *src = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + color = *src; + + rgba[0][RCOMP] = (GLubyte)(color>>(G+B))<<RS; + rgba[0][GCOMP] = (GLubyte)((color>>B)& ((1<<G)-1))<<GS; + rgba[0][BCOMP] = (GLubyte) (color & ((1<<B)-1))<<BS; + rgba[0][ACOMP] = 0; } - x++; y++; + x++; + y++; rgba++; } } -int GGIsetup_driver(GGIMesaContext ggictx, struct ggi_mesa_info *info) +void GGIset_read_buffer(GLcontext *ctx, GLframebuffer *buffer, GLenum mode) { - GLcontext *ctx = ggictx->gl_ctx; - - ctx->Driver.WriteRGBASpan = GGIwrite_rgba_span; - ctx->Driver.WriteRGBSpan = GGIwrite_rgb_span; -// ctx->Driver.WriteMonoRGBASpan = GGIwrite_mono_span; - ctx->Driver.WriteRGBAPixels = GGIwrite_rgba_pixels; -// ctx->Driver.WriteMonoRGBAPixels = GGIwrite_mono_pixels; - - ctx->Driver.WriteCI32Span = GGIwrite_ci32_span; - ctx->Driver.WriteCI8Span = GGIwrite_ci8_span; -// ctx->Driver.WriteMonoCISpan = GGIwrite_mono_span; - ctx->Driver.WriteCI32Pixels = GGIwrite_ci32_pixels; -// ctx->Driver.WriteMonoCIPixels = GGIwrite_mono_pixels; - - ctx->Driver.ReadCI32Span = GGIread_ci32_span; - ctx->Driver.ReadRGBASpan = GGIread_rgba_span; - ctx->Driver.ReadCI32Pixels = GGIread_ci32_pixels; - ctx->Driver.ReadRGBAPixels = GGIread_rgba_pixels; +} - info->red_bits = R; - info->green_bits =G; - info->blue_bits = B; +int GGIsetup_driver(ggi_mesa_context_t ggi_ctx) +{ + struct swrast_device_driver *swdd = + _swrast_GetDeviceDriverReference(ggi_ctx->gl_ctx); + + GGIMESADPRINT_LIBS("linear_%d: GGIsetup_driver\n", sizeof(FB_TYPE)*8); + + swdd->WriteRGBASpan = GGIwrite_rgba_span; + swdd->WriteRGBSpan = GGIwrite_rgb_span; + swdd->WriteMonoRGBASpan = GGIwrite_mono_rgba_span; + swdd->WriteRGBAPixels = GGIwrite_rgba_pixels; + swdd->WriteMonoRGBAPixels = GGIwrite_mono_rgba_pixels; + + swdd->WriteCI32Span = GGIwrite_ci32_span; + swdd->WriteCI8Span = GGIwrite_ci8_span; + swdd->WriteMonoCISpan = GGIwrite_mono_ci_span; + swdd->WriteCI32Pixels = GGIwrite_ci32_pixels; + swdd->WriteMonoCIPixels = GGIwrite_mono_ci_pixels; + + swdd->ReadCI32Span = GGIread_ci32_span; + swdd->ReadRGBASpan = GGIread_rgba_span; + swdd->ReadCI32Pixels = GGIread_ci32_pixels; + swdd->ReadRGBAPixels = GGIread_rgba_pixels; + + swdd->SetReadBuffer = GGIset_read_buffer; return 0; } static int GGIopen(ggi_visual_t vis,struct ggi_dlhandle *dlh, - const char *args,void *argptr, uint32 *dlret) -{ - LIBGGI_MESAEXT(vis)->setup_driver=GGIsetup_driver; + const char *args,void *argptr, uint32 *dlret) +{ + GGIMESADPRINT_CORE("linear_%d: GGIOpen\n", sizeof(FB_TYPE)*8); + LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver; *dlret = GGI_DL_OPDRAW; return 0; @@ -332,15 +411,15 @@ static int GGIopen(ggi_visual_t vis,struct ggi_dlhandle *dlh, int DLOPENFUNC(int func, void **funcptr) { switch (func) { - case GGIFUNC_open: - *funcptr = GGIopen; - return 0; - case GGIFUNC_exit: - case GGIFUNC_close: - *funcptr = NULL; - return 0; - default: - *funcptr = NULL; + case GGIFUNC_open: + *funcptr = GGIopen; + return 0; + case GGIFUNC_exit: + case GGIFUNC_close: + *funcptr = NULL; + return 0; + default: + *funcptr = NULL; } return GGI_ENOTFOUND; } |