2 * Mesa 3-D graphics library
5 * Copyright (C) 2009-2010 Chia-I Wu <olv@0xlab.org>
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
29 #include "EGL/egl.h" /* for EGL native types */
31 #include "pipe/p_compiler.h"
32 #include "pipe/p_screen.h"
33 #include "pipe/p_context.h"
34 #include "pipe/p_state.h"
36 #include "native_probe.h"
37 #include "native_modeset.h"
40 * Only color buffers are listed. The others are allocated privately through,
41 * for example, st_renderbuffer_alloc_storage().
43 enum native_attachment
{
44 NATIVE_ATTACHMENT_FRONT_LEFT
,
45 NATIVE_ATTACHMENT_BACK_LEFT
,
46 NATIVE_ATTACHMENT_FRONT_RIGHT
,
47 NATIVE_ATTACHMENT_BACK_RIGHT
,
49 NUM_NATIVE_ATTACHMENTS
52 enum native_param_type
{
54 * Return TRUE if window/pixmap surfaces use the buffers of the native
57 NATIVE_PARAM_USE_NATIVE_BUFFER
60 struct native_surface
{
62 * Available for caller's use.
66 void (*destroy
)(struct native_surface
*nsurf
);
69 * Swap the front and back buffers so that the back buffer is visible. It
70 * is no-op if the surface is single-buffered. The contents of the back
71 * buffer after swapping may or may not be preserved.
73 boolean (*swap_buffers
)(struct native_surface
*nsurf
);
76 * Make the front buffer visible. In some native displays, changes to the
77 * front buffer might not be visible immediately and require manual flush.
79 boolean (*flush_frontbuffer
)(struct native_surface
*nsurf
);
82 * Validate the buffers of the surface. textures, if not NULL, points to an
83 * array of size NUM_NATIVE_ATTACHMENTS and the returned textures are owned
84 * by the caller. A sequence number is also returned. The caller can use
85 * it to check if anything has changed since the last call. Any of the
86 * pointers may be NULL and it indicates the caller has no interest in those
89 * If this function is called multiple times with different attachment
90 * masks, those not listed in the latest call might be destroyed. This
91 * behavior might change in the future.
93 boolean (*validate
)(struct native_surface
*nsurf
, uint attachment_mask
,
94 unsigned int *seq_num
, struct pipe_resource
**textures
,
95 int *width
, int *height
);
98 * Wait until all native commands affecting the surface has been executed.
100 void (*wait
)(struct native_surface
*nsurf
);
104 * Describe a native display config.
106 struct native_config
{
107 /* available buffers and their format */
109 enum pipe_format color_format
;
111 /* supported surface types */
116 int native_visual_id
;
117 int native_visual_type
;
121 boolean transparent_rgb
;
122 int transparent_rgb_values
[3];
126 * A pipe winsys abstracts the OS. A pipe screen abstracts the graphcis
127 * hardware. A native display consists of a pipe winsys, a pipe screen, and
128 * the native display server.
130 struct native_display
{
132 * The pipe screen of the native display.
134 struct pipe_screen
*screen
;
137 * Available for caller's use.
141 void (*destroy
)(struct native_display
*ndpy
);
144 * Query the parameters of the native display.
146 * The return value is defined by the parameter.
148 int (*get_param
)(struct native_display
*ndpy
,
149 enum native_param_type param
);
152 * Get the supported configs. The configs are owned by the display, but
153 * the returned array should be FREE()ed.
155 const struct native_config
**(*get_configs
)(struct native_display
*ndpy
,
159 * Test if a pixmap is supported by the given config. Required unless no
160 * config has pixmap_bit set.
162 * This function is usually called to find a config that supports a given
163 * pixmap. Thus, it is usually called with the same pixmap in a row.
165 boolean (*is_pixmap_supported
)(struct native_display
*ndpy
,
166 EGLNativePixmapType pix
,
167 const struct native_config
*nconf
);
171 * Create a window surface. Required unless no config has window_bit set.
173 struct native_surface
*(*create_window_surface
)(struct native_display
*ndpy
,
174 EGLNativeWindowType win
,
175 const struct native_config
*nconf
);
178 * Create a pixmap surface. Required unless no config has pixmap_bit set.
180 struct native_surface
*(*create_pixmap_surface
)(struct native_display
*ndpy
,
181 EGLNativePixmapType pix
,
182 const struct native_config
*nconf
);
184 const struct native_display_modeset
*modeset
;
188 * The handler for events that a native display may generate. The events are
189 * generated asynchronously and the handler may be called by any thread at any
192 struct native_event_handler
{
194 * This function is called when a surface needs to be validated.
196 void (*invalid_surface
)(struct native_display
*ndpy
,
197 struct native_surface
*nsurf
,
198 unsigned int seq_num
);
202 * Test whether an attachment is set in the mask.
204 static INLINE boolean
205 native_attachment_mask_test(uint mask
, enum native_attachment att
)
207 return !!(mask
& (1 << att
));
211 native_get_name(void);
213 struct native_display
*
214 native_create_display(EGLNativeDisplayType dpy
,
215 struct native_event_handler
*handler
);
217 #endif /* _NATIVE_H_ */