Update contrib.
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: Appearance interface
18 #ifndef __M3G_APPEARANCE_H__
19 #define __M3G_APPEARANCE_H__
24 * \brief Appearance interface
27 #include "m3g_object.h"
28 #include "m3g_compositingmode.h"
29 #include "m3g_polygonmode.h"
30 #include "m3g_material.h"
31 #include "m3g_texture.h"
33 #include "m3g_rendercontext.h"
35 /* Limits for user settable layer */
36 #define M3G_APPEARANCE_MIN_LAYER -63
37 #define M3G_APPEARANCE_MAX_LAYER 63
38 #define M3G_APPEARANCE_HARD_SORT_BITS 8
40 typedef /*@dependent@*//*@null@*/ Texture *TexturePtr;
44 * \brief Appearance object
46 struct M3GAppearanceImpl
50 /*@dependent@*//*@null@*/
53 /*@dependent@*//*@null@*/
54 CompositingMode *compositingMode;
56 /*@dependent@*//*@null@*/
57 PolygonMode *polygonMode;
59 /*@dependent@*//*@null@*/
62 TexturePtr texture[M3G_NUM_TEXTURE_UNITS];
70 /*----------------------------------------------------------------------
72 *--------------------------------------------------------------------*/
74 static void m3gApplyAppearance(const Appearance *appearance,
80 * \brief Get vertex mask
82 * \param app Appearance object
85 static M3G_INLINE M3Gbitmask m3gGetVertexMask(const Appearance *app)
87 return app->vertexMask;
92 * \brief Shortcut getter for color mask
94 static M3G_INLINE M3Gbool m3gColorMask(const Appearance *app)
97 const CompositingMode *cm = app->compositingMode;
98 return !cm || cm->colorWrite;
105 * \brief Shortcut getter for alpha mask
107 static M3G_INLINE M3Gbool m3gAlphaMask(const Appearance *app)
110 const CompositingMode *cm = app->compositingMode;
111 return !cm || cm->alphaWrite;
118 * \brief Get sortkey for render queue
120 * Sort key is a combination of user settable layer and
121 * blending mode. Blended objects are always drawn last.
123 * \param appearance Appearance object
126 static M3G_INLINE M3Guint m3gGetAppearanceSortKey(const Appearance *appearance)
129 M3Guint key = appearance->sortKey;
131 /* The blending state bit is set dynamically, as it may change
132 * without changing the appearance (we have no signaling from
133 * CompositingMode for that) */
135 if (appearance->compositingMode != NULL
136 && appearance->compositingMode->blendingMode != M3G_REPLACE) {
137 key |= (1u << (32 - M3G_APPEARANCE_HARD_SORT_BITS));
140 if (m3gGetColorMaskWorkaround(M3G_INTERFACE(appearance))) {
141 /* Override the top 2 bits of the sorting key so that ColorMask
142 * changes are minimized */
144 key &= ~(0x03 << 22);
145 key |= (((M3Guint) m3gColorMask(appearance)) & 1) << 23;
146 key |= (((M3Guint) m3gAlphaMask(appearance)) & 1) << 22;
158 * \brief Release the textures bound for this appearance
160 static void m3gReleaseTextures(const Appearance *appearance);
162 #endif /*__M3G_APPEARANCE_H__*/