summaryrefslogtreecommitdiffstats
path: root/include/freerdp/client/rdpgfx.h
blob: df9e2a7a5ea8d7d9d81eb35c092cfee5ff737c6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/**
 * FreeRDP: A Remote Desktop Protocol Implementation
 * Graphics Pipeline Extension
 *
 * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 * Copyright 2015 Thincast Technologies GmbH
 * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FREERDP_CHANNEL_RDPGFX_CLIENT_RDPGFX_H
#define FREERDP_CHANNEL_RDPGFX_CLIENT_RDPGFX_H

#include <freerdp/api.h>
#include <freerdp/types.h>

#include <freerdp/codecs.h>

#include <freerdp/channels/rdpgfx.h>
#include <freerdp/utils/profiler.h>

#include <freerdp/cache/persistent.h>

#ifdef __cplusplus
extern "C"
{
#endif

	/**
	 * Client Interface
	 */
	typedef struct gdi_gfx_surface gdiGfxSurface;
	typedef struct s_rdpgfx_client_context RdpgfxClientContext;

	typedef UINT (*pcRdpgfxResetGraphics)(RdpgfxClientContext* context,
	                                      const RDPGFX_RESET_GRAPHICS_PDU* resetGraphics);
	typedef UINT (*pcRdpgfxStartFrame)(RdpgfxClientContext* context,
	                                   const RDPGFX_START_FRAME_PDU* startFrame);
	typedef UINT (*pcRdpgfxEndFrame)(RdpgfxClientContext* context,
	                                 const RDPGFX_END_FRAME_PDU* endFrame);
	typedef UINT (*pcRdpgfxSurfaceCommand)(RdpgfxClientContext* context,
	                                       const RDPGFX_SURFACE_COMMAND* cmd);
	typedef UINT (*pcRdpgfxDeleteEncodingContext)(
	    RdpgfxClientContext* context,
	    const RDPGFX_DELETE_ENCODING_CONTEXT_PDU* deleteEncodingContext);
	typedef UINT (*pcRdpgfxCreateSurface)(RdpgfxClientContext* context,
	                                      const RDPGFX_CREATE_SURFACE_PDU* createSurface);
	typedef UINT (*pcRdpgfxDeleteSurface)(RdpgfxClientContext* context,
	                                      const RDPGFX_DELETE_SURFACE_PDU* deleteSurface);
	typedef UINT (*pcRdpgfxSolidFill)(RdpgfxClientContext* context,
	                                  const RDPGFX_SOLID_FILL_PDU* solidFill);
	typedef UINT (*pcRdpgfxSurfaceToSurface)(RdpgfxClientContext* context,
	                                         const RDPGFX_SURFACE_TO_SURFACE_PDU* surfaceToSurface);
	typedef UINT (*pcRdpgfxSurfaceToCache)(RdpgfxClientContext* context,
	                                       const RDPGFX_SURFACE_TO_CACHE_PDU* surfaceToCache);
	typedef UINT (*pcRdpgfxCacheToSurface)(RdpgfxClientContext* context,
	                                       const RDPGFX_CACHE_TO_SURFACE_PDU* cacheToSurface);
	typedef UINT (*pcRdpgfxCacheImportOffer)(RdpgfxClientContext* context,
	                                         const RDPGFX_CACHE_IMPORT_OFFER_PDU* cacheImportOffer);
	typedef UINT (*pcRdpgfxCacheImportReply)(RdpgfxClientContext* context,
	                                         const RDPGFX_CACHE_IMPORT_REPLY_PDU* cacheImportReply);
	typedef UINT (*pcRdpgfxEvictCacheEntry)(RdpgfxClientContext* context,
	                                        const RDPGFX_EVICT_CACHE_ENTRY_PDU* evictCacheEntry);
	typedef UINT (*pcRdpgfxImportCacheEntry)(RdpgfxClientContext* context, UINT16 cacheSlot,
	                                         const PERSISTENT_CACHE_ENTRY* importCacheEntry);
	typedef UINT (*pcRdpgfxExportCacheEntry)(RdpgfxClientContext* context, UINT16 cacheSlot,
	                                         PERSISTENT_CACHE_ENTRY* importCacheEntry);
	typedef UINT (*pcRdpgfxMapSurfaceToOutput)(
	    RdpgfxClientContext* context, const RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU* surfaceToOutput);
	typedef UINT (*pcRdpgfxMapSurfaceToScaledOutput)(
	    RdpgfxClientContext* context,
	    const RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU* surfaceToOutput);
	typedef UINT (*pcRdpgfxMapSurfaceToWindow)(
	    RdpgfxClientContext* context, const RDPGFX_MAP_SURFACE_TO_WINDOW_PDU* surfaceToWindow);
	typedef UINT (*pcRdpgfxMapSurfaceToScaledWindow)(
	    RdpgfxClientContext* context,
	    const RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU* surfaceToWindow);
	typedef UINT (*pcRdpgfxSetSurfaceData)(RdpgfxClientContext* context, UINT16 surfaceId,
	                                       void* pData);
	typedef void* (*pcRdpgfxGetSurfaceData)(RdpgfxClientContext* context, UINT16 surfaceId);
	typedef UINT (*pcRdpgfxGetSurfaceIds)(RdpgfxClientContext* context, UINT16** ppSurfaceIds,
	                                      UINT16* count);
	typedef UINT (*pcRdpgfxSetCacheSlotData)(RdpgfxClientContext* context, UINT16 cacheSlot,
	                                         void* pData);
	typedef void* (*pcRdpgfxGetCacheSlotData)(RdpgfxClientContext* context, UINT16 cacheSlot);

	typedef UINT (*pcRdpgfxUpdateSurfaces)(RdpgfxClientContext* context);

	typedef UINT (*pcRdpgfxUpdateWindowFromSurface)(RdpgfxClientContext* context,
	                                                gdiGfxSurface* surface);

	typedef UINT (*pcRdpgfxUpdateSurfaceArea)(RdpgfxClientContext* context, UINT16 surfaceId,
	                                          UINT32 nrRects, const RECTANGLE_16* rects);

	typedef UINT (*pcRdpgfxOnOpen)(RdpgfxClientContext* context, BOOL* do_caps_advertise,
	                               BOOL* do_frame_acks);
	typedef UINT (*pcRdpgfxOnClose)(RdpgfxClientContext* context);
	typedef UINT (*pcRdpgfxCapsAdvertise)(RdpgfxClientContext* context,
	                                      const RDPGFX_CAPS_ADVERTISE_PDU* capsAdvertise);
	typedef UINT (*pcRdpgfxCapsConfirm)(RdpgfxClientContext* context,
	                                    const RDPGFX_CAPS_CONFIRM_PDU* capsConfirm);
	typedef UINT (*pcRdpgfxFrameAcknowledge)(RdpgfxClientContext* context,
	                                         const RDPGFX_FRAME_ACKNOWLEDGE_PDU* frameAcknowledge);
	typedef UINT (*pcRdpgfxQoeFrameAcknowledge)(
	    RdpgfxClientContext* context, const RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU* qoeFrameAcknowledge);

	typedef UINT (*pcRdpgfxMapWindowForSurface)(RdpgfxClientContext* context, UINT16 surfaceID,
	                                            UINT64 windowID);
	typedef UINT (*pcRdpgfxUnmapWindowForSurface)(RdpgfxClientContext* context, UINT64 windowID);

	struct s_rdpgfx_client_context
	{
		void* handle;
		void* custom;

		/* Implementations require locking */
		pcRdpgfxResetGraphics ResetGraphics;
		pcRdpgfxStartFrame StartFrame;
		pcRdpgfxEndFrame EndFrame;
		pcRdpgfxSurfaceCommand SurfaceCommand;
		pcRdpgfxDeleteEncodingContext DeleteEncodingContext;
		pcRdpgfxCreateSurface CreateSurface;
		pcRdpgfxDeleteSurface DeleteSurface;
		pcRdpgfxSolidFill SolidFill;
		pcRdpgfxSurfaceToSurface SurfaceToSurface;
		pcRdpgfxSurfaceToCache SurfaceToCache;
		pcRdpgfxCacheToSurface CacheToSurface;
		pcRdpgfxCacheImportOffer CacheImportOffer;
		pcRdpgfxCacheImportReply CacheImportReply;
		pcRdpgfxImportCacheEntry ImportCacheEntry;
		pcRdpgfxExportCacheEntry ExportCacheEntry;
		pcRdpgfxEvictCacheEntry EvictCacheEntry;
		pcRdpgfxMapSurfaceToOutput MapSurfaceToOutput;
		pcRdpgfxMapSurfaceToScaledOutput MapSurfaceToScaledOutput;
		pcRdpgfxMapSurfaceToWindow MapSurfaceToWindow;
		pcRdpgfxMapSurfaceToScaledWindow MapSurfaceToScaledWindow;

		pcRdpgfxGetSurfaceIds GetSurfaceIds;
		pcRdpgfxSetSurfaceData SetSurfaceData;
		pcRdpgfxGetSurfaceData GetSurfaceData;
		pcRdpgfxSetCacheSlotData SetCacheSlotData;
		pcRdpgfxGetCacheSlotData GetCacheSlotData;

		/* Proxy callbacks */
		pcRdpgfxOnOpen OnOpen;
		pcRdpgfxOnClose OnClose;
		pcRdpgfxCapsAdvertise CapsAdvertise;
		pcRdpgfxCapsConfirm CapsConfirm;
		pcRdpgfxFrameAcknowledge FrameAcknowledge;
		pcRdpgfxQoeFrameAcknowledge QoeFrameAcknowledge;

		/* No locking required */
		pcRdpgfxUpdateSurfaces UpdateSurfaces;
		pcRdpgfxUpdateSurfaceArea UpdateSurfaceArea;
		pcRdpgfxUpdateWindowFromSurface UpdateWindowFromSurface;

		/* These callbacks allow creating/destroying a window directly
		 * mapped to a surface.
		 * NOTE: The surface is already locked.
		 */
		pcRdpgfxMapWindowForSurface MapWindowForSurface;
		pcRdpgfxUnmapWindowForSurface UnmapWindowForSurface;

		CRITICAL_SECTION mux;
		rdpCodecs* codecs;
		PROFILER_DEFINE(SurfaceProfiler)
	};

	FREERDP_API void rdpgfx_client_context_free(RdpgfxClientContext* context);

	WINPR_ATTR_MALLOC(rdpgfx_client_context_free, 1)
	FREERDP_API RdpgfxClientContext* rdpgfx_client_context_new(rdpContext* context);

#ifdef __cplusplus
}
#endif

#endif /* FREERDP_CHANNEL_RDPGFX_CLIENT_RDPGFX_H */