xorg: add capture 16x16 aligned

This commit is contained in:
Jay Sorg 2014-05-04 18:17:17 -07:00
parent 42de994741
commit 6b0e224c1b
1 changed files with 123 additions and 0 deletions

View File

@ -298,6 +298,7 @@ rdpCapture0(RegionPtr in_reg, BoxPtr *out_rects, int *num_out_rects,
}
/******************************************************************************/
/* make out_rects always multiple of 16 width and height */
static Bool
rdpCapture1(RegionPtr in_reg, BoxPtr *out_rects, int *num_out_rects,
void *src, int src_width, int src_height,
@ -305,6 +306,128 @@ rdpCapture1(RegionPtr in_reg, BoxPtr *out_rects, int *num_out_rects,
void *dst, int dst_width, int dst_height,
int dst_stride, int dst_format, int max_rects)
{
BoxPtr psrc_rects;
BoxRec rect;
RegionRec reg;
char *src_rect;
char *dst_rect;
int num_regions;
int bytespp;
int src_bytespp;
int dst_bytespp;
int width;
int height;
int min_width;
int min_height;
int src_offset;
int dst_offset;
int bytes;
int i;
int j;
int k;
int red;
int green;
int blue;
Bool rv;
unsigned int *s32;
unsigned int *d32;
unsigned short *d16;
unsigned char *d8;
LLOGLN(10, ("rdpCapture0:"));
rv = TRUE;
min_width = min(dst_width, src_width);
min_height = min(dst_height, src_height);
rect.x1 = 0;
rect.y1 = 0;
rect.x2 = min_width;
rect.y2 = min_height;
rdpRegionInit(&reg, &rect, 0);
rdpRegionIntersect(&reg, in_reg, &reg);
num_regions = REGION_NUM_RECTS(&reg);
if (num_regions > max_rects)
{
num_regions = 1;
psrc_rects = rdpRegionExtents(&reg);
}
else
{
psrc_rects = REGION_RECTS(&reg);
}
if (num_regions < 1)
{
return FALSE;
}
*num_out_rects = num_regions;
*out_rects = (BoxPtr) g_malloc(sizeof(BoxRec) * num_regions, 0);
for (i = 0; i < num_regions; i++)
{
rect = psrc_rects[i];
width = rect.x2 - rect.x1;
height = rect.y2 - rect.y1;
width = (width + 15) & ~15;
height = (height + 15) & ~15;
rect.x2 = rect.x1 + width;
rect.y2 = rect.y1 + height;
if (rect.x2 > min_width)
{
rect.x2 = min_width;
rect.x1 = min_width - 16;
}
if (rect.y2 > min_height)
{
rect.y2 = min_height;
rect.y1 = min_height - 16;
}
(*out_rects)[i] = rect;
}
if ((src_format == XRDP_a8r8g8b8) && (dst_format == XRDP_a8b8g8r8))
{
src_bytespp = 4;
dst_bytespp = 4;
for (i = 0; i < num_regions; i++)
{
/* get rect to copy */
rect = (*out_rects)[i];
/* get rect dimensions */
width = rect.x2 - rect.x1;
height = rect.y2 - rect.y1;
/* point to start of each rect in respective memory */
src_offset = rect.y1 * src_stride + rect.x1 * src_bytespp;
dst_offset = rect.y1 * dst_stride + rect.x1 * dst_bytespp;
src_rect = src + src_offset;
dst_rect = dst + dst_offset;
/* copy one line at a time */
for (j = 0; j < height; j++)
{
s32 = (unsigned int *) src_rect;
d32 = (unsigned int *) dst_rect;
for (k = 0; k < width; k++)
{
SPLITCOLOR32(red, green, blue, *s32);
*d32 = COLOR24(red, green, blue);
s32++;
d32++;
}
src_rect += src_stride;
dst_rect += dst_stride;
}
}
}
return FALSE;
}