|
|
|
@ -20,17 +20,152 @@
|
|
|
|
|
|
|
|
|
|
#include "xrdp.h"
|
|
|
|
|
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
#include <painter.h> /* libpainter */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define LLOG_LEVEL 1
|
|
|
|
|
#define LLOGLN(_level, _args) \
|
|
|
|
|
do \
|
|
|
|
|
{ \
|
|
|
|
|
if (_level < LLOG_LEVEL) \
|
|
|
|
|
{ \
|
|
|
|
|
g_write("xrdp:xrdp_painter [%10.10u]: ", g_time3()); \
|
|
|
|
|
g_writeln _args ; \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
while (0)
|
|
|
|
|
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
static int APP_CC
|
|
|
|
|
xrdp_painter_add_dirty_rect(struct xrdp_painter *self, int x, int y,
|
|
|
|
|
int cx, int cy, struct xrdp_rect *clip_rect)
|
|
|
|
|
{
|
|
|
|
|
int x2;
|
|
|
|
|
int y2;
|
|
|
|
|
struct xrdp_rect rect;
|
|
|
|
|
|
|
|
|
|
if (clip_rect != 0)
|
|
|
|
|
{
|
|
|
|
|
x2 = x + cx;
|
|
|
|
|
y2 = y + cy;
|
|
|
|
|
x = MAX(x, clip_rect->left);
|
|
|
|
|
y = MAX(y, clip_rect->top);
|
|
|
|
|
x2 = MIN(x2, clip_rect->right);
|
|
|
|
|
y2 = MIN(y2, clip_rect->bottom);
|
|
|
|
|
cx = x2 - x;
|
|
|
|
|
cy = y2 - y;
|
|
|
|
|
}
|
|
|
|
|
if (cx < 1 || cy < 1)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
rect.left = x;
|
|
|
|
|
rect.top = y;
|
|
|
|
|
rect.right = x + cx;
|
|
|
|
|
rect.bottom = y + cy;
|
|
|
|
|
xrdp_region_add_rect(self->dirty_region, &rect);
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_add_dirty_rect: x %d y %d cx %d cy %d",
|
|
|
|
|
x, y, cx, cy));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
static int
|
|
|
|
|
xrdp_painter_send_dirty(struct xrdp_painter *self)
|
|
|
|
|
{
|
|
|
|
|
int cx;
|
|
|
|
|
int cy;
|
|
|
|
|
int bpp;
|
|
|
|
|
int Bpp;
|
|
|
|
|
int index;
|
|
|
|
|
int jndex;
|
|
|
|
|
int error;
|
|
|
|
|
char *ldata;
|
|
|
|
|
char *src;
|
|
|
|
|
char *dst;
|
|
|
|
|
struct xrdp_rect rect;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_send_dirty:"));
|
|
|
|
|
|
|
|
|
|
bpp = self->wm->screen->bpp;
|
|
|
|
|
Bpp = (bpp + 7) / 8;
|
|
|
|
|
if (Bpp == 3)
|
|
|
|
|
{
|
|
|
|
|
Bpp = 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jndex = 0;
|
|
|
|
|
error = xrdp_region_get_rect(self->dirty_region, jndex, &rect);
|
|
|
|
|
while (error == 0)
|
|
|
|
|
{
|
|
|
|
|
cx = rect.right - rect.left;
|
|
|
|
|
cy = rect.bottom - rect.top;
|
|
|
|
|
ldata = (char *)g_malloc(cx * cy * Bpp, 0);
|
|
|
|
|
if (ldata == 0)
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
src = self->wm->screen->data;
|
|
|
|
|
src += self->wm->screen->line_size * rect.top;
|
|
|
|
|
src += rect.left * Bpp;
|
|
|
|
|
dst = ldata;
|
|
|
|
|
for (index = 0; index < cy; index++)
|
|
|
|
|
{
|
|
|
|
|
g_memcpy(dst, src, cx * Bpp);
|
|
|
|
|
src += self->wm->screen->line_size;
|
|
|
|
|
dst += cx * Bpp;
|
|
|
|
|
}
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_send_dirty: x %d y %d cx %d cy %d",
|
|
|
|
|
rect.left, rect.top, cx, cy));
|
|
|
|
|
libxrdp_send_bitmap(self->session, cx, cy, bpp,
|
|
|
|
|
ldata, rect.left, rect.top, cx, cy);
|
|
|
|
|
g_free(ldata);
|
|
|
|
|
|
|
|
|
|
jndex++;
|
|
|
|
|
error = xrdp_region_get_rect(self->dirty_region, jndex, &rect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xrdp_region_delete(self->dirty_region);
|
|
|
|
|
self->dirty_region = xrdp_region_create(self->wm);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
struct xrdp_painter *APP_CC
|
|
|
|
|
xrdp_painter_create(struct xrdp_wm *wm, struct xrdp_session *session)
|
|
|
|
|
{
|
|
|
|
|
struct xrdp_painter *self;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_create:"));
|
|
|
|
|
self = (struct xrdp_painter *)g_malloc(sizeof(struct xrdp_painter), 1);
|
|
|
|
|
self->wm = wm;
|
|
|
|
|
self->session = session;
|
|
|
|
|
self->rop = 0xcc; /* copy will use 0xcc */
|
|
|
|
|
self->clip_children = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (self->session->client_info->no_orders_supported)
|
|
|
|
|
{
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
if (painter_create(&(self->painter)) != PT_ERROR_NONE)
|
|
|
|
|
{
|
|
|
|
|
self->painter = 0;
|
|
|
|
|
LLOGLN(0, ("xrdp_painter_create: painter_create failed"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_create: painter_create success"));
|
|
|
|
|
}
|
|
|
|
|
self->dirty_region = xrdp_region_create(wm);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -38,11 +173,17 @@ xrdp_painter_create(struct xrdp_wm *wm, struct xrdp_session *session)
|
|
|
|
|
void APP_CC
|
|
|
|
|
xrdp_painter_delete(struct xrdp_painter *self)
|
|
|
|
|
{
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_delete:"));
|
|
|
|
|
if (self == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
painter_delete(self->painter);
|
|
|
|
|
xrdp_region_delete(self->dirty_region);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
g_free(self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -54,6 +195,13 @@ wm_painter_set_target(struct xrdp_painter *self)
|
|
|
|
|
int index;
|
|
|
|
|
struct list *del_list;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("wm_painter_set_target:"));
|
|
|
|
|
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self->wm->target_surface->type == WND_TYPE_SCREEN)
|
|
|
|
|
{
|
|
|
|
|
if (self->wm->current_surface_index != 0xffff)
|
|
|
|
@ -97,11 +245,19 @@ wm_painter_set_target(struct xrdp_painter *self)
|
|
|
|
|
int APP_CC
|
|
|
|
|
xrdp_painter_begin_update(struct xrdp_painter *self)
|
|
|
|
|
{
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_begin_update:"));
|
|
|
|
|
if (self == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self->begin_end_level++;
|
|
|
|
|
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libxrdp_orders_init(self->session);
|
|
|
|
|
wm_painter_set_target(self);
|
|
|
|
|
return 0;
|
|
|
|
@ -111,11 +267,25 @@ xrdp_painter_begin_update(struct xrdp_painter *self)
|
|
|
|
|
int APP_CC
|
|
|
|
|
xrdp_painter_end_update(struct xrdp_painter *self)
|
|
|
|
|
{
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_end_update:"));
|
|
|
|
|
if (self == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self->begin_end_level--;
|
|
|
|
|
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
if (self->begin_end_level == 0)
|
|
|
|
|
{
|
|
|
|
|
xrdp_painter_send_dirty(self);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libxrdp_orders_send(self->session);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -270,6 +440,7 @@ xrdp_painter_text_width(struct xrdp_painter *self, const char *text)
|
|
|
|
|
struct xrdp_font_char *font_item;
|
|
|
|
|
twchar *wstr;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_text_width:"));
|
|
|
|
|
xrdp_painter_font_needed(self);
|
|
|
|
|
|
|
|
|
|
if (self->font == 0)
|
|
|
|
@ -307,6 +478,7 @@ xrdp_painter_text_height(struct xrdp_painter *self, const char *text)
|
|
|
|
|
struct xrdp_font_char *font_item;
|
|
|
|
|
twchar *wstr;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_text_height:"));
|
|
|
|
|
xrdp_painter_font_needed(self);
|
|
|
|
|
|
|
|
|
|
if (self->font == 0)
|
|
|
|
@ -342,6 +514,13 @@ xrdp_painter_setup_brush(struct xrdp_painter *self,
|
|
|
|
|
{
|
|
|
|
|
int cache_id;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_setup_brush:"));
|
|
|
|
|
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_memcpy(out_brush, in_brush, sizeof(struct xrdp_brush));
|
|
|
|
|
|
|
|
|
|
if (in_brush->style == 3)
|
|
|
|
@ -358,6 +537,38 @@ xrdp_painter_setup_brush(struct xrdp_painter *self,
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
static int APP_CC
|
|
|
|
|
get_pt_format(struct xrdp_painter *self)
|
|
|
|
|
{
|
|
|
|
|
switch (self->wm->screen->bpp)
|
|
|
|
|
{
|
|
|
|
|
case 8:
|
|
|
|
|
return PT_FORMAT_r3g3b2;
|
|
|
|
|
case 15:
|
|
|
|
|
return PT_FORMAT_a1r5g5b5;
|
|
|
|
|
case 16:
|
|
|
|
|
return PT_FORMAT_r5g6b5;
|
|
|
|
|
}
|
|
|
|
|
return PT_FORMAT_a8r8g8b8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
static int
|
|
|
|
|
get_rgb_from_rdp_color(struct xrdp_painter *self, int rdp_color)
|
|
|
|
|
{
|
|
|
|
|
if (self->wm->screen->bpp < 24)
|
|
|
|
|
{
|
|
|
|
|
return rdp_color;
|
|
|
|
|
}
|
|
|
|
|
/* well, this is really BGR2RGB */
|
|
|
|
|
return XR_RGB2BGR(rdp_color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* fill in an area of the screen with one color */
|
|
|
|
|
int APP_CC
|
|
|
|
@ -375,11 +586,120 @@ xrdp_painter_fill_rect(struct xrdp_painter *self,
|
|
|
|
|
int dy;
|
|
|
|
|
int rop;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_fill_rect:"));
|
|
|
|
|
|
|
|
|
|
if (self == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dx = 0;
|
|
|
|
|
dy = 0;
|
|
|
|
|
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
struct painter_bitmap dst_pb;
|
|
|
|
|
struct xrdp_bitmap *ldst;
|
|
|
|
|
struct painter_bitmap pat;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_fill_rect: dst->type %d", dst->type));
|
|
|
|
|
if (dst->type != WND_TYPE_OFFSCREEN)
|
|
|
|
|
{
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_fill_rect: using painter"));
|
|
|
|
|
|
|
|
|
|
ldst = self->wm->screen;
|
|
|
|
|
|
|
|
|
|
g_memset(&dst_pb, 0, sizeof(dst_pb));
|
|
|
|
|
dst_pb.format = get_pt_format(self);
|
|
|
|
|
dst_pb.width = ldst->width;
|
|
|
|
|
dst_pb.stride_bytes = ldst->line_size;
|
|
|
|
|
dst_pb.height = ldst->height;
|
|
|
|
|
dst_pb.data = ldst->data;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_fill_rect: ldst->width %d ldst->height %d "
|
|
|
|
|
"dst->data %p self->fg_color %d",
|
|
|
|
|
ldst->width, ldst->height, ldst->data, self->fg_color));
|
|
|
|
|
|
|
|
|
|
xrdp_bitmap_get_screen_clip(dst, self, &clip_rect, &dx, &dy);
|
|
|
|
|
region = xrdp_region_create(self->wm);
|
|
|
|
|
xrdp_wm_get_vis_region(self->wm, dst, x, y, cx, cy, region,
|
|
|
|
|
self->clip_children);
|
|
|
|
|
x += dx;
|
|
|
|
|
y += dy;
|
|
|
|
|
|
|
|
|
|
rop = self->rop;
|
|
|
|
|
switch (self->rop)
|
|
|
|
|
{
|
|
|
|
|
case 0x5a:
|
|
|
|
|
rop = PT_ROP_DSx;
|
|
|
|
|
break;
|
|
|
|
|
case 0xf0:
|
|
|
|
|
rop = PT_ROP_S;
|
|
|
|
|
break;
|
|
|
|
|
case 0xfb:
|
|
|
|
|
rop = PT_ROP_D;
|
|
|
|
|
break;
|
|
|
|
|
case 0xc0:
|
|
|
|
|
rop = PT_ROP_DSa;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
painter_set_rop(self->painter, rop);
|
|
|
|
|
|
|
|
|
|
if (self->mix_mode == 0)
|
|
|
|
|
{
|
|
|
|
|
painter_set_pattern_mode(self->painter, PT_PATTERN_MODE_OPAQUE);
|
|
|
|
|
painter_set_fgcolor(self->painter, get_rgb_from_rdp_color(self, self->fg_color));
|
|
|
|
|
k = 0;
|
|
|
|
|
while (xrdp_region_get_rect(region, k, &rect) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (rect_intersect(&rect, &clip_rect, &draw_rect))
|
|
|
|
|
{
|
|
|
|
|
painter_set_clip(self->painter,
|
|
|
|
|
draw_rect.left, draw_rect.top,
|
|
|
|
|
draw_rect.right - draw_rect.left,
|
|
|
|
|
draw_rect.bottom - draw_rect.top);
|
|
|
|
|
painter_fill_rect(self->painter, &dst_pb, x, y, cx, cy);
|
|
|
|
|
xrdp_painter_add_dirty_rect(self, x, y, cx, cy, &draw_rect);
|
|
|
|
|
}
|
|
|
|
|
k++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
painter_set_pattern_mode(self->painter, PT_PATTERN_MODE_OPAQUE);
|
|
|
|
|
painter_set_fgcolor(self->painter, get_rgb_from_rdp_color(self, self->fg_color));
|
|
|
|
|
painter_set_bgcolor(self->painter, get_rgb_from_rdp_color(self, self->bg_color));
|
|
|
|
|
painter_set_pattern_origin(self->painter, self->brush.x_origin, self->brush.y_origin);
|
|
|
|
|
g_memset(&pat, 0, sizeof(pat));
|
|
|
|
|
pat.format = PT_FORMAT_c1;
|
|
|
|
|
pat.width = 8;
|
|
|
|
|
pat.stride_bytes = 1;
|
|
|
|
|
pat.height = 8;
|
|
|
|
|
pat.data = self->brush.pattern;
|
|
|
|
|
k = 0;
|
|
|
|
|
while (xrdp_region_get_rect(region, k, &rect) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (rect_intersect(&rect, &clip_rect, &draw_rect))
|
|
|
|
|
{
|
|
|
|
|
painter_set_clip(self->painter,
|
|
|
|
|
draw_rect.left, draw_rect.top,
|
|
|
|
|
draw_rect.right - draw_rect.left,
|
|
|
|
|
draw_rect.bottom - draw_rect.top);
|
|
|
|
|
painter_fill_pattern(self->painter, &dst_pb, &pat,
|
|
|
|
|
x, y, x, y, cx, cy);
|
|
|
|
|
xrdp_painter_add_dirty_rect(self, x, y, cx, cy, &draw_rect);
|
|
|
|
|
}
|
|
|
|
|
k++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
painter_clear_clip(self->painter);
|
|
|
|
|
xrdp_region_delete(region);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* todo data */
|
|
|
|
|
|
|
|
|
|
if (dst->type == WND_TYPE_BITMAP) /* 0 */
|
|
|
|
@ -508,11 +828,14 @@ xrdp_painter_draw_text(struct xrdp_painter *self,
|
|
|
|
|
struct xrdp_font_char *font_item;
|
|
|
|
|
twchar *wstr;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_draw_text:"));
|
|
|
|
|
|
|
|
|
|
if (self == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
len = g_mbstowcs(0, text, 0);
|
|
|
|
|
|
|
|
|
|
if (len < 1)
|
|
|
|
@ -534,6 +857,88 @@ xrdp_painter_draw_text(struct xrdp_painter *self,
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
struct painter_bitmap pat;
|
|
|
|
|
struct painter_bitmap dst_pb;
|
|
|
|
|
struct xrdp_bitmap *ldst;
|
|
|
|
|
|
|
|
|
|
if (dst->type != WND_TYPE_OFFSCREEN)
|
|
|
|
|
{
|
|
|
|
|
ldst = self->wm->screen;
|
|
|
|
|
/* convert to wide char */
|
|
|
|
|
wstr = (twchar *)g_malloc((len + 2) * sizeof(twchar), 0);
|
|
|
|
|
g_mbstowcs(wstr, text, len + 1);
|
|
|
|
|
font = self->font;
|
|
|
|
|
total_width = 0;
|
|
|
|
|
total_height = 0;
|
|
|
|
|
for (index = 0; index < len; index++)
|
|
|
|
|
{
|
|
|
|
|
font_item = font->font_items + wstr[index];
|
|
|
|
|
k = font_item->incby;
|
|
|
|
|
total_width += k;
|
|
|
|
|
total_height = MAX(total_height, font_item->height);
|
|
|
|
|
}
|
|
|
|
|
xrdp_bitmap_get_screen_clip(dst, self, &clip_rect, &dx, &dy);
|
|
|
|
|
region = xrdp_region_create(self->wm);
|
|
|
|
|
xrdp_wm_get_vis_region(self->wm, dst, x, y,
|
|
|
|
|
total_width, total_height,
|
|
|
|
|
region, self->clip_children);
|
|
|
|
|
x += dx;
|
|
|
|
|
y += dy;
|
|
|
|
|
g_memset(&dst_pb, 0, sizeof(dst_pb));
|
|
|
|
|
dst_pb.format = get_pt_format(self);
|
|
|
|
|
dst_pb.width = ldst->width;
|
|
|
|
|
dst_pb.stride_bytes = ldst->line_size;
|
|
|
|
|
dst_pb.height = ldst->height;
|
|
|
|
|
dst_pb.data = ldst->data;
|
|
|
|
|
painter_set_rop(self->painter, PT_ROP_S);
|
|
|
|
|
painter_set_pattern_origin(self->painter, 0, 0);
|
|
|
|
|
painter_set_pattern_mode(self->painter, PT_PATTERN_MODE_NORMAL);
|
|
|
|
|
painter_set_fgcolor(self->painter,
|
|
|
|
|
get_rgb_from_rdp_color(self, self->fg_color));
|
|
|
|
|
k = 0;
|
|
|
|
|
while (xrdp_region_get_rect(region, k, &rect) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (rect_intersect(&rect, &clip_rect, &draw_rect))
|
|
|
|
|
{
|
|
|
|
|
painter_set_clip(self->painter,
|
|
|
|
|
draw_rect.left, draw_rect.top,
|
|
|
|
|
draw_rect.right - draw_rect.left,
|
|
|
|
|
draw_rect.bottom - draw_rect.top);
|
|
|
|
|
for (index = 0; index < len; index++)
|
|
|
|
|
{
|
|
|
|
|
font_item = font->font_items + wstr[index];
|
|
|
|
|
g_memset(&pat, 0, sizeof(pat));
|
|
|
|
|
pat.format = PT_FORMAT_c1;
|
|
|
|
|
pat.width = font_item->width;
|
|
|
|
|
pat.stride_bytes = (font_item->width + 7) / 8;
|
|
|
|
|
pat.height = font_item->height;
|
|
|
|
|
pat.data = font_item->data;
|
|
|
|
|
x1 = x + font_item->offset;
|
|
|
|
|
y1 = y + (font_item->height + font_item->baseline);
|
|
|
|
|
painter_fill_pattern(self->painter, &dst_pb, &pat,
|
|
|
|
|
0, 0, x1, y1,
|
|
|
|
|
font_item->width,
|
|
|
|
|
font_item->height);
|
|
|
|
|
xrdp_painter_add_dirty_rect(self, x, y,
|
|
|
|
|
font_item->width,
|
|
|
|
|
font_item->height,
|
|
|
|
|
&draw_rect);
|
|
|
|
|
x += font_item->incby;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
k++;
|
|
|
|
|
}
|
|
|
|
|
painter_clear_clip(self->painter);
|
|
|
|
|
xrdp_region_delete(region);
|
|
|
|
|
g_free(wstr);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* convert to wide char */
|
|
|
|
|
wstr = (twchar *)g_malloc((len + 2) * sizeof(twchar), 0);
|
|
|
|
|
g_mbstowcs(wstr, text, len + 1);
|
|
|
|
@ -616,11 +1021,18 @@ xrdp_painter_draw_text2(struct xrdp_painter *self,
|
|
|
|
|
int dx;
|
|
|
|
|
int dy;
|
|
|
|
|
|
|
|
|
|
LLOGLN(0, ("xrdp_painter_draw_text2:"));
|
|
|
|
|
|
|
|
|
|
if (self == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* todo data */
|
|
|
|
|
|
|
|
|
|
if (dst->type == WND_TYPE_BITMAP)
|
|
|
|
@ -711,11 +1123,76 @@ xrdp_painter_copy(struct xrdp_painter *self,
|
|
|
|
|
int index;
|
|
|
|
|
struct list *del_list;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_copy:"));
|
|
|
|
|
|
|
|
|
|
if (self == 0 || src == 0 || dst == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
struct painter_bitmap src_pb;
|
|
|
|
|
struct painter_bitmap dst_pb;
|
|
|
|
|
struct xrdp_bitmap *ldst;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_copy: src->type %d dst->type %d", src->type, dst->type));
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_copy: self->rop 0x%2.2x", self->rop));
|
|
|
|
|
|
|
|
|
|
if (dst->type != WND_TYPE_OFFSCREEN)
|
|
|
|
|
{
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_copy: using painter"));
|
|
|
|
|
ldst = self->wm->screen;
|
|
|
|
|
|
|
|
|
|
g_memset(&dst_pb, 0, sizeof(dst_pb));
|
|
|
|
|
dst_pb.format = get_pt_format(self);
|
|
|
|
|
dst_pb.width = ldst->width;
|
|
|
|
|
dst_pb.stride_bytes = ldst->line_size;
|
|
|
|
|
dst_pb.height = ldst->height;
|
|
|
|
|
dst_pb.data = ldst->data;
|
|
|
|
|
|
|
|
|
|
g_memset(&src_pb, 0, sizeof(src_pb));
|
|
|
|
|
src_pb.format = get_pt_format(self);
|
|
|
|
|
src_pb.width = src->width;
|
|
|
|
|
src_pb.stride_bytes = src->line_size;
|
|
|
|
|
src_pb.height = src->height;
|
|
|
|
|
src_pb.data = src->data;
|
|
|
|
|
|
|
|
|
|
xrdp_bitmap_get_screen_clip(dst, self, &clip_rect, &dx, &dy);
|
|
|
|
|
region = xrdp_region_create(self->wm);
|
|
|
|
|
xrdp_wm_get_vis_region(self->wm, dst, x, y, cx, cy, region,
|
|
|
|
|
self->clip_children);
|
|
|
|
|
x += dx;
|
|
|
|
|
y += dy;
|
|
|
|
|
k = 0;
|
|
|
|
|
|
|
|
|
|
painter_set_rop(self->painter, self->rop);
|
|
|
|
|
while (xrdp_region_get_rect(region, k, &rect1) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (rect_intersect(&rect1, &clip_rect, &draw_rect))
|
|
|
|
|
{
|
|
|
|
|
painter_set_clip(self->painter,
|
|
|
|
|
draw_rect.left, draw_rect.top,
|
|
|
|
|
draw_rect.right - draw_rect.left,
|
|
|
|
|
draw_rect.bottom - draw_rect.top);
|
|
|
|
|
LLOGLN(10, (" x %d y %d cx %d cy %d srcx %d srcy %d",
|
|
|
|
|
x, y, cx, cy, srcx, srcy));
|
|
|
|
|
painter_copy(self->painter, &dst_pb, x, y, cx, cy,
|
|
|
|
|
&src_pb, srcx, srcy);
|
|
|
|
|
xrdp_painter_add_dirty_rect(self, x, y, cx, cy,
|
|
|
|
|
&draw_rect);
|
|
|
|
|
}
|
|
|
|
|
k++;
|
|
|
|
|
}
|
|
|
|
|
painter_clear_clip(self->painter);
|
|
|
|
|
xrdp_region_delete(region);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* todo data */
|
|
|
|
|
|
|
|
|
|
if (dst->type == WND_TYPE_BITMAP)
|
|
|
|
@ -848,7 +1325,7 @@ xrdp_painter_copy(struct xrdp_painter *self,
|
|
|
|
|
while (i < (srcx + cx))
|
|
|
|
|
{
|
|
|
|
|
w = MIN(64, ((srcx + cx) - i));
|
|
|
|
|
h = MIN(63, ((srcy + cy) - j));
|
|
|
|
|
h = MIN(64, ((srcy + cy) - j));
|
|
|
|
|
b = xrdp_bitmap_create(w, h, src->bpp, 0, self->wm);
|
|
|
|
|
#if 1
|
|
|
|
|
xrdp_bitmap_copy_box_with_crc(src, b, i, j, w, h);
|
|
|
|
@ -883,7 +1360,7 @@ xrdp_painter_copy(struct xrdp_painter *self,
|
|
|
|
|
i += 64;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
j += 63;
|
|
|
|
|
j += 64;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xrdp_region_delete(region);
|
|
|
|
@ -918,11 +1395,18 @@ xrdp_painter_composite(struct xrdp_painter* self,
|
|
|
|
|
int cache_srcidx;
|
|
|
|
|
int cache_mskidx;
|
|
|
|
|
|
|
|
|
|
LLOGLN(0, ("xrdp_painter_composite:"));
|
|
|
|
|
|
|
|
|
|
if (self == 0 || src == 0 || dst == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* todo data */
|
|
|
|
|
|
|
|
|
|
if (dst->type == WND_TYPE_BITMAP)
|
|
|
|
@ -985,10 +1469,75 @@ xrdp_painter_line(struct xrdp_painter *self,
|
|
|
|
|
int dy;
|
|
|
|
|
int rop;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_line:"));
|
|
|
|
|
if (self == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if (self->painter != 0)
|
|
|
|
|
{
|
|
|
|
|
#if defined(XRDP_PAINTER)
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
|
|
|
|
int cx;
|
|
|
|
|
int cy;
|
|
|
|
|
struct painter_bitmap dst_pb;
|
|
|
|
|
struct xrdp_bitmap *ldst;
|
|
|
|
|
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_line: dst->type %d", dst->type));
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_line: self->rop 0x%2.2x", self->rop));
|
|
|
|
|
|
|
|
|
|
if (dst->type != WND_TYPE_OFFSCREEN)
|
|
|
|
|
{
|
|
|
|
|
LLOGLN(10, ("xrdp_painter_line: using painter"));
|
|
|
|
|
ldst = self->wm->screen;
|
|
|
|
|
|
|
|
|
|
g_memset(&dst_pb, 0, sizeof(dst_pb));
|
|
|
|
|
dst_pb.format = get_pt_format(self);
|
|
|
|
|
dst_pb.width = ldst->width;
|
|
|
|
|
dst_pb.stride_bytes = ldst->line_size;
|
|
|
|
|
dst_pb.height = ldst->height;
|
|
|
|
|
dst_pb.data = ldst->data;
|
|
|
|
|
|
|
|
|
|
xrdp_bitmap_get_screen_clip(dst, self, &clip_rect, &dx, &dy);
|
|
|
|
|
region = xrdp_region_create(self->wm);
|
|
|
|
|
x = MIN(x1, x2);
|
|
|
|
|
y = MIN(y1, y2);
|
|
|
|
|
cx = g_abs(x1 - x2) + 1;
|
|
|
|
|
cy = g_abs(y1 - y2) + 1;
|
|
|
|
|
xrdp_wm_get_vis_region(self->wm, dst, x, y, cx, cy,
|
|
|
|
|
region, self->clip_children);
|
|
|
|
|
x1 += dx;
|
|
|
|
|
y1 += dy;
|
|
|
|
|
x2 += dx;
|
|
|
|
|
y2 += dy;
|
|
|
|
|
k = 0;
|
|
|
|
|
rop = self->rop;
|
|
|
|
|
|
|
|
|
|
painter_set_rop(self->painter, rop);
|
|
|
|
|
painter_set_fgcolor(self->painter, self->pen.color);
|
|
|
|
|
while (xrdp_region_get_rect(region, k, &rect) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (rect_intersect(&rect, &clip_rect, &draw_rect))
|
|
|
|
|
{
|
|
|
|
|
painter_set_clip(self->painter,
|
|
|
|
|
draw_rect.left, draw_rect.top,
|
|
|
|
|
draw_rect.right - draw_rect.left,
|
|
|
|
|
draw_rect.bottom - draw_rect.top);
|
|
|
|
|
painter_line(self->painter, &dst_pb, x1, y1, x2, x2,
|
|
|
|
|
self->pen.width, 0);
|
|
|
|
|
xrdp_painter_add_dirty_rect(self, x, y, cx, cy,
|
|
|
|
|
&draw_rect);
|
|
|
|
|
}
|
|
|
|
|
k++;
|
|
|
|
|
}
|
|
|
|
|
painter_clear_clip(self->painter);
|
|
|
|
|
xrdp_region_delete(region);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* todo data */
|
|
|
|
|
|
|
|
|
|