libfreerdp-cache: add pointer cache
This commit is contained in:
parent
e5fb626d75
commit
a51995e482
@ -445,7 +445,7 @@ int stream_equal_dump(void * dataS, size_t sizeS, void * data, size_t size)
|
|||||||
{
|
{
|
||||||
printf("----------------- stream_equal_dump -----------------\n");
|
printf("----------------- stream_equal_dump -----------------\n");
|
||||||
printf("Stream and dump have different length (%d != %d)\n",
|
printf("Stream and dump have different length (%d != %d)\n",
|
||||||
sizeS, size);
|
(int) sizeS, (int) size);
|
||||||
printf("Stream hexdump:\n");
|
printf("Stream hexdump:\n");
|
||||||
freerdp_hexdump(dataS, sizeS);
|
freerdp_hexdump(dataS, sizeS);
|
||||||
|
|
||||||
@ -462,7 +462,7 @@ int stream_equal_dump(void * dataS, size_t sizeS, void * data, size_t size)
|
|||||||
if (((uint8*)dataS)[i] != ((uint8*)data)[i])
|
if (((uint8*)dataS)[i] != ((uint8*)data)[i])
|
||||||
{
|
{
|
||||||
printf("----------------- stream_equal_dump -----------------\n");
|
printf("----------------- stream_equal_dump -----------------\n");
|
||||||
printf("Stream and dump have different content from %d offset.\n", i);
|
printf("Stream and dump have different content from %d offset.\n", (int) i);
|
||||||
printf("Stream hexdump:\n");
|
printf("Stream hexdump:\n");
|
||||||
freerdp_hexdump(dataS, sizeS);
|
freerdp_hexdump(dataS, sizeS);
|
||||||
|
|
||||||
|
2
include/freerdp/cache/cache.h
vendored
2
include/freerdp/cache/cache.h
vendored
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <freerdp/cache/glyph.h>
|
#include <freerdp/cache/glyph.h>
|
||||||
#include <freerdp/cache/brush.h>
|
#include <freerdp/cache/brush.h>
|
||||||
|
#include <freerdp/cache/pointer.h>
|
||||||
#include <freerdp/cache/bitmap_v2.h>
|
#include <freerdp/cache/bitmap_v2.h>
|
||||||
#include <freerdp/cache/offscreen.h>
|
#include <freerdp/cache/offscreen.h>
|
||||||
#include <freerdp/cache/color_table.h>
|
#include <freerdp/cache/color_table.h>
|
||||||
@ -38,6 +39,7 @@ struct rdp_cache
|
|||||||
|
|
||||||
rdpGlyph* glyph;
|
rdpGlyph* glyph;
|
||||||
rdpBrush* brush;
|
rdpBrush* brush;
|
||||||
|
rdpPointer* pointer;
|
||||||
rdpBitmapV2* bitmap_v2;
|
rdpBitmapV2* bitmap_v2;
|
||||||
rdpOffscreen* offscreen;
|
rdpOffscreen* offscreen;
|
||||||
rdpColorTable* color_table;
|
rdpColorTable* color_table;
|
||||||
|
48
include/freerdp/cache/pointer.h
vendored
Normal file
48
include/freerdp/cache/pointer.h
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* FreeRDP: A Remote Desktop Protocol Client
|
||||||
|
* Pointer 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 __POINTER_CACHE_H
|
||||||
|
#define __POINTER_CACHE_H
|
||||||
|
|
||||||
|
#include <freerdp/api.h>
|
||||||
|
#include <freerdp/types.h>
|
||||||
|
#include <freerdp/utils/stream.h>
|
||||||
|
|
||||||
|
struct _POINTER_CACHE_ENTRY
|
||||||
|
{
|
||||||
|
void* entry;
|
||||||
|
void* extra;
|
||||||
|
};
|
||||||
|
typedef struct _POINTER_CACHE_ENTRY POINTER_CACHE_ENTRY;
|
||||||
|
|
||||||
|
struct rdp_pointer
|
||||||
|
{
|
||||||
|
uint16 cacheSize;
|
||||||
|
rdpSettings* settings;
|
||||||
|
POINTER_CACHE_ENTRY* entries;
|
||||||
|
};
|
||||||
|
typedef struct rdp_pointer rdpPointer;
|
||||||
|
|
||||||
|
FREERDP_API void* pointer_get(rdpPointer* pointer, uint16 index, void** extra);
|
||||||
|
FREERDP_API void pointer_put(rdpPointer* pointer, uint16 index, void* entry, void* extra);
|
||||||
|
|
||||||
|
FREERDP_API rdpPointer* pointer_new(rdpSettings* settings);
|
||||||
|
FREERDP_API void pointer_free(rdpPointer* pointer);
|
||||||
|
|
||||||
|
#endif /* __POINTER_CACHE_H */
|
@ -255,8 +255,9 @@ struct rdp_settings
|
|||||||
uint8 received_caps[32];
|
uint8 received_caps[32];
|
||||||
uint8 order_support[32];
|
uint8 order_support[32];
|
||||||
|
|
||||||
boolean color_pointer;
|
|
||||||
boolean sound_beeps;
|
boolean sound_beeps;
|
||||||
|
boolean color_pointer;
|
||||||
|
uint16 pointer_cache_size;
|
||||||
|
|
||||||
boolean fastpath_input;
|
boolean fastpath_input;
|
||||||
boolean fastpath_output;
|
boolean fastpath_output;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
set(FREERDP_CACHE_SRCS
|
set(FREERDP_CACHE_SRCS
|
||||||
brush.c
|
brush.c
|
||||||
|
pointer.c
|
||||||
bitmap_v2.c
|
bitmap_v2.c
|
||||||
offscreen.c
|
offscreen.c
|
||||||
color_table.c
|
color_table.c
|
||||||
|
@ -33,6 +33,7 @@ rdpCache* cache_new(rdpSettings* settings)
|
|||||||
cache->settings = settings;
|
cache->settings = settings;
|
||||||
cache->glyph = glyph_new(settings);
|
cache->glyph = glyph_new(settings);
|
||||||
cache->brush = brush_new(settings);
|
cache->brush = brush_new(settings);
|
||||||
|
cache->pointer = pointer_new(settings);
|
||||||
cache->bitmap_v2 = bitmap_v2_new(settings);
|
cache->bitmap_v2 = bitmap_v2_new(settings);
|
||||||
cache->offscreen = offscreen_new(settings);
|
cache->offscreen = offscreen_new(settings);
|
||||||
cache->color_table = color_table_new(settings);
|
cache->color_table = color_table_new(settings);
|
||||||
@ -45,7 +46,9 @@ void cache_free(rdpCache* cache)
|
|||||||
{
|
{
|
||||||
if (cache != NULL)
|
if (cache != NULL)
|
||||||
{
|
{
|
||||||
|
glyph_free(cache->glyph);
|
||||||
brush_free(cache->brush);
|
brush_free(cache->brush);
|
||||||
|
pointer_free(cache->pointer);
|
||||||
bitmap_v2_free(cache->bitmap_v2);
|
bitmap_v2_free(cache->bitmap_v2);
|
||||||
offscreen_free(cache->offscreen);
|
offscreen_free(cache->offscreen);
|
||||||
color_table_free(cache->color_table);
|
color_table_free(cache->color_table);
|
||||||
|
89
libfreerdp-cache/pointer.c
Normal file
89
libfreerdp-cache/pointer.c
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* FreeRDP: A Remote Desktop Protocol Client
|
||||||
|
* Glyph 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 <freerdp/cache/pointer.h>
|
||||||
|
|
||||||
|
void* pointer_get(rdpPointer* pointer, uint16 index, void** extra)
|
||||||
|
{
|
||||||
|
void* entry;
|
||||||
|
|
||||||
|
if (index >= pointer->cacheSize)
|
||||||
|
{
|
||||||
|
printf("invalid pointer index:%d\n", index);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry = pointer->entries[index].entry;
|
||||||
|
|
||||||
|
if (extra != NULL)
|
||||||
|
extra = pointer->entries[index].extra;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pointer_put(rdpPointer* pointer, uint16 index, void* entry, void* extra)
|
||||||
|
{
|
||||||
|
if (index >= pointer->cacheSize)
|
||||||
|
{
|
||||||
|
printf("invalid pointer index:%d\n", index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer->entries[index].entry = entry;
|
||||||
|
pointer->entries[index].extra = extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
rdpPointer* pointer_new(rdpSettings* settings)
|
||||||
|
{
|
||||||
|
rdpPointer* pointer;
|
||||||
|
|
||||||
|
pointer = (rdpPointer*) xzalloc(sizeof(rdpPointer));
|
||||||
|
|
||||||
|
if (pointer != NULL)
|
||||||
|
{
|
||||||
|
pointer->settings = settings;
|
||||||
|
pointer->cacheSize = settings->pointer_cache_size;
|
||||||
|
pointer->entries = xzalloc(sizeof(POINTER_CACHE_ENTRY) * pointer->cacheSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pointer_free(rdpPointer* pointer)
|
||||||
|
{
|
||||||
|
if (pointer != NULL)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < pointer->cacheSize; i++)
|
||||||
|
{
|
||||||
|
if (pointer->entries[i].entry != NULL)
|
||||||
|
xfree(pointer->entries[i].entry);
|
||||||
|
|
||||||
|
if (pointer->entries[i].extra != NULL)
|
||||||
|
xfree(pointer->entries[i].extra);
|
||||||
|
}
|
||||||
|
|
||||||
|
xfree(pointer->entries);
|
||||||
|
xfree(pointer);
|
||||||
|
}
|
||||||
|
}
|
@ -488,8 +488,8 @@ void rdp_write_pointer_capability_set(STREAM* s, rdpSettings* settings)
|
|||||||
colorPointerFlag = (settings->color_pointer) ? True : False;
|
colorPointerFlag = (settings->color_pointer) ? True : False;
|
||||||
|
|
||||||
stream_write_uint16(s, colorPointerFlag); /* colorPointerFlag (2 bytes) */
|
stream_write_uint16(s, colorPointerFlag); /* colorPointerFlag (2 bytes) */
|
||||||
stream_write_uint16(s, 20); /* colorPointerCacheSize (2 bytes) */
|
stream_write_uint16(s, settings->pointer_cache_size); /* colorPointerCacheSize (2 bytes) */
|
||||||
stream_write_uint16(s, 20); /* pointerCacheSize (2 bytes) */
|
stream_write_uint16(s, settings->pointer_cache_size); /* pointerCacheSize (2 bytes) */
|
||||||
|
|
||||||
rdp_capability_set_finish(s, header, CAPSET_TYPE_POINTER);
|
rdp_capability_set_finish(s, header, CAPSET_TYPE_POINTER);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ rdpSettings* settings_new()
|
|||||||
|
|
||||||
settings->color_pointer = True;
|
settings->color_pointer = True;
|
||||||
settings->large_pointer = True;
|
settings->large_pointer = True;
|
||||||
|
settings->pointer_cache_size = 32;
|
||||||
|
|
||||||
settings->draw_gdi_plus = False;
|
settings->draw_gdi_plus = False;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user