mesa: reimplement IROUND(), add F_TO_I()
[mesa.git] / src / mesa / main / context.h
index 8c115c73c65979345f6657a555f6fa6c775b20de..a66dd507670cd1c365df5c9d2e320a8ab67c56c1 100644 (file)
  * There are three large Mesa data types/classes which are meant to be
  * used by device drivers:
  * - struct gl_context: this contains the Mesa rendering state
- * - struct gl_config:  this describes the color buffer (RGB vs. ci), whether or not
- *   there's a depth buffer, stencil buffer, etc.
- * - struct gl_framebuffer:  contains pointers to the depth buffer, stencil buffer,
- *   accum buffer and alpha buffers.
+ * - struct gl_config:  this describes the color buffer (RGB vs. ci), whether
+ *   or not there's a depth buffer, stencil buffer, etc.
+ * - struct gl_framebuffer:  contains pointers to the depth buffer, stencil
+ *   buffer, accum buffer and alpha buffers.
  *
  * These types should be encapsulated by corresponding device driver
  * data types.  See xmesa.h and xmesaP.h for an example.
  *
- * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer are base classes
- * which the device driver must derive from.
+ * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer
+ * are base classes which the device driver must derive from.
  *
  * The following functions create and destroy these data types.
  */
 #include "mtypes.h"
 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 struct _glapi_table;
 
 
@@ -192,48 +197,48 @@ _mesa_Flush( void );
 
 /**
  * Flush vertices.
- * \param newstate  bitmask of _NEW_x flags
+ *
+ * \param ctx GL context.
+ * \param newstate new state.
  *
  * Checks if dd_function_table::NeedFlush is marked to flush stored vertices,
  * and calls dd_function_table::FlushVertices if so. Marks
  * __struct gl_contextRec::NewState with \p newstate.
  */
-static INLINE void
-FLUSH_VERTICES(struct gl_context *ctx, GLbitfield newstate)
-{
-   if (MESA_VERBOSE & VERBOSE_STATE)
-      _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);
-   if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES)
-      ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES);
-   ctx->NewState |= newstate;
-}
-
+#define FLUSH_VERTICES(ctx, newstate)                          \
+do {                                                           \
+   if (MESA_VERBOSE & VERBOSE_STATE)                           \
+      _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\
+   if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES)          \
+      ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES);   \
+   ctx->NewState |= newstate;                                  \
+} while (0)
 
 /**
  * Flush current state.
- * \param newstate  bitmask of _NEW_x flags
+ *
+ * \param ctx GL context.
+ * \param newstate new state.
  *
  * Checks if dd_function_table::NeedFlush is marked to flush current state,
  * and calls dd_function_table::FlushVertices if so. Marks
  * __struct gl_contextRec::NewState with \p newstate.
  */
-static INLINE void
-FLUSH_CURRENT(struct gl_context *ctx, GLbitfield newstate)
-{
-   if (MESA_VERBOSE & VERBOSE_STATE)
-      _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION);
-   if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT)
-      ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT);
-   ctx->NewState |= newstate;
-}
-
+#define FLUSH_CURRENT(ctx, newstate)                           \
+do {                                                           \
+   if (MESA_VERBOSE & VERBOSE_STATE)                           \
+      _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION);        \
+   if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT)           \
+      ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT);    \
+   ctx->NewState |= newstate;                                  \
+} while (0)
 
 /**
  * Macro to assert that the API call was made outside the
  * glBegin()/glEnd() pair, with return value.
  * 
  * \param ctx GL context.
- * \param retval value to return value in case the assertion fails.
+ * \param retval value to return in case the assertion fails.
  */
 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval)              \
 do {                                                                   \
@@ -274,7 +279,7 @@ do {                                                                        \
  * glBegin()/glEnd() pair and flush the vertices, with return value.
  * 
  * \param ctx GL context.
- * \param retval value to return value in case the assertion fails.
+ * \param retval value to return in case the assertion fails.
  */
 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)    \
 do {                                                                   \
@@ -285,29 +290,9 @@ do {                                                                       \
 /*@}*/
 
 
-
-/**
- * Is the secondary color needed?
- */
-#define NEED_SECONDARY_COLOR(CTX)                                      \
-   (((CTX)->Light.Enabled &&                                           \
-     (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)    \
-    || (CTX)->Fog.ColorSumEnabled                                      \
-    || ((CTX)->VertexProgram._Current &&                               \
-        ((CTX)->VertexProgram._Current != (CTX)->VertexProgram._TnlProgram) &&    \
-        ((CTX)->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) \
-    || ((CTX)->FragmentProgram._Current &&                             \
-        ((CTX)->FragmentProgram._Current != (CTX)->FragmentProgram._TexEnvProgram) &&  \
-        ((CTX)->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) \
-   )
-
-
-/**
- * Is RGBA LogicOp enabled?
- */
-#define RGBA_LOGICOP_ENABLED(CTX) \
-  ((CTX)->Color.ColorLogicOpEnabled || \
-   ((CTX)->Color.BlendEnabled && (CTX)->Color.Blend[0].EquationRGB == GL_LOGIC_OP))
+#ifdef __cplusplus
+}
+#endif
 
 
 #endif /* CONTEXT_H */