cogl-blend-string: Don't split combined blend statements into two
authorNeil Roberts <neil@linux.intel.com>
Wed, 12 May 2010 16:56:25 +0000 (17:56 +0100)
committerNeil Roberts <neil@linux.intel.com>
Mon, 17 May 2010 15:31:28 +0000 (16:31 +0100)
commit502446ed8dc56ab9dccacbdd68f54306fe4d3558
treea47bd00f7e992d4d5b9dd8afbdb4875db72aa6a6
parent47d54930164f3c3478ccba66a01aadd0e72802d0
cogl-blend-string: Don't split combined blend statements into two

When a single statement is used to specify the factors for both the
RGB and alpha parts it previously split up the statement into
two. This works but it ends up unnecessarily using glBlendFuncSeparate
when glBlendFunc would suffice.

For example, the blend statement

 RGBA = ADD(SRC_COLOR*(SRC_COLOR), DST_COLOR*(1-SRC_COLOR))

would get split into the two statements

 RGBA = ADD(SRC_COLOR*(SRC_COLOR[RGB]), DST_COLOR*(1-SRC_COLOR[RGB]))
 A    = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR*(1-SRC_COLOR[A]))

That translates to:

 glBlendFuncSeparate (GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,
                      GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

This patch makes it so that arg_to_gl_blend_factor can handle the
combined RGBA mask instead. That way the single statement gets
translated to the equivalent call:

 glBlendFunc (GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
clutter/cogl/cogl/cogl-material.c