libfreerdp-cache: refactoring of color table cache
This commit is contained in:
parent
f2b88dcfae
commit
b2644901f4
@ -274,7 +274,7 @@ void wf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
|
||||
|
||||
void wf_gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_color_table)
|
||||
{
|
||||
color_table_put(update->context->cache->color_table, cache_color_table->cacheIndex, (void*) cache_color_table->colorTable);
|
||||
palette_cache_put(update->context->cache->color_table, cache_color_table->cacheIndex, (void*) cache_color_table->colorTable);
|
||||
}
|
||||
|
||||
void wf_gdi_cache_glyph(rdpUpdate* update, CACHE_GLYPH_ORDER* cache_glyph)
|
||||
|
@ -613,11 +613,6 @@ void xf_gdi_mem3blt(rdpUpdate* update, MEM3BLT_ORDER* mem3blt)
|
||||
|
||||
}
|
||||
|
||||
void xf_gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_color_table)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void xf_gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command)
|
||||
{
|
||||
int i, tx, ty;
|
||||
@ -768,8 +763,6 @@ void xf_gdi_register_update_callbacks(rdpUpdate* update)
|
||||
update->EllipseSC = NULL;
|
||||
update->EllipseCB = NULL;
|
||||
|
||||
update->CacheColorTable = xf_gdi_cache_color_table;
|
||||
|
||||
update->SurfaceBits = xf_gdi_surface_bits;
|
||||
}
|
||||
|
||||
|
@ -666,6 +666,7 @@ boolean xf_post_connect(freerdp* instance)
|
||||
brush_cache_register_callbacks(instance->update);
|
||||
bitmap_cache_register_callbacks(instance->update);
|
||||
offscreen_cache_register_callbacks(instance->update);
|
||||
palette_cache_register_callbacks(instance->update);
|
||||
}
|
||||
|
||||
instance->context->rail = rail_new(instance->settings);
|
||||
|
4
include/freerdp/cache/cache.h
vendored
4
include/freerdp/cache/cache.h
vendored
@ -30,7 +30,7 @@
|
||||
#include <freerdp/cache/pointer.h>
|
||||
#include <freerdp/cache/bitmap.h>
|
||||
#include <freerdp/cache/offscreen.h>
|
||||
#include <freerdp/cache/color_table.h>
|
||||
#include <freerdp/cache/palette.h>
|
||||
|
||||
struct rdp_cache
|
||||
{
|
||||
@ -41,7 +41,7 @@ struct rdp_cache
|
||||
rdpPointerCache* pointer;
|
||||
rdpBitmapCache* bitmap;
|
||||
rdpOffscreenCache* offscreen;
|
||||
rdpColorTableCache* color_table;
|
||||
rdpPaletteCache* palette;
|
||||
};
|
||||
|
||||
FREERDP_API rdpCache* cache_new(rdpSettings* settings);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Color Table Cache
|
||||
* Palette (Color Table) Cache
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
@ -17,31 +17,38 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_TABLE_CACHE_H
|
||||
#define __COLOR_TABLE_CACHE_H
|
||||
#ifndef __PALETTE_CACHE_H
|
||||
#define __PALETTE_CACHE_H
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/update.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
struct _COLOR_TABLE_ENTRY
|
||||
typedef struct _PALETTE_TABLE_ENTRY PALETTE_TABLE_ENTRY;
|
||||
typedef struct rdp_palette_cache rdpPaletteCache;
|
||||
|
||||
#include <freerdp/cache/cache.h>
|
||||
|
||||
struct _PALETTE_TABLE_ENTRY
|
||||
{
|
||||
void* entry;
|
||||
};
|
||||
typedef struct _COLOR_TABLE_ENTRY COLOR_TABLE_ENTRY;
|
||||
|
||||
struct rdp_color_table_cache
|
||||
struct rdp_palette_cache
|
||||
{
|
||||
uint8 maxEntries;
|
||||
rdpSettings* settings;
|
||||
COLOR_TABLE_ENTRY* entries;
|
||||
PALETTE_TABLE_ENTRY* entries;
|
||||
};
|
||||
typedef struct rdp_color_table_cache rdpColorTableCache;
|
||||
|
||||
FREERDP_API void* color_table_get(rdpColorTableCache* color_table, uint8 index);
|
||||
FREERDP_API void color_table_put(rdpColorTableCache* color_table, uint8 index, void* entry);
|
||||
FREERDP_API void* palette_cache_get(rdpPaletteCache* palette, uint8 index);
|
||||
FREERDP_API void palette_cache_put(rdpPaletteCache* palette, uint8 index, void* entry);
|
||||
|
||||
FREERDP_API rdpColorTableCache* color_table_cache_new(rdpSettings* settings);
|
||||
FREERDP_API void color_table_cache_free(rdpColorTableCache* color_table);
|
||||
FREERDP_API void palette_cache_register_callbacks(rdpUpdate* update);
|
||||
|
||||
#endif /* __COLOR_TABLE_CACHE_H */
|
||||
FREERDP_API rdpPaletteCache* palette_cache_new(rdpSettings* settings);
|
||||
FREERDP_API void palette_cache_free(rdpPaletteCache* palette_cache);
|
||||
|
||||
#endif /* __PALETTE_CACHE_H */
|
@ -22,7 +22,7 @@ set(FREERDP_CACHE_SRCS
|
||||
pointer.c
|
||||
bitmap.c
|
||||
offscreen.c
|
||||
color_table.c
|
||||
palette.c
|
||||
glyph.c
|
||||
cache.c)
|
||||
|
||||
|
@ -36,7 +36,7 @@ rdpCache* cache_new(rdpSettings* settings)
|
||||
cache->pointer = pointer_cache_new(settings);
|
||||
cache->bitmap = bitmap_cache_new(settings);
|
||||
cache->offscreen = offscreen_cache_new(settings);
|
||||
cache->color_table = color_table_cache_new(settings);
|
||||
cache->palette = palette_cache_new(settings);
|
||||
}
|
||||
|
||||
return cache;
|
||||
@ -51,7 +51,7 @@ void cache_free(rdpCache* cache)
|
||||
pointer_cache_free(cache->pointer);
|
||||
bitmap_cache_free(cache->bitmap);
|
||||
offscreen_cache_free(cache->offscreen);
|
||||
color_table_cache_free(cache->color_table);
|
||||
palette_cache_free(cache->palette);
|
||||
xfree(cache);
|
||||
}
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Color Table 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/color_table.h>
|
||||
|
||||
void* color_table_get(rdpColorTableCache* color_table, uint8 index)
|
||||
{
|
||||
void* entry;
|
||||
|
||||
if (index > color_table->maxEntries)
|
||||
{
|
||||
printf("invalid color table index: 0x%04X\n", index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry = color_table->entries[index].entry;
|
||||
|
||||
if (entry == NULL)
|
||||
{
|
||||
printf("invalid color table at index: 0x%04X\n", index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void color_table_put(rdpColorTableCache* color_table, uint8 index, void* entry)
|
||||
{
|
||||
if (index > color_table->maxEntries)
|
||||
{
|
||||
printf("invalid color table index: 0x%04X\n", index);
|
||||
return;
|
||||
}
|
||||
|
||||
color_table->entries[index].entry = entry;
|
||||
}
|
||||
|
||||
rdpColorTableCache* color_table_cache_new(rdpSettings* settings)
|
||||
{
|
||||
rdpColorTableCache* color_table;
|
||||
|
||||
color_table = (rdpColorTableCache*) xzalloc(sizeof(rdpColorTableCache));
|
||||
|
||||
if (color_table != NULL)
|
||||
{
|
||||
color_table->settings = settings;
|
||||
|
||||
color_table->maxEntries = 6;
|
||||
|
||||
color_table->entries = (COLOR_TABLE_ENTRY*) xzalloc(sizeof(COLOR_TABLE_ENTRY) * color_table->maxEntries);
|
||||
}
|
||||
|
||||
return color_table;
|
||||
}
|
||||
|
||||
void color_table_cache_free(rdpColorTableCache* color_table)
|
||||
{
|
||||
if (color_table != NULL)
|
||||
{
|
||||
xfree(color_table->entries);
|
||||
xfree(color_table);
|
||||
}
|
||||
}
|
||||
|
92
libfreerdp-cache/palette.c
Normal file
92
libfreerdp-cache/palette.c
Normal file
@ -0,0 +1,92 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Palette (Color Table) 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/palette.h>
|
||||
|
||||
void update_gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_color_table)
|
||||
{
|
||||
rdpCache* cache = update->context->cache;
|
||||
palette_cache_put(cache->palette, cache_color_table->cacheIndex, (void*) cache_color_table->colorTable);
|
||||
}
|
||||
|
||||
void* palette_cache_get(rdpPaletteCache* palette_cache, uint8 index)
|
||||
{
|
||||
void* entry;
|
||||
|
||||
if (index > palette_cache->maxEntries)
|
||||
{
|
||||
printf("invalid color table index: 0x%04X\n", index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry = palette_cache->entries[index].entry;
|
||||
|
||||
if (entry == NULL)
|
||||
{
|
||||
printf("invalid color table at index: 0x%04X\n", index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void palette_cache_put(rdpPaletteCache* palette_cache, uint8 index, void* entry)
|
||||
{
|
||||
if (index > palette_cache->maxEntries)
|
||||
{
|
||||
printf("invalid color table index: 0x%04X\n", index);
|
||||
return;
|
||||
}
|
||||
|
||||
palette_cache->entries[index].entry = entry;
|
||||
}
|
||||
|
||||
void palette_cache_register_callbacks(rdpUpdate* update)
|
||||
{
|
||||
update->CacheColorTable = update_gdi_cache_color_table;
|
||||
}
|
||||
|
||||
rdpPaletteCache* palette_cache_new(rdpSettings* settings)
|
||||
{
|
||||
rdpPaletteCache* palette_cache;
|
||||
|
||||
palette_cache = (rdpPaletteCache*) xzalloc(sizeof(rdpPaletteCache));
|
||||
|
||||
if (palette_cache != NULL)
|
||||
{
|
||||
palette_cache->settings = settings;
|
||||
palette_cache->maxEntries = 6;
|
||||
palette_cache->entries = (PALETTE_TABLE_ENTRY*) xzalloc(sizeof(PALETTE_TABLE_ENTRY) * palette_cache->maxEntries);
|
||||
}
|
||||
|
||||
return palette_cache;
|
||||
}
|
||||
|
||||
void palette_cache_free(rdpPaletteCache* palette_cache)
|
||||
{
|
||||
if (palette_cache != NULL)
|
||||
{
|
||||
xfree(palette_cache->entries);
|
||||
xfree(palette_cache);
|
||||
}
|
||||
}
|
||||
|
@ -625,12 +625,6 @@ void gdi_mem3blt(rdpUpdate* update, MEM3BLT_ORDER* mem3blt)
|
||||
|
||||
}
|
||||
|
||||
void gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_color_table)
|
||||
{
|
||||
rdpCache* cache = update->context->cache;
|
||||
color_table_put(cache->color_table, cache_color_table->cacheIndex, (void*) cache_color_table->colorTable);
|
||||
}
|
||||
|
||||
int tilenum = 0;
|
||||
|
||||
void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command)
|
||||
@ -777,8 +771,6 @@ void gdi_register_update_callbacks(rdpUpdate* update)
|
||||
update->EllipseSC = NULL;
|
||||
update->EllipseCB = NULL;
|
||||
|
||||
update->CacheColorTable = gdi_cache_color_table;
|
||||
|
||||
update->SurfaceBits = gdi_surface_bits;
|
||||
}
|
||||
|
||||
@ -905,6 +897,7 @@ int gdi_init(freerdp* instance, uint32 flags, uint8* buffer)
|
||||
glyph_cache_register_callbacks(instance->update);
|
||||
bitmap_cache_register_callbacks(instance->update);
|
||||
offscreen_cache_register_callbacks(instance->update);
|
||||
palette_cache_register_callbacks(instance->update);
|
||||
|
||||
gdi_register_graphics(instance->context->graphics);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user