[Glamor] [PATCH 2/5] render: Enable more componentAlpha support.

Zhigang Gong zhigang.gong at linux.intel.com
Fri Apr 6 06:28:55 PDT 2012


Actually only PictOpAtop,PictOpAtopReverse and PictOpXor
can't be implemented by using single source blending.
All the other can be easily support. Slightly change
the code to support them. Consider those three Ops
are not frequenly used in real application. We simply
fallback them currently.

PictOpAtop: 		s*mask*dst.a + (1 - s.a*mask)*dst
PictOpAtopReverse: 	s*mask*(1 - dst.a) + dst *s.a*mask
PictOpXor:		s*mask*(1 - dst.a) + dst * (1 - s.a*mask)

The two oprands in the above three ops are all reated to dst and
the blend factors are not constant (0 or 1), it's hardly to
convert it to single source blend.

Now, the rendercheck is runing more smoothly.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/glamor_render.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/glamor_render.c b/src/glamor_render.c
index 00a6e1e..9410adf 100644
--- a/src/glamor_render.c
+++ b/src/glamor_render.c
@@ -461,11 +461,6 @@ glamor_set_composite_op(ScreenPtr screen,
 	if (mask && mask->componentAlpha
 	    && PICT_FORMAT_RGB(mask->format) != 0 && op_info->source_alpha)
 	{
-		if (source_blend != GL_ZERO) {
-			glamor_fallback
-			    ("Dual-source composite blending not supported\n");
-			return GL_FALSE;
-		}
 		if (dest_blend == GL_SRC_ALPHA)
 			dest_blend = GL_SRC_COLOR;
 		else if (dest_blend == GL_ONE_MINUS_SRC_ALPHA)
@@ -954,15 +949,17 @@ glamor_composite_with_shader(CARD8 op,
 		if (!mask->componentAlpha) {
 			key.in = SHADER_IN_NORMAL;
 		} else {
-			/* We only handle two CA modes. */
-			if (op == PictOpAdd)
+			if (op == PictOpClear)
+				key.mask = SHADER_MASK_NONE;
+			else if (op == PictOpSrc || op == PictOpAdd
+				 || op == PictOpIn || op == PictOpOut
+				 || op == PictOpOverReverse)
 				key.in = SHADER_IN_CA_SOURCE;
-			else if (op == PictOpOutReverse) {
+			else if (op == PictOpOutReverse || op == PictOpInReverse) {
 				key.in = SHADER_IN_CA_ALPHA;
 			} else {
 				glamor_fallback
-				    ("Unsupported component alpha op: %d\n",
-				     op);
+				    ("Unsupported component alpha op: %d\n", op);
 				goto fail;
 			}
 		}
@@ -2911,10 +2908,13 @@ _glamor_composite(CARD8 op,
 					 x_dest, y_dest, width, height);
 			goto done;
 
-		} else if (op != PictOpAdd && op != PictOpOutReverse) {
-			glamor_fallback
-			    ("glamor_composite(): component alpha\n");
-			goto fail;
+		} else if (op == PictOpAtop
+			   || op == PictOpAtopReverse
+			   || op == PictOpXor
+			   || op >= PictOpSaturate) {
+				glamor_fallback
+					("glamor_composite(): component alpha op %x\n", op);
+				goto fail;
 		}
 	}
 	if (!mask) {
-- 
1.7.4.4



More information about the Glamor mailing list