[Glamor] [PATCH 3/3] Use the direct render path for A1

junyan.he at linux.intel.com junyan.he at linux.intel.com
Mon Jun 4 13:48:30 PDT 2012


From: Junyan He <junyan.he at linux.intel.com>

 Because when mask depth is 1, there is no Anti-Alias at all,
 in this case, the directly render can work well and it is faseter.

Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
 src/glamor_priv.h      |    2 +-
 src/glamor_trapezoid.c |   33 ++++++++++++++++++++++++++-------
 2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/glamor_priv.h b/src/glamor_priv.h
index 8253f99..d853333 100644
--- a/src/glamor_priv.h
+++ b/src/glamor_priv.h
@@ -785,7 +785,7 @@ glamor_poly_line(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
 #define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
 #ifndef GLAMOR_GLES2
 #define GLAMOR_GRADIENT_SHADER
-#define GLAMOR_TRAPEZOID_SHADER
+//#define GLAMOR_TRAPEZOID_SHADER
 #endif
 
 #endif				/* GLAMOR_PRIV_H */
diff --git a/src/glamor_trapezoid.c b/src/glamor_trapezoid.c
index cc0029b..ab6d60d 100644
--- a/src/glamor_trapezoid.c
+++ b/src/glamor_trapezoid.c
@@ -1404,15 +1404,34 @@ _glamor_trapezoids(CARD8 op,
 	stride = PixmapBytePad(width, mask_format->depth);
 
 #ifdef GLAMOR_TRAPEZOID_SHADER
-	picture = glamor_create_mask_picture(screen, dst, mask_format,
-	          width, height, 1);
-	if (!picture)
-		return TRUE;
+	/* We seperate the render to two paths.
+	   Some GL implemetation do not implement the Anti-Alias for triangles
+	   and polygen's filling. So when the edge is not vertical or horizontal,
+	   sawtooth will be obvious. The trapezoid is widely used to render wide
+	   lines and circles. In these case, the line or circle will be divided
+	   into a large number of small trapezoids to approximate it, so the sawtooth
+	   at the edge will cause the result not be acceptable.
+	   When the depth of the mask is 1, there is no Anti-Alias needed, so we
+	   use the clip logic to generate the result directly(fast path).
+	   When the depth is not 1, AA is needed and we use a shader to generate
+	   a temp mask pixmap.
+	 */
+	if(mask_format->depth == 1) {
+		ret = _glamor_trapezoids_with_shader(op, src, dst, mask_format,
+		                                     x_src, y_src, ntrap, traps);
+		if(ret)
+			return TRUE;
+	} else {
+		picture = glamor_create_mask_picture(screen, dst, mask_format,
+		          width, height, 1);
+		if (!picture)
+			return TRUE;
 
-	ret = _glamor_generate_trapezoid_with_shader(screen, picture, traps, ntrap, &bounds);
+		ret = _glamor_generate_trapezoid_with_shader(screen, picture, traps, ntrap, &bounds);
 
-	if (!ret)
-		FreePicture(picture, 0);
+		if (!ret)
+			FreePicture(picture, 0);
+	}
 #endif
 
 	if (!ret) {
-- 
1.7.7.6



More information about the Glamor mailing list