diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2014-02-18 17:09:53 -0800 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2014-02-18 17:09:53 -0800 |
commit | c11afcd67292f7e394e6adc77d89770a6662212f (patch) | |
tree | d88e548bd3fe0821e4b02bce7835353b077dbfee /xorg/server/module/rdpCapture.c | |
parent | 8cd57e07102a048d1e4b8ae4228a4cbdde88d509 (diff) | |
download | xrdp-proprietary-c11afcd67292f7e394e6adc77d89770a6662212f.tar.gz xrdp-proprietary-c11afcd67292f7e394e6adc77d89770a6662212f.zip |
work on xorg driver
Diffstat (limited to 'xorg/server/module/rdpCapture.c')
-rw-r--r-- | xorg/server/module/rdpCapture.c | 158 |
1 files changed, 105 insertions, 53 deletions
diff --git a/xorg/server/module/rdpCapture.c b/xorg/server/module/rdpCapture.c index 62b9fde8..8819713a 100644 --- a/xorg/server/module/rdpCapture.c +++ b/xorg/server/module/rdpCapture.c @@ -38,65 +38,117 @@ #define LLOGLN(_level, _args) \ do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) -/** - * Copy an array of rectangles from one memory area to another - *****************************************************************************/ - -Bool rdpCapture(RegionPtr in_reg, RegionPtr out_reg, - void *src, int src_width, int src_height, int src_stride, int src_format, - void *dst, int dst_width, int dst_height, int dst_stride, int dst_format, - int mode) +/******************************************************************************/ +static Bool +rdpCapture0(RegionPtr in_reg, RegionPtr out_reg, + void *src, int src_width, int src_height, + int src_stride, int src_format, + void *dst, int dst_width, int dst_height, + int dst_stride, int dst_format, int max_rects) { - BoxRec rect; - char *src_rect; - char *dst_rect; - int num_regions; - int bpp; - int width; - int height; - int offset; - int bytes; - int i; - int j; - - /* - * note: mode = 0: default, one is to one copy - * xxx_format = 0: default, 4 bytes per pixel - */ - - /* for now we only handle defaults */ - - /* number of rectangles to copy */ - num_regions = REGION_NUM_RECTS(in_reg); - - /* get bytes per pixel */ - bpp = src_stride / src_width; - - for (i = 0; i < num_regions; i++) + BoxPtr prects; + BoxRec rect; + RegionRec reg; + char *src_rect; + char *dst_rect; + int num_regions; + int bytespp; + int width; + int height; + int src_offset; + int dst_offset; + int bytes; + int i; + int j; + Bool rv; + + LLOGLN(10, ("rdpCapture0:")); + + rv = TRUE; + + rect.x1 = 0; + rect.y1 = 0; + rect.x2 = min(dst_width, src_width); + rect.y2 = min(dst_height, src_height); + rdpRegionInit(®, &rect, 0); + rdpRegionIntersect(®, in_reg, ®); + + num_regions = REGION_NUM_RECTS(®); + + if (num_regions > max_rects) { - /* get rect to copy */ - rect = REGION_RECTS(in_reg)[i]; - - /* get rect dimensions */ - width = rect.x2 - rect.x1; - height = rect.y2 - rect.y1; - - /* point to start of each rect in respective memory */ - offset = rect.y1 * src_stride + rect.x1 * bpp; - src_rect = src + offset; - dst_rect = dst + offset; + num_regions = 1; + prects = rdpRegionExtents(®); + rdpRegionUninit(out_reg); + rdpRegionInit(out_reg, prects, 0); + } + else + { + prects = REGION_RECTS(®); + rdpRegionCopy(out_reg, ®); + } - /* bytes per line */ - bytes = width * bpp; + if ((src_format == XRDP_a8r8g8b8) && (dst_format == XRDP_a8r8g8b8)) + { + bytespp = 4; - /* copy one line at a time */ - for (j = 0; j < height; j++) + for (i = 0; i < num_regions; i++) { - memcpy(dst_rect, src_rect, bytes); - src_rect += src_stride; - dst_rect += src_stride; + /* get rect to copy */ + rect = prects[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 * bytespp; + dst_offset = rect.y1 * dst_stride + rect.x1 * bytespp; + src_rect = src + src_offset; + dst_rect = dst + dst_offset; + + /* bytes per line */ + bytes = width * bytespp; + + /* copy one line at a time */ + for (j = 0; j < height; j++) + { + memcpy(dst_rect, src_rect, bytes); + src_rect += src_stride; + dst_rect += dst_stride; + } } } + else + { + LLOGLN(0, ("rdpCapture0: unimp color conversion")); + } + rdpRegionUninit(®); + return rv; +} - return rdpRegionCopy(out_reg, in_reg); +/** + * Copy an array of rectangles from one memory area to another + *****************************************************************************/ +Bool +rdpCapture(RegionPtr in_reg, RegionPtr out_reg, + void *src, int src_width, int src_height, + int src_stride, int src_format, + void *dst, int dst_width, int dst_height, + int dst_stride, int dst_format, int mode) +{ + LLOGLN(10, ("rdpCapture:")); + switch (mode) + { + case 0: + return rdpCapture0(in_reg, out_reg, + src, src_width, src_height, + src_stride, src_format, + dst, dst_width, dst_height, + dst_stride, dst_format, 15); + default: + LLOGLN(0, ("rdpCapture: unimp mode")); + break; + } + return TRUE; } |