*/
#include "imports.h"
+#include "formats.h"
#include "mipmap.h"
#include "texcompress.h"
#include "texformat.h"
#include "teximage.h"
+#include "texstore.h"
#include "image.h"
struct gl_texture_object *texObj)
{
const struct gl_texture_image *srcImage;
- const struct gl_texture_format *convertFormat;
+ gl_format convertFormat;
const GLubyte *srcData = NULL;
GLubyte *dstData = NULL;
GLint level, maxLevels;
ASSERT(maxLevels > 0); /* bad target */
/* Find convertFormat - the format that do_row() will process */
- if (srcImage->IsCompressed) {
+ if (_mesa_is_format_compressed(srcImage->TexFormat)) {
/* setup for compressed textures */
GLuint row;
GLint components, size;
texObj->Target == GL_TEXTURE_CUBE_MAP_ARB);
if (srcImage->_BaseFormat == GL_RGB) {
- convertFormat = &_mesa_texformat_rgb;
+ convertFormat = MESA_FORMAT_RGB888;
components = 3;
}
else if (srcImage->_BaseFormat == GL_RGBA) {
- convertFormat = &_mesa_texformat_rgba;
+ convertFormat = MESA_FORMAT_RGBA8888;
components = 4;
}
else {
&dstWidth, &dstHeight, &dstDepth);
if (!nextLevel) {
/* all done */
- if (srcImage->IsCompressed) {
+ if (_mesa_is_format_compressed(srcImage->TexFormat)) {
_mesa_free((void *) srcData);
_mesa_free(dstData);
}
dstImage->TexFormat = srcImage->TexFormat;
dstImage->FetchTexelc = srcImage->FetchTexelc;
dstImage->FetchTexelf = srcImage->FetchTexelf;
- dstImage->IsCompressed = srcImage->IsCompressed;
- if (dstImage->IsCompressed) {
+ if (_mesa_is_format_compressed(dstImage->TexFormat)) {
dstImage->CompressedSize
= ctx->Driver.CompressedTextureSize(ctx, dstImage->Width,
dstImage->Height,
dstImage->Depth,
- dstImage->TexFormat->MesaFormat);
+ dstImage->TexFormat);
ASSERT(dstImage->CompressedSize > 0);
}
/* Alloc new teximage data buffer.
* Setup src and dest data pointers.
*/
- if (dstImage->IsCompressed) {
+ if (_mesa_is_format_compressed(dstImage->TexFormat)) {
dstImage->Data = _mesa_alloc_texmemory(dstImage->CompressedSize);
if (!dstImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
ASSERT(dstData);
}
else {
- bytesPerTexel = dstImage->TexFormat->TexelBytes;
+ bytesPerTexel = _mesa_get_format_bytes(dstImage->TexFormat);
ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0);
dstImage->Data = _mesa_alloc_texmemory(dstWidth * dstHeight
* dstDepth * bytesPerTexel);
dstData, dstImage->RowStride);
- if (dstImage->IsCompressed) {
+ if (_mesa_is_format_compressed(dstImage->TexFormat)) {
GLubyte *temp;
/* compress image from dstData into dstImage->Data */
- const GLenum srcFormat = convertFormat->BaseFormat;
+ const GLenum srcFormat = _mesa_get_format_base_format(convertFormat);
GLint dstRowStride
- = _mesa_compressed_row_stride(dstImage->TexFormat->MesaFormat, dstWidth);
+ = _mesa_compressed_row_stride(dstImage->TexFormat, dstWidth);
ASSERT(srcFormat == GL_RGB || srcFormat == GL_RGBA);
- dstImage->TexFormat->StoreImage(ctx, 2, dstImage->_BaseFormat,
- dstImage->TexFormat,
- dstImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride, 0, /* strides */
- dstWidth, dstHeight, 1, /* size */
- srcFormat, CHAN_TYPE,
- dstData, /* src data, actually */
- &ctx->DefaultPacking);
+
+ _mesa_texstore(ctx, 2, dstImage->_BaseFormat,
+ dstImage->TexFormat,
+ dstImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride, 0, /* strides */
+ dstWidth, dstHeight, 1, /* size */
+ srcFormat, CHAN_TYPE,
+ dstData, /* src data, actually */
+ &ctx->DefaultPacking);
+
/* swap src and dest pointers */
temp = (GLubyte *) srcData;
srcData = dstData;