~ubuntu-branches/ubuntu/raring/remmina/raring

« back to all changes in this revision

Viewing changes to remmina-plugins/rdp/rdp_graphics.c

  • Committer: Package Import Robot
  • Author(s): Luca Falavigna
  • Date: 2012-02-11 17:28:48 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20120211172848-rh3ffi7075qyobuq
Tags: 1.0.0-1
* New upstream release.
  - Compatible with FreeRDP 1.0 (Closes: #658363).
  - Ported to GTK3, this also fixes an incompatibility with
    GTK2 and recent Avahi with GTK3 support, which lead to
    crashes when scanning network services (Closes: #626499).
* debian/patches/libvncserver.patch:
  - Do not use convenience copy of libvncserver.
* debian/patches/g_thread_init.patch:
  - Do not use deprecated g_thread_init function.
* debian/patches/REMMINA_COMMAND_NONE.patch:
  - Removed, obsoleted by GApplication port.
* debian/clean:
  - Remove spurious files created at build-time.
* debian/compat:
  - Bump compatibility level to 9.
* debian/control:
  - Refresh build-dependencies to match new structure.
  - Drop remmina-dev package, no longer used.
  - Build packages once provided by remmina-plugins.
  - Provide remmina-common package.
  - Provide remmina-plugin-gnome package.
* debian/copyright:
  - Refresh copyright information.
* debian/docs:
  - Documentation is no longer accurate, do not ship it anymore.
* debian/remmina-dev.install:
  - Drop remmina-dev package, no longer used.
* debian/remmina-plugin-telepathy.install:
  - Adjust location for Remmina.client.
  - Disable D-BUS support for now.
* debian/rules:
  - Compile with -DWITH_APPINDICATOR=OFF.
  - Do not treat plugins as shared libraries.
* debian/watch:
  - Adjust watch file to match new download location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Remmina - The GTK+ Remote Desktop Client
 
3
 * Copyright (C) 2010 Jay Sorg
 
4
 * Copyright (C) 2010-2011 Vic Lee
 
5
 * Copyright (C) 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 59 Temple Place, Suite 330, 
 
20
 * Boston, MA 02111-1307, USA.
 
21
 */
 
22
 
 
23
#include "rdp_plugin.h"
 
24
#include "rdp_event.h"
 
25
#include "rdp_graphics.h"
 
26
 
 
27
#include <freerdp/utils/memory.h>
 
28
#include <freerdp/codec/color.h>
 
29
#include <freerdp/codec/bitmap.h>
 
30
 
 
31
//#define RF_BITMAP
 
32
//#define RF_GLYPH
 
33
 
 
34
/* Bitmap Class */
 
35
 
 
36
void rf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
 
37
{
 
38
#ifdef RF_BITMAP
 
39
        uint8* data;
 
40
        Pixmap pixmap;
 
41
        XImage* image;
 
42
        rfContext* rfi = (rfContext*) context;
 
43
 
 
44
        XSetFunction(rfi->display, rfi->gc, GXcopy);
 
45
        pixmap = XCreatePixmap(rfi->display, rfi->drawable, bitmap->width, bitmap->height, rfi->depth);
 
46
 
 
47
        if (bitmap->data != NULL)
 
48
        {
 
49
                data = freerdp_image_convert(bitmap->data, NULL,
 
50
                                bitmap->width, bitmap->height, rfi->srcBpp, rfi->bpp, rfi->clrconv);
 
51
 
 
52
                if (bitmap->ephemeral != true)
 
53
                {
 
54
                        image = XCreateImage(rfi->display, rfi->visual, rfi->depth,
 
55
                                ZPixmap, 0, (char*) data, bitmap->width, bitmap->height, rfi->scanline_pad, 0);
 
56
 
 
57
                        XPutImage(rfi->display, pixmap, rfi->gc, image, 0, 0, 0, 0, bitmap->width, bitmap->height);
 
58
                        XFree(image);
 
59
 
 
60
                        if (data != bitmap->data)
 
61
                                xfree(data);
 
62
                }
 
63
                else
 
64
                {
 
65
                        if (data != bitmap->data)
 
66
                                xfree(bitmap->data);
 
67
 
 
68
                        bitmap->data = data;
 
69
                }
 
70
        }
 
71
 
 
72
        ((rfBitmap*) bitmap)->pixmap = pixmap;
 
73
#endif
 
74
}
 
75
 
 
76
void rf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
 
77
{
 
78
#ifdef RF_BITMAP
 
79
        rfContext* rfi = (rfContext*) context;
 
80
 
 
81
        printf("rf_Bitmap_Free\n");
 
82
 
 
83
        if (((rfBitmap*) bitmap)->pixmap != 0)
 
84
                XFreePixmap(rfi->display, ((rfBitmap*) bitmap)->pixmap);
 
85
#endif
 
86
}
 
87
 
 
88
void rf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
 
89
{
 
90
#ifdef RF_BITMAP
 
91
        XImage* image;
 
92
        int width, height;
 
93
        rfContext* rfi = (rfContext*) context;
 
94
 
 
95
        printf("rf_Bitmap_Paint\n");
 
96
 
 
97
        width = bitmap->right - bitmap->left + 1;
 
98
        height = bitmap->bottom - bitmap->top + 1;
 
99
 
 
100
        XSetFunction(rfi->display, rfi->gc, GXcopy);
 
101
 
 
102
        image = XCreateImage(rfi->display, rfi->visual, rfi->depth,
 
103
                        ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, rfi->scanline_pad, 0);
 
104
 
 
105
        XPutImage(rfi->display, rfi->primary, rfi->gc,
 
106
                        image, 0, 0, bitmap->left, bitmap->top, width, height);
 
107
 
 
108
        XFree(image);
 
109
 
 
110
        //XCopyArea(rfi->display, rfi->primary, rfi->drawable, rfi->gc,
 
111
        //                      bitmap->left, bitmap->top, width, height, bitmap->left, bitmap->top);
 
112
 
 
113
        //gdi_InvalidateRegion(rfi->hdc, bitmap->left, bitmap->top, width, height);
 
114
#endif
 
115
}
 
116
 
 
117
void rf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
 
118
        uint8* data, int width, int height, int bpp, int length, boolean compressed)
 
119
{
 
120
#ifdef RF_BITMAP
 
121
        uint16 size;
 
122
 
 
123
        printf("rf_Bitmap_Decompress\n");
 
124
 
 
125
        size = width * height * (bpp + 7) / 8;
 
126
 
 
127
        if (bitmap->data == NULL)
 
128
                bitmap->data = (uint8*) xmalloc(size);
 
129
        else
 
130
                bitmap->data = (uint8*) xrealloc(bitmap->data, size);
 
131
 
 
132
        if (compressed)
 
133
        {
 
134
                boolean status;
 
135
 
 
136
                status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp);
 
137
 
 
138
                if (status != true)
 
139
                {
 
140
                        printf("Bitmap Decompression Failed\n");
 
141
                }
 
142
        }
 
143
        else
 
144
        {
 
145
                freerdp_image_flip(data, bitmap->data, width, height, bpp);
 
146
        }
 
147
 
 
148
        bitmap->compressed = false;
 
149
        bitmap->length = size;
 
150
        bitmap->bpp = bpp;
 
151
#endif
 
152
}
 
153
 
 
154
void rf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, boolean primary)
 
155
{
 
156
#ifdef RF_BITMAP
 
157
        rfContext* rfi = (rfContext*) context;
 
158
 
 
159
        if (primary)
 
160
                rfi->drawing = rfi->primary;
 
161
        else
 
162
                rfi->drawing = ((rfBitmap*) bitmap)->pixmap;
 
163
#endif
 
164
}
 
165
 
 
166
/* Pointer Class */
 
167
 
 
168
void rf_Pointer_New(rdpContext* context, rdpPointer* pointer)
 
169
{
 
170
 
 
171
}
 
172
 
 
173
void rf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
 
174
{
 
175
 
 
176
}
 
177
 
 
178
void rf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
 
179
{
 
180
 
 
181
}
 
182
 
 
183
/* Glyph Class */
 
184
 
 
185
void rf_Glyph_New(rdpContext* context, rdpGlyph* glyph)
 
186
{
 
187
#ifdef RF_GLYPH
 
188
        int scanline;
 
189
        XImage* image;
 
190
        rfContext* rfi;
 
191
        rfGlyph* rf_glyph;
 
192
 
 
193
        rf_glyph = (rfGlyph*) glyph;
 
194
        rfi = (rfContext*) context;
 
195
 
 
196
        scanline = (glyph->cx + 7) / 8;
 
197
 
 
198
        rf_glyph->pixmap = XCreatePixmap(rfi->display, rfi->drawing, glyph->cx, glyph->cy, 1);
 
199
 
 
200
        image = XCreateImage(rfi->display, rfi->visual, 1,
 
201
                        ZPixmap, 0, (char*) glyph->aj, glyph->cx, glyph->cy, 8, scanline);
 
202
 
 
203
        image->byte_order = MSBFirst;
 
204
        image->bitmap_bit_order = MSBFirst;
 
205
 
 
206
        XInitImage(image);
 
207
        XPutImage(rfi->display, rf_glyph->pixmap, rfi->gc_mono, image, 0, 0, 0, 0, glyph->cx, glyph->cy);
 
208
        XFree(image);
 
209
#endif
 
210
}
 
211
 
 
212
void rf_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
 
213
{
 
214
#ifdef RF_GLYPH
 
215
        rfContext* rfi = (rfContext*) context;
 
216
 
 
217
        if (((rfGlyph*) glyph)->pixmap != 0)
 
218
                XFreePixmap(rfi->display, ((rfGlyph*) glyph)->pixmap);
 
219
#endif
 
220
}
 
221
 
 
222
void rf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y)
 
223
{
 
224
#ifdef RF_GLYPH
 
225
        rfGlyph* rf_glyph;
 
226
        rfContext* rfi = (rfContext*) context;
 
227
 
 
228
        rf_glyph = (rfGlyph*) glyph;
 
229
 
 
230
        XSetStipple(rfi->display, rfi->gc, rf_glyph->pixmap);
 
231
        XSetTSOrigin(rfi->display, rfi->gc, x, y);
 
232
        XFillRectangle(rfi->display, rfi->drawing, rfi->gc, x, y, glyph->cx, glyph->cy);
 
233
        XSetStipple(rfi->display, rfi->gc, rfi->bitmap_mono);
 
234
#endif
 
235
}
 
236
 
 
237
void rf_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor)
 
238
{
 
239
#ifdef RF_GLYPH
 
240
        rfContext* rfi = (rfContext*) context;
 
241
 
 
242
        bgcolor = (rfi->clrconv->invert)?
 
243
                freerdp_color_convert_var_bgr(bgcolor, rfi->srcBpp, 32, rfi->clrconv):
 
244
                freerdp_color_convert_var_rgb(bgcolor, rfi->srcBpp, 32, rfi->clrconv);
 
245
 
 
246
        fgcolor = (rfi->clrconv->invert)?
 
247
                freerdp_color_convert_var_bgr(fgcolor, rfi->srcBpp, 32, rfi->clrconv):
 
248
                freerdp_color_convert_var_rgb(fgcolor, rfi->srcBpp, 32, rfi->clrconv);
 
249
 
 
250
        XSetFunction(rfi->display, rfi->gc, GXcopy);
 
251
        XSetFillStyle(rfi->display, rfi->gc, FillSolid);
 
252
        XSetForeground(rfi->display, rfi->gc, fgcolor);
 
253
        XFillRectangle(rfi->display, rfi->drawing, rfi->gc, x, y, width, height);
 
254
 
 
255
        XSetForeground(rfi->display, rfi->gc, bgcolor);
 
256
        XSetBackground(rfi->display, rfi->gc, fgcolor);
 
257
        XSetFillStyle(rfi->display, rfi->gc, FillStippled);
 
258
#endif
 
259
}
 
260
 
 
261
void rf_Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor)
 
262
{
 
263
#ifdef RF_GLYPH
 
264
        rfContext* rfi = (rfContext*) context;
 
265
 
 
266
        if (rfi->drawing == rfi->primary)
 
267
        {
 
268
                //XCopyArea(rfi->display, rfi->primary, rfi->drawable, rfi->gc, x, y, width, height, x, y);
 
269
                //gdi_InvalidateRegion(rfi->hdc, x, y, width, height);
 
270
        }
 
271
#endif
 
272
}
 
273
 
 
274
/* Graphics Module */
 
275
 
 
276
void rf_register_graphics(rdpGraphics* graphics)
 
277
{
 
278
        rdpBitmap* bitmap;
 
279
        rdpPointer* pointer;
 
280
        rdpGlyph* glyph;
 
281
 
 
282
        bitmap = xnew(rdpBitmap);
 
283
        bitmap->size = sizeof(rfBitmap);
 
284
 
 
285
        bitmap->New = rf_Bitmap_New;
 
286
        bitmap->Free = rf_Bitmap_Free;
 
287
        bitmap->Paint = rf_Bitmap_Paint;
 
288
        bitmap->Decompress = rf_Bitmap_Decompress;
 
289
        bitmap->SetSurface = rf_Bitmap_SetSurface;
 
290
 
 
291
        graphics_register_bitmap(graphics, bitmap);
 
292
        xfree(bitmap);
 
293
 
 
294
        pointer = xnew(rdpPointer);
 
295
        pointer->size = sizeof(rfPointer);
 
296
 
 
297
        pointer->New = rf_Pointer_New;
 
298
        pointer->Free = rf_Pointer_Free;
 
299
        pointer->Set = rf_Pointer_Set;
 
300
 
 
301
        graphics_register_pointer(graphics, pointer);
 
302
        xfree(pointer);
 
303
 
 
304
        glyph = xnew(rdpGlyph);
 
305
        glyph->size = sizeof(rfGlyph);
 
306
 
 
307
        glyph->New = rf_Glyph_New;
 
308
        glyph->Free = rf_Glyph_Free;
 
309
        glyph->Draw = rf_Glyph_Draw;
 
310
        glyph->BeginDraw = rf_Glyph_BeginDraw;
 
311
        glyph->EndDraw = rf_Glyph_EndDraw;
 
312
 
 
313
        graphics_register_glyph(graphics, glyph);
 
314
        xfree(glyph);
 
315
}