m3g/m3gcore11/inc/m3g_appearance.h
changeset 36 01a6848ebfd7
parent 0 5d03bc08d59c
equal deleted inserted replaced
0:5d03bc08d59c 36:01a6848ebfd7
   123  * \param appearance    Appearance object
   123  * \param appearance    Appearance object
   124  * \return              sort key
   124  * \return              sort key
   125  */
   125  */
   126 static M3G_INLINE M3Guint m3gGetAppearanceSortKey(const Appearance *appearance)
   126 static M3G_INLINE M3Guint m3gGetAppearanceSortKey(const Appearance *appearance)
   127 {
   127 {
   128     M3Guint key = appearance ? appearance->sortKey : 0;
   128     if (appearance) {
       
   129         M3Guint key = appearance->sortKey;
   129 
   130 
   130     /* The blending state bit is set dynamically, as it may change
   131         /* The blending state bit is set dynamically, as it may change
   131      * without changing the appearance (we have no signaling from
   132          * without changing the appearance (we have no signaling from
   132      * CompositingMode for that) */
   133          * CompositingMode for that) */
   133     
   134         
   134     if (appearance->compositingMode != NULL
   135         if (appearance->compositingMode != NULL
   135         && appearance->compositingMode->blendingMode != M3G_REPLACE) {
   136             && appearance->compositingMode->blendingMode != M3G_REPLACE) {
   136         key |= (1u << (32 - M3G_APPEARANCE_HARD_SORT_BITS));
   137             key |= (1u << (32 - M3G_APPEARANCE_HARD_SORT_BITS));
   137     }
   138         }
   138 
   139 
   139     if (m3gGetColorMaskWorkaround(M3G_INTERFACE(appearance))) {
   140         if (m3gGetColorMaskWorkaround(M3G_INTERFACE(appearance))) {
   140         /* Override the top 2 bits of the sorting key so that ColorMask
   141             /* Override the top 2 bits of the sorting key so that ColorMask
   141          * changes are minimized */
   142              * changes are minimized */
   142         if (appearance) {
   143             if (appearance) {
   143             key &= ~(0x03 << 22);
   144                 key &= ~(0x03 << 22);
   144             key |= (((M3Guint) m3gColorMask(appearance)) & 1) << 23;
   145                 key |= (((M3Guint) m3gColorMask(appearance)) & 1) << 23;
   145             key |= (((M3Guint) m3gAlphaMask(appearance)) & 1) << 22;
   146                 key |= (((M3Guint) m3gAlphaMask(appearance)) & 1) << 22;
       
   147             }
   146         }
   148         }
   147     }
       
   148 
   149 
   149     return key;
   150         return key;
       
   151     } 
       
   152 
       
   153     return M3G_FALSE;
   150 }
   154 }
   151 
   155 
   152 /*!
   156 /*!
   153  * \internal
   157  * \internal
   154  * \brief Release the textures bound for this appearance
   158  * \brief Release the textures bound for this appearance