diff options
author | Brian Paul <[email protected]> | 2009-10-29 16:30:36 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-10-29 16:31:57 -0600 |
commit | d0b6147291fe42d7d733b3d0e5b10c4f4f08030f (patch) | |
tree | d59696cbbf4101fb2c525bd3f8f2e8bad1b2d53f | |
parent | fcbf66364032743abeb41a82a5ceaf68a15d900f (diff) |
intel: remove memcpy_get_tex_image() code
This has been lifted into core Mesa where it can be used for all drivers
that use the _mesa_get_teximage() fallback for ctx->Driver.GetTexImage().
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex_image.c | 105 |
1 files changed, 2 insertions, 103 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 6301444c340..3dce1b0a879 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -620,104 +620,6 @@ intelCompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level, /** - * Try to use memcpy() to do a glGetTexImage(). - * \return GL_TRUE if done, GL_FALSE otherwise - */ -static GLboolean -memcpy_get_tex_image(GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid * pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLboolean memCopy = GL_FALSE; - - /* Texture image should have been mapped already */ - assert(texImage->Data); - - /* - * Check if the src/dst formats are compatible. - * Also note that GL's pixel transfer ops don't apply to glGetTexImage() - * so we don't have to worry about those. - */ - if ((texObj->Target == GL_TEXTURE_1D || - texObj->Target == GL_TEXTURE_2D || - texObj->Target == GL_TEXTURE_RECTANGLE || - (texObj->Target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && - texObj->Target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) { - if (texImage->TexFormat == MESA_FORMAT_ARGB8888 && - format == GL_BGRA && - type == GL_UNSIGNED_BYTE && - _mesa_little_endian()) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_AL88 && - format == GL_LUMINANCE_ALPHA && - type == GL_UNSIGNED_BYTE && - _mesa_little_endian()) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_L8 && - format == GL_LUMINANCE && - type == GL_UNSIGNED_BYTE) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_A8 && - format == GL_ALPHA && - type == GL_UNSIGNED_BYTE) { - memCopy = GL_TRUE; - } - } - - if (memCopy) { - struct gl_pixelstore_attrib *pack = &ctx->Pack; - - if (_mesa_is_bufferobj(pack->BufferObj)) { - /* Packing texture image into a PBO */ - GLubyte *buf = (GLubyte *) - ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, pack->BufferObj); - if (!buf) { - /* out of memory or other unexpected error */ - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage(map PBO failed)"); - return GL_TRUE; /* failed, but done */ - } - pixels = ADD_POINTERS(buf, pixels); - } - - { - const GLuint bpp = _mesa_get_format_bytes(texImage->TexFormat); - const GLuint bytesPerRow = texImage->Width * bpp; - GLubyte *dst = - _mesa_image_address2d(&ctx->Pack, pixels, texImage->Width, - texImage->Height, format, type, 0, 0); - const GLint dstRowStride = - _mesa_image_row_stride(&ctx->Pack, texImage->Width, format, type); - const GLubyte *src = texImage->Data; - const GLint srcRowStride = texImage->RowStride * bpp; - GLuint row; - - if (bytesPerRow == dstRowStride && bytesPerRow == dstRowStride) { - memcpy(dst, src, bytesPerRow * texImage->Height); - } - else { - for (row = 0; row < texImage->Height; row++) { - memcpy(dst, src, bytesPerRow); - dst += dstRowStride; - src += srcRowStride; - } - } - } - - if (_mesa_is_bufferobj(pack->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, pack->BufferObj); - } - } - - return memCopy; -} - - -/** * Need to map texture image into memory before copying image data, * then unmap it. */ @@ -768,11 +670,8 @@ intel_get_tex_image(GLcontext * ctx, GLenum target, GLint level, texObj, texImage); } else { - if (!memcpy_get_tex_image(ctx, target, level, format, type, pixels, - texObj, texImage)) { - _mesa_get_teximage(ctx, target, level, format, type, pixels, - texObj, texImage); - } + _mesa_get_teximage(ctx, target, level, format, type, pixels, + texObj, texImage); } |