First public contribution.
2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Image interface
18 #ifndef __M3G_IMAGE_H__
19 #define __M3G_IMAGE_H__
24 * \brief Image interface
27 #include "m3g_object.h"
30 #if !defined(M3G_NGL_TEXTURE_API)
31 typedef struct LargeImageImpl LargeImage;
43 M3GImageFormat format;
44 M3GPixelFormat internalFormat;
49 # if !defined(M3G_NGL_TEXTURE_API)
51 LargeImage *large; /*! \internal \ */
56 M3Gsizei paletteBytes;
58 M3Gbitmask flags : 8; /* flags defined in m3g_core.h */
59 M3Gbitmask special : 8; /* flags defined below */
61 M3Gbool pinned : 1; /* image can not be deleted */
63 M3Gbool powerOfTwoDirty : 1;
64 M3Gbool mipDataMapCount : 4; /* max. 16 concurrent uses */
65 # if !defined(M3G_NGL_TEXTURE_API)
66 M3Gbool mipmapsDirty : 1; /*!< \internal 'dirty' overrides this */
69 /* For easy cloning of immutable images without replicating the
70 * data, we must keep a reference to the original so that it isn't
71 * deleted until we are */
77 * \internal \brief "special" flag bits */
79 #define IMG_LARGE 0x02
81 /*----------------------------------------------------------------------
83 *--------------------------------------------------------------------*/
85 static void m3gBindTextureImage(Image *img, M3Genum levelFilter, M3Genum imageFilter);
86 static void m3gReleaseTextureImage(Image *img);
88 static Image *m3gGetPowerOfTwoImage(Image *img);
90 static M3GPixelFormat m3gPixelFormat (M3GImageFormat format);
91 static M3Gint m3gBytesPerPixel(M3GPixelFormat format);
93 static void m3gConvertPixels(M3GPixelFormat srcFormat, const M3Gubyte *src,
94 M3GPixelFormat dstFormat, M3Gubyte *dst,
97 static void m3gConvertPixelRect(
98 M3GPixelFormat srcFormat, const M3Gubyte *src, M3Gsizei srcStride,
99 M3Gsizei width, M3Gsizei height,
100 M3GPixelFormat dstFormat, M3Gubyte *dst, M3Gsizei dstStride);
102 static void m3gCopyImagePixels(Image *dst, const Image *src);
103 #if !defined(M3G_NGL_TEXTURE_API)
104 static void m3gCopyFrameBufferImage(Image *dst);
105 static void m3gDrawFrameBufferImage(RenderContext *ctx, const Image *src);
106 #endif /* !defined(M3G_NGL_TEXTURE_API)*/
108 static void m3gInvalidateImage(Image *img);
110 #if defined(M3G_NGL_TEXTURE_API)
111 static M3Gbool m3gValidateMipmapMemory(Image *img);
115 static M3Gsizei m3gGetImageStride(const Image *img);
117 static M3Gint m3gGetAlpha(Image *image, M3Gint x, M3Gint y);
119 static M3G_INLINE M3Gbool m3gIsInternallyPaletted(const Image *img)
121 return (img->paletteBytes > 0);
127 * \brief Type-safe helper function
129 static M3G_INLINE void m3gDeleteImage(Image *img)
131 m3gDeleteObject((Object*) img);
135 #endif /*__M3G_IMAGE_H__*/