From adce7378c3f5ef063b328cce3a87e2c08c2d0ef3 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 7 Feb 2023 15:42:52 +0100 Subject: [PATCH] [core,cache] make protocol caches private most protocol internal caches do not need to be exposed. this reduces the public API and allows us to more easily improve/change this during a release cycle --- client/Mac/mfreerdp.h | 1 - client/Windows/wf_client.h | 1 - client/X11/xf_client.c | 5 -- client/X11/xf_client.h | 2 +- include/freerdp/cache/bitmap.h | 70 ------------------ include/freerdp/cache/brush.h | 51 ------------- include/freerdp/cache/cache.h | 60 ---------------- include/freerdp/cache/glyph.h | 71 ------------------- include/freerdp/cache/palette.h | 63 ---------------- include/freerdp/cache/pointer.h | 58 --------------- include/freerdp/gdi/gdi.h | 1 - libfreerdp/cache/CMakeLists.txt | 2 + libfreerdp/cache/bitmap.c | 2 +- libfreerdp/cache/bitmap.h | 66 ++++++++++++++--- libfreerdp/cache/brush.c | 3 +- libfreerdp/cache/brush.h | 40 ++++++++--- libfreerdp/cache/cache.c | 2 - libfreerdp/cache/cache.h | 45 ++++++++++-- libfreerdp/cache/glyph.c | 3 +- libfreerdp/cache/glyph.h | 53 ++++++++++++-- libfreerdp/cache/nine_grid.c | 3 +- .../freerdp => libfreerdp}/cache/nine_grid.h | 14 ++-- libfreerdp/cache/offscreen.c | 5 +- .../freerdp => libfreerdp}/cache/offscreen.h | 14 ++-- libfreerdp/cache/palette.c | 2 +- libfreerdp/cache/palette.h | 37 +++++++++- libfreerdp/cache/pointer.c | 2 +- libfreerdp/cache/pointer.h | 67 ++++++++++++----- libfreerdp/core/connection.c | 2 +- libfreerdp/core/freerdp.c | 2 +- libfreerdp/gdi/gdi.c | 1 + 31 files changed, 283 insertions(+), 465 deletions(-) delete mode 100644 include/freerdp/cache/bitmap.h delete mode 100644 include/freerdp/cache/brush.h delete mode 100644 include/freerdp/cache/cache.h delete mode 100644 include/freerdp/cache/glyph.h delete mode 100644 include/freerdp/cache/palette.h delete mode 100644 include/freerdp/cache/pointer.h rename {include/freerdp => libfreerdp}/cache/nine_grid.h (72%) rename {include/freerdp => libfreerdp}/cache/offscreen.h (69%) diff --git a/client/Mac/mfreerdp.h b/client/Mac/mfreerdp.h index 857e6fe1c..bc9315027 100644 --- a/client/Mac/mfreerdp.h +++ b/client/Mac/mfreerdp.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include diff --git a/client/Windows/wf_client.h b/client/Windows/wf_client.h index 08803ad0c..85261765a 100644 --- a/client/Windows/wf_client.h +++ b/client/Windows/wf_client.h @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 1375e3fff..a44fdf75f 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -1260,11 +1260,6 @@ static BOOL xf_post_connect(freerdp* instance) } xf_gdi_register_update_callbacks(update); - brush_cache_register_callbacks(context->update); - glyph_cache_register_callbacks(context->update); - bitmap_cache_register_callbacks(context->update); - offscreen_cache_register_callbacks(context->update); - palette_cache_register_callbacks(context->update); } #ifdef WITH_XRENDER diff --git a/client/X11/xf_client.h b/client/X11/xf_client.h index e3b00bf9b..c9bc21b12 100644 --- a/client/X11/xf_client.h +++ b/client/X11/xf_client.h @@ -32,7 +32,7 @@ #include #include #include -#include + #include #ifdef __cplusplus diff --git a/include/freerdp/cache/bitmap.h b/include/freerdp/cache/bitmap.h deleted file mode 100644 index 641c8a770..000000000 --- a/include/freerdp/cache/bitmap.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Bitmap Cache V2 - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 FREERDP_BITMAP_V2_CACHE_H -#define FREERDP_BITMAP_V2_CACHE_H - -#include -#include -#include -#include -#include - -#include - -typedef struct -{ - UINT32 number; - rdpBitmap** entries; -} BITMAP_V2_CELL; - -typedef struct -{ - pMemBlt MemBlt; /* 0 */ - pMem3Blt Mem3Blt; /* 1 */ - pCacheBitmap CacheBitmap; /* 2 */ - pCacheBitmapV2 CacheBitmapV2; /* 3 */ - pCacheBitmapV3 CacheBitmapV3; /* 4 */ - pBitmapUpdate BitmapUpdate; /* 5 */ - UINT32 paddingA[16 - 6]; /* 6 */ - - UINT32 maxCells; /* 16 */ - BITMAP_V2_CELL* cells; /* 17 */ - UINT32 paddingB[32 - 18]; /* 18 */ - - /* internal */ - rdpContext* context; - rdpPersistentCache* persistent; -} rdpBitmapCache; - -#ifdef __cplusplus -extern "C" -{ -#endif - - FREERDP_API void bitmap_cache_register_callbacks(rdpUpdate* update); - - FREERDP_API rdpBitmapCache* bitmap_cache_new(rdpContext* context); - FREERDP_API void bitmap_cache_free(rdpBitmapCache* bitmap_cache); - -#ifdef __cplusplus -} -#endif - -#endif /* FREERDP_BITMAP_V2_CACHE_H */ diff --git a/include/freerdp/cache/brush.h b/include/freerdp/cache/brush.h deleted file mode 100644 index 35070b31f..000000000 --- a/include/freerdp/cache/brush.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Brush Cache - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 FREERDP_BRUSH_CACHE_H -#define FREERDP_BRUSH_CACHE_H - -#include -#include -#include -#include - -#include - -typedef struct rdp_brush_cache rdpBrushCache; - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - - FREERDP_API void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp); - FREERDP_API void brush_cache_put(rdpBrushCache* brush, UINT32 index, void* entry, UINT32 bpp); - - FREERDP_API void brush_cache_register_callbacks(rdpUpdate* update); - - FREERDP_API rdpBrushCache* brush_cache_new(rdpContext* context); - FREERDP_API void brush_cache_free(rdpBrushCache* brush); - -#ifdef __cplusplus -} -#endif - -#endif /* FREERDP_BRUSH_CACHE_H */ diff --git a/include/freerdp/cache/cache.h b/include/freerdp/cache/cache.h deleted file mode 100644 index 50b2e5968..000000000 --- a/include/freerdp/cache/cache.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * RDP Caches - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 FREERDP_CACHE_H -#define FREERDP_CACHE_H - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -struct rdp_cache -{ - rdpGlyphCache* glyph; /* 0 */ - rdpBrushCache* brush; /* 1 */ - rdpPointerCache* pointer; /* 2 */ - rdpBitmapCache* bitmap; /* 3 */ - rdpOffscreenCache* offscreen; /* 4 */ - rdpPaletteCache* palette; /* 5 */ - rdpNineGridCache* nine_grid; /* 6 */ -}; - -#ifdef __cplusplus -extern "C" -{ -#endif - - FREERDP_API rdpCache* cache_new(rdpContext* context); - FREERDP_API void cache_free(rdpCache* cache); - -#ifdef __cplusplus -} -#endif - -#endif /* FREERDP_CACHE_H */ diff --git a/include/freerdp/cache/glyph.h b/include/freerdp/cache/glyph.h deleted file mode 100644 index 988a9c2b7..000000000 --- a/include/freerdp/cache/glyph.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Glyph Cache - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 FREERDP_GLYPH_CACHE_H -#define FREERDP_GLYPH_CACHE_H - -#include -#include -#include - -#include -#include - -typedef struct -{ - UINT32 number; - UINT32 maxCellSize; - rdpGlyph** entries; -} GLYPH_CACHE; - -typedef struct -{ - void* fragment; - UINT32 size; -} FRAGMENT_CACHE_ENTRY; - -typedef struct -{ - FRAGMENT_CACHE_ENTRY entries[256]; -} FRAGMENT_CACHE; - -typedef struct -{ - FRAGMENT_CACHE fragCache; - GLYPH_CACHE glyphCache[10]; - - wLog* log; - rdpContext* context; -} rdpGlyphCache; - -#ifdef __cplusplus -extern "C" -{ -#endif - - FREERDP_API void glyph_cache_register_callbacks(rdpUpdate* update); - - FREERDP_API rdpGlyphCache* glyph_cache_new(rdpContext* context); - FREERDP_API void glyph_cache_free(rdpGlyphCache* glyph); - -#ifdef __cplusplus -} -#endif - -#endif /* FREERDP_GLYPH_CACHE_H */ diff --git a/include/freerdp/cache/palette.h b/include/freerdp/cache/palette.h deleted file mode 100644 index 482a9d860..000000000 --- a/include/freerdp/cache/palette.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Palette (Color Table) Cache - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 FREERDP_PALETTE_CACHE_H -#define FREERDP_PALETTE_CACHE_H - -#include -#include -#include -#include - -#include - -typedef struct rdp_palette_cache rdpPaletteCache; - -#include - -typedef struct -{ - void* entry; -} PALETTE_TABLE_ENTRY; - -struct rdp_palette_cache -{ - UINT32 maxEntries; /* 0 */ - PALETTE_TABLE_ENTRY* entries; /* 1 */ - - /* internal */ - - rdpContext* context; -}; - -#ifdef __cplusplus -extern "C" -{ -#endif - - FREERDP_API void palette_cache_register_callbacks(rdpUpdate* update); - - FREERDP_API rdpPaletteCache* palette_cache_new(rdpContext* context); - FREERDP_API void palette_cache_free(rdpPaletteCache* palette_cache); - -#ifdef __cplusplus -} -#endif - -#endif /* FREERDP_PALETTE_CACHE_H */ diff --git a/include/freerdp/cache/pointer.h b/include/freerdp/cache/pointer.h deleted file mode 100644 index 0b7450410..000000000 --- a/include/freerdp/cache/pointer.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Pointer Cache - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 FREERDP_POINTER_CACHE_H -#define FREERDP_POINTER_CACHE_H - -#include -#include -#include -#include -#include - -#include - -typedef struct rdp_pointer_cache rdpPointerCache; - -#include - -struct rdp_pointer_cache -{ - UINT32 cacheSize; /* 0 */ - rdpPointer** entries; /* 1 */ - - /* internal */ - rdpContext* context; -}; - -#ifdef __cplusplus -extern "C" -{ -#endif - - FREERDP_API void pointer_cache_register_callbacks(rdpUpdate* update); - - FREERDP_API rdpPointerCache* pointer_cache_new(rdpContext* context); - FREERDP_API void pointer_cache_free(rdpPointerCache* pointer_cache); - -#ifdef __cplusplus -} -#endif - -#endif /* FREERDP_POINTER_CACHE_H */ diff --git a/include/freerdp/gdi/gdi.h b/include/freerdp/gdi/gdi.h index e021b2be9..a421de3e7 100644 --- a/include/freerdp/gdi/gdi.h +++ b/include/freerdp/gdi/gdi.h @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/libfreerdp/cache/CMakeLists.txt b/libfreerdp/cache/CMakeLists.txt index 5cea23ae3..369faecbb 100644 --- a/libfreerdp/cache/CMakeLists.txt +++ b/libfreerdp/cache/CMakeLists.txt @@ -27,7 +27,9 @@ freerdp_module_add( bitmap.h persistent.c nine_grid.c + nine_grid.h offscreen.c + offscreen.h palette.c palette.h glyph.c diff --git a/libfreerdp/cache/bitmap.c b/libfreerdp/cache/bitmap.c index 96fd6e273..37f7b9d8e 100644 --- a/libfreerdp/cache/bitmap.c +++ b/libfreerdp/cache/bitmap.c @@ -29,13 +29,13 @@ #include #include -#include #include #include "../gdi/gdi.h" #include "../core/graphics.h" #include "bitmap.h" +#include "cache.h" #define TAG FREERDP_TAG("cache.bitmap") diff --git a/libfreerdp/cache/bitmap.h b/libfreerdp/cache/bitmap.h index d8e394fb3..22748a7a5 100644 --- a/libfreerdp/cache/bitmap.h +++ b/libfreerdp/cache/bitmap.h @@ -23,19 +23,63 @@ #include #include -FREERDP_LOCAL BITMAP_UPDATE* copy_bitmap_update(rdpContext* context, const BITMAP_UPDATE* pointer); -FREERDP_LOCAL void free_bitmap_update(rdpContext* context, BITMAP_UPDATE* pointer); +#include -FREERDP_LOCAL CACHE_BITMAP_ORDER* copy_cache_bitmap_order(rdpContext* context, - const CACHE_BITMAP_ORDER* order); -FREERDP_LOCAL void free_cache_bitmap_order(rdpContext* context, CACHE_BITMAP_ORDER* order); +typedef struct +{ + UINT32 number; + rdpBitmap** entries; +} BITMAP_V2_CELL; -FREERDP_LOCAL CACHE_BITMAP_V2_ORDER* copy_cache_bitmap_v2_order(rdpContext* context, - const CACHE_BITMAP_V2_ORDER* order); -FREERDP_LOCAL void free_cache_bitmap_v2_order(rdpContext* context, CACHE_BITMAP_V2_ORDER* order); +typedef struct +{ + pMemBlt MemBlt; /* 0 */ + pMem3Blt Mem3Blt; /* 1 */ + pCacheBitmap CacheBitmap; /* 2 */ + pCacheBitmapV2 CacheBitmapV2; /* 3 */ + pCacheBitmapV3 CacheBitmapV3; /* 4 */ + pBitmapUpdate BitmapUpdate; /* 5 */ + UINT32 paddingA[16 - 6]; /* 6 */ -FREERDP_LOCAL CACHE_BITMAP_V3_ORDER* copy_cache_bitmap_v3_order(rdpContext* context, - const CACHE_BITMAP_V3_ORDER* order); -FREERDP_LOCAL void free_cache_bitmap_v3_order(rdpContext* context, CACHE_BITMAP_V3_ORDER* order); + UINT32 maxCells; /* 16 */ + BITMAP_V2_CELL* cells; /* 17 */ + UINT32 paddingB[32 - 18]; /* 18 */ + + /* internal */ + rdpContext* context; + rdpPersistentCache* persistent; +} rdpBitmapCache; + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_LOCAL void bitmap_cache_register_callbacks(rdpUpdate* update); + + FREERDP_LOCAL rdpBitmapCache* bitmap_cache_new(rdpContext* context); + FREERDP_LOCAL void bitmap_cache_free(rdpBitmapCache* bitmap_cache); + + FREERDP_LOCAL BITMAP_UPDATE* copy_bitmap_update(rdpContext* context, + const BITMAP_UPDATE* pointer); + FREERDP_LOCAL void free_bitmap_update(rdpContext* context, BITMAP_UPDATE* pointer); + + FREERDP_LOCAL CACHE_BITMAP_ORDER* copy_cache_bitmap_order(rdpContext* context, + const CACHE_BITMAP_ORDER* order); + FREERDP_LOCAL void free_cache_bitmap_order(rdpContext* context, CACHE_BITMAP_ORDER* order); + + FREERDP_LOCAL CACHE_BITMAP_V2_ORDER* + copy_cache_bitmap_v2_order(rdpContext* context, const CACHE_BITMAP_V2_ORDER* order); + FREERDP_LOCAL void free_cache_bitmap_v2_order(rdpContext* context, + CACHE_BITMAP_V2_ORDER* order); + + FREERDP_LOCAL CACHE_BITMAP_V3_ORDER* + copy_cache_bitmap_v3_order(rdpContext* context, const CACHE_BITMAP_V3_ORDER* order); + FREERDP_LOCAL void free_cache_bitmap_v3_order(rdpContext* context, + CACHE_BITMAP_V3_ORDER* order); + +#ifdef __cplusplus +} +#endif #endif /* FREERDP_LIB_CACHE_BITMAP_H */ diff --git a/libfreerdp/cache/brush.c b/libfreerdp/cache/brush.c index 0eac321da..79b69327b 100644 --- a/libfreerdp/cache/brush.c +++ b/libfreerdp/cache/brush.c @@ -28,9 +28,8 @@ #include #include -#include - #include "brush.h" +#include "cache.h" #define TAG FREERDP_TAG("cache.brush") diff --git a/libfreerdp/cache/brush.h b/libfreerdp/cache/brush.h index 3a2f019be..ff01487d1 100644 --- a/libfreerdp/cache/brush.h +++ b/libfreerdp/cache/brush.h @@ -1,8 +1,8 @@ /** * FreeRDP: A Remote Desktop Protocol Implementation + * Brush Cache * - * Copyright 2018 Armin Novak - * Copyright 2018 Thincast Technologies GmbH + * Copyright 2011 Marc-Andre Moreau * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,15 +17,37 @@ * limitations under the License. */ -#ifndef FREERDP_LIB_CACHE_BRUSH_H -#define FREERDP_LIB_CACHE_BRUSH_H +#ifndef FREERDP_LIB_BRUSH_CACHE_H +#define FREERDP_LIB_BRUSH_CACHE_H #include +#include #include -#include +#include -FREERDP_LOCAL CACHE_BRUSH_ORDER* copy_cache_brush_order(rdpContext* context, - const CACHE_BRUSH_ORDER* order); -FREERDP_LOCAL void free_cache_brush_order(rdpContext* context, CACHE_BRUSH_ORDER* order); +#include -#endif /* FREERDP_LIB_CACHE_BRUSH_H */ +typedef struct rdp_brush_cache rdpBrushCache; + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_LOCAL void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp); + FREERDP_LOCAL void brush_cache_put(rdpBrushCache* brush, UINT32 index, void* entry, UINT32 bpp); + + FREERDP_LOCAL void brush_cache_register_callbacks(rdpUpdate* update); + + FREERDP_LOCAL rdpBrushCache* brush_cache_new(rdpContext* context); + FREERDP_LOCAL void brush_cache_free(rdpBrushCache* brush); + + FREERDP_LOCAL CACHE_BRUSH_ORDER* copy_cache_brush_order(rdpContext* context, + const CACHE_BRUSH_ORDER* order); + FREERDP_LOCAL void free_cache_brush_order(rdpContext* context, CACHE_BRUSH_ORDER* order); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_LIB_BRUSH_CACHE_H */ diff --git a/libfreerdp/cache/cache.c b/libfreerdp/cache/cache.c index 884187d75..afd155a74 100644 --- a/libfreerdp/cache/cache.c +++ b/libfreerdp/cache/cache.c @@ -23,8 +23,6 @@ #include -#include - #include "cache.h" rdpCache* cache_new(rdpContext* context) diff --git a/libfreerdp/cache/cache.h b/libfreerdp/cache/cache.h index 5cb15386f..81c4987da 100644 --- a/libfreerdp/cache/cache.h +++ b/libfreerdp/cache/cache.h @@ -24,13 +24,44 @@ #include #include -FREERDP_LOCAL CACHE_COLOR_TABLE_ORDER* -copy_cache_color_table_order(rdpContext* context, const CACHE_COLOR_TABLE_ORDER* order); -FREERDP_LOCAL void free_cache_color_table_order(rdpContext* context, - CACHE_COLOR_TABLE_ORDER* order); +#include "glyph.h" +#include "brush.h" +#include "pointer.h" +#include "bitmap.h" +#include "nine_grid.h" +#include "offscreen.h" +#include "palette.h" -FREERDP_LOCAL SURFACE_BITS_COMMAND* copy_surface_bits_command(rdpContext* context, - const SURFACE_BITS_COMMAND* order); -FREERDP_LOCAL void free_surface_bits_command(rdpContext* context, SURFACE_BITS_COMMAND* order); +struct rdp_cache +{ + rdpGlyphCache* glyph; /* 0 */ + rdpBrushCache* brush; /* 1 */ + rdpPointerCache* pointer; /* 2 */ + rdpBitmapCache* bitmap; /* 3 */ + rdpOffscreenCache* offscreen; /* 4 */ + rdpPaletteCache* palette; /* 5 */ + rdpNineGridCache* nine_grid; /* 6 */ +}; + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_LOCAL rdpCache* cache_new(rdpContext* context); + FREERDP_LOCAL void cache_free(rdpCache* cache); + + FREERDP_LOCAL CACHE_COLOR_TABLE_ORDER* + copy_cache_color_table_order(rdpContext* context, const CACHE_COLOR_TABLE_ORDER* order); + FREERDP_LOCAL void free_cache_color_table_order(rdpContext* context, + CACHE_COLOR_TABLE_ORDER* order); + + FREERDP_LOCAL SURFACE_BITS_COMMAND* + copy_surface_bits_command(rdpContext* context, const SURFACE_BITS_COMMAND* order); + FREERDP_LOCAL void free_surface_bits_command(rdpContext* context, SURFACE_BITS_COMMAND* order); + +#ifdef __cplusplus +} +#endif #endif /* FREERDP_LIB_CACHE_CACHE_H */ diff --git a/libfreerdp/cache/glyph.c b/libfreerdp/cache/glyph.c index 3b5c935e9..62fd5a515 100644 --- a/libfreerdp/cache/glyph.c +++ b/libfreerdp/cache/glyph.c @@ -28,10 +28,9 @@ #include #include -#include -#include #include "glyph.h" +#include "cache.h" #define TAG FREERDP_TAG("cache.glyph") diff --git a/libfreerdp/cache/glyph.h b/libfreerdp/cache/glyph.h index 4866b6792..ba8ede8b3 100644 --- a/libfreerdp/cache/glyph.h +++ b/libfreerdp/cache/glyph.h @@ -24,12 +24,53 @@ #include #include -FREERDP_LOCAL CACHE_GLYPH_ORDER* copy_cache_glyph_order(rdpContext* context, - const CACHE_GLYPH_ORDER* glyph); -FREERDP_LOCAL void free_cache_glyph_order(rdpContext* context, CACHE_GLYPH_ORDER* glyph); +typedef struct +{ + UINT32 number; + UINT32 maxCellSize; + rdpGlyph** entries; +} GLYPH_CACHE; -FREERDP_LOCAL CACHE_GLYPH_V2_ORDER* copy_cache_glyph_v2_order(rdpContext* context, - const CACHE_GLYPH_V2_ORDER* glyph); -FREERDP_LOCAL void free_cache_glyph_v2_order(rdpContext* context, CACHE_GLYPH_V2_ORDER* glyph); +typedef struct +{ + void* fragment; + UINT32 size; +} FRAGMENT_CACHE_ENTRY; + +typedef struct +{ + FRAGMENT_CACHE_ENTRY entries[256]; +} FRAGMENT_CACHE; + +typedef struct +{ + FRAGMENT_CACHE fragCache; + GLYPH_CACHE glyphCache[10]; + + wLog* log; + rdpContext* context; +} rdpGlyphCache; + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_LOCAL void glyph_cache_register_callbacks(rdpUpdate* update); + + FREERDP_LOCAL rdpGlyphCache* glyph_cache_new(rdpContext* context); + FREERDP_LOCAL void glyph_cache_free(rdpGlyphCache* glyph); + + FREERDP_LOCAL CACHE_GLYPH_ORDER* copy_cache_glyph_order(rdpContext* context, + const CACHE_GLYPH_ORDER* glyph); + FREERDP_LOCAL void free_cache_glyph_order(rdpContext* context, CACHE_GLYPH_ORDER* glyph); + + FREERDP_LOCAL CACHE_GLYPH_V2_ORDER* + copy_cache_glyph_v2_order(rdpContext* context, const CACHE_GLYPH_V2_ORDER* glyph); + FREERDP_LOCAL void free_cache_glyph_v2_order(rdpContext* context, CACHE_GLYPH_V2_ORDER* glyph); + +#ifdef __cplusplus +} +#endif #endif /* FREERDP_LIB_CACHE_GLYPH_H */ diff --git a/libfreerdp/cache/nine_grid.c b/libfreerdp/cache/nine_grid.c index d0becf941..229a3369f 100644 --- a/libfreerdp/cache/nine_grid.c +++ b/libfreerdp/cache/nine_grid.c @@ -28,7 +28,8 @@ #include #include -#include +#include "nine_grid.h" +#include "cache.h" #define TAG FREERDP_TAG("cache.nine_grid") diff --git a/include/freerdp/cache/nine_grid.h b/libfreerdp/cache/nine_grid.h similarity index 72% rename from include/freerdp/cache/nine_grid.h rename to libfreerdp/cache/nine_grid.h index f5dcedf30..d89f7d09b 100644 --- a/include/freerdp/cache/nine_grid.h +++ b/libfreerdp/cache/nine_grid.h @@ -17,8 +17,8 @@ * limitations under the License. */ -#ifndef FREERDP_NINE_GRID_CACHE_H -#define FREERDP_NINE_GRID_CACHE_H +#ifndef FREERDP_LIB_NINE_GRID_CACHE_H +#define FREERDP_LIB_NINE_GRID_CACHE_H #include #include @@ -29,20 +29,20 @@ typedef struct rdp_nine_grid_cache rdpNineGridCache; -#include +#include "nine_grid.h" #ifdef __cplusplus extern "C" { #endif - FREERDP_API void nine_grid_cache_register_callbacks(rdpUpdate* update); + FREERDP_LOCAL void nine_grid_cache_register_callbacks(rdpUpdate* update); - FREERDP_API rdpNineGridCache* nine_grid_cache_new(rdpContext* context); - FREERDP_API void nine_grid_cache_free(rdpNineGridCache* nine_grid); + FREERDP_LOCAL rdpNineGridCache* nine_grid_cache_new(rdpContext* context); + FREERDP_LOCAL void nine_grid_cache_free(rdpNineGridCache* nine_grid); #ifdef __cplusplus } #endif -#endif /* FREERDP_NINE_GRID_CACHE_H */ +#endif /* FREERDP_LIB_NINE_GRID_CACHE_H */ diff --git a/libfreerdp/cache/offscreen.c b/libfreerdp/cache/offscreen.c index 75f1eee8c..c139dcb03 100644 --- a/libfreerdp/cache/offscreen.c +++ b/libfreerdp/cache/offscreen.c @@ -26,11 +26,12 @@ #include #include -#include -#include #include "../core/graphics.h" +#include "offscreen.h" +#include "cache.h" + #define TAG FREERDP_TAG("cache.offscreen") struct rdp_offscreen_cache diff --git a/include/freerdp/cache/offscreen.h b/libfreerdp/cache/offscreen.h similarity index 69% rename from include/freerdp/cache/offscreen.h rename to libfreerdp/cache/offscreen.h index 0c30dc43b..744f78083 100644 --- a/include/freerdp/cache/offscreen.h +++ b/libfreerdp/cache/offscreen.h @@ -17,8 +17,8 @@ * limitations under the License. */ -#ifndef FREERDP_OFFSCREEN_CACHE_H -#define FREERDP_OFFSCREEN_CACHE_H +#ifndef FREERDP_LIB_OFFSCREEN_CACHE_H +#define FREERDP_LIB_OFFSCREEN_CACHE_H #include #include @@ -34,15 +34,15 @@ extern "C" { #endif - FREERDP_API rdpBitmap* offscreen_cache_get(rdpOffscreenCache* offscreen_cache, UINT32 index); + FREERDP_LOCAL rdpBitmap* offscreen_cache_get(rdpOffscreenCache* offscreen_cache, UINT32 index); - FREERDP_API void offscreen_cache_register_callbacks(rdpUpdate* update); + FREERDP_LOCAL void offscreen_cache_register_callbacks(rdpUpdate* update); - FREERDP_API rdpOffscreenCache* offscreen_cache_new(rdpContext* context); - FREERDP_API void offscreen_cache_free(rdpOffscreenCache* offscreen); + FREERDP_LOCAL rdpOffscreenCache* offscreen_cache_new(rdpContext* context); + FREERDP_LOCAL void offscreen_cache_free(rdpOffscreenCache* offscreen); #ifdef __cplusplus } #endif -#endif /* FREERDP_OFFSCREEN_CACHE_H */ +#endif /* FREERDP_LIB_OFFSCREEN_CACHE_H */ diff --git a/libfreerdp/cache/palette.c b/libfreerdp/cache/palette.c index 08e18ebb4..10879574a 100644 --- a/libfreerdp/cache/palette.c +++ b/libfreerdp/cache/palette.c @@ -24,9 +24,9 @@ #include #include -#include #include "palette.h" +#include "cache.h" #define TAG FREERDP_TAG("cache.palette") diff --git a/libfreerdp/cache/palette.h b/libfreerdp/cache/palette.h index cb2c7d70b..fcd9f2d72 100644 --- a/libfreerdp/cache/palette.h +++ b/libfreerdp/cache/palette.h @@ -23,8 +23,39 @@ #include #include -FREERDP_LOCAL PALETTE_UPDATE* copy_palette_update(rdpContext* context, - const PALETTE_UPDATE* pointer); -FREERDP_LOCAL void free_palette_update(rdpContext* context, PALETTE_UPDATE* pointer); +typedef struct rdp_palette_cache rdpPaletteCache; + +typedef struct +{ + void* entry; +} PALETTE_TABLE_ENTRY; + +struct rdp_palette_cache +{ + UINT32 maxEntries; /* 0 */ + PALETTE_TABLE_ENTRY* entries; /* 1 */ + + /* internal */ + + rdpContext* context; +}; + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_LOCAL void palette_cache_register_callbacks(rdpUpdate* update); + + FREERDP_LOCAL rdpPaletteCache* palette_cache_new(rdpContext* context); + FREERDP_LOCAL void palette_cache_free(rdpPaletteCache* palette_cache); + + FREERDP_LOCAL PALETTE_UPDATE* copy_palette_update(rdpContext* context, + const PALETTE_UPDATE* pointer); + FREERDP_LOCAL void free_palette_update(rdpContext* context, PALETTE_UPDATE* pointer); + +#ifdef __cplusplus +} +#endif #endif /* FREERDP_LIB_CACHE_PALETTE_H */ diff --git a/libfreerdp/cache/pointer.c b/libfreerdp/cache/pointer.c index 08291601c..cf7027640 100644 --- a/libfreerdp/cache/pointer.c +++ b/libfreerdp/cache/pointer.c @@ -26,9 +26,9 @@ #include #include -#include #include "pointer.h" +#include "cache.h" #define TAG FREERDP_TAG("cache.pointer") diff --git a/libfreerdp/cache/pointer.h b/libfreerdp/cache/pointer.h index 95ba34f6c..6498aef0c 100644 --- a/libfreerdp/cache/pointer.h +++ b/libfreerdp/cache/pointer.h @@ -24,29 +24,58 @@ #include #include -FREERDP_LOCAL POINTER_COLOR_UPDATE* copy_pointer_color_update(rdpContext* context, - const POINTER_COLOR_UPDATE* pointer); -FREERDP_LOCAL void free_pointer_color_update(rdpContext* context, POINTER_COLOR_UPDATE* pointer); +typedef struct rdp_pointer_cache rdpPointerCache; -FREERDP_LOCAL POINTER_LARGE_UPDATE* copy_pointer_large_update(rdpContext* context, - const POINTER_LARGE_UPDATE* pointer); -FREERDP_LOCAL void free_pointer_large_update(rdpContext* context, POINTER_LARGE_UPDATE* pointer); +struct rdp_pointer_cache +{ + UINT32 cacheSize; /* 0 */ + rdpPointer** entries; /* 1 */ -FREERDP_LOCAL POINTER_NEW_UPDATE* copy_pointer_new_update(rdpContext* context, - const POINTER_NEW_UPDATE* pointer); -FREERDP_LOCAL void free_pointer_new_update(rdpContext* context, POINTER_NEW_UPDATE* pointer); + /* internal */ + rdpContext* context; +}; -FREERDP_LOCAL POINTER_CACHED_UPDATE* -copy_pointer_cached_update(rdpContext* context, const POINTER_CACHED_UPDATE* pointer); -FREERDP_LOCAL void free_pointer_cached_update(rdpContext* context, POINTER_CACHED_UPDATE* pointer); +#ifdef __cplusplus +extern "C" +{ +#endif -FREERDP_LOCAL POINTER_POSITION_UPDATE* -copy_pointer_position_update(rdpContext* context, const POINTER_POSITION_UPDATE* pointer); -FREERDP_LOCAL void free_pointer_position_update(rdpContext* context, - POINTER_POSITION_UPDATE* pointer); + FREERDP_LOCAL void pointer_cache_register_callbacks(rdpUpdate* update); -FREERDP_LOCAL POINTER_SYSTEM_UPDATE* -copy_pointer_system_update(rdpContext* context, const POINTER_SYSTEM_UPDATE* pointer); -FREERDP_LOCAL void free_pointer_system_update(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer); + FREERDP_LOCAL rdpPointerCache* pointer_cache_new(rdpContext* context); + FREERDP_LOCAL void pointer_cache_free(rdpPointerCache* pointer_cache); + + FREERDP_LOCAL POINTER_COLOR_UPDATE* + copy_pointer_color_update(rdpContext* context, const POINTER_COLOR_UPDATE* pointer); + FREERDP_LOCAL void free_pointer_color_update(rdpContext* context, + POINTER_COLOR_UPDATE* pointer); + + FREERDP_LOCAL POINTER_LARGE_UPDATE* + copy_pointer_large_update(rdpContext* context, const POINTER_LARGE_UPDATE* pointer); + FREERDP_LOCAL void free_pointer_large_update(rdpContext* context, + POINTER_LARGE_UPDATE* pointer); + + FREERDP_LOCAL POINTER_NEW_UPDATE* copy_pointer_new_update(rdpContext* context, + const POINTER_NEW_UPDATE* pointer); + FREERDP_LOCAL void free_pointer_new_update(rdpContext* context, POINTER_NEW_UPDATE* pointer); + + FREERDP_LOCAL POINTER_CACHED_UPDATE* + copy_pointer_cached_update(rdpContext* context, const POINTER_CACHED_UPDATE* pointer); + FREERDP_LOCAL void free_pointer_cached_update(rdpContext* context, + POINTER_CACHED_UPDATE* pointer); + + FREERDP_LOCAL POINTER_POSITION_UPDATE* + copy_pointer_position_update(rdpContext* context, const POINTER_POSITION_UPDATE* pointer); + FREERDP_LOCAL void free_pointer_position_update(rdpContext* context, + POINTER_POSITION_UPDATE* pointer); + + FREERDP_LOCAL POINTER_SYSTEM_UPDATE* + copy_pointer_system_update(rdpContext* context, const POINTER_SYSTEM_UPDATE* pointer); + FREERDP_LOCAL void free_pointer_system_update(rdpContext* context, + POINTER_SYSTEM_UPDATE* pointer); + +#ifdef __cplusplus +} +#endif #endif /* FREERDP_LIB_CACHE_POINTER_H */ diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index f040d14d0..ff4881249 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -38,8 +38,8 @@ #include #include #include -#include +#include "../cache/pointer.h" #include "../crypto/crypto.h" #include "../crypto/privatekey.h" #include "../crypto/certificate.h" diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index cfabb078c..94b763ad2 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -51,9 +51,9 @@ #include #include #include -#include #include +#include "../cache/pointer.h" #include "settings.h" #include "utils.h" diff --git a/libfreerdp/gdi/gdi.c b/libfreerdp/gdi/gdi.c index 085c19b88..01d041df7 100644 --- a/libfreerdp/gdi/gdi.c +++ b/libfreerdp/gdi/gdi.c @@ -45,6 +45,7 @@ #include "gdi.h" #include "../core/graphics.h" #include "../core/update.h" +#include "../cache/cache.h" #define TAG FREERDP_TAG("gdi")