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 EnterCriticalSection(&lobby->lock);
44
45#if defined(WITH_RDTK)
46 rdtkSurface* surface = nullptr;
47 rdtkEngine* engine = rdtk_engine_new();
48 if (!engine)
49 goto fail;
50
51 surface =
52 rdtk_surface_new(engine, lobby->data, WINPR_ASSERTING_INT_CAST(uint16_t, lobby->width),
53 WINPR_ASSERTING_INT_CAST(uint16_t, lobby->height), lobby->scanline);
54 if (!surface)
55 goto fail;
56#endif
57
58 invalidRect.left = 0;
59 invalidRect.top = 0;
60 WINPR_ASSERT(lobby->width <= UINT16_MAX);
61 WINPR_ASSERT(lobby->height <= UINT16_MAX);
62 invalidRect.right = (UINT16)lobby->width;
63 invalidRect.bottom = (UINT16)lobby->height;
64 if (server->shareSubRect)
65 {
66 /* If we have shared sub rect setting, only fill shared rect */
67 if (!rectangles_intersection(&invalidRect, &(server->subRect), &invalidRect))
68 goto fail;
69 }
70
71#if defined(WITH_RDTK)
72 const int width = invalidRect.right - invalidRect.left;
73 const int height = invalidRect.bottom - invalidRect.top;
74 WINPR_ASSERT(width <= UINT16_MAX);
75 WINPR_ASSERT(width >= 0);
76 WINPR_ASSERT(height <= UINT16_MAX);
77 WINPR_ASSERT(height >= 0);
78
79 if (rdtk_surface_fill(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height,
80 0x3BB9FF) < 0)
81 goto fail;
82
83 if (rdtk_label_draw(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height,
84 nullptr, "Welcome", 0, 0) < 0)
85 goto fail;
86 // rdtk_button_draw(surface, 16, 64, 128, 32, nullptr, "button");
87 // rdtk_text_field_draw(surface, 16, 128, 128, 32, nullptr, "text field");
88#endif
89
90 if (!region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect))
91 goto fail;
92
93 rc = TRUE;
94fail:
95
96#if defined(WITH_RDTK)
97 rdtk_surface_free(surface);
98 rdtk_engine_free(engine);
99#endif
100
101 LeaveCriticalSection(&lobby->lock);
102 return rc;
103}