mesa: Support EXT_framebuffer_blit targets in ES 3.0 as well.
[mesa.git] / src / mesa / main / blend.c
index 5bc40a028bd18901800548222451fa4ef019803d..1930b1c37ce39bb6bfd720e9ed1fb1243b9e300f 100644 (file)
@@ -58,16 +58,18 @@ legal_src_factor(const struct gl_context *ctx, GLenum factor)
    case GL_DST_ALPHA:
    case GL_ONE_MINUS_DST_ALPHA:
    case GL_SRC_ALPHA_SATURATE:
+      return GL_TRUE;
    case GL_CONSTANT_COLOR:
    case GL_ONE_MINUS_CONSTANT_COLOR:
    case GL_CONSTANT_ALPHA:
    case GL_ONE_MINUS_CONSTANT_ALPHA:
-      return GL_TRUE;
+      return _mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2;
    case GL_SRC1_COLOR:
    case GL_SRC1_ALPHA:
    case GL_ONE_MINUS_SRC1_COLOR:
    case GL_ONE_MINUS_SRC1_ALPHA:
-      return ctx->Extensions.ARB_blend_func_extended;
+      return _mesa_is_desktop_gl(ctx)
+         && ctx->Extensions.ARB_blend_func_extended;
    default:
       return GL_FALSE;
    }
@@ -93,17 +95,22 @@ legal_dst_factor(const struct gl_context *ctx, GLenum factor)
    case GL_ONE_MINUS_SRC_ALPHA:
    case GL_DST_ALPHA:
    case GL_ONE_MINUS_DST_ALPHA:
+      return GL_TRUE;
    case GL_CONSTANT_COLOR:
    case GL_ONE_MINUS_CONSTANT_COLOR:
    case GL_CONSTANT_ALPHA:
    case GL_ONE_MINUS_CONSTANT_ALPHA:
-      return GL_TRUE;
+      return _mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2;
    case GL_SRC_ALPHA_SATURATE:
+      return (_mesa_is_desktop_gl(ctx)
+              && ctx->Extensions.ARB_blend_func_extended)
+         || _mesa_is_gles3(ctx);
    case GL_SRC1_COLOR:
    case GL_SRC1_ALPHA:
    case GL_ONE_MINUS_SRC1_COLOR:
    case GL_ONE_MINUS_SRC1_ALPHA:
-      return ctx->Extensions.ARB_blend_func_extended;
+      return _mesa_is_desktop_gl(ctx)
+         && ctx->Extensions.ARB_blend_func_extended;
    default:
       return GL_FALSE;
    }
@@ -163,7 +170,7 @@ validate_blend_factors(struct gl_context *ctx, const char *func,
 void GLAPIENTRY
 _mesa_BlendFunc( GLenum sfactor, GLenum dfactor )
 {
-   _mesa_BlendFuncSeparateEXT(sfactor, dfactor, sfactor, dfactor);
+   _mesa_BlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
 }
 
 static GLboolean
@@ -194,7 +201,7 @@ update_uses_dual_src(struct gl_context *ctx, int buf)
  * \param dfactorA alpha destination factor operator.
  */
 void GLAPIENTRY
-_mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
+_mesa_BlendFuncSeparate( GLenum sfactorRGB, GLenum dfactorRGB,
                             GLenum sfactorA, GLenum dfactorA )
 {
    GLuint buf, numBuffers;
@@ -249,16 +256,13 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
 }
 
 
-#if _HAVE_FULL_GL
-
-
 /**
  * Set blend source/dest factors for one color buffer/target.
  */
 void GLAPIENTRY
-_mesa_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
+_mesa_BlendFunciARB(GLuint buf, GLenum sfactor, GLenum dfactor)
 {
-   _mesa_BlendFuncSeparatei(buf, sfactor, dfactor, sfactor, dfactor);
+   _mesa_BlendFuncSeparateiARB(buf, sfactor, dfactor, sfactor, dfactor);
 }
 
 
@@ -266,7 +270,7 @@ _mesa_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
  * Set separate blend source/dest factors for one color buffer/target.
  */
 void GLAPIENTRY
-_mesa_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
+_mesa_BlendFuncSeparateiARB(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
                          GLenum sfactorA, GLenum dfactorA)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -380,7 +384,7 @@ _mesa_BlendEquation( GLenum mode )
  * Set blend equation for one color buffer/target.
  */
 void GLAPIENTRY
-_mesa_BlendEquationi(GLuint buf, GLenum mode)
+_mesa_BlendEquationiARB(GLuint buf, GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -415,7 +419,7 @@ _mesa_BlendEquationi(GLuint buf, GLenum mode)
 
 
 void GLAPIENTRY
-_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA )
+_mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA )
 {
    GLuint buf, numBuffers;
    GLboolean changed;
@@ -473,7 +477,7 @@ _mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA )
  * Set separate blend equations for one color buffer/target.
  */
 void GLAPIENTRY
-_mesa_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA)
+_mesa_BlendEquationSeparateiARB(GLuint buf, GLenum modeRGB, GLenum modeA)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -513,10 +517,6 @@ _mesa_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA)
 }
 
 
-
-#endif /* _HAVE_FULL_GL */
-
-
 /**
  * Set the blending color.
  *
@@ -659,7 +659,7 @@ _mesa_LogicOp( GLenum opcode )
       ctx->Driver.LogicOpcode( ctx, opcode );
 }
 
-#if _HAVE_FULL_GL
+
 void GLAPIENTRY
 _mesa_IndexMask( GLuint mask )
 {
@@ -672,7 +672,6 @@ _mesa_IndexMask( GLuint mask )
    FLUSH_VERTICES(ctx, _NEW_COLOR);
    ctx->Color.IndexMask = mask;
 }
-#endif
 
 
 /**
@@ -731,7 +730,7 @@ _mesa_ColorMask( GLboolean red, GLboolean green,
  * For GL_EXT_draw_buffers2 and GL3
  */
 void GLAPIENTRY
-_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green,
+_mesa_ColorMaski( GLuint buf, GLboolean red, GLboolean green,
                         GLboolean blue, GLboolean alpha )
 {
    GLubyte tmp[4];
@@ -767,7 +766,7 @@ _mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green,
 
 
 void GLAPIENTRY
-_mesa_ClampColorARB(GLenum target, GLenum clamp)
+_mesa_ClampColor(GLenum target, GLenum clamp)
 {
    GET_CURRENT_CONTEXT(ctx);
 
@@ -851,6 +850,13 @@ void _mesa_init_color( struct gl_context * ctx )
    ctx->Color._ClampFragmentColor = GL_TRUE;
    ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB;
    ctx->Color._ClampReadColor = GL_TRUE;
+
+   if (ctx->API == API_OPENGLES2) {
+      /* GLES 3 behaves as though GL_FRAMEBUFFER_SRGB is always enabled. */
+      ctx->Color.sRGBEnabled = GL_TRUE;
+   } else {
+      ctx->Color.sRGBEnabled = GL_FALSE;
+   }
 }
 
 /*@}*/