xf86-video-intel: 2 commits - src/sna/sna_blt.c src/sna/sna_video.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Oct 31 04:28:27 PDT 2011


 src/sna/sna_blt.c   |    4 ++
 src/sna/sna_video.c |   79 ++++++++++++++++++++--------------------------------
 2 files changed, 35 insertions(+), 48 deletions(-)

New commits:
commit b1287e49347e0fff67f43d157fa87758d5cbe588
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 31 11:27:36 2011 +0000

    sna/video: Fix copy region for cropped video
    
    Reported-by: Clemens Eisserer <linuxhippy at gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42412
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c
index c8171dc..d1d5b52 100644
--- a/src/sna/sna_video.c
+++ b/src/sna/sna_video.c
@@ -145,8 +145,7 @@ sna_video_clip_helper(ScrnInfoPtr scrn,
 	 * For overlay video, compute the relevant CRTC and
 	 * clip video to that
 	 */
-	crtc = sna_covering_crtc(scrn, dst, video->desired_crtc,
-				   &crtc_box);
+	crtc = sna_covering_crtc(scrn, dst, video->desired_crtc, &crtc_box);
 
 	/* For textured video, we don't actually want to clip at all. */
 	if (crtc && !video->textured) {
@@ -262,24 +261,24 @@ sna_video_buffer(struct sna *sna,
 	return video->buf;
 }
 
-static void sna_memcpy_plane(unsigned char *dst, unsigned char *src,
-			       int height, int width,
-			       int dstPitch, int srcPitch, Rotation rotation)
+static void sna_memcpy_plane(uint8_t *dst, const uint8_t *src,
+			     int height, int width,
+			     int dstPitch, int srcPitch,
+			     Rotation rotation)
 {
+	const uint8_t *s;
 	int i, j = 0;
-	unsigned char *s;
 
 	switch (rotation) {
 	case RR_Rotate_0:
 		/* optimise for the case of no clipping */
 		if (srcPitch == dstPitch && srcPitch == width)
 			memcpy(dst, src, srcPitch * height);
-		else
-			for (i = 0; i < height; i++) {
-				memcpy(dst, src, width);
-				src += srcPitch;
-				dst += dstPitch;
-			}
+		else while (height--) {
+			memcpy(dst, src, width);
+			src += srcPitch;
+			dst += dstPitch;
+		}
 		break;
 	case RR_Rotate_90:
 		for (i = 0; i < height; i++) {
@@ -315,51 +314,37 @@ static void sna_memcpy_plane(unsigned char *dst, unsigned char *src,
 static void
 sna_copy_planar_data(struct sna_video *video,
 		     const struct sna_video_frame *frame,
-		     unsigned char *src,
-		     unsigned char *dst,
+		     const uint8_t *src,
+		     uint8_t *dst,
 		     int srcPitch, int srcPitch2,
-		     int srcH, int top, int left)
+		     int srcH, int top, int left, int h, int w)
 {
-	unsigned char *src1, *dst1;
+	uint8_t *d;
 
-	/* Copy Y data */
-	src1 = src + (top * srcPitch) + left;
-
-	sna_memcpy_plane(dst, src1,
-			 frame->height, frame->width,
-			 frame->pitch[1], srcPitch,
+	sna_memcpy_plane(dst, src + top * srcPitch + left,
+			 h, w, frame->pitch[1], srcPitch,
 			 video->rotation);
 
-	/* Copy V data for YV12, or U data for I420 */
-	src1 = src +		/* start of YUV data */
-	    (srcH * srcPitch) +	/* move over Luma plane */
-	    ((top >> 1) * srcPitch2) +	/* move down from by top lines */
-	    (left >> 1);	/* move left by left pixels */
+	src += srcH * srcPitch; /* move over Luma plane */
 
 	if (frame->id == FOURCC_I420)
-		dst1 = dst + frame->UBufOffset;
+		d = dst + frame->UBufOffset;
 	else
-		dst1 = dst + frame->VBufOffset;
+		d = dst + frame->VBufOffset;
 
-	sna_memcpy_plane(dst1, src1,
-			 frame->height / 2, frame->width / 2,
-			 frame->pitch[0], srcPitch2,
+	sna_memcpy_plane(d, src + (top >> 1) * srcPitch2 + (left >> 1),
+			 h / 2, w / 2, frame->pitch[0], srcPitch2,
 			 video->rotation);
 
-	/* Copy U data for YV12, or V data for I420 */
-	src1 = src +		/* start of YUV data */
-	    (srcH * srcPitch) +	/* move over Luma plane */
-	    ((srcH >> 1) * srcPitch2) +	/* move over Chroma plane */
-	    ((top >> 1) * srcPitch2) +	/* move down from by top lines */
-	    (left >> 1);	/* move left by left pixels */
+	src += (srcH >> 1) * srcPitch2; /* move over Chroma plane */
+
 	if (frame->id == FOURCC_I420)
-		dst1 = dst + frame->VBufOffset;
+		d = dst + frame->VBufOffset;
 	else
-		dst1 = dst + frame->UBufOffset;
+		d = dst + frame->UBufOffset;
 
-	sna_memcpy_plane(dst1, src1,
-			 frame->height / 2, frame->width / 2,
-			 frame->pitch[0], srcPitch2,
+	sna_memcpy_plane(d, src + (top >> 1) * srcPitch2 + (left >> 1),
+			 h / 2, w / 2, frame->pitch[0], srcPitch2,
 			 video->rotation);
 }
 
@@ -369,10 +354,8 @@ sna_copy_packed_data(struct sna_video *video,
 		     unsigned char *buf,
 		     unsigned char *dst,
 		     int srcPitch,
-		     int top, int left)
+		     int top, int left, int h, int w)
 {
-	int w = frame->width;
-	int h = frame->height;
 	unsigned char *src;
 	unsigned char *s;
 	int i, j;
@@ -524,14 +507,14 @@ sna_video_copy_data(struct sna *sna,
 		sna_copy_planar_data(video, frame,
 				     buf, dst,
 				     srcPitch, srcPitch2,
-				     nlines, top, left);
+				     frame->height, top, left, nlines, npixels);
 	} else {
 		int srcPitch = frame->width << 1;
 
 		sna_copy_packed_data(video, frame,
 				     buf, dst,
 				     srcPitch,
-				     top, left);
+				     top, left, nlines, npixels);
 	}
 
 	munmap(dst, video->buf->size);
commit b4ab412cb3eb8d37a33f5eeae5c613090ad2df0f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 31 10:37:43 2011 +0000

    sna/blt: Optimise fill with GXcopy and pixel==0 to a GXclear
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c
index 2ae4ac0..ae24e62 100644
--- a/src/sna/sna_blt.c
+++ b/src/sna/sna_blt.c
@@ -142,6 +142,8 @@ static bool sna_blt_fill_init(struct sna *sna,
 
 	if (alu == GXclear)
 		pixel = 0;
+	if (alu == GXcopy && pixel == 0)
+		alu = GXclear;
 
 	blt->br13 = 1<<31 | (fill_ROP[alu] << 16) | pitch;
 	switch (bpp) {
@@ -1612,6 +1614,8 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu,
 
 	if (alu == GXclear)
 		pixel = 0;
+	if (alu == GXcopy && pixel == 0)
+		alu = GXclear;
 
 	br13 |= 1<<31 | fill_ROP[alu] << 16;
 	switch (bpp) {


More information about the xorg-commit mailing list