libfreerdp-gdi: add bitmap updates, make use of it through freerdp-test

This commit is contained in:
Marc-André Moreau 2011-07-28 01:34:53 -04:00
parent 70ebd47cc4
commit 6a13313c50
5 changed files with 27 additions and 18 deletions

View File

@ -17,6 +17,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
include_directories(../../libfreerdp-gdi)
include_directories(../../libfreerdp-core)
add_executable(freerdp-test

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include "gdi.h"
#include "connection.h"
#include <freerdp/freerdp.h>
@ -190,23 +191,11 @@ boolean freerdp_process_params(int argc, char* argv[], rdpSettings* settings, in
return True;
}
int bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap)
{
printf("received bitmap update from core\n");
return 0;
}
void register_update_callbacks(rdpUpdate* update)
{
update->Bitmap = bitmap_update;
}
int main(int argc, char* argv[])
{
int index = 1;
instance = freerdp_new();
register_update_callbacks(instance->update);
settings = instance->settings;
rdp = (rdpRdp*) instance->rdp;
@ -217,8 +206,7 @@ int main(int argc, char* argv[])
return 0;
}
printf("hostname:%s username:%s password:%s\n",
settings->hostname, settings->username, settings->password);
gdi_init(instance, 0);
rdp_client_connect(rdp);

View File

@ -407,6 +407,8 @@ typedef int (*pcGlyphIndex)(rdpUpdate* update, GLYPH_INDEX_ORDER* glyph_index);
struct rdp_update
{
void* rdp;
void* param1;
void* param2;
pcSynchronize Synchronize;
pcBitmap Bitmap;

View File

@ -1065,6 +1065,24 @@ gdi_ui_decode(struct rdp_inst * inst, uint8 * data, int size)
}
#endif
int gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap)
{
int i;
BITMAP_DATA* bmp;
GDI_IMAGE* gdi_bmp;
GDI* gdi = GET_GDI(update);
for (i = 0; i < bitmap->number; i++)
{
bmp = &bitmap->bitmaps[i];
gdi_bmp = gdi_bitmap_new(gdi, bmp->width, bmp->height, gdi->dstBpp, bmp->data);
gdi_BitBlt(gdi->primary->hdc, bmp->left, bmp->top, bmp->width, bmp->height, gdi_bmp->hdc, 0, 0, GDI_SRCCOPY);
gdi_bitmap_free((GDI_IMAGE*) gdi_bmp);
}
return 0;
}
/**
* Register GDI callbacks with libfreerdp.
* @param inst current instance
@ -1073,7 +1091,7 @@ gdi_ui_decode(struct rdp_inst * inst, uint8 * data, int size)
void gdi_register_update_callbacks(rdpUpdate* update)
{
update->Bitmap = NULL;
update->Bitmap = gdi_bitmap_update;
update->Palette = NULL;
update->DstBlt = NULL;
update->PatBlt = NULL;
@ -1109,7 +1127,7 @@ int gdi_init(freerdp* instance, uint32 flags)
{
GDI *gdi = (GDI*) malloc(sizeof(GDI));
memset(gdi, 0, sizeof(GDI));
SET_GDI(instance, gdi);
SET_GDI(instance->update, gdi);
gdi->width = instance->settings->width;
gdi->height = instance->settings->height;

View File

@ -256,8 +256,8 @@ void gdi_bitmap_free(GDI_IMAGE *gdi_bmp);
int gdi_init(freerdp* instance, uint32 flags);
void gdi_free(freerdp* instance);
#define SET_GDI(_inst, _gdi) (_inst)->param2 = _gdi
#define GET_GDI(_inst) ((GDI*) ((_inst)->param2))
#define SET_GDI(_instance, _gdi) (_instance)->param1 = _gdi
#define GET_GDI(_instance) ((GDI*) ((_instance)->param1))
#ifdef WITH_DEBUG_GDI
#define DEBUG_GDI(fmt, ...) DEBUG_CLASS(GDI, fmt, ## __VA_ARGS__)