Ville Syrjala's logic op patch
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 12 Nov 2003 15:27:52 +0000 (15:27 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 12 Nov 2003 15:27:52 +0000 (15:27 +0000)
src/mesa/main/blend.c
src/mesa/main/enable.c
src/mesa/main/mtypes.h
src/mesa/swrast/s_blend.c
src/mesa/swrast/s_context.c
src/mesa/swrast/s_span.c

index e3cdbff..e5032bf 100644 (file)
@@ -334,8 +334,9 @@ _mesa_BlendEquation( GLenum mode )
    /* This is needed to support 1.1's RGB logic ops AND
     * 1.0's blending logicops.
     */
-   ctx->Color.ColorLogicOpEnabled = (mode==GL_LOGIC_OP &&
-                                    ctx->Color.BlendEnabled);
+   ctx->Color._LogicOpEnabled = (ctx->Color.ColorLogicOpEnabled ||
+                                 (ctx->Color.BlendEnabled &&
+                                  mode == GL_LOGIC_OP));
 
    if (ctx->Driver.BlendEquation)
       (*ctx->Driver.BlendEquation)( ctx, mode );
@@ -572,6 +573,7 @@ void _mesa_init_color( GLcontext * ctx )
    ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 );
    ctx->Color.IndexLogicOpEnabled = GL_FALSE;
    ctx->Color.ColorLogicOpEnabled = GL_FALSE;
+   ctx->Color._LogicOpEnabled = GL_FALSE;
    ctx->Color.LogicOp = GL_COPY;
    ctx->Color.DitherFlag = GL_TRUE;
 
index f882f94..a882cf4 100644 (file)
@@ -231,9 +231,12 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
             return;
          FLUSH_VERTICES(ctx, _NEW_COLOR);
          ctx->Color.BlendEnabled = state;
-         /* The following needed to accomodate 1.0 RGB logic op blending */
-         ctx->Color.ColorLogicOpEnabled =
-            (ctx->Color.BlendEquation == GL_LOGIC_OP && state);
+         /* This is needed to support 1.1's RGB logic ops AND
+          * 1.0's blending logicops.
+          */
+         ctx->Color._LogicOpEnabled =
+            (ctx->Color.ColorLogicOpEnabled ||
+             (state && ctx->Color.BlendEquation == GL_LOGIC_OP));
          break;
 #if FEATURE_userclip
       case GL_CLIP_PLANE0:
@@ -383,6 +386,12 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
             return;
          FLUSH_VERTICES(ctx, _NEW_COLOR);
          ctx->Color.ColorLogicOpEnabled = state;
+         /* This is needed to support 1.1's RGB logic ops AND
+          * 1.0's blending logicops.
+          */
+         ctx->Color._LogicOpEnabled =
+            (state || (ctx->Color.BlendEnabled &&
+                       ctx->Color.BlendEquation == GL_LOGIC_OP));
          break;
       case GL_MAP1_COLOR_4:
          if (ctx->Eval.Map1Color4 == state)
index ea8ae2d..0a5c995 100644 (file)
@@ -430,6 +430,7 @@ struct gl_colorbuffer_attrib {
    GLenum LogicOp;                     /**< Logic operator */
    GLboolean IndexLogicOpEnabled;      /**< Color index logic op enabled flag */
    GLboolean ColorLogicOpEnabled;      /**< RGBA logic op enabled flag */
+   GLboolean _LogicOpEnabled;          /**< RGBA logic op + EXT_blend_logic_op enabled flag */
    /*@}*/
 
    GLboolean DitherFlag;               /**< Dither enable flag */
index 345df37..6d522ff 100644 (file)
@@ -780,7 +780,7 @@ _swrast_blend_span( GLcontext *ctx, const struct sw_span *span,
 
    ASSERT(span->end <= MAX_WIDTH);
    ASSERT(span->arrayMask & SPAN_RGBA);
-   ASSERT(!ctx->Color.ColorLogicOpEnabled);
+   ASSERT(!ctx->Color._LogicOpEnabled);
 
    /* Read span of current frame buffer pixels */
    if (span->arrayMask & SPAN_XY) {
index 09eb614..fb09eb3 100644 (file)
@@ -59,7 +59,7 @@ _swrast_update_rasterflags( GLcontext *ctx )
    if (ctx->Visual.rgbMode) {
       const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
       if (colorMask != 0xffffffff)        RasterMask |= MASKING_BIT;
-      if (ctx->Color.ColorLogicOpEnabled) RasterMask |= LOGIC_OP_BIT;
+      if (ctx->Color._LogicOpEnabled)     RasterMask |= LOGIC_OP_BIT;
       if (ctx->Texture._EnabledUnits)     RasterMask |= TEXTURE_BIT;
    }
    else {
index a3be973..0131147 100644 (file)
@@ -716,7 +716,7 @@ multi_write_rgba_span( GLcontext *ctx, struct sw_span *span )
          /* make copy of incoming colors */
          MEMCPY( rgbaTmp, span->array->rgba, 4 * span->end * sizeof(GLchan) );
 
-         if (ctx->Color.ColorLogicOpEnabled) {
+         if (ctx->Color._LogicOpEnabled) {
             _swrast_logicop_rgba_span(ctx, span, rgbaTmp);
          }
          else if (ctx->Color.BlendEnabled) {
@@ -1100,7 +1100,7 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
    }
    else {
       /* normal: write to exactly one buffer */
-      if (ctx->Color.ColorLogicOpEnabled) {
+      if (ctx->Color._LogicOpEnabled) {
          _swrast_logicop_rgba_span(ctx, span, span->array->rgba);
          monoColor = GL_FALSE;
       }
@@ -1373,7 +1373,7 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
    }
    else {
       /* normal: write to exactly one buffer */
-      if (ctx->Color.ColorLogicOpEnabled) {
+      if (ctx->Color._LogicOpEnabled) {
          _swrast_logicop_rgba_span(ctx, span, span->array->rgba);
       }
       else if (ctx->Color.BlendEnabled) {