diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-09-25 17:07:59 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-09-25 17:07:59 -0600 |
commit | 960fe21008eb00bf778f82476e3d00df0a5c34db (patch) | |
tree | 8417b5d7114998eb21ced5f039ec5e2fff4b1724 /src/mesa | |
parent | b28f4a27d586b3ba3a7e87db761b6d624dd3e672 (diff) |
comments, null ptr checks, etc.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 30449658e9..fb89ceef8c 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -209,7 +209,9 @@ make_vertex_shader(struct st_context *st, GLboolean passColor) } - +/** + * Make mipmap tree containing the glDrawPixels image. + */ static struct pipe_mipmap_tree * make_mipmap_tree(struct st_context *st, GLsizei width, GLsizei height, GLenum format, GLenum type, @@ -230,11 +232,14 @@ make_mipmap_tree(struct st_context *st, cpp = st_sizeof_format(pipeFormat); mt = CALLOC_STRUCT(pipe_mipmap_tree); + if (!mt) + return NULL; if (unpack->BufferObj && unpack->BufferObj->Name) { /* mt->region = buffer_object_region(unpack->BufferObj); */ + printf("st_DrawPixels (sourcing from PBO not implemented yet)\n"); } else { static const GLuint dstImageOffsets = 0; @@ -654,10 +659,12 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, struct pipe_mipmap_tree *mt = make_mipmap_tree(ctx->st, width, height, format, type, unpack, pixels); - draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2], - width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY, - mt, stvp, stfp, NULL); - free_mipmap_tree(st->pipe, mt); + if (mt) { + draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2], + width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY, + mt, stvp, stfp, NULL); + free_mipmap_tree(st->pipe, mt); + } } else { /* blit */ @@ -671,9 +678,9 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, * Create a texture which represents a bitmap image. */ static struct pipe_mipmap_tree * -create_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap) +make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap) { struct pipe_context *pipe = ctx->st->pipe; const uint flags = PIPE_SURFACE_FLAG_TEXTURE; @@ -707,6 +714,16 @@ create_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, * Create a mipmap tree. */ mt = CALLOC_STRUCT(pipe_mipmap_tree); + if (!mt) + return NULL; + + if (unpack->BufferObj && unpack->BufferObj->Name) { + /* + mt->region = buffer_object_region(unpack->BufferObj); + */ + printf("st_Bitmap (sourcing from PBO not implemented yet)\n"); + } + /* allocate texture region/storage */ mt->region = pipe->region_alloc(pipe, cpp, width, height, flags); @@ -714,6 +731,10 @@ create_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, /* map texture region */ dest = pipe->region_map(pipe, mt->region); + if (!dest) { + printf("st_Bitmap region_map() failed!?!"); + return NULL; + } /* Put image into texture region. * Note that the image is actually going to be upside down in @@ -732,7 +753,7 @@ create_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, for (col = 0; col < width; col++) { /* set texel to 255 if bit is set */ - destRow[comp] = 255; //(*src & mask) ? 255 : 0; + destRow[comp] = (*src & mask) ? 255 : 0; destRow += cpp; if (mask == 128U) { @@ -822,14 +843,15 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, st_validate_state(st); - mt = create_bitmap_texture(ctx, width, height, unpack, bitmap); - - draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2], - width, height, 1.0, 1.0, - mt, stvp, stfp, - ctx->Current.RasterColor); + mt = make_bitmap_texture(ctx, width, height, unpack, bitmap); + if (mt) { + draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2], + width, height, 1.0, 1.0, + mt, stvp, stfp, + ctx->Current.RasterColor); - free_mipmap_tree(st->pipe, mt); + free_mipmap_tree(st->pipe, mt); + } } |