mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
libfreerdp-cache: start NineGrid cache
This commit is contained in:
2
include/freerdp/cache/cache.h
vendored
2
include/freerdp/cache/cache.h
vendored
@@ -29,6 +29,7 @@
|
||||
#include <freerdp/cache/brush.h>
|
||||
#include <freerdp/cache/pointer.h>
|
||||
#include <freerdp/cache/bitmap.h>
|
||||
#include <freerdp/cache/nine_grid.h>
|
||||
#include <freerdp/cache/offscreen.h>
|
||||
#include <freerdp/cache/palette.h>
|
||||
|
||||
@@ -40,6 +41,7 @@ struct rdp_cache
|
||||
rdpBitmapCache* bitmap; /* 3 */
|
||||
rdpOffscreenCache* offscreen; /* 4 */
|
||||
rdpPaletteCache* palette; /* 5 */
|
||||
rdpNineGridCache* nine_grid; /* 6 */
|
||||
|
||||
/* internal */
|
||||
|
||||
|
||||
63
include/freerdp/cache/nine_grid.h
vendored
Normal file
63
include/freerdp/cache/nine_grid.h
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* NineGrid Cache
|
||||
*
|
||||
* Copyright 2012 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 __NINE_GRID_CACHE_H
|
||||
#define __NINE_GRID_CACHE_H
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/update.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
typedef struct _NINE_GRID_ENTRY NINE_GRID_ENTRY;
|
||||
typedef struct rdp_nine_grid_cache rdpNineGridCache;
|
||||
|
||||
#include <freerdp/cache/cache.h>
|
||||
|
||||
struct _NINE_GRID_ENTRY
|
||||
{
|
||||
void* entry;
|
||||
};
|
||||
|
||||
struct rdp_nine_grid_cache
|
||||
{
|
||||
pDrawNineGrid DrawNineGrid; /* 0 */
|
||||
pMultiDrawNineGrid MultiDrawNineGrid; /* 1 */
|
||||
uint32 paddingA[16 - 2]; /* 2 */
|
||||
|
||||
uint32 maxEntries; /* 16 */
|
||||
uint32 maxSize; /* 17 */
|
||||
NINE_GRID_ENTRY* entries; /* 18 */
|
||||
uint32 paddingB[32 - 19]; /* 19 */
|
||||
|
||||
/* internal */
|
||||
|
||||
rdpSettings* settings;
|
||||
};
|
||||
|
||||
FREERDP_API void* nine_grid_cache_get(rdpNineGridCache* nine_grid, uint32 index);
|
||||
FREERDP_API void nine_grid_cache_put(rdpNineGridCache* nine_grid, uint32 index, void* entry);
|
||||
|
||||
FREERDP_API void nine_grid_cache_register_callbacks(rdpUpdate* update);
|
||||
|
||||
FREERDP_API rdpNineGridCache* nine_grid_cache_new(rdpSettings* settings);
|
||||
FREERDP_API void nine_grid_cache_free(rdpNineGridCache* nine_grid);
|
||||
|
||||
#endif /* __NINE_GRID_CACHE_H */
|
||||
@@ -21,6 +21,7 @@ set(FREERDP_CACHE_SRCS
|
||||
brush.c
|
||||
pointer.c
|
||||
bitmap.c
|
||||
nine_grid.c
|
||||
offscreen.c
|
||||
palette.c
|
||||
glyph.c
|
||||
|
||||
@@ -37,6 +37,7 @@ rdpCache* cache_new(rdpSettings* settings)
|
||||
cache->bitmap = bitmap_cache_new(settings);
|
||||
cache->offscreen = offscreen_cache_new(settings);
|
||||
cache->palette = palette_cache_new(settings);
|
||||
cache->nine_grid = nine_grid_cache_new(settings);
|
||||
}
|
||||
|
||||
return cache;
|
||||
@@ -52,6 +53,7 @@ void cache_free(rdpCache* cache)
|
||||
bitmap_cache_free(cache->bitmap);
|
||||
offscreen_cache_free(cache->offscreen);
|
||||
palette_cache_free(cache->palette);
|
||||
nine_grid_cache_free(cache->nine_grid);
|
||||
xfree(cache);
|
||||
}
|
||||
}
|
||||
|
||||
130
libfreerdp-cache/nine_grid.c
Normal file
130
libfreerdp-cache/nine_grid.c
Normal file
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* NineGrid Cache
|
||||
*
|
||||
* Copyright 2012 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/update.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
|
||||
#include <freerdp/cache/nine_grid.h>
|
||||
|
||||
void update_gdi_draw_nine_grid(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_grid)
|
||||
{
|
||||
rdpCache* cache = context->cache;
|
||||
IFCALL(cache->nine_grid->DrawNineGrid, context, draw_nine_grid);
|
||||
}
|
||||
|
||||
void update_gdi_multi_draw_nine_grid(rdpContext* context, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
|
||||
{
|
||||
rdpCache* cache = context->cache;
|
||||
IFCALL(cache->nine_grid->MultiDrawNineGrid, context, multi_draw_nine_grid);
|
||||
}
|
||||
|
||||
void nine_grid_cache_register_callbacks(rdpUpdate* update)
|
||||
{
|
||||
rdpCache* cache = update->context->cache;
|
||||
|
||||
cache->nine_grid->DrawNineGrid = update->primary->DrawNineGrid;
|
||||
cache->nine_grid->MultiDrawNineGrid = update->primary->MultiDrawNineGrid;
|
||||
|
||||
update->primary->DrawNineGrid = update_gdi_draw_nine_grid;
|
||||
update->primary->MultiDrawNineGrid = update_gdi_multi_draw_nine_grid;
|
||||
}
|
||||
|
||||
void* nine_grid_cache_get(rdpNineGridCache* nine_grid, uint32 index)
|
||||
{
|
||||
void* entry;
|
||||
|
||||
if (index > nine_grid->maxEntries)
|
||||
{
|
||||
printf("invalid NineGrid index: 0x%04X\n", index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry = nine_grid->entries[index].entry;
|
||||
|
||||
if (entry == NULL)
|
||||
{
|
||||
printf("invalid NineGrid at index: 0x%04X\n", index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void nine_grid_cache_put(rdpNineGridCache* nine_grid, uint32 index, void* entry)
|
||||
{
|
||||
void* prevEntry;
|
||||
|
||||
if (index > nine_grid->maxEntries)
|
||||
{
|
||||
printf("invalid NineGrid index: 0x%04X\n", index);
|
||||
return;
|
||||
}
|
||||
|
||||
prevEntry = nine_grid->entries[index].entry;
|
||||
|
||||
if (prevEntry != NULL)
|
||||
xfree(prevEntry);
|
||||
|
||||
nine_grid->entries[index].entry = entry;
|
||||
}
|
||||
|
||||
rdpNineGridCache* nine_grid_cache_new(rdpSettings* settings)
|
||||
{
|
||||
rdpNineGridCache* nine_grid;
|
||||
|
||||
nine_grid = (rdpNineGridCache*) xzalloc(sizeof(rdpNineGridCache));
|
||||
|
||||
if (nine_grid != NULL)
|
||||
{
|
||||
nine_grid->settings = settings;
|
||||
|
||||
nine_grid->maxSize = 2560;
|
||||
nine_grid->maxEntries = 256;
|
||||
|
||||
nine_grid->settings->draw_nine_grid_cache_size = nine_grid->maxSize;
|
||||
nine_grid->settings->draw_nine_grid_cache_entries = nine_grid->maxEntries;
|
||||
|
||||
nine_grid->entries = (NINE_GRID_ENTRY*) xzalloc(sizeof(NINE_GRID_ENTRY) * nine_grid->maxEntries);
|
||||
}
|
||||
|
||||
return nine_grid;
|
||||
}
|
||||
|
||||
void nine_grid_cache_free(rdpNineGridCache* nine_grid)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (nine_grid != NULL)
|
||||
{
|
||||
if (nine_grid->entries != NULL)
|
||||
{
|
||||
for (i = 0; i < (int) nine_grid->maxEntries; i++)
|
||||
{
|
||||
if (nine_grid->entries[i].entry != NULL)
|
||||
xfree(nine_grid->entries[i].entry);
|
||||
}
|
||||
|
||||
xfree(nine_grid->entries);
|
||||
}
|
||||
|
||||
xfree(nine_grid);
|
||||
}
|
||||
}
|
||||
@@ -1110,7 +1110,7 @@ void rdp_write_draw_nine_grid_cache_capability_set(STREAM* s, rdpSettings* setti
|
||||
|
||||
header = rdp_capability_set_start(s);
|
||||
|
||||
drawNineGridSupportLevel = (settings->draw_nine_grid) ? DRAW_NINEGRID_SUPPORTED : DRAW_NINEGRID_NO_SUPPORT;
|
||||
drawNineGridSupportLevel = (settings->draw_nine_grid) ? DRAW_NINEGRID_SUPPORTED_V2 : DRAW_NINEGRID_NO_SUPPORT;
|
||||
|
||||
stream_write_uint32(s, drawNineGridSupportLevel); /* drawNineGridSupportLevel (4 bytes) */
|
||||
stream_write_uint16(s, settings->draw_nine_grid_cache_size); /* drawNineGridCacheSize (2 bytes) */
|
||||
|
||||
Reference in New Issue
Block a user