19#include <freerdp/config.h>
23#include "shadow_subsystem.h"
25static pfnShadowSubsystemEntry pSubsystemEntry =
nullptr;
27void shadow_subsystem_set_entry(pfnShadowSubsystemEntry pEntry)
29 pSubsystemEntry = pEntry;
33static int shadow_subsystem_load_entry_points(RDP_SHADOW_ENTRY_POINTS* pEntryPoints)
35 WINPR_ASSERT(pEntryPoints);
36 ZeroMemory(pEntryPoints,
sizeof(RDP_SHADOW_ENTRY_POINTS));
41 if (pSubsystemEntry(pEntryPoints) < 0)
47rdpShadowSubsystem* shadow_subsystem_new(
void)
49 RDP_SHADOW_ENTRY_POINTS ep = WINPR_C_ARRAY_INIT;
51 if (shadow_subsystem_load_entry_points(&ep) < 0)
57 rdpShadowSubsystem* subsystem = ep.New();
67void shadow_subsystem_free(rdpShadowSubsystem* subsystem)
69 if (subsystem && subsystem->ep.Free)
70 subsystem->ep.Free(subsystem);
73int shadow_subsystem_init(rdpShadowSubsystem* subsystem, rdpShadowServer* server)
77 if (!subsystem || !subsystem->ep.Init)
80 subsystem->server = server;
81 subsystem->selectedMonitor = server->selectedMonitor;
83 if (!(subsystem->MsgPipe = MessagePipe_New()))
86 if (!(subsystem->updateEvent = shadow_multiclient_new()))
89 status = subsystem->ep.Init(subsystem);
94 if (subsystem->MsgPipe)
96 MessagePipe_Free(subsystem->MsgPipe);
97 subsystem->MsgPipe =
nullptr;
100 if (subsystem->updateEvent)
102 shadow_multiclient_free(subsystem->updateEvent);
103 subsystem->updateEvent =
nullptr;
109static void shadow_subsystem_free_queued_message(
void* obj)
111 wMessage* message = (wMessage*)obj;
114 message->Free(message);
115 message->Free =
nullptr;
119void shadow_subsystem_uninit(rdpShadowSubsystem* subsystem)
124 if (subsystem->ep.Uninit)
125 subsystem->ep.Uninit(subsystem);
127 if (subsystem->MsgPipe)
132 obj1 = MessageQueue_Object(subsystem->MsgPipe->In);
134 obj1->
fnObjectFree = shadow_subsystem_free_queued_message;
135 MessageQueue_Clear(subsystem->MsgPipe->In);
137 obj2 = MessageQueue_Object(subsystem->MsgPipe->Out);
138 obj2->
fnObjectFree = shadow_subsystem_free_queued_message;
139 MessageQueue_Clear(subsystem->MsgPipe->Out);
140 MessagePipe_Free(subsystem->MsgPipe);
141 subsystem->MsgPipe =
nullptr;
144 if (subsystem->updateEvent)
146 shadow_multiclient_free(subsystem->updateEvent);
147 subsystem->updateEvent =
nullptr;
151int shadow_subsystem_start(rdpShadowSubsystem* subsystem)
155 if (!subsystem || !subsystem->ep.Start)
158 status = subsystem->ep.Start(subsystem);
163int shadow_subsystem_stop(rdpShadowSubsystem* subsystem)
167 if (!subsystem || !subsystem->ep.Stop)
170 status = subsystem->ep.Stop(subsystem);
175UINT32 shadow_enum_monitors(
MONITOR_DEF* monitors, UINT32 maxMonitors)
177 UINT32 numMonitors = 0;
178 RDP_SHADOW_ENTRY_POINTS ep;
180 if (shadow_subsystem_load_entry_points(&ep) < 0)
183 numMonitors = ep.EnumMonitors(monitors, maxMonitors);
194#if !defined(WITHOUT_FREERDP_3x_DEPRECATED)
195int shadow_subsystem_pointer_convert_alpha_pointer_data(
196 const BYTE* WINPR_RESTRICT pixels, BOOL premultiplied, UINT32 width, UINT32 height,
199 return shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
200 pixels, PIXEL_FORMAT_BGRX32, premultiplied, width, height, pointerColor);
204int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
205 const BYTE* pixels, UINT32 format, BOOL premultiplied, UINT32 width, UINT32 height,
211 BYTE* andBits =
nullptr;
213 const size_t bpp = FreeRDPGetBytesPerPixel(format);
215 xorStep = (width * 3);
216 xorStep += (xorStep % 2);
218 andStep = ((width + 7) / 8);
219 andStep += (andStep % 2);
221 pointerColor->lengthXorMask = height * xorStep;
222 pointerColor->xorMaskData = (BYTE*)calloc(1, pointerColor->lengthXorMask);
224 if (!pointerColor->xorMaskData)
227 pointerColor->lengthAndMask = height * andStep;
228 pointerColor->andMaskData = (BYTE*)calloc(1, pointerColor->lengthAndMask);
230 if (!pointerColor->andMaskData)
232 free(pointerColor->xorMaskData);
233 pointerColor->xorMaskData =
nullptr;
237 for (
size_t y = 0; y < height; y++)
239 const BYTE* pSrc8 = &pixels[(width * bpp) * (height - 1 - y)];
240 BYTE* pDst8 = &(pointerColor->xorMaskData[y * xorStep]);
243 andBits = &(pointerColor->andMaskData[andStep * y]);
245 for (
size_t x = 0; x < width; x++)
252 const UINT32 color = FreeRDPReadColor(&pSrc8[x * bpp], format);
253 FreeRDPSplitColor(color, format, &R, &G, &B, &A,
nullptr);
293void shadow_subsystem_frame_update(rdpShadowSubsystem* subsystem)
295 shadow_multiclient_publish_and_wait(subsystem->updateEvent);
This struct contains function pointer to initialize/free objects.
OBJECT_FREE_FN fnObjectFree