19 #include <freerdp/config.h>
21 #include <winpr/assert.h>
23 #include "shadow_surface.h"
25 #include "shadow_screen.h"
26 #include "shadow_lobby.h"
28 rdpShadowScreen* shadow_screen_new(rdpShadowServer* server)
31 WINPR_ASSERT(server->subsystem);
33 rdpShadowScreen* screen = (rdpShadowScreen*)calloc(1,
sizeof(rdpShadowScreen));
38 screen->server = server;
39 rdpShadowSubsystem* subsystem = server->subsystem;
41 if (!InitializeCriticalSectionAndSpinCount(&(screen->lock), 4000))
44 region16_init(&(screen->invalidRegion));
46 WINPR_ASSERT(subsystem->selectedMonitor < ARRAYSIZE(subsystem->monitors));
47 const MONITOR_DEF* primary = &(subsystem->monitors[subsystem->selectedMonitor]);
48 WINPR_ASSERT(primary);
50 INT64 x = primary->left;
51 INT64 y = primary->top;
52 INT64 width = primary->right - primary->left + 1;
53 INT64 height = primary->bottom - primary->top + 1;
56 WINPR_ASSERT(x <= UINT16_MAX);
58 WINPR_ASSERT(y <= UINT16_MAX);
59 WINPR_ASSERT(width >= 0);
60 WINPR_ASSERT(width <= UINT16_MAX);
61 WINPR_ASSERT(height >= 0);
62 WINPR_ASSERT(height <= UINT16_MAX);
64 screen->width = (UINT16)width;
65 screen->height = (UINT16)height;
68 shadow_surface_new(server, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height);
73 server->surface = screen->primary;
75 screen->lobby = shadow_surface_new(server, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height);
80 server->lobby = screen->lobby;
82 if (!shadow_client_init_lobby(server))
88 WINPR_PRAGMA_DIAG_PUSH
89 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
90 shadow_screen_free(screen);
96 void shadow_screen_free(rdpShadowScreen* screen)
101 DeleteCriticalSection(&(screen->lock));
103 region16_uninit(&(screen->invalidRegion));
107 shadow_surface_free(screen->primary);
108 screen->primary = NULL;
113 shadow_surface_free(screen->lobby);
114 screen->lobby = NULL;
120 BOOL shadow_screen_resize(rdpShadowScreen* screen)
125 WINPR_ASSERT(screen->server);
127 rdpShadowSubsystem* subsystem = screen->server->subsystem;
128 WINPR_ASSERT(subsystem);
129 WINPR_ASSERT(subsystem->monitors);
131 MONITOR_DEF* primary = &(subsystem->monitors[subsystem->selectedMonitor]);
132 WINPR_ASSERT(primary);
134 const INT32 x = primary->left;
135 const INT32 y = primary->top;
136 const INT32 width = primary->right - primary->left + 1;
137 const INT32 height = primary->bottom - primary->top + 1;
139 WINPR_ASSERT(x >= 0);
140 WINPR_ASSERT(x <= UINT16_MAX);
141 WINPR_ASSERT(y >= 0);
142 WINPR_ASSERT(y <= UINT16_MAX);
143 WINPR_ASSERT(width >= 0);
144 WINPR_ASSERT(width <= UINT16_MAX);
145 WINPR_ASSERT(height >= 0);
146 WINPR_ASSERT(height <= UINT16_MAX);
148 if (shadow_surface_resize(screen->primary, (UINT16)x, (UINT16)y, (UINT16)width,
150 shadow_surface_resize(screen->lobby, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height))
152 if (((UINT32)width != screen->width) || ((UINT32)height != screen->height))
155 screen->width = (UINT32)width;
156 screen->height = (UINT32)height;
157 shadow_client_init_lobby(screen->server);