From 7a36345f70a0b8ac2d480bb52eb2c74c2be5a978 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 16 Jan 2012 12:10:46 -0700 Subject: [PATCH] mesa: rename gl_renderbuffer::Data to Buffer To better indicate that this pointer to the malloc'd memory. --- src/mesa/drivers/dri/intel/intel_fbo.c | 6 +++--- src/mesa/drivers/dri/swrast/swrast.c | 26 +++++++++++++------------- src/mesa/drivers/osmesa/osmesa.c | 14 +++++++------- src/mesa/drivers/x11/xm_api.c | 4 ++-- src/mesa/main/mtypes.h | 2 +- src/mesa/swrast/s_renderbuffer.c | 23 +++++++++++++---------- src/mesa/swrast/s_texrender.c | 4 ++-- 7 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index e13d62cc914..5463776aeb6 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -132,11 +132,11 @@ intel_map_renderbuffer(struct gl_context *ctx, void *map; int stride; - if (!irb && rb->Data) { + if (!irb && rb->Buffer) { /* this is a malloc'd renderbuffer (accum buffer) */ GLint bpp = _mesa_get_format_bytes(rb->Format); GLint rowStride = rb->RowStrideBytes; - *out_map = (GLubyte *) rb->Data + y * rowStride + x * bpp; + *out_map = (GLubyte *) rb->Buffer + y * rowStride + x * bpp; *out_stride = rowStride; return; } @@ -185,7 +185,7 @@ intel_unmap_renderbuffer(struct gl_context *ctx, DBG("%s: rb %d (%s)\n", __FUNCTION__, rb->Name, _mesa_get_format_name(rb->Format)); - if (!irb && rb->Data) { + if (!irb && rb->Buffer) { /* this is a malloc'd renderbuffer (accum buffer) */ /* nothing to do */ return; diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 19da7028e8a..f7cb3c24a58 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -265,7 +265,7 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb) { TRACE; - free(rb->Data); + free(rb->Buffer); free(rb); } @@ -289,7 +289,7 @@ swrast_alloc_front_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, (void) ctx; (void) internalFormat; - rb->Data = NULL; + rb->Buffer = NULL; rb->Width = width; rb->Height = height; xrb->pitch = bytes_per_line(width * xrb->bpp, 32); @@ -305,11 +305,11 @@ swrast_alloc_back_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, TRACE; - free(rb->Data); + free(rb->Buffer); swrast_alloc_front_storage(ctx, rb, internalFormat, width, height); - rb->Data = malloc(height * xrb->pitch); + rb->Buffer = malloc(height * xrb->pitch); return GL_TRUE; } @@ -380,7 +380,7 @@ swrast_map_renderbuffer(struct gl_context *ctx, GLint *out_stride) { struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); - GLubyte *map = rb->Data; + GLubyte *map = rb->Buffer; int cpp = _mesa_get_format_bytes(rb->Format); int stride = rb->Width * cpp; @@ -395,18 +395,18 @@ swrast_map_renderbuffer(struct gl_context *ctx, xrb->map_h = h; stride = w * cpp; - rb->Data = malloc(h * stride); + rb->Buffer = malloc(h * stride); sPriv->swrast_loader->getImage(dPriv, x, y, w, h, - (char *)rb->Data, + (char *)rb->Buffer, dPriv->loaderPrivate); - *out_map = rb->Data; + *out_map = rb->Buffer; *out_stride = stride; return; } - ASSERT(rb->Data); + ASSERT(rb->Buffer); if (rb->AllocStorage == swrast_alloc_back_storage) { map += (rb->Height - 1) * stride; @@ -434,12 +434,12 @@ swrast_unmap_renderbuffer(struct gl_context *ctx, sPriv->swrast_loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_DRAW, xrb->map_x, xrb->map_y, xrb->map_w, xrb->map_h, - rb->Data, + rb->Buffer, dPriv->loaderPrivate); } - free(rb->Data); - rb->Data = NULL; + free(rb->Buffer); + rb->Buffer = NULL; } } @@ -556,7 +556,7 @@ dri_swap_buffers(__DRIdrawable * dPriv) 0, 0, frontrb->Base.Width, frontrb->Base.Height, - backrb->Base.Data, + backrb->Base.Buffer, dPriv->loaderPrivate); } diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 5c1a3f3b783..1c4f52b7cd2 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -354,7 +354,7 @@ static void compute_row_addresses( OSMesaContext osmesa ) { GLint bytesPerRow, i; - GLubyte *origin = (GLubyte *) osmesa->rb->Data; + GLubyte *origin = (GLubyte *) osmesa->rb->Buffer; GLint rowlength; /* in pixels */ GLint height = osmesa->rb->Height; @@ -383,7 +383,7 @@ compute_row_addresses( OSMesaContext osmesa ) /** - * Don't use _mesa_delete_renderbuffer since we can't free rb->Data. + * Don't use _mesa_delete_renderbuffer since we can't free rb->Buffer. */ static void osmesa_delete_renderbuffer(struct gl_renderbuffer *rb) @@ -891,7 +891,7 @@ OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type, /* Set renderbuffer fields. Set width/height = 0 to force * osmesa_renderbuffer_storage() being called by _mesa_resize_framebuffer() */ - osmesa->rb->Data = buffer; + osmesa->rb->Buffer = buffer; osmesa->rb->Width = osmesa->rb->Height = 0; /* Set the framebuffer's size. This causes the @@ -1024,7 +1024,7 @@ OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height, if (c->gl_buffer) rb = c->gl_buffer->Attachment[BUFFER_DEPTH].Renderbuffer; - if (!rb || !rb->Data) { + if (!rb || !rb->Buffer) { *width = 0; *height = 0; *bytesPerValue = 0; @@ -1038,7 +1038,7 @@ OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height, *bytesPerValue = sizeof(GLushort); else *bytesPerValue = sizeof(GLuint); - *buffer = rb->Data; + *buffer = (void *) rb->Buffer; return GL_TRUE; } } @@ -1056,11 +1056,11 @@ GLAPI GLboolean GLAPIENTRY OSMesaGetColorBuffer( OSMesaContext osmesa, GLint *width, GLint *height, GLint *format, void **buffer ) { - if (osmesa->rb && osmesa->rb->Data) { + if (osmesa->rb && osmesa->rb->Buffer) { *width = osmesa->rb->Width; *height = osmesa->rb->Height; *format = osmesa->format; - *buffer = osmesa->rb->Data; + *buffer = (void *) osmesa->rb->Buffer; return GL_TRUE; } else { diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index bdee2a2a341..d0374ec121a 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1484,7 +1484,7 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height, { struct gl_renderbuffer *rb = b->mesa_buffer.Attachment[BUFFER_DEPTH].Renderbuffer; - if (!rb || !rb->Data) { + if (!rb || !rb->Buffer) { *width = 0; *height = 0; *bytesPerValue = 0; @@ -1496,7 +1496,7 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height, *height = b->mesa_buffer.Height; *bytesPerValue = b->mesa_buffer.Visual.depthBits <= 16 ? sizeof(GLushort) : sizeof(GLuint); - *buffer = rb->Data; + *buffer = (void *) rb->Buffer; return GL_TRUE; } } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 638f1ec165d..919244dfa3a 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2559,7 +2559,7 @@ struct gl_renderbuffer gl_format Format; /**< The actual renderbuffer memory format */ /* XXX the following fields are obsolete and wil go away */ - GLvoid *Data; /**< This may not be used by some kinds of RBs */ + GLvoid *Buffer; /**< Malloc'd memory for software buffers */ /** The following fields are only valid while the buffer is mapped */ GLubyte *Map; diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c index 825214c95df..52697f2ac75 100644 --- a/src/mesa/swrast/s_renderbuffer.c +++ b/src/mesa/swrast/s_renderbuffer.c @@ -113,18 +113,18 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, } /* free old buffer storage */ - if (rb->Data) { - free(rb->Data); - rb->Data = NULL; + if (rb->Buffer) { + free(rb->Buffer); + rb->Buffer = NULL; } rb->RowStrideBytes = width * _mesa_get_format_bytes(rb->Format); if (width > 0 && height > 0) { /* allocate new buffer storage */ - rb->Data = malloc(width * height * _mesa_get_format_bytes(rb->Format)); + rb->Buffer = malloc(width * height * _mesa_get_format_bytes(rb->Format)); - if (rb->Data == NULL) { + if (rb->Buffer == NULL) { rb->Width = 0; rb->Height = 0; _mesa_error(ctx, GL_OUT_OF_MEMORY, @@ -162,9 +162,9 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, static void soft_renderbuffer_delete(struct gl_renderbuffer *rb) { - if (rb->Data) { - free(rb->Data); - rb->Data = NULL; + if (rb->Buffer) { + free(rb->Buffer); + rb->Buffer = NULL; } free(rb); } @@ -178,11 +178,14 @@ _swrast_map_soft_renderbuffer(struct gl_context *ctx, GLubyte **out_map, GLint *out_stride) { - GLubyte *map = rb->Data; + GLubyte *map = rb->Buffer; int cpp = _mesa_get_format_bytes(rb->Format); int stride = rb->Width * cpp; - ASSERT(rb->Data); + if (!map) { + *out_map = NULL; + *out_stride = 0; + } map += y * stride; map += x * cpp; diff --git a/src/mesa/swrast/s_texrender.c b/src/mesa/swrast/s_texrender.c index 368fa98b214..af4be7bab1c 100644 --- a/src/mesa/swrast/s_texrender.c +++ b/src/mesa/swrast/s_texrender.c @@ -135,12 +135,12 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) */ if (att->Texture->Target == GL_TEXTURE_3D || att->Texture->Target == GL_TEXTURE_2D_ARRAY_EXT) { - trb->Base.Data = trb->TexImage->Buffer + + trb->Base.Buffer = trb->TexImage->Buffer + trb->TexImage->ImageOffsets[trb->Zoffset] * _mesa_get_format_bytes(trb->TexImage->Base.TexFormat); } else { - trb->Base.Data = trb->TexImage->Buffer; + trb->Base.Buffer = trb->TexImage->Buffer; } /* XXX may need more special cases here */ -- 2.30.2