* \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1
* if an invalid type enum.
*/
-GLint _mesa_sizeof_type( GLenum type )
+GLint
+_mesa_sizeof_type( GLenum type )
{
switch (type) {
case GL_BITMAP:
* Same as _mesa_sizeof_type() but also accepting the packed pixel
* format data types.
*/
-GLint _mesa_sizeof_packed_type( GLenum type )
+GLint
+_mesa_sizeof_packed_type( GLenum type )
{
switch (type) {
case GL_BITMAP:
*
* \return the number of components in the given format, or -1 if a bad format.
*/
-GLint _mesa_components_in_format( GLenum format )
+GLint
+_mesa_components_in_format( GLenum format )
{
switch (format) {
case GL_COLOR_INDEX:
*
* \return bytes per pixel, or -1 if a bad format or type was given.
*/
-GLint _mesa_bytes_per_pixel( GLenum format, GLenum type )
+GLint
+_mesa_bytes_per_pixel( GLenum format, GLenum type )
{
GLint comps = _mesa_components_in_format( format );
if (comps < 0)
* \param type pixel data type.
*
* \return the stride in bytes for the given parameters.
- *
- * Computes the number of bytes per pixel and row and compensates for alignment.
- *
- * \sa gl_pixelstore_attrib.
*/
GLint
_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32],
const struct gl_pixelstore_attrib *unpacking )
{
- GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap( 32, 32, pattern, unpacking );
+ GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap(32, 32, pattern, unpacking);
if (ptrn) {
/* Convert pattern from GLubytes to GLuints and handle big/little
* endian differences
| (p[3] );
p += 4;
}
- FREE(ptrn);
+ _mesa_free(ptrn);
}
}
/* Alloc dest storage */
bytes = ((width + 7) / 8 * height);
- buffer = (GLubyte *) MALLOC( bytes );
+ buffer = (GLubyte *) _mesa_malloc( bytes );
if (!buffer)
return NULL;
-
width_in_bytes = CEILING( width, 8 );
dst = buffer;
for (row = 0; row < height; row++) {
_mesa_image_address2d(packing, pixels, width, height,
GL_COLOR_INDEX, GL_BITMAP, row, 0);
if (!src) {
- FREE(buffer);
+ _mesa_free(buffer);
return NULL;
}
if (packing->SkipPixels == 0) {
- MEMCPY( dst, src, width_in_bytes );
+ _mesa_memcpy( dst, src, width_in_bytes );
if (packing->LsbFirst) {
flip_bytes( dst, width_in_bytes );
}
return;
if (packing->SkipPixels == 0) {
- MEMCPY( dst, src, width_in_bytes );
+ _mesa_memcpy( dst, src, width_in_bytes );
if (packing->LsbFirst) {
flip_bytes( dst, width_in_bytes );
}
/* Test for optimized case first */
if (transferOps == 0 && dstFormat == GL_RGBA && dstType == CHAN_TYPE) {
/* common simple case */
- MEMCPY(dstAddr, srcRgba, n * 4 * sizeof(GLchan));
+ _mesa_memcpy(dstAddr, srcRgba, n * 4 * sizeof(GLchan));
}
else if (transferOps == 0 && dstFormat == GL_RGB && dstType == CHAN_TYPE) {
/* common simple case */
if (srcType == CHAN_TYPE) {
if (dstFormat == GL_RGBA) {
if (srcFormat == GL_RGBA) {
- MEMCPY( dest, source, n * 4 * sizeof(GLchan) );
+ _mesa_memcpy( dest, source, n * 4 * sizeof(GLchan) );
return;
}
else if (srcFormat == GL_RGB) {
}
else if (dstFormat == GL_RGB) {
if (srcFormat == GL_RGB) {
- MEMCPY( dest, source, n * 3 * sizeof(GLchan) );
+ _mesa_memcpy( dest, source, n * 3 * sizeof(GLchan) );
return;
}
else if (srcFormat == GL_RGBA) {
else if (dstFormat == srcFormat) {
GLint comps = _mesa_components_in_format(srcFormat);
assert(comps > 0);
- MEMCPY( dest, source, n * comps * sizeof(GLchan) );
+ _mesa_memcpy( dest, source, n * comps * sizeof(GLchan) );
return;
}
}
*/
if (transferOps == 0 && srcType == GL_UNSIGNED_BYTE
&& dstType == GL_UNSIGNED_BYTE) {
- MEMCPY(dest, source, n * sizeof(GLubyte));
+ _mesa_memcpy(dest, source, n * sizeof(GLubyte));
}
else if (transferOps == 0 && srcType == GL_UNSIGNED_INT
&& dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) {
- MEMCPY(dest, source, n * sizeof(GLuint));
+ _mesa_memcpy(dest, source, n * sizeof(GLuint));
}
else {
/*
}
break;
case GL_UNSIGNED_INT:
- MEMCPY(dest, indexes, n * sizeof(GLuint));
+ _mesa_memcpy(dest, indexes, n * sizeof(GLuint));
break;
default:
_mesa_problem(ctx, "bad dstType in _mesa_unpack_index_span");
if (transferOps & (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT)) {
/* make a copy of input */
- MEMCPY(indexes, source, n * sizeof(GLuint));
+ _mesa_memcpy(indexes, source, n * sizeof(GLuint));
if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
_mesa_shift_and_offset_ci( ctx, n, indexes);
}
if (transferOps == 0 &&
srcType == GL_UNSIGNED_BYTE &&
dstType == GL_UNSIGNED_BYTE) {
- MEMCPY(dest, source, n * sizeof(GLubyte));
+ _mesa_memcpy(dest, source, n * sizeof(GLubyte));
}
else if (transferOps == 0 &&
srcType == GL_UNSIGNED_INT &&
dstType == GL_UNSIGNED_INT &&
!srcPacking->SwapBytes) {
- MEMCPY(dest, source, n * sizeof(GLuint));
+ _mesa_memcpy(dest, source, n * sizeof(GLuint));
}
else {
/*
}
break;
case GL_UNSIGNED_INT:
- MEMCPY(dest, indexes, n * sizeof(GLuint));
+ _mesa_memcpy(dest, indexes, n * sizeof(GLuint));
break;
default:
_mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span");
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset ||
ctx->Pixel.MapStencilFlag) {
/* make a copy of input */
- MEMCPY(stencil, source, n * sizeof(GLstencil));
+ _mesa_memcpy(stencil, source, n * sizeof(GLstencil));
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
_mesa_shift_and_offset_stencil( ctx, n, stencil );
}
switch (dstType) {
case GL_UNSIGNED_BYTE:
if (sizeof(GLstencil) == 8) {
- MEMCPY( dest, source, n );
+ _mesa_memcpy( dest, source, n );
}
else {
GLubyte *dst = (GLubyte *) dest;
break;
case GL_BYTE:
if (sizeof(GLstencil) == 8) {
- MEMCPY( dest, source, n );
+ _mesa_memcpy( dest, source, n );
}
else {
GLbyte *dst = (GLbyte *) dest;
}
break;
case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */
- if (dstType == GL_UNSIGNED_INT && ctx->Pixel.DepthScale == 1.0 &&
- ctx->Pixel.DepthBias == 0.0 && depthScale == (GLfloat) 0xffffff) {
+ if (dstType == GL_UNSIGNED_INT &&
+ depthScale == (GLfloat) 0xffffff &&
+ ctx->Pixel.DepthScale == 1.0 &&
+ ctx->Pixel.DepthBias == 0.0) {
const GLuint *src = (const GLuint *) source;
GLuint *zValues = (GLuint *) dest;
GLuint i;
}
break;
case GL_FLOAT:
- MEMCPY(depthValues, source, n * sizeof(GLfloat));
+ _mesa_memcpy(depthValues, source, n * sizeof(GLfloat));
break;
case GL_HALF_FLOAT_ARB:
{
else if (dstType == GL_UNSIGNED_SHORT) {
GLushort *zValues = (GLushort *) dest;
GLuint i;
+ ASSERT(depthScale <= 65535.0);
for (i = 0; i < n; i++) {
zValues[i] = (GLushort) (depthValues[i] * depthScale);
}
}
{
- GLubyte *destBuffer = (GLubyte *) MALLOC(bytesPerRow * height * depth);
+ GLubyte *destBuffer
+ = (GLubyte *) _mesa_malloc(bytesPerRow * height * depth);
GLubyte *dst;
GLint img, row;
if (!destBuffer)
for (row = 0; row < height; row++) {
const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels,
width, height, format, type, img, row, 0);
- MEMCPY(dst, src, bytesPerRow);
+ _mesa_memcpy(dst, src, bytesPerRow);
/* byte flipping/swapping */
if (flipBytes) {
flip_bytes((GLubyte *) dst, bytesPerRow);
}
}
-#endif
+#endif /* _HAVE_FULL_GL */
/**