19#include <freerdp/config.h>
23#include "shadow_subsystem.h"
25static pfnShadowSubsystemEntry pSubsystemEntry = NULL;
27void shadow_subsystem_set_entry(pfnShadowSubsystemEntry pEntry)
29 pSubsystemEntry = pEntry;
32static int shadow_subsystem_load_entry_points(RDP_SHADOW_ENTRY_POINTS* pEntryPoints)
34 WINPR_ASSERT(pEntryPoints);
35 ZeroMemory(pEntryPoints,
sizeof(RDP_SHADOW_ENTRY_POINTS));
40 if (pSubsystemEntry(pEntryPoints) < 0)
46rdpShadowSubsystem* shadow_subsystem_new(
void)
48 RDP_SHADOW_ENTRY_POINTS ep;
49 rdpShadowSubsystem* subsystem = NULL;
51 shadow_subsystem_load_entry_points(&ep);
61 CopyMemory(&(subsystem->ep), &ep,
sizeof(RDP_SHADOW_ENTRY_POINTS));
66void shadow_subsystem_free(rdpShadowSubsystem* subsystem)
68 if (subsystem && subsystem->ep.Free)
69 subsystem->ep.Free(subsystem);
72int shadow_subsystem_init(rdpShadowSubsystem* subsystem, rdpShadowServer* server)
76 if (!subsystem || !subsystem->ep.Init)
79 subsystem->server = server;
80 subsystem->selectedMonitor = server->selectedMonitor;
82 if (!(subsystem->MsgPipe = MessagePipe_New()))
85 if (!(subsystem->updateEvent = shadow_multiclient_new()))
88 if ((status = subsystem->ep.Init(subsystem)) >= 0)
92 if (subsystem->MsgPipe)
94 MessagePipe_Free(subsystem->MsgPipe);
95 subsystem->MsgPipe = NULL;
98 if (subsystem->updateEvent)
100 shadow_multiclient_free(subsystem->updateEvent);
101 subsystem->updateEvent = NULL;
107static void shadow_subsystem_free_queued_message(
void* obj)
109 wMessage* message = (wMessage*)obj;
112 message->Free(message);
113 message->Free = NULL;
117void shadow_subsystem_uninit(rdpShadowSubsystem* subsystem)
122 if (subsystem->ep.Uninit)
123 subsystem->ep.Uninit(subsystem);
125 if (subsystem->MsgPipe)
130 obj1 = MessageQueue_Object(subsystem->MsgPipe->In);
132 obj1->fnObjectFree = shadow_subsystem_free_queued_message;
133 MessageQueue_Clear(subsystem->MsgPipe->In);
135 obj2 = MessageQueue_Object(subsystem->MsgPipe->Out);
136 obj2->fnObjectFree = shadow_subsystem_free_queued_message;
137 MessageQueue_Clear(subsystem->MsgPipe->Out);
138 MessagePipe_Free(subsystem->MsgPipe);
139 subsystem->MsgPipe = NULL;
142 if (subsystem->updateEvent)
144 shadow_multiclient_free(subsystem->updateEvent);
145 subsystem->updateEvent = NULL;
149int shadow_subsystem_start(rdpShadowSubsystem* subsystem)
153 if (!subsystem || !subsystem->ep.Start)
156 status = subsystem->ep.Start(subsystem);
161int shadow_subsystem_stop(rdpShadowSubsystem* subsystem)
165 if (!subsystem || !subsystem->ep.Stop)
168 status = subsystem->ep.Stop(subsystem);
173UINT32 shadow_enum_monitors(
MONITOR_DEF* monitors, UINT32 maxMonitors)
175 UINT32 numMonitors = 0;
176 RDP_SHADOW_ENTRY_POINTS ep;
178 if (shadow_subsystem_load_entry_points(&ep) < 0)
181 numMonitors = ep.EnumMonitors(monitors, maxMonitors);
192#if !defined(WITHOUT_FREERDP_3x_DEPRECATED)
193int shadow_subsystem_pointer_convert_alpha_pointer_data(
194 const BYTE* WINPR_RESTRICT pixels, BOOL premultiplied, UINT32 width, UINT32 height,
197 return shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
198 pixels, PIXEL_FORMAT_BGRX32, premultiplied, width, height, pointerColor);
202int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
203 const BYTE* pixels, UINT32 format, BOOL premultiplied, UINT32 width, UINT32 height,
209 BYTE* andBits = NULL;
211 const size_t bpp = FreeRDPGetBytesPerPixel(format);
213 xorStep = (width * 3);
214 xorStep += (xorStep % 2);
216 andStep = ((width + 7) / 8);
217 andStep += (andStep % 2);
219 pointerColor->lengthXorMask = height * xorStep;
220 pointerColor->xorMaskData = (BYTE*)calloc(1, pointerColor->lengthXorMask);
222 if (!pointerColor->xorMaskData)
225 pointerColor->lengthAndMask = height * andStep;
226 pointerColor->andMaskData = (BYTE*)calloc(1, pointerColor->lengthAndMask);
228 if (!pointerColor->andMaskData)
230 free(pointerColor->xorMaskData);
231 pointerColor->xorMaskData = NULL;
235 for (
size_t y = 0; y < height; y++)
237 const BYTE* pSrc8 = &pixels[(width * bpp) * (height - 1 - y)];
238 BYTE* pDst8 = &(pointerColor->xorMaskData[y * xorStep]);
241 andBits = &(pointerColor->andMaskData[andStep * y]);
243 for (
size_t x = 0; x < width; x++)
250 const UINT32 color = FreeRDPReadColor(&pSrc8[x * bpp], format);
251 FreeRDPSplitColor(color, format, &R, &G, &B, &A, NULL);
291void shadow_subsystem_frame_update(rdpShadowSubsystem* subsystem)
293 shadow_multiclient_publish_and_wait(subsystem->updateEvent);
This struct contains function pointer to initialize/free objects.