libfreerdp-cache: started offscreen bitmap cache

This commit is contained in:
Marc-André Moreau 2011-08-04 16:22:15 -04:00
parent 0c981407e5
commit 1dcc1c2be2
15 changed files with 367 additions and 64 deletions

View File

@ -89,6 +89,7 @@ add_subdirectory(include)
add_subdirectory(libfreerdp-utils)
add_subdirectory(libfreerdp-kbd)
add_subdirectory(libfreerdp-gdi)
add_subdirectory(libfreerdp-cache)
add_subdirectory(libfreerdp-chanman)
add_subdirectory(libfreerdp-core)
add_subdirectory(channels)

View File

@ -94,10 +94,36 @@ boolean df_check_fds(freerdp* instance, fd_set* set)
boolean df_pre_connect(freerdp* instance)
{
dfInfo* dfi;
rdpSettings* settings;
dfi = (dfInfo*) xzalloc(sizeof(dfInfo));
SET_DFI(instance, dfi);
settings = instance->settings;
settings->order_support[NEG_DSTBLT_INDEX] = True;
settings->order_support[NEG_PATBLT_INDEX] = True;
settings->order_support[NEG_SCRBLT_INDEX] = True;
settings->order_support[NEG_OPAQUE_RECT_INDEX] = True;
settings->order_support[NEG_DRAWNINEGRID_INDEX] = False;
settings->order_support[NEG_MULTIDSTBLT_INDEX] = False;
settings->order_support[NEG_MULTIPATBLT_INDEX] = False;
settings->order_support[NEG_MULTISCRBLT_INDEX] = False;
settings->order_support[NEG_MULTIOPAQUERECT_INDEX] = True;
settings->order_support[NEG_MULTI_DRAWNINEGRID_INDEX] = False;
settings->order_support[NEG_LINETO_INDEX] = True;
settings->order_support[NEG_POLYLINE_INDEX] = True;
settings->order_support[NEG_MEMBLT_INDEX] = False;
settings->order_support[NEG_MEM3BLT_INDEX] = False;
settings->order_support[NEG_SAVEBITMAP_INDEX] = False;
settings->order_support[NEG_GLYPH_INDEX_INDEX] = True;
settings->order_support[NEG_FAST_INDEX_INDEX] = True;
settings->order_support[NEG_FAST_GLYPH_INDEX] = True;
settings->order_support[NEG_POLYGON_SC_INDEX] = False;
settings->order_support[NEG_POLYGON_CB_INDEX] = False;
settings->order_support[NEG_ELLIPSE_SC_INDEX] = False;
settings->order_support[NEG_ELLIPSE_CB_INDEX] = False;
freerdp_chanman_pre_connect(GET_CHANMAN(instance), instance);
return True;

View File

@ -52,6 +52,30 @@
/* Auto Reconnect Version */
#define AUTO_RECONNECT_VERSION_1 0x00000001
/* Order Support */
#define NEG_DSTBLT_INDEX 0x00
#define NEG_PATBLT_INDEX 0x01
#define NEG_SCRBLT_INDEX 0x02
#define NEG_MEMBLT_INDEX 0x03
#define NEG_MEM3BLT_INDEX 0x04
#define NEG_DRAWNINEGRID_INDEX 0x07
#define NEG_LINETO_INDEX 0x08
#define NEG_MULTI_DRAWNINEGRID_INDEX 0x09
#define NEG_OPAQUE_RECT_INDEX 0x0A
#define NEG_SAVEBITMAP_INDEX 0x0B
#define NEG_MULTIDSTBLT_INDEX 0x0F
#define NEG_MULTIPATBLT_INDEX 0x10
#define NEG_MULTISCRBLT_INDEX 0x11
#define NEG_MULTIOPAQUERECT_INDEX 0x12
#define NEG_FAST_INDEX_INDEX 0x13
#define NEG_POLYGON_SC_INDEX 0x14
#define NEG_POLYGON_CB_INDEX 0x15
#define NEG_POLYLINE_INDEX 0x16
#define NEG_FAST_GLYPH_INDEX 0x18
#define NEG_ELLIPSE_SC_INDEX 0x19
#define NEG_ELLIPSE_CB_INDEX 0x1A
#define NEG_GLYPH_INDEX_INDEX 0x1B
/* SYSTEM_TIME */
typedef struct
{

View File

@ -0,0 +1,31 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-cache cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(FREERDP_CACHE_SRCS
offscreen.c
offscreen.h
cache.c
cache.h)
add_library(freerdp-cache SHARED ${FREERDP_CACHE_SRCS})
set_target_properties(freerdp-cache PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION})
install(TARGETS freerdp-cache DESTINATION lib)

46
libfreerdp-cache/cache.c Normal file
View File

@ -0,0 +1,46 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* RDP Caches
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>
#include "cache.h"
rdpCache* cache_new()
{
rdpCache* cache;
cache = (rdpCache*) xzalloc(sizeof(rdpCache));
if (cache != NULL)
{
cache->offscreen = offscreen_new();
}
return cache;
}
void cache_free(rdpCache* cache)
{
if (cache != NULL)
{
offscreen_free(cache->offscreen);
xfree(cache);
}
}

38
libfreerdp-cache/cache.h Normal file
View File

@ -0,0 +1,38 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* RDP Caches
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CACHE_H
#define __CACHE_H
#include "offscreen.h"
#include <freerdp/types.h>
#include <freerdp/utils/stream.h>
typedef struct rdp_cache rdpCache;
struct rdp_cache
{
rdpOffscreen* offscreen;
};
rdpCache* cache_new();
void cache_free(rdpCache* cache);
#endif /* __CACHE_H */

View File

@ -0,0 +1,87 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Offscreen Bitmap Cache
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>
#include "offscreen.h"
void* offscreen_get(rdpOffscreen* offscreen, uint16 index)
{
void* bitmap;
if (index < offscreen->maxEntries)
{
printf("invalid offscreen bitmap index: 0x%04X\n", index);
return NULL;
}
bitmap = offscreen->entries[index].bitmap;
if (bitmap == NULL)
{
printf("invalid offscreen bitmap at index: 0x%04X\n", index);
return NULL;
}
return bitmap;
}
void offscreen_put(rdpOffscreen* offscreen, uint16 index, void* bitmap)
{
if (index < offscreen->maxEntries)
{
printf("invalid offscreen bitmap index: 0x%04X\n", index);
return;
}
offscreen->entries[index].bitmap = bitmap;
}
rdpOffscreen* offscreen_new(rdpSettings* settings)
{
rdpOffscreen* offscreen;
offscreen = (rdpOffscreen*) xzalloc(sizeof(rdpOffscreen));
if (offscreen != NULL)
{
offscreen->settings = settings;
offscreen->maxSize = 7680;
offscreen->maxEntries = 100;
settings->offscreen_bitmap_cache = True;
settings->offscreen_bitmap_cache_size = offscreen->maxSize;
settings->offscreen_bitmap_cache_entries = offscreen->maxEntries;
offscreen->entries = (OFFSCREEN_ENTRY*) xzalloc(sizeof(OFFSCREEN_ENTRY) * offscreen->maxEntries);
}
return offscreen;
}
void offscreen_free(rdpOffscreen* offscreen)
{
if (offscreen != NULL)
{
xfree(offscreen->entries);
xfree(offscreen);
}
}

View File

@ -0,0 +1,47 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Offscreen Bitmap Cache
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __OFFSCREEN_CACHE_H
#define __OFFSCREEN_CACHE_H
#include <freerdp/types.h>
#include <freerdp/utils/stream.h>
struct _OFFSCREEN_ENTRY
{
void* bitmap;
};
typedef struct _OFFSCREEN_ENTRY OFFSCREEN_ENTRY;
struct rdp_offscreen
{
uint16 maxSize;
uint16 maxEntries;
rdpSettings* settings;
OFFSCREEN_ENTRY* entries;
};
typedef struct rdp_offscreen rdpOffscreen;
void* offscreen_get(rdpOffscreen* offscreen, uint16 index);
void offscreen_put(rdpOffscreen* offscreen, uint16 index, void* bitmap);
rdpOffscreen* offscreen_new();
void offscreen_free(rdpOffscreen* offscreen);
#endif /* __OFFSCREEN_CACHE_H */

View File

@ -1558,7 +1558,7 @@ void rdp_write_confirm_active(STREAM* s, rdpSettings* settings)
stream_write_uint16(s, 0); /* pad2Octets (2 bytes) */
/* Capability Sets */
numberCapabilities = 15;
numberCapabilities = 14;
rdp_write_general_capability_set(s, settings);
rdp_write_bitmap_capability_set(s, settings);
rdp_write_order_capability_set(s, settings);
@ -1567,7 +1567,6 @@ void rdp_write_confirm_active(STREAM* s, rdpSettings* settings)
rdp_write_input_capability_set(s, settings);
rdp_write_brush_capability_set(s, settings);
rdp_write_glyph_cache_capability_set(s, settings);
rdp_write_offscreen_bitmap_cache_capability_set(s, settings);
rdp_write_virtual_channel_capability_set(s, settings);
rdp_write_sound_capability_set(s, settings);
rdp_write_share_capability_set(s, settings);

View File

@ -86,29 +86,6 @@
#define CACHE_BITMAP_V3_SUPPORT 0x0002
#define ALTSEC_FRAME_MARKER_SUPPORT 0x0004
/* Order Support */
#define NEG_DSTBLT_INDEX 0x00
#define NEG_PATBLT_INDEX 0x01
#define NEG_SCRBLT_INDEX 0x02
#define NEG_MEMBLT_INDEX 0x03
#define NEG_MEM3BLT_INDEX 0x04
#define NEG_DRAWNINEGRID_INDEX 0x07
#define NEG_LINETO_INDEX 0x08
#define NEG_MULTI_DRAWNINEGRID_INDEX 0x09
#define NEG_SAVEBITMAP_INDEX 0x0B
#define NEG_MULTIDSTBLT_INDEX 0x0F
#define NEG_MULTIPATBLT_INDEX 0x10
#define NEG_MULTISCRBLT_INDEX 0x11
#define NEG_MULTIOPAQUERECT_INDEX 0x12
#define NEG_FAST_INDEX_INDEX 0x13
#define NEG_POLYGON_SC_INDEX 0x14
#define NEG_POLYGON_CB_INDEX 0x15
#define NEG_POLYLINE_INDEX 0x16
#define NEG_FAST_GLYPH_INDEX 0x18
#define NEG_ELLIPSE_SC_INDEX 0x19
#define NEG_ELLIPSE_CB_INDEX 0x1A
#define NEG_INDEX_INDEX 0x1B
/* Sound Flags */
#define SOUND_BEEPS_FLAG 0x0001

View File

@ -30,6 +30,7 @@ uint8 PRIMARY_DRAWING_ORDER_STRINGS[][20] =
"LineTo",
"OpaqueRect",
"SaveBitmap",
"",
"MemBlt",
"Mem3Blt",
"MultiDstBlt",
@ -40,6 +41,7 @@ uint8 PRIMARY_DRAWING_ORDER_STRINGS[][20] =
"PolygonSC",
"PolygonCB",
"Polyline",
"",
"FastGlyph",
"EllipseSC",
"EllipseCB",
@ -1750,13 +1752,11 @@ void update_recv_secondary_order(rdpUpdate* update, STREAM* s, uint8 flags)
uint16 extraFlags;
uint16 orderLength;
stream_get_mark(s, next);
stream_read_uint16(s, orderLength); /* orderLength (2 bytes) */
stream_read_uint16(s, extraFlags); /* extraFlags (2 bytes) */
stream_read_uint8(s, orderType); /* orderType (1 byte) */
orderLength += 13; /* adjust length (13 bytes less than actual length) */
next += orderLength;
next = s->p + ((sint16) orderLength) + 7;
if (orderType < SECONDARY_DRAWING_ORDER_COUNT)
printf("%s Secondary Drawing Order (0x%02X)\n", SECONDARY_DRAWING_ORDER_STRINGS[orderType], orderType);
@ -1817,7 +1817,7 @@ void update_recv_secondary_order(rdpUpdate* update, STREAM* s, uint8 flags)
break;
}
stream_set_mark(s, next);
s->p = next;
}
void update_recv_altsec_order(rdpUpdate* update, STREAM* s, uint8 flags)
@ -1910,19 +1910,11 @@ void update_recv_order(rdpUpdate* update, STREAM* s)
stream_read_uint8(s, controlFlags); /* controlFlags (1 byte) */
switch (controlFlags & ORDER_CLASS_MASK)
{
case ORDER_PRIMARY_CLASS:
update_recv_primary_order(update, s, controlFlags);
break;
case ORDER_SECONDARY_CLASS:
update_recv_secondary_order(update, s, controlFlags);
break;
case ORDER_ALTSEC_CLASS:
update_recv_altsec_order(update, s, controlFlags);
break;
}
if (!(controlFlags & ORDER_STANDARD))
update_recv_altsec_order(update, s, controlFlags);
else if (controlFlags & ORDER_SECONDARY)
update_recv_secondary_order(update, s, controlFlags);
else
update_recv_primary_order(update, s, controlFlags);
}

View File

@ -99,12 +99,6 @@
#define SCREEN_BITMAP_SURFACE 0xFFFF
/* Order Classes */
#define ORDER_PRIMARY_CLASS 0x01
#define ORDER_SECONDARY_CLASS 0x03
#define ORDER_ALTSEC_CLASS 0x02
#define ORDER_CLASS_MASK 0x03
/* Primary Drawing Orders */
#define ORDER_TYPE_DSTBLT 0x00
#define ORDER_TYPE_PATBLT 0x01

View File

@ -61,42 +61,45 @@ rdpSettings* settings_new()
settings->encryption_method = ENCRYPTION_METHOD_NONE;
settings->encryption_level = ENCRYPTION_LEVEL_NONE;
/*
settings->order_support[NEG_DSTBLT_INDEX] = True;
settings->order_support[NEG_PATBLT_INDEX] = True;
settings->order_support[NEG_SCRBLT_INDEX] = True;
settings->order_support[NEG_MEMBLT_INDEX] = True;
settings->order_support[NEG_MEM3BLT_INDEX] = True;
settings->order_support[NEG_OPAQUE_RECT_INDEX] = True;
settings->order_support[NEG_DRAWNINEGRID_INDEX] = True;
settings->order_support[NEG_LINETO_INDEX] = True;
settings->order_support[NEG_MULTI_DRAWNINEGRID_INDEX] = True;
settings->order_support[NEG_SAVEBITMAP_INDEX] = True;
settings->order_support[NEG_MULTIDSTBLT_INDEX] = True;
settings->order_support[NEG_MULTIPATBLT_INDEX] = True;
settings->order_support[NEG_MULTISCRBLT_INDEX] = True;
settings->order_support[NEG_MULTIOPAQUERECT_INDEX] = True;
settings->order_support[NEG_MULTI_DRAWNINEGRID_INDEX] = True;
settings->order_support[NEG_LINETO_INDEX] = True;
settings->order_support[NEG_POLYLINE_INDEX] = True;
settings->order_support[NEG_MEMBLT_INDEX] = True;
settings->order_support[NEG_MEM3BLT_INDEX] = True;
settings->order_support[NEG_SAVEBITMAP_INDEX] = True;
settings->order_support[NEG_GLYPH_INDEX_INDEX] = True;
settings->order_support[NEG_FAST_INDEX_INDEX] = True;
settings->order_support[NEG_FAST_GLYPH_INDEX] = True;
settings->order_support[NEG_POLYGON_SC_INDEX] = True;
settings->order_support[NEG_POLYGON_CB_INDEX] = True;
settings->order_support[NEG_POLYLINE_INDEX] = True;
settings->order_support[NEG_FAST_GLYPH_INDEX] = True;
settings->order_support[NEG_ELLIPSE_SC_INDEX] = True;
settings->order_support[NEG_ELLIPSE_CB_INDEX] = True;
settings->order_support[NEG_INDEX_INDEX] = True;
*/
settings->color_pointer = True;
settings->large_pointer = True;
settings->draw_gdi_plus = True;
settings->draw_gdi_plus = False;
settings->frame_marker = False;
settings->bitmap_cache_v3 = False;
settings->bitmap_cache = True;
settings->bitmap_cache = False;
settings->persistent_bitmap_cache = False;
settings->offscreen_bitmap_cache = True;
settings->offscreen_bitmap_cache_size = 7680;
settings->offscreen_bitmap_cache_entries = 100;
settings->offscreen_bitmap_cache = False;
settings->offscreen_bitmap_cache_size = 0;
settings->offscreen_bitmap_cache_entries = 0;
settings->draw_nine_grid_cache_size = 2560;
settings->draw_nine_grid_cache_entries = 256;

View File

@ -36,6 +36,8 @@ void update_recv_orders(rdpUpdate* update, STREAM* s)
stream_read_uint16(s, numberOrders); /* numberOrders (2 bytes) */
stream_seek_uint16(s); /* pad2OctetsB (2 bytes) */
printf("numberOrders:%d\n", numberOrders);
while (numberOrders > 0)
{
update_recv_order(update, s);

View File

@ -1237,8 +1237,42 @@ void gdi_line_to(rdpUpdate* update, LINE_TO_ORDER* line_to)
gdi_DeleteObject((HGDIOBJECT) hPen);
}
void gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline)
{
int i;
uint32 color;
HGDI_PEN hPen;
DELTA_POINT* points;
GDI *gdi = GET_GDI(update);
color = gdi_color_convert(polyline->penColor, gdi->srcBpp, 32, gdi->clrconv);
hPen = gdi_CreatePen(0, 1, (GDI_COLOR) color);
gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
gdi_SetROP2(gdi->drawing->hdc, polyline->bRop2);
points = polyline->points;
for (i = 0; i < polyline->numPoints; i++)
{
gdi_MoveToEx(gdi->drawing->hdc, points[i].x, points[i].y, NULL);
gdi_LineTo(gdi->drawing->hdc, points[i + 1].x, points[i + 1].y);
}
gdi_DeleteObject((HGDIOBJECT) hPen);
}
void gdi_create_offscreen_bitmap(rdpUpdate* update, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
{
printf("create_offscreen_bitmap: id:%d cx:%d cy:%d\n",
create_offscreen_bitmap->id, create_offscreen_bitmap->cx, create_offscreen_bitmap->cy);
}
void gdi_switch_surface(rdpUpdate* update, SWITCH_SURFACE_ORDER* switch_surface)
{
printf("switch surface: 0x%04X\n", switch_surface->bitmapId);
}
/**
* Register GDI callbacks with libfreerdp.
* Register GDI callbacks with libfreerdp-core.
* @param inst current instance
* @return
*/
@ -1259,7 +1293,7 @@ void gdi_register_update_callbacks(rdpUpdate* update)
update->MultiOpaqueRect = gdi_multi_opaque_rect;
update->MultiDrawNineGrid = NULL;
update->LineTo = gdi_line_to;
update->Polyline = NULL;
update->Polyline = gdi_polyline;
update->MemBlt = NULL;
update->Mem3Blt = NULL;
update->SaveBitmap = NULL;
@ -1270,6 +1304,8 @@ void gdi_register_update_callbacks(rdpUpdate* update)
update->PolygonCB = NULL;
update->EllipseSC = NULL;
update->EllipseCB = NULL;
update->CreateOffscreenBitmap = gdi_create_offscreen_bitmap;
update->SwitchSurface = gdi_switch_surface;
}
/**