os/graphics/m3g/m3gcore11/inc/m3g_interface.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: M3G interface class internal interface
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
#ifndef __M3G_INTERFACE_H__
sl@0
    19
#define __M3G_INTERFACE_H__
sl@0
    20
sl@0
    21
/*!
sl@0
    22
 * \internal
sl@0
    23
 * \file
sl@0
    24
 * \brief M3G interface class internal interface
sl@0
    25
 */
sl@0
    26
sl@0
    27
typedef struct M3GInterfaceImpl Interface;
sl@0
    28
sl@0
    29
/*--------------------------------------------------------------------
sl@0
    30
 * Memory allocation functions
sl@0
    31
 *------------------------------------------------------------------*/
sl@0
    32
sl@0
    33
#if !defined(M3G_DEBUG_HEAP_TRACKING)
sl@0
    34
sl@0
    35
static /*@only@*//*@null@*/ void* m3gAlloc(/*@in@*/ Interface *m3g,
sl@0
    36
                                           M3Gsize bytes);
sl@0
    37
sl@0
    38
static /*@only@*//*@null@*/ void* m3gAllocZ(/*@in@*/ Interface *m3g,
sl@0
    39
                                            M3Gsize bytes);
sl@0
    40
sl@0
    41
static void m3gFree(/*@in@*/ Interface *m3g,
sl@0
    42
                    /*@only@*//*@out@*//*@null@*/ void *ptr);
sl@0
    43
sl@0
    44
static /*@only@*//*@null@*/ M3GMemObject m3gAllocObject(Interface *m3g,
sl@0
    45
                                                        M3Gsize bytes);
sl@0
    46
static void m3gFreeObject(Interface *m3g,
sl@0
    47
                          /*@only@*//*@out@*//*@null@*/ M3GMemObject handle);
sl@0
    48
sl@0
    49
#define m3gMarkObject(p)
sl@0
    50
#define m3gIsObject(p) (M3G_FALSE)
sl@0
    51
#define m3gUnmarkObject(p)
sl@0
    52
sl@0
    53
#endif /* !M3G_DEBUG_HEAP_TRACKING */
sl@0
    54
sl@0
    55
#if 0
sl@0
    56
static void m3gRecycle(Interface *m3g, void *ptr, M3Gsize bytes);
sl@0
    57
#endif
sl@0
    58
sl@0
    59
static M3Gbool m3gGetColorMaskWorkaround(Interface *m3g);
sl@0
    60
static M3Gbool m3gGetTwoSidedLightingWorkaround(Interface *m3g);
sl@0
    61
sl@0
    62
/*--------------------------------------------------------------------
sl@0
    63
 * Debug memory allocation functions
sl@0
    64
 *------------------------------------------------------------------*/
sl@0
    65
sl@0
    66
#if defined(M3G_DEBUG_HEAP_TRACKING)
sl@0
    67
sl@0
    68
static /*@only@*//*@null@*/ void* m3gDebugAlloc(
sl@0
    69
    /*@in@*/ Interface *m3g, M3Gsize bytes, const char *file, int line);
sl@0
    70
sl@0
    71
static /*@only@*//*@null@*/ void* m3gDebugAllocZ(
sl@0
    72
    /*@in@*/ Interface *m3g, M3Gsize bytes, const char *file, int line);
sl@0
    73
sl@0
    74
static void m3gDebugFree(/*@in@*/ Interface *m3g,
sl@0
    75
                         /*@only@*//*@out@*//*@null@*/ void *ptr,
sl@0
    76
                         const char *file, int line);
sl@0
    77
sl@0
    78
static /*@only@*//*@null@*/ M3GMemObject m3gDebugAllocObject(
sl@0
    79
    Interface *m3g, M3Gsize bytes, const char *file, int line);
sl@0
    80
sl@0
    81
static void m3gDebugFreeObject(
sl@0
    82
    Interface *m3g, /*@only@*//*@out@*//*@null@*/ M3GMemObject handle,
sl@0
    83
    const char *file, int line);
sl@0
    84
sl@0
    85
#define m3gAlloc(m3g, bytes) \
sl@0
    86
    m3gDebugAlloc(m3g, bytes, __FILE__, __LINE__)
sl@0
    87
#define m3gAllocZ(m3g, bytes) \
sl@0
    88
    m3gDebugAllocZ(m3g, bytes, __FILE__, __LINE__)
sl@0
    89
sl@0
    90
#define m3gAllocObject(m3g, bytes) \
sl@0
    91
    m3gDebugAllocObject(m3g, bytes, __FILE__, __LINE__)
sl@0
    92
sl@0
    93
#define m3gFree(m3g, ptr)       m3gDebugFree(m3g, ptr, __FILE__, __LINE__)
sl@0
    94
#define m3gFreeObject(m3g, obj) m3gDebugFreeObject(m3g, obj, __FILE__, __LINE__)
sl@0
    95
sl@0
    96
static void m3gMarkObject(void *ptr);
sl@0
    97
static M3Gbool m3gIsObject(const void *ptr);
sl@0
    98
static void m3gUnmarkObject(void *ptr);
sl@0
    99
    
sl@0
   100
#endif /* M3G_DEBUG_HEAP_TRACKING */
sl@0
   101
sl@0
   102
/*----------------------------------------------------------------------
sl@0
   103
 * Profiling
sl@0
   104
 *--------------------------------------------------------------------*/
sl@0
   105
sl@0
   106
#if defined(M3G_ENABLE_PROFILING)
sl@0
   107
sl@0
   108
static void m3gIncStat(Interface *m3g, M3Gstatistic stat, M3Gint increment);
sl@0
   109
static void m3gResetStat(Interface *m3g, M3Gstatistic stat);
sl@0
   110
static void m3gUpdateMemoryPeakCounter(Interface *m3g);
sl@0
   111
static void m3gLogMemoryPeakCounter(const Interface *m3g);
sl@0
   112
static void m3gLogProfileCounters(Interface *m3g);
sl@0
   113
extern void m3gBeginProfile(int stat);
sl@0
   114
extern int m3gEndProfile(int stat);
sl@0
   115
extern void m3gCleanupProfile(void);
sl@0
   116
#define M3G_BEGIN_PROFILE(m3g, stat) m3gBeginProfile(stat);
sl@0
   117
#define M3G_END_PROFILE(m3g, stat)   m3gIncStat(m3g, stat, m3gEndProfile(stat));
sl@0
   118
sl@0
   119
#else
sl@0
   120
sl@0
   121
#define m3gIncStat(m3g, stat, increment) (M3G_UNREF(m3g), M3G_UNREF(stat), M3G_UNREF(increment))
sl@0
   122
#define m3gResetStat(m3g, stat)         (M3G_UNREF(m3g), M3G_UNREF(stat))
sl@0
   123
#define m3gUpdateMemoryPeakCounter(m3g) (M3G_UNREF(m3g))
sl@0
   124
#define m3gLogMemoryPeakCounter(m3g)    (M3G_UNREF(m3g))
sl@0
   125
#define m3gLogProfileCounters(m3g)      (M3G_UNREF(m3g))
sl@0
   126
#define m3gCleanupProfile()
sl@0
   127
#define M3G_BEGIN_PROFILE(m3g, stat)    (M3G_UNREF(m3g), M3G_UNREF(stat))
sl@0
   128
#define M3G_END_PROFILE(m3g, stat)      (M3G_UNREF(m3g), M3G_UNREF(stat))
sl@0
   129
#endif
sl@0
   130
sl@0
   131
/*--------------------------------------------------------------------
sl@0
   132
 * Other internal functions
sl@0
   133
 *------------------------------------------------------------------*/
sl@0
   134
sl@0
   135
static void     m3gAddChildObject(Interface *m3g, Object *obj);
sl@0
   136
static void     m3gDelChildObject(Interface *m3g, Object *obj);
sl@0
   137
sl@0
   138
#include "m3g_array.h"
sl@0
   139
static void     m3gGetObjectsWithClassID(Interface *m3g, M3GClass classID, PointerArray* objects);
sl@0
   140
sl@0
   141
#if !defined(M3G_NGL_TEXTURE_API)
sl@0
   142
static void     m3gDeleteGLTextures(Interface *m3g, M3Gsizei n, M3Guint *t);
sl@0
   143
static void     m3gCollectGLObjects(Interface *m3g);
sl@0
   144
#else
sl@0
   145
#   define m3gCollectGLObjects(a)
sl@0
   146
#endif
sl@0
   147
sl@0
   148
static void*    m3gAllocTemp(Interface *m3g, M3Gsizei bytes);
sl@0
   149
static void     m3gFreeTemp(Interface *m3g);
sl@0
   150
sl@0
   151
static void*    m3gMapObject    (Interface *m3g, M3GMemObject handle);
sl@0
   152
static void     m3gUnmapObject  (Interface *m3g, M3GMemObject handle);
sl@0
   153
sl@0
   154
static void     m3gGarbageCollectAll            (Interface *m3g);
sl@0
   155
sl@0
   156
#include "m3g_tcache.h"
sl@0
   157
static TCache *m3gGetTransformCache(Interface *m3g);
sl@0
   158
sl@0
   159
#if defined(M3G_NGL_CONTEXT_API)
sl@0
   160
static void *m3gGetExternalFB(Interface *m3g, M3Guint userTarget);
sl@0
   161
static void m3gReleaseExternalFB(Interface *m3g, M3Guint userTarget);
sl@0
   162
static void m3gSignalTargetRelease(Interface *m3g, M3Guint userTarget);
sl@0
   163
#endif /* M3G_NGL_CONTEXT_API */
sl@0
   164
sl@0
   165
#if defined(M3G_DEBUG)
sl@0
   166
static void m3gDebugRaiseError(/*@in@*/ Interface *m3g,
sl@0
   167
                               M3Genum error,
sl@0
   168
                               const char *filename,
sl@0
   169
                               int line);
sl@0
   170
#define m3gRaiseError(m3g, error) \
sl@0
   171
    m3gDebugRaiseError(m3g, error, __FILE__, __LINE__)
sl@0
   172
#else
sl@0
   173
static void m3gRaiseError(/*@in@*/ Interface *m3g, M3Genum error);
sl@0
   174
#endif /* M3G_DEBUG */
sl@0
   175
sl@0
   176
#ifdef M3G_NATIVE_LOADER
sl@0
   177
static M3GError m3gErrorRaised(const Interface *m3g);
sl@0
   178
static m3gErrorHandler *m3gSetErrorHandler(Interface *m3g, m3gErrorHandler *errorHandler);
sl@0
   179
#endif
sl@0
   180
sl@0
   181
/* Memory locking only affects assertions in debug builds, so let's
sl@0
   182
 * disable it in non-debug ones for a bit of extra performance */
sl@0
   183
sl@0
   184
#if defined(M3G_DEBUG)
sl@0
   185
#define m3gLockMemory(a) m3gDebugLockMemory((a), __FILE__, __LINE__)
sl@0
   186
static void    m3gDebugLockMemory(Interface *interface, const char *file, int line);
sl@0
   187
static void    m3gUnlockMemory  (Interface *interface);
sl@0
   188
static M3Gbool m3gMemoryLocked  (Interface *interface);
sl@0
   189
#else
sl@0
   190
#   define m3gLockMemory(a)   ((void)(a))
sl@0
   191
#   define m3gUnlockMemory(a) ((void)(a))
sl@0
   192
#   define m3gMemoryLocked(a) (M3G_FALSE)
sl@0
   193
#endif
sl@0
   194
sl@0
   195
#if defined(M3G_NGL_CONTEXT_API) && !defined(M3G_NGL_TEXTURE_API)
sl@0
   196
#   define M3G_ASSERT_NO_LOCK(interface)
sl@0
   197
#else
sl@0
   198
#   define M3G_ASSERT_NO_LOCK(interface) M3G_ASSERT(!m3gMemoryLocked(interface))
sl@0
   199
#endif
sl@0
   200
sl@0
   201
static void m3gInitializeGL(Interface *interface);
sl@0
   202
static void m3gShutdownGL(Interface *interface);
sl@0
   203
sl@0
   204
/* Self-validation */
sl@0
   205
sl@0
   206
#if defined(M3G_DEBUG)
sl@0
   207
/*@notfunction@*/
sl@0
   208
#   define M3G_VALIDATE_MEMBLOCK(ptr) m3gValidateMemory(ptr)
sl@0
   209
static void m3gValidateMemory(const void *ptr);
sl@0
   210
/*@notfunction@*/
sl@0
   211
#   define M3G_VALIDATE_INTERFACE(m3g) m3gValidateInterface(m3g)
sl@0
   212
static void m3gValidateInterface(const Interface *m3g);
sl@0
   213
sl@0
   214
#else
sl@0
   215
#   define M3G_VALIDATE_MEMBLOCK(ptr)
sl@0
   216
#   define M3G_VALIDATE_INTERFACE(m3g)
sl@0
   217
#endif
sl@0
   218
sl@0
   219
#endif /*__M3G_INTERFACE_H__*/