FreeRDP
Loading...
Searching...
No Matches
shadow_lobby.c
1
19#include <freerdp/config.h>
20
21#include <winpr/assert.h>
22#include <winpr/cast.h>
23
24#if defined(WITH_RDTK)
25#include <rdtk/rdtk.h>
26#endif
27
28#include "shadow.h"
29
30#include "shadow_lobby.h"
31
32BOOL shadow_client_init_lobby(rdpShadowServer* server)
33{
34 BOOL rc = FALSE;
35 RECTANGLE_16 invalidRect = WINPR_C_ARRAY_INIT;
36
37 WINPR_ASSERT(server);
38 rdpShadowSurface* lobby = server->lobby;
39
40 if (!lobby)
41 return FALSE;
42
43#if defined(WITH_RDTK)
44 rdtkEngine* engine = rdtk_engine_new();
45 if (!engine)
46 return FALSE;
47
48 EnterCriticalSection(&lobby->lock);
49 rdtkSurface* surface =
50 rdtk_surface_new(engine, lobby->data, WINPR_ASSERTING_INT_CAST(uint16_t, lobby->width),
51 WINPR_ASSERTING_INT_CAST(uint16_t, lobby->height), lobby->scanline);
52 if (!surface)
53 goto fail;
54#endif
55
56 invalidRect.left = 0;
57 invalidRect.top = 0;
58 WINPR_ASSERT(lobby->width <= UINT16_MAX);
59 WINPR_ASSERT(lobby->height <= UINT16_MAX);
60 invalidRect.right = (UINT16)lobby->width;
61 invalidRect.bottom = (UINT16)lobby->height;
62 if (server->shareSubRect)
63 {
64 /* If we have shared sub rect setting, only fill shared rect */
65 if (!rectangles_intersection(&invalidRect, &(server->subRect), &invalidRect))
66 goto fail;
67 }
68
69#if defined(WITH_RDTK)
70 const int width = invalidRect.right - invalidRect.left;
71 const int height = invalidRect.bottom - invalidRect.top;
72 WINPR_ASSERT(width <= UINT16_MAX);
73 WINPR_ASSERT(width >= 0);
74 WINPR_ASSERT(height <= UINT16_MAX);
75 WINPR_ASSERT(height >= 0);
76
77 if (rdtk_surface_fill(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height,
78 0x3BB9FF) < 0)
79 goto fail;
80
81 if (rdtk_label_draw(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height,
82 nullptr, "Welcome", 0, 0) < 0)
83 goto fail;
84 // rdtk_button_draw(surface, 16, 64, 128, 32, nullptr, "button");
85 // rdtk_text_field_draw(surface, 16, 128, 128, 32, nullptr, "text field");
86#endif
87
88 if (!region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect))
89 goto fail;
90
91 rc = TRUE;
92fail:
93
94#if defined(WITH_RDTK)
95 rdtk_surface_free(surface);
96 rdtk_engine_free(engine);
97#endif
98
99 LeaveCriticalSection(&lobby->lock);
100 return rc;
101}