1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/m3g/m3gcore11/inc/m3g_interface.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,219 @@
1.4 +/*
1.5 +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: M3G interface class internal interface
1.18 +*
1.19 +*/
1.20 +
1.21 +#ifndef __M3G_INTERFACE_H__
1.22 +#define __M3G_INTERFACE_H__
1.23 +
1.24 +/*!
1.25 + * \internal
1.26 + * \file
1.27 + * \brief M3G interface class internal interface
1.28 + */
1.29 +
1.30 +typedef struct M3GInterfaceImpl Interface;
1.31 +
1.32 +/*--------------------------------------------------------------------
1.33 + * Memory allocation functions
1.34 + *------------------------------------------------------------------*/
1.35 +
1.36 +#if !defined(M3G_DEBUG_HEAP_TRACKING)
1.37 +
1.38 +static /*@only@*//*@null@*/ void* m3gAlloc(/*@in@*/ Interface *m3g,
1.39 + M3Gsize bytes);
1.40 +
1.41 +static /*@only@*//*@null@*/ void* m3gAllocZ(/*@in@*/ Interface *m3g,
1.42 + M3Gsize bytes);
1.43 +
1.44 +static void m3gFree(/*@in@*/ Interface *m3g,
1.45 + /*@only@*//*@out@*//*@null@*/ void *ptr);
1.46 +
1.47 +static /*@only@*//*@null@*/ M3GMemObject m3gAllocObject(Interface *m3g,
1.48 + M3Gsize bytes);
1.49 +static void m3gFreeObject(Interface *m3g,
1.50 + /*@only@*//*@out@*//*@null@*/ M3GMemObject handle);
1.51 +
1.52 +#define m3gMarkObject(p)
1.53 +#define m3gIsObject(p) (M3G_FALSE)
1.54 +#define m3gUnmarkObject(p)
1.55 +
1.56 +#endif /* !M3G_DEBUG_HEAP_TRACKING */
1.57 +
1.58 +#if 0
1.59 +static void m3gRecycle(Interface *m3g, void *ptr, M3Gsize bytes);
1.60 +#endif
1.61 +
1.62 +static M3Gbool m3gGetColorMaskWorkaround(Interface *m3g);
1.63 +static M3Gbool m3gGetTwoSidedLightingWorkaround(Interface *m3g);
1.64 +
1.65 +/*--------------------------------------------------------------------
1.66 + * Debug memory allocation functions
1.67 + *------------------------------------------------------------------*/
1.68 +
1.69 +#if defined(M3G_DEBUG_HEAP_TRACKING)
1.70 +
1.71 +static /*@only@*//*@null@*/ void* m3gDebugAlloc(
1.72 + /*@in@*/ Interface *m3g, M3Gsize bytes, const char *file, int line);
1.73 +
1.74 +static /*@only@*//*@null@*/ void* m3gDebugAllocZ(
1.75 + /*@in@*/ Interface *m3g, M3Gsize bytes, const char *file, int line);
1.76 +
1.77 +static void m3gDebugFree(/*@in@*/ Interface *m3g,
1.78 + /*@only@*//*@out@*//*@null@*/ void *ptr,
1.79 + const char *file, int line);
1.80 +
1.81 +static /*@only@*//*@null@*/ M3GMemObject m3gDebugAllocObject(
1.82 + Interface *m3g, M3Gsize bytes, const char *file, int line);
1.83 +
1.84 +static void m3gDebugFreeObject(
1.85 + Interface *m3g, /*@only@*//*@out@*//*@null@*/ M3GMemObject handle,
1.86 + const char *file, int line);
1.87 +
1.88 +#define m3gAlloc(m3g, bytes) \
1.89 + m3gDebugAlloc(m3g, bytes, __FILE__, __LINE__)
1.90 +#define m3gAllocZ(m3g, bytes) \
1.91 + m3gDebugAllocZ(m3g, bytes, __FILE__, __LINE__)
1.92 +
1.93 +#define m3gAllocObject(m3g, bytes) \
1.94 + m3gDebugAllocObject(m3g, bytes, __FILE__, __LINE__)
1.95 +
1.96 +#define m3gFree(m3g, ptr) m3gDebugFree(m3g, ptr, __FILE__, __LINE__)
1.97 +#define m3gFreeObject(m3g, obj) m3gDebugFreeObject(m3g, obj, __FILE__, __LINE__)
1.98 +
1.99 +static void m3gMarkObject(void *ptr);
1.100 +static M3Gbool m3gIsObject(const void *ptr);
1.101 +static void m3gUnmarkObject(void *ptr);
1.102 +
1.103 +#endif /* M3G_DEBUG_HEAP_TRACKING */
1.104 +
1.105 +/*----------------------------------------------------------------------
1.106 + * Profiling
1.107 + *--------------------------------------------------------------------*/
1.108 +
1.109 +#if defined(M3G_ENABLE_PROFILING)
1.110 +
1.111 +static void m3gIncStat(Interface *m3g, M3Gstatistic stat, M3Gint increment);
1.112 +static void m3gResetStat(Interface *m3g, M3Gstatistic stat);
1.113 +static void m3gUpdateMemoryPeakCounter(Interface *m3g);
1.114 +static void m3gLogMemoryPeakCounter(const Interface *m3g);
1.115 +static void m3gLogProfileCounters(Interface *m3g);
1.116 +extern void m3gBeginProfile(int stat);
1.117 +extern int m3gEndProfile(int stat);
1.118 +extern void m3gCleanupProfile(void);
1.119 +#define M3G_BEGIN_PROFILE(m3g, stat) m3gBeginProfile(stat);
1.120 +#define M3G_END_PROFILE(m3g, stat) m3gIncStat(m3g, stat, m3gEndProfile(stat));
1.121 +
1.122 +#else
1.123 +
1.124 +#define m3gIncStat(m3g, stat, increment) (M3G_UNREF(m3g), M3G_UNREF(stat), M3G_UNREF(increment))
1.125 +#define m3gResetStat(m3g, stat) (M3G_UNREF(m3g), M3G_UNREF(stat))
1.126 +#define m3gUpdateMemoryPeakCounter(m3g) (M3G_UNREF(m3g))
1.127 +#define m3gLogMemoryPeakCounter(m3g) (M3G_UNREF(m3g))
1.128 +#define m3gLogProfileCounters(m3g) (M3G_UNREF(m3g))
1.129 +#define m3gCleanupProfile()
1.130 +#define M3G_BEGIN_PROFILE(m3g, stat) (M3G_UNREF(m3g), M3G_UNREF(stat))
1.131 +#define M3G_END_PROFILE(m3g, stat) (M3G_UNREF(m3g), M3G_UNREF(stat))
1.132 +#endif
1.133 +
1.134 +/*--------------------------------------------------------------------
1.135 + * Other internal functions
1.136 + *------------------------------------------------------------------*/
1.137 +
1.138 +static void m3gAddChildObject(Interface *m3g, Object *obj);
1.139 +static void m3gDelChildObject(Interface *m3g, Object *obj);
1.140 +
1.141 +#include "m3g_array.h"
1.142 +static void m3gGetObjectsWithClassID(Interface *m3g, M3GClass classID, PointerArray* objects);
1.143 +
1.144 +#if !defined(M3G_NGL_TEXTURE_API)
1.145 +static void m3gDeleteGLTextures(Interface *m3g, M3Gsizei n, M3Guint *t);
1.146 +static void m3gCollectGLObjects(Interface *m3g);
1.147 +#else
1.148 +# define m3gCollectGLObjects(a)
1.149 +#endif
1.150 +
1.151 +static void* m3gAllocTemp(Interface *m3g, M3Gsizei bytes);
1.152 +static void m3gFreeTemp(Interface *m3g);
1.153 +
1.154 +static void* m3gMapObject (Interface *m3g, M3GMemObject handle);
1.155 +static void m3gUnmapObject (Interface *m3g, M3GMemObject handle);
1.156 +
1.157 +static void m3gGarbageCollectAll (Interface *m3g);
1.158 +
1.159 +#include "m3g_tcache.h"
1.160 +static TCache *m3gGetTransformCache(Interface *m3g);
1.161 +
1.162 +#if defined(M3G_NGL_CONTEXT_API)
1.163 +static void *m3gGetExternalFB(Interface *m3g, M3Guint userTarget);
1.164 +static void m3gReleaseExternalFB(Interface *m3g, M3Guint userTarget);
1.165 +static void m3gSignalTargetRelease(Interface *m3g, M3Guint userTarget);
1.166 +#endif /* M3G_NGL_CONTEXT_API */
1.167 +
1.168 +#if defined(M3G_DEBUG)
1.169 +static void m3gDebugRaiseError(/*@in@*/ Interface *m3g,
1.170 + M3Genum error,
1.171 + const char *filename,
1.172 + int line);
1.173 +#define m3gRaiseError(m3g, error) \
1.174 + m3gDebugRaiseError(m3g, error, __FILE__, __LINE__)
1.175 +#else
1.176 +static void m3gRaiseError(/*@in@*/ Interface *m3g, M3Genum error);
1.177 +#endif /* M3G_DEBUG */
1.178 +
1.179 +#ifdef M3G_NATIVE_LOADER
1.180 +static M3GError m3gErrorRaised(const Interface *m3g);
1.181 +static m3gErrorHandler *m3gSetErrorHandler(Interface *m3g, m3gErrorHandler *errorHandler);
1.182 +#endif
1.183 +
1.184 +/* Memory locking only affects assertions in debug builds, so let's
1.185 + * disable it in non-debug ones for a bit of extra performance */
1.186 +
1.187 +#if defined(M3G_DEBUG)
1.188 +#define m3gLockMemory(a) m3gDebugLockMemory((a), __FILE__, __LINE__)
1.189 +static void m3gDebugLockMemory(Interface *interface, const char *file, int line);
1.190 +static void m3gUnlockMemory (Interface *interface);
1.191 +static M3Gbool m3gMemoryLocked (Interface *interface);
1.192 +#else
1.193 +# define m3gLockMemory(a) ((void)(a))
1.194 +# define m3gUnlockMemory(a) ((void)(a))
1.195 +# define m3gMemoryLocked(a) (M3G_FALSE)
1.196 +#endif
1.197 +
1.198 +#if defined(M3G_NGL_CONTEXT_API) && !defined(M3G_NGL_TEXTURE_API)
1.199 +# define M3G_ASSERT_NO_LOCK(interface)
1.200 +#else
1.201 +# define M3G_ASSERT_NO_LOCK(interface) M3G_ASSERT(!m3gMemoryLocked(interface))
1.202 +#endif
1.203 +
1.204 +static void m3gInitializeGL(Interface *interface);
1.205 +static void m3gShutdownGL(Interface *interface);
1.206 +
1.207 +/* Self-validation */
1.208 +
1.209 +#if defined(M3G_DEBUG)
1.210 +/*@notfunction@*/
1.211 +# define M3G_VALIDATE_MEMBLOCK(ptr) m3gValidateMemory(ptr)
1.212 +static void m3gValidateMemory(const void *ptr);
1.213 +/*@notfunction@*/
1.214 +# define M3G_VALIDATE_INTERFACE(m3g) m3gValidateInterface(m3g)
1.215 +static void m3gValidateInterface(const Interface *m3g);
1.216 +
1.217 +#else
1.218 +# define M3G_VALIDATE_MEMBLOCK(ptr)
1.219 +# define M3G_VALIDATE_INTERFACE(m3g)
1.220 +#endif
1.221 +
1.222 +#endif /*__M3G_INTERFACE_H__*/