summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/ggi/default
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-06-10 15:16:44 +0000
committerBrian Paul <[email protected]>2002-06-10 15:16:44 +0000
commitb58c5ad7b0a2c3ed3ecf189f284e23118091fa68 (patch)
tree65f0df21580a254758afe61094c51d436118ec54 /src/mesa/drivers/ggi/default
parentdd41748f63b819c36c4234a525e5609660ceb395 (diff)
GGI driver updates (Filip Spacek)
Diffstat (limited to 'src/mesa/drivers/ggi/default')
-rw-r--r--src/mesa/drivers/ggi/default/linear.c347
-rw-r--r--src/mesa/drivers/ggi/default/stubs.c265
2 files changed, 387 insertions, 225 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;
}
diff --git a/src/mesa/drivers/ggi/default/stubs.c b/src/mesa/drivers/ggi/default/stubs.c
index 07999276fbf..27eb363627d 100644
--- a/src/mesa/drivers/ggi/default/stubs.c
+++ b/src/mesa/drivers/ggi/default/stubs.c
@@ -26,13 +26,16 @@
#include <ggi/internal/ggi-dl.h>
#include <ggi/mesa/ggimesa_int.h>
+#include <ggi/mesa/debug.h>
#include "mmath.h"
#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "swrast/s_context.h"
-#include "swrast/s_depth.h"
-#include "swrast/s_triangle.h"
+//#include "swrast_setup/swrast_setup.h"
+//#include "swrast/s_context.h"
+//#include "swrast/s_depth.h"
+//#include "swrast/s_triangle.h"
+
+#define FLIP(coord) (LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y-(coord)-1)
/**********************************************************************/
/***** Write spans of pixels *****/
@@ -43,18 +46,21 @@ void GGIwrite_ci32_span(const GLcontext *ctx,
const GLuint ci[],
const GLubyte mask[] )
{
- y=FLIP(y);
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
+ y = FLIP(y);
if (mask)
{
while (n--) {
- if (*mask++) ggiPutPixel(VIS,x,y,*ci);
+ if (*mask++)
+ ggiPutPixel(ggi_ctx->ggi_visual, x, y, *ci);
x++;
ci++;
}
}
else
{
- while (n--) ggiPutPixel(VIS,x++,y,*ci++);
+ while (n--)
+ ggiPutPixel(ggi_ctx->ggi_visual, x++, y, *ci++);
}
}
@@ -63,36 +69,69 @@ void GGIwrite_ci8_span(const GLcontext *ctx,
const GLubyte ci[],
const GLubyte mask[] )
{
- y=FLIP(y);
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
+ y = FLIP(y);
if (mask)
{
while (n--) {
- if (*mask++) ggiPutPixel(VIS,x,y,*ci);
+ if (*mask++)
+ ggiPutPixel(ggi_ctx->ggi_visual, x, y, *ci);
x++;
ci++;
}
}
else
{
- while (n--) ggiPutPixel(VIS,x++,y,*ci++);
+ while (n--)
+ ggiPutPixel(ggi_ctx->ggi_visual, x++, y, *ci++);
}
}
-void GGIwrite_mono_span( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte mask[] )
+void GGIwrite_mono_ci_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLuint ci, const GLubyte mask[])
{
- y=FLIP(y);
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
+ y = FLIP(y);
if (mask)
{
while (n--) {
- if (*mask++) ggiDrawPixel(VIS,x,y);
+ if (*mask++)
+ ggiPutPixel(ggi_ctx->ggi_visual, x, y, ci);
x++;
}
}
else
{
- ggiDrawHLine(VIS,x,y,n);
+ while (n--)
+ ggiPutPixel(ggi_ctx->ggi_visual, x++, y, ci);
+ }
+}
+
+void GGIwrite_mono_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLchan rgba[4], const GLubyte mask[])
+{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
+ ggi_color rgb;
+ ggi_pixel col;
+
+ y = FLIP(y);
+
+ rgb.r = (uint16)(rgba[RCOMP]) << SHIFT;
+ rgb.g = (uint16)(rgba[GCOMP]) << SHIFT;
+ rgb.b = (uint16)(rgba[BCOMP]) << SHIFT;
+ col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
+
+ if (mask)
+ {
+ while (n--) {
+ if (*mask++)
+ ggiPutPixel(ggi_ctx->ggi_visual, x, y, col);
+ x++;
+ }
+ }
+ else
+ {
+ ggiDrawHLine(ggi_ctx->ggi_visual, x, y, n);
}
}
@@ -101,20 +140,21 @@ void GGIwrite_rgba_span( const GLcontext *ctx,
const GLubyte rgba[][4],
const GLubyte mask[])
{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
- y=FLIP(y);
+ y = FLIP(y);
if (mask)
{
while (n--) {
if (*mask++)
{
- rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
- rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
- rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
- col=ggiMapColor(VIS,&rgb);
- ggiPutPixel(VIS,x,y,col);
+ rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
+ rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
+ rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
+ col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
+ ggiPutPixel(ggi_ctx->ggi_visual, x, y, col);
}
x++;
rgba++;
@@ -124,34 +164,36 @@ void GGIwrite_rgba_span( const GLcontext *ctx,
{
while (n--)
{
- rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
- rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
- rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
- col=ggiMapColor(VIS,&rgb);
- ggiPutPixel(VIS,x++,y,col);
+ rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
+ rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
+ rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
+ col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
+ ggiPutPixel(ggi_ctx->ggi_visual, x++, y, col);
rgba++;
}
}
}
+
void GGIwrite_rgb_span( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte rgba[][3],
const GLubyte mask[] )
{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
- y=FLIP(y);
+ y = FLIP(y);
if (mask)
{
while (n--) {
if (*mask++)
{
- rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
- rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
- rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
- col=ggiMapColor(VIS,&rgb);
- ggiPutPixel(VIS,x,y,col);
+ rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
+ rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
+ rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
+ col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
+ ggiPutPixel(ggi_ctx->ggi_visual, x, y, col);
}
x++;
rgba++;
@@ -161,11 +203,11 @@ void GGIwrite_rgb_span( const GLcontext *ctx,
{
while (n--)
{
- rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
- rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
- rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
- col=ggiMapColor(VIS,&rgb);
- ggiPutPixel(VIS,x++,y,col);
+ rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
+ rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
+ rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
+ col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
+ ggiPutPixel(ggi_ctx->ggi_visual, x++, y, col);
rgba++;
}
}
@@ -181,24 +223,26 @@ void GGIwrite_rgb_span( const GLcontext *ctx,
void GGIread_ci32_span( const GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint ci[])
{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
y = FLIP(y);
while (n--)
- ggiGetPixel(VIS, x++, y,ci++);
+ ggiGetPixel(ggi_ctx->ggi_visual, x++, y, ci++);
}
void GGIread_rgba_span( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLubyte rgba[][4])
{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
- y=FLIP(y);
+ y = FLIP(y);
while (n--)
{
- ggiGetPixel(VIS,x++,y,&col);
- ggiUnmapPixel(VIS,col,&rgb);
+ ggiGetPixel(ggi_ctx->ggi_visual, x++, y, &col);
+ ggiUnmapPixel(ggi_ctx->ggi_visual, col, &rgb);
rgba[0][RCOMP] = (GLubyte) (rgb.r >> SHIFT);
rgba[0][GCOMP] = (GLubyte) (rgb.g >> SHIFT);
rgba[0][BCOMP] = (GLubyte) (rgb.b >> SHIFT);
@@ -215,21 +259,24 @@ void GGIwrite_ci32_pixels( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLuint ci[], const GLubyte mask[] )
{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
while (n--) {
- if (*mask++) ggiPutPixel(VIS,*x, FLIP(*y),*ci);
+ if (*mask++)
+ ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), *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[])
{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
while (n--) {
- if (*mask++) ggiDrawPixel(VIS,*x,FLIP(*y));
+ if (*mask++)
+ ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), ci);
x++;
y++;
}
@@ -240,21 +287,43 @@ void GGIwrite_rgba_pixels( const GLcontext *ctx,
const GLubyte rgba[][4],
const GLubyte mask[] )
{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_pixel col;
ggi_color rgb;
while (n--) {
if (*mask++) {
- rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
- rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
- rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
- col=ggiMapColor(VIS,&rgb);
- ggiPutPixel(VIS,*x,FLIP(*y),col);
+ rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
+ rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
+ rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
+ col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
+ ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), col);
}
- 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;
+ ggi_color rgb;
+ ggi_pixel col;
+
+ rgb.r = (uint16)(rgba[RCOMP]) << SHIFT;
+ rgb.g = (uint16)(rgba[GCOMP]) << SHIFT;
+ rgb.b = (uint16)(rgba[BCOMP]) << SHIFT;
+ col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
+
+ while (n--) {
+ if (*mask++)
+ ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), col);
+ x++;
+ y++;
+ }
+}
/**********************************************************************/
/***** Read arrays of pixels *****/
@@ -264,9 +333,10 @@ void GGIread_ci32_pixels( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint ci[], const GLubyte mask[])
{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
while (n--) {
if (*mask++)
- ggiGetPixel(VIS, *x, FLIP(*y) ,ci);
+ ggiGetPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), ci);
ci++;
x++;
y++;
@@ -278,6 +348,7 @@ void GGIread_rgba_pixels( const GLcontext *ctx,
GLubyte rgba[][4],
const GLubyte mask[] )
{
+ ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
@@ -285,47 +356,59 @@ void GGIread_rgba_pixels( const GLcontext *ctx,
{
if (*mask++)
{
- ggiGetPixel(VIS,*x,FLIP(*y),&col);
- ggiUnmapPixel(VIS,col,&rgb);
- rgba[0][RCOMP]= rgb.r >> SHIFT;
- rgba[0][GCOMP]= rgb.g >> SHIFT;
- rgba[0][BCOMP]= rgb.b >> SHIFT;
- rgba[0][ACOMP]=0;
+ ggiGetPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), &col);
+ ggiUnmapPixel(ggi_ctx->ggi_visual, col, &rgb);
+ rgba[0][RCOMP] = rgb.r >> SHIFT;
+ rgba[0][GCOMP] = rgb.g >> SHIFT;
+ rgba[0][BCOMP] = rgb.b >> SHIFT;
+ rgba[0][ACOMP] = 0;
}
- x++; y++;
+ x++;
+ y++;
rgba++;
}
}
-
-static swrast_tri_func ggimesa_stubs_get_triangle_func(GLcontext *ctx);
-
-int GGIsetup_driver(GGIMesaContext ggictx, struct ggi_mesa_info *info)
+int GGIextend_visual(ggi_visual_t vis)
{
- GLcontext *ctx = ggictx->gl_ctx;
+ return 0;
+}
- ctx->Driver.WriteRGBASpan = GGIwrite_rgba_span;
- ctx->Driver.WriteRGBSpan = GGIwrite_rgb_span;
- ctx->Driver.WriteRGBAPixels = GGIwrite_rgba_pixels;
+//static swrast_tri_func ggimesa_stubs_get_triangle_func(GLcontext *ctx);
- ctx->Driver.WriteCI32Span = GGIwrite_ci32_span;
- ctx->Driver.WriteCI8Span = GGIwrite_ci8_span;
- ctx->Driver.WriteCI32Pixels = GGIwrite_ci32_pixels;
+int GGIsetup_driver(ggi_mesa_context_t ggi_ctx)
+{
+ struct swrast_device_driver *swdd =
+ _swrast_GetDeviceDriverReference(ggi_ctx->gl_ctx);
- ctx->Driver.ReadCI32Span = GGIread_ci32_span;
- ctx->Driver.ReadRGBASpan = GGIread_rgba_span;
- ctx->Driver.ReadCI32Pixels = GGIread_ci32_pixels;
- ctx->Driver.ReadRGBAPixels = GGIread_rgba_pixels;
+ GGIMESADPRINT_CORE("stubs: setup_driver\n");
+
+ 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;
return 0;
}
-void GGIupdate_state(GLcontext *ctx)
+void GGIupdate_state(ggi_mesa_context_t *ctx)
{
- ctx->Driver.TriangleFunc = _swsetup_Triangle;
+ //ctx->Driver.TriangleFunc = _swsetup_Triangle;
}
-
+/*
void GGItriangle_flat(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2)
{
//#define INTERP_Z 1
@@ -402,10 +485,10 @@ static swrast_tri_func ggimesa_stubs_get_triangle_func(GLcontext *ctx)
return GGItriangle_flat;
}
-
+*/
static int GGIopen(ggi_visual_t vis, struct ggi_dlhandle *dlh,
const char *args, void *argptr, uint32 *dlret)
-{
+{
LIBGGI_MESAEXT(vis)->update_state = GGIupdate_state;
LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver;
@@ -416,15 +499,15 @@ static int GGIopen(ggi_visual_t vis, struct ggi_dlhandle *dlh,
int MesaGGIdl_stubs(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;
}