work on xorg driver

ulab-next
Jay Sorg 11 years ago
parent 8cd57e0710
commit c11afcd672

@ -30,6 +30,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "rdpPri.h" #include "rdpPri.h"
/* PIXMAN_a8r8g8b8 */
#define XRDP_a8r8g8b8 \
((32 << 24) | (2 << 16) | (8 << 12) | (8 << 8) | (8 << 4) | 8)
#define PixelDPI 100 #define PixelDPI 100
#define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10)) #define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10))

@ -38,65 +38,117 @@
#define LLOGLN(_level, _args) \ #define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
/** /******************************************************************************/
* Copy an array of rectangles from one memory area to another static Bool
*****************************************************************************/ rdpCapture0(RegionPtr in_reg, RegionPtr out_reg,
void *src, int src_width, int src_height,
Bool rdpCapture(RegionPtr in_reg, RegionPtr out_reg, int src_stride, int src_format,
void *src, int src_width, int src_height, int src_stride, int src_format, void *dst, int dst_width, int dst_height,
void *dst, int dst_width, int dst_height, int dst_stride, int dst_format, int dst_stride, int dst_format, int max_rects)
int mode)
{ {
BoxRec rect; BoxPtr prects;
char *src_rect; BoxRec rect;
char *dst_rect; RegionRec reg;
int num_regions; char *src_rect;
int bpp; char *dst_rect;
int width; int num_regions;
int height; int bytespp;
int offset; int width;
int bytes; int height;
int i; int src_offset;
int j; int dst_offset;
int bytes;
/* int i;
* note: mode = 0: default, one is to one copy int j;
* xxx_format = 0: default, 4 bytes per pixel Bool rv;
*/
LLOGLN(10, ("rdpCapture0:"));
/* for now we only handle defaults */
rv = TRUE;
/* number of rectangles to copy */
num_regions = REGION_NUM_RECTS(in_reg); rect.x1 = 0;
rect.y1 = 0;
/* get bytes per pixel */ rect.x2 = min(dst_width, src_width);
bpp = src_stride / src_width; rect.y2 = min(dst_height, src_height);
rdpRegionInit(&reg, &rect, 0);
for (i = 0; i < num_regions; i++) rdpRegionIntersect(&reg, in_reg, &reg);
num_regions = REGION_NUM_RECTS(&reg);
if (num_regions > max_rects)
{ {
/* get rect to copy */ num_regions = 1;
rect = REGION_RECTS(in_reg)[i]; prects = rdpRegionExtents(&reg);
rdpRegionUninit(out_reg);
/* get rect dimensions */ rdpRegionInit(out_reg, prects, 0);
width = rect.x2 - rect.x1; }
height = rect.y2 - rect.y1; else
{
/* point to start of each rect in respective memory */ prects = REGION_RECTS(&reg);
offset = rect.y1 * src_stride + rect.x1 * bpp; rdpRegionCopy(out_reg, &reg);
src_rect = src + offset; }
dst_rect = dst + offset;
/* bytes per line */ if ((src_format == XRDP_a8r8g8b8) && (dst_format == XRDP_a8r8g8b8))
bytes = width * bpp; {
bytespp = 4;
/* copy one line at a time */ for (i = 0; i < num_regions; i++)
for (j = 0; j < height; j++)
{ {
memcpy(dst_rect, src_rect, bytes); /* get rect to copy */
src_rect += src_stride; rect = prects[i];
dst_rect += src_stride;
/* 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(&reg);
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;
} }

@ -18,7 +18,10 @@
* Routines to copy regions from framebuffer to shared memory * Routines to copy regions from framebuffer to shared memory
*/ */
Bool rdpCapture(RegionPtr in_reg, RegionPtr out_reg, Bool
void *src, int src_width, int src_height, int src_stride, int src_format, rdpCapture(RegionPtr in_reg, RegionPtr out_reg,
void *dst, int dst_width, int dst_height, int dst_stride, int dst_format, void *src, int src_width, int src_height,
int mode) int src_stride, int src_format,
void *dst, int dst_width, int dst_height,
int dst_stride, int dst_format,
int mode);

@ -42,6 +42,7 @@ Client connection to xrdp
#include "rdpMisc.h" #include "rdpMisc.h"
#include "rdpInput.h" #include "rdpInput.h"
#include "rdpReg.h" #include "rdpReg.h"
#include "rdpCapture.h"
#define LOG_LEVEL 1 #define LOG_LEVEL 1
#define LLOGLN(_level, _args) \ #define LLOGLN(_level, _args) \
@ -116,6 +117,8 @@ rdpClientConGotConnection(ScreenPtr pScreen, rdpPtr dev)
LLOGLN(0, ("rdpClientConGotConnection:")); LLOGLN(0, ("rdpClientConGotConnection:"));
clientCon = (rdpClientCon *) g_malloc(sizeof(rdpClientCon), 1); clientCon = (rdpClientCon *) g_malloc(sizeof(rdpClientCon), 1);
clientCon->dev = dev; clientCon->dev = dev;
dev->do_dirty_ons = 1;
make_stream(clientCon->in_s); make_stream(clientCon->in_s);
init_stream(clientCon->in_s, 8192); init_stream(clientCon->in_s, 8192);
make_stream(clientCon->out_s); make_stream(clientCon->out_s);
@ -262,6 +265,8 @@ rdpClientConDisconnect(rdpPtr dev, rdpClientCon *clientCon)
dev->clientConTail = plcli; dev->clientConTail = plcli;
} }
} }
LLOGLN(0, ("rdpClientConDisconnect: clientCon removed from "
"dev list"));
break; break;
} }
plcli = pcli; plcli = pcli;
@ -797,6 +802,24 @@ rdpClientConProcessMsgClientRegion(rdpPtr dev, rdpClientCon *clientCon)
return 0; return 0;
} }
/******************************************************************************/
static int
rdpClientConProcessMsgClientRegionEx(rdpPtr dev, rdpClientCon *clientCon)
{
struct stream *s;
int flags;
LLOGLN(10, ("rdpClientConProcessMsgClientRegionEx:"));
s = clientCon->in_s;
in_uint32_le(s, flags);
in_uint32_le(s, clientCon->rect_id_ack);
LLOGLN(10, ("rdpClientConProcessMsgClientRegionEx: flags 0x%8.8x", flags));
LLOGLN(10, ("rdpClientConProcessMsgClientRegionEx: rect_id %d "
"rect_id_ack %d", clientCon->rect_id, clientCon->rect_id_ack));
return 0;
}
/******************************************************************************/ /******************************************************************************/
static int static int
rdpClientConProcessMsg(rdpPtr dev, rdpClientCon *clientCon) rdpClientConProcessMsg(rdpPtr dev, rdpClientCon *clientCon)
@ -819,6 +842,9 @@ rdpClientConProcessMsg(rdpPtr dev, rdpClientCon *clientCon)
case 105: /* client region */ case 105: /* client region */
rdpClientConProcessMsgClientRegion(dev, clientCon); rdpClientConProcessMsgClientRegion(dev, clientCon);
break; break;
case 106: /* client region ex */
rdpClientConProcessMsgClientRegionEx(dev, clientCon);
break;
default: default:
break; break;
} }
@ -1848,40 +1874,104 @@ rdpClientConCheckDirtyScreen(rdpPtr dev, rdpClientCon *clientCon)
return 0; return 0;
} }
/******************************************************************************/
static int
rdpClientConSendPaintRectShmEx(rdpPtr dev, rdpClientCon *clientCon,
struct image_data *id,
RegionPtr dirtyReg, RegionPtr copyReg)
{
int index;
int size;
int num_rects_d;
int num_rects_c;
struct stream *s;
BoxRec box;
rdpClientConBeginUpdate(dev, clientCon);
num_rects_d = REGION_NUM_RECTS(dirtyReg);
num_rects_c = REGION_NUM_RECTS(copyReg);
size = 2 + 2 + 2 + num_rects_d * 8 + 2 + num_rects_c * 8;
size += 4 + 4 + 4 + 4 + 2 + 2;
rdpClientConPreCheck(dev, clientCon, size);
s = clientCon->out_s;
out_uint16_le(s, 61);
out_uint16_le(s, size);
clientCon->count++;
out_uint16_le(s, num_rects_d);
for (index = 0; index < num_rects_d; index++)
{
box = REGION_RECTS(dirtyReg)[index];
out_uint16_le(s, box.x1);
out_uint16_le(s, box.y1);
out_uint16_le(s, box.x2 - box.x1);
out_uint16_le(s, box.y2 - box.y1);
}
out_uint16_le(s, num_rects_c);
for (index = 0; index < num_rects_c; index++)
{
box = REGION_RECTS(copyReg)[index];
out_uint16_le(s, box.x1);
out_uint16_le(s, box.y1);
out_uint16_le(s, box.x2 - box.x1);
out_uint16_le(s, box.y2 - box.y1);
}
out_uint32_le(s, 0);
clientCon->rect_id++;
out_uint32_le(s, clientCon->rect_id);
out_uint32_le(s, id->shmem_id);
out_uint32_le(s, id->shmem_offset);
out_uint16_le(s, clientCon->rdp_width);
out_uint16_le(s, clientCon->rdp_height);
rdpClientConEndUpdate(dev, clientCon);
return 0;
}
/******************************************************************************/ /******************************************************************************/
static CARD32 static CARD32
rdpDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg) rdpDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg)
{ {
rdpClientCon *clientCon; rdpClientCon *clientCon;
int num_rects; RegionRec reg;
int index; struct image_data id;
BoxRec box;
LLOGLN(10, ("rdpDeferredUpdateCallback:")); LLOGLN(10, ("rdpDeferredUpdateCallback:"));
clientCon = (rdpClientCon *) arg; clientCon = (rdpClientCon *) arg;
if (clientCon->rect_id != clientCon->rect_id_ack) if (clientCon->rect_id != clientCon->rect_id_ack)
{ {
LLOGLN(10, ("rdpDeferredUpdateCallback: reschedual")); LLOGLN(0, ("rdpDeferredUpdateCallback: reschedual"));
clientCon->updateTimer = TimerSet(clientCon->updateTimer, 0, 40, clientCon->updateTimer = TimerSet(clientCon->updateTimer, 0, 40,
rdpDeferredUpdateCallback, clientCon); rdpDeferredUpdateCallback, clientCon);
return 0; return 0;
} }
else
clientCon->updateSchedualed = FALSE;
rdpClientConBeginUpdate(clientCon->dev, clientCon);
num_rects = REGION_NUM_RECTS(clientCon->dirtyRegion);
for (index = 0; index < num_rects; index++)
{ {
box = REGION_RECTS(clientCon->dirtyRegion)[index]; LLOGLN(10, ("rdpDeferredUpdateCallback: sending"));
LLOGLN(10, (" x1 %d y1 %d x2 %d y2 %d cx %d cy %d", box.x1, box.y1,
box.x2, box.y2, box.x2 - box.x1, box.y2 - box.y1));
rdpClientConSendArea(clientCon->dev, clientCon, NULL, box.x1, box.y1,
box.x2 - box.x1, box.y2 - box.y1);
} }
rdpClientConEndUpdate(clientCon->dev, clientCon); rdpClientConGetScreenImageRect(clientCon->dev, clientCon, &id);
LLOGLN(10, ("rdpDeferredUpdateCallback: rdp_width %d rdp_height %d "
"rdp_Bpp %d screen width %d screen height %d",
clientCon->rdp_width, clientCon->rdp_height, clientCon->rdp_Bpp,
id.width, id.height));
clientCon->updateSchedualed = FALSE;
rdpRegionInit(&reg, NullBox, 0);
rdpCapture(clientCon->dirtyRegion, &reg,
id.pixels, id.width, id.height,
id.lineBytes, XRDP_a8r8g8b8,
id.shmem_pixels, clientCon->rdp_width, clientCon->rdp_height,
clientCon->rdp_width * clientCon->rdp_Bpp , XRDP_a8r8g8b8, 0);
rdpClientConSendPaintRectShmEx(clientCon->dev, clientCon, &id,
clientCon->dirtyRegion, &reg);
rdpRegionDestroy(clientCon->dirtyRegion); rdpRegionDestroy(clientCon->dirtyRegion);
clientCon->dirtyRegion = rdpRegionCreate(NullBox, 0); clientCon->dirtyRegion = rdpRegionCreate(NullBox, 0);
rdpRegionUninit(&reg);
return 0; return 0;
} }
@ -1890,6 +1980,8 @@ int
rdpClientConAddDirtyScreenReg(rdpPtr dev, rdpClientCon *clientCon, rdpClientConAddDirtyScreenReg(rdpPtr dev, rdpClientCon *clientCon,
RegionPtr reg) RegionPtr reg)
{ {
LLOGLN(10, ("rdpClientConAddDirtyScreenReg:"));
rdpRegionUnion(clientCon->dirtyRegion, clientCon->dirtyRegion, reg); rdpRegionUnion(clientCon->dirtyRegion, clientCon->dirtyRegion, reg);
if (clientCon->updateSchedualed == FALSE) if (clientCon->updateSchedualed == FALSE)
{ {
@ -1969,7 +2061,6 @@ rdpClientConSendArea(rdpPtr dev, rdpClientCon *clientCon,
{ {
struct image_data lid; struct image_data lid;
BoxRec box; BoxRec box;
RegionRec reg;
int ly; int ly;
int size; int size;
char *src; char *src;
@ -2069,9 +2160,7 @@ rdpClientConSendArea(rdpPtr dev, rdpClientCon *clientCon,
out_uint16_le(s, id->height); out_uint16_le(s, id->height);
out_uint16_le(s, x); out_uint16_le(s, x);
out_uint16_le(s, y); out_uint16_le(s, y);
rdpRegionInit(&reg, &box, 0); rdpRegionUnionRect(clientCon->shmRegion, &box);
rdpRegionUnion(clientCon->shmRegion, clientCon->shmRegion, &reg);
rdpRegionUninit(&reg);
return; return;
} }
} }

@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <xf86.h> #include <xf86.h>
#include <xf86_OSproc.h> #include <xf86_OSproc.h>
#include "mipict.h" #include <mipict.h>
#include <picture.h> #include <picture.h>
#include "rdp.h" #include "rdp.h"

Loading…
Cancel
Save