20 #include <freerdp/config.h>
24 #include <winpr/crt.h>
26 #include <freerdp/log.h>
27 #include <freerdp/update.h>
28 #include <freerdp/freerdp.h>
29 #include <winpr/stream.h>
31 #include "nine_grid.h"
34 #define TAG FREERDP_TAG("cache.nine_grid")
41 struct rdp_nine_grid_cache
43 pDrawNineGrid DrawNineGrid;
44 pMultiDrawNineGrid MultiDrawNineGrid;
45 UINT32 paddingA[16 - 2];
49 NINE_GRID_ENTRY* entries;
50 UINT32 paddingB[32 - 19];
55 static void* nine_grid_cache_get(rdpNineGridCache* nine_grid, UINT32 index);
56 static void nine_grid_cache_put(rdpNineGridCache* nine_grid, UINT32 index,
void* entry);
58 static BOOL update_gdi_draw_nine_grid(rdpContext* context,
61 rdpCache* cache = context->cache;
62 return IFCALLRESULT(TRUE, cache->nine_grid->DrawNineGrid, context, draw_nine_grid);
65 static BOOL update_gdi_multi_draw_nine_grid(rdpContext* context,
68 rdpCache* cache = context->cache;
69 return IFCALLRESULT(TRUE, cache->nine_grid->MultiDrawNineGrid, context, multi_draw_nine_grid);
72 void nine_grid_cache_register_callbacks(rdpUpdate* update)
74 rdpCache* cache = update->context->cache;
76 cache->nine_grid->DrawNineGrid = update->primary->DrawNineGrid;
77 cache->nine_grid->MultiDrawNineGrid = update->primary->MultiDrawNineGrid;
79 update->primary->DrawNineGrid = update_gdi_draw_nine_grid;
80 update->primary->MultiDrawNineGrid = update_gdi_multi_draw_nine_grid;
83 void* nine_grid_cache_get(rdpNineGridCache* nine_grid, UINT32 index)
87 if (index >= nine_grid->maxEntries)
89 WLog_ERR(TAG,
"invalid NineGrid index: 0x%08" PRIX32
"", index);
93 entry = nine_grid->entries[index].entry;
97 WLog_ERR(TAG,
"invalid NineGrid at index: 0x%08" PRIX32
"", index);
104 void nine_grid_cache_put(rdpNineGridCache* nine_grid, UINT32 index,
void* entry)
106 if (index >= nine_grid->maxEntries)
108 WLog_ERR(TAG,
"invalid NineGrid index: 0x%08" PRIX32
"", index);
112 free(nine_grid->entries[index].entry);
113 nine_grid->entries[index].entry = entry;
116 rdpNineGridCache* nine_grid_cache_new(rdpContext* context)
118 rdpNineGridCache* nine_grid = NULL;
119 rdpSettings* settings = NULL;
121 WINPR_ASSERT(context);
123 settings = context->settings;
124 WINPR_ASSERT(settings);
126 nine_grid = (rdpNineGridCache*)calloc(1,
sizeof(rdpNineGridCache));
130 nine_grid->context = context;
132 nine_grid->maxSize = 2560;
133 nine_grid->maxEntries = 256;
138 nine_grid->maxEntries))
141 nine_grid->entries = (NINE_GRID_ENTRY*)calloc(nine_grid->maxEntries,
sizeof(NINE_GRID_ENTRY));
142 if (!nine_grid->entries)
148 WINPR_PRAGMA_DIAG_PUSH
149 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
150 nine_grid_cache_free(nine_grid);
151 WINPR_PRAGMA_DIAG_POP
155 void nine_grid_cache_free(rdpNineGridCache* nine_grid)
157 if (nine_grid != NULL)
159 if (nine_grid->entries != NULL)
161 for (
size_t i = 0; i < nine_grid->maxEntries; i++)
162 free(nine_grid->entries[i].entry);
164 free(nine_grid->entries);
FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 param)
Sets a UINT32 settings value.