diff options
author | Brian <[email protected]> | 2007-08-10 08:33:43 +0100 |
---|---|---|
committer | Brian <[email protected]> | 2007-08-10 08:33:43 +0100 |
commit | d2bfdae860022b2cef2fff2de25440ba0e8f1d2b (patch) | |
tree | 8dbc91e95755abe7806b353db03b08000edd8933 | |
parent | c7157065b2c3be768e1b72e5a0980261bce315a7 (diff) |
invert Y axis
-rw-r--r-- | src/mesa/drivers/x11/xm_surface.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 9d7d25667e1..1915151ba48 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -63,24 +63,28 @@ xmesa_rb(struct softpipe_surface *sps) } +#define FLIP(Y) Y = xrb->St.Base.Height - (Y) - 1; + + /** * quad reading/writing * These functions are just wrappers around the existing renderbuffer * functions. + * Note that Y=0 is the top of the surface. */ static void read_quad_f(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rgba)[NUM_CHANNELS]) { - struct xmesa_surface *xms = xmesa_surf(sps); struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GLubyte temp[16]; GLfloat *dst = (GLfloat *) rgba; GLuint i; GET_CURRENT_CONTEXT(ctx); + FLIP(y); xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, temp); - xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y - 1, temp + 8); for (i = 0; i < 16; i++) { dst[i] = UBYTE_TO_FLOAT(temp[i]); } @@ -90,14 +94,14 @@ static void read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { - struct xmesa_surface *xms = xmesa_surf(sps); struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GLubyte temp[16]; GLfloat *dst = (GLfloat *) rrrr; GLuint i, j; GET_CURRENT_CONTEXT(ctx); + FLIP(y); xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, temp); - xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y - 1, temp + 8); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { dst[j * 4 + i] = UBYTE_TO_FLOAT(temp[i * 4 + j]); @@ -114,11 +118,12 @@ write_quad_f(struct softpipe_surface *sps, GLint x, GLint y, const GLfloat *src = (const GLfloat *) rgba; GLuint i; GET_CURRENT_CONTEXT(ctx); + FLIP(y); for (i = 0; i < 16; i++) { UNCLAMPED_FLOAT_TO_UBYTE(temp[i], src[i]); } xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y, temp, NULL); - xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8, NULL); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y - 1, temp + 8, NULL); } static void @@ -130,13 +135,14 @@ write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, const GLfloat *src = (const GLfloat *) rrrr; GLuint i, j; GET_CURRENT_CONTEXT(ctx); + FLIP(y); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + i], src[i * 4 + j]); } } xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y, temp, NULL); - xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8, NULL); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y - 1, temp + 8, NULL); } static void @@ -145,8 +151,9 @@ read_quad_ub(struct softpipe_surface *sps, GLint x, GLint y, { struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GET_CURRENT_CONTEXT(ctx); + FLIP(y); xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, rgba); - xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, rgba + 2); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y - 1, rgba + 2); } static void @@ -155,20 +162,10 @@ write_quad_ub(struct softpipe_surface *sps, GLint x, GLint y, { struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GET_CURRENT_CONTEXT(ctx); + FLIP(y); xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, rgba); - xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, rgba + 2); -} - -#if 0 -static void -write_mono_row_ub(struct softpipe_surface *sps, GLuint count, GLint x, GLint y, - GLubyte rgba[NUM_CHANNELS]) -{ - struct xmesa_renderbuffer *xrb = xmesa_rb(sps); - GET_CURRENT_CONTEXT(ctx); - xrb->St.Base.PutMonoRow(ctx, &xrb->St.Base, count, x, y, rgba, NULL); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y - 1, rgba + 2); } -#endif /** |