1 #ifndef _QEMU_YAGL_EGL_SURFACE_H
2 #define _QEMU_YAGL_EGL_SURFACE_H
4 #include "yagl_types.h"
5 #include "yagl_resource.h"
6 #include "yagl_egl_surface_attribs.h"
7 #include "qemu-thread.h"
10 struct yagl_egl_display;
11 struct yagl_egl_config;
12 struct yagl_compiled_transfer;
14 struct yagl_egl_surface
16 struct yagl_resource res;
18 struct yagl_egl_display *dpy;
20 struct yagl_egl_config *cfg;
26 struct yagl_egl_window_attribs window;
27 struct yagl_egl_pixmap_attribs pixmap;
28 struct yagl_egl_pbuffer_attribs pbuffer;
32 * Backing image compiled transfers are the only ones that
33 * can be accessed from multiple threads
34 * simultaneously. When we call
35 * eglDestroySurface we want to destroy backing image
36 * immediately, because target's pixmap will no longer be available
37 * after host 'eglDestroySurface' call is complete. The surface however
38 * may be accessed from another thread where it's current
39 * (from eglSwapBuffers for example), in that case the result of the call
40 * must be EGL_BAD_SURFACE.
45 * Compiled transfer for backing image. It'll become NULL
46 * after eglDestroySurface is called.
48 struct yagl_compiled_transfer *bimage_ct;
54 * Host pre-allocated storage for backing image.
55 * This will go to compiled transfer above.
60 * Native pbuffer surface.
62 EGLSurface native_sfc;
65 * Attribs with which this 'native_sfc' was created with.
67 struct yagl_egl_pbuffer_attribs native_sfc_attribs;
71 * Takes ownership of 'bimage_ct'. byte-copies 'attribs'.
73 struct yagl_egl_surface
74 *yagl_egl_surface_create_window(struct yagl_egl_display *dpy,
75 struct yagl_egl_config *cfg,
76 const struct yagl_egl_window_attribs *attribs,
77 struct yagl_compiled_transfer *bimage_ct,
83 * Takes ownership of 'bimage_ct'. byte-copies 'attribs'.
85 struct yagl_egl_surface
86 *yagl_egl_surface_create_pixmap(struct yagl_egl_display *dpy,
87 struct yagl_egl_config *cfg,
88 const struct yagl_egl_pixmap_attribs *attribs,
89 struct yagl_compiled_transfer *bimage_ct,
95 * Takes ownership of 'bimage_ct'. byte-copies 'attribs'.
97 struct yagl_egl_surface
98 *yagl_egl_surface_create_pbuffer(struct yagl_egl_display *dpy,
99 struct yagl_egl_config *cfg,
100 const struct yagl_egl_pbuffer_attribs *attribs,
101 struct yagl_compiled_transfer *bimage_ct,
107 * Lock/unlock surface for 'bimage' access, all 'bimage' operations
108 * must be carried out while surface is locked.
112 void yagl_egl_surface_lock(struct yagl_egl_surface *sfc);
114 void yagl_egl_surface_unlock(struct yagl_egl_surface *sfc);
121 * Takes ownership of 'native_sfc' and 'bimage_ct'.
123 * This will destroy old surface data and update it with new one.
124 * Must be called while surface is locked.
126 void yagl_egl_surface_update(struct yagl_egl_surface *sfc,
127 EGLSurface native_sfc,
128 struct yagl_compiled_transfer *bimage_ct,
134 * This will destroy old surface data.
135 * Must be called while surface is locked.
137 void yagl_egl_surface_invalidate(struct yagl_egl_surface *sfc);
140 * Helper functions that simply acquire/release yagl_egl_surface::res
145 * Passing NULL won't hurt, this is for convenience.
147 void yagl_egl_surface_acquire(struct yagl_egl_surface *sfc);
150 * Passing NULL won't hurt, this is for convenience.
152 void yagl_egl_surface_release(struct yagl_egl_surface *sfc);