Flutter Engine
egl_utils.h File Reference
#include <EGL/egl.h>
#include <glib.h>

Go to the source code of this file.

Functions

G_BEGIN_DECLS const gchar * egl_error_to_string (EGLint error)
 
gchar * egl_config_to_string (EGLDisplay display, EGLConfig config)
 

Function Documentation

◆ egl_config_to_string()

gchar* egl_config_to_string ( EGLDisplay  display,
EGLConfig  config 
)

egl_config_to_string: : an EGL display. : an EGL configuration.

Converts an EGL configuration to a human readable string. e.g. "EGL_CONFIG_ID=1 EGL_RED_SIZE=8...".

Returns: a configuration description.

Definition at line 126 of file egl_utils.cc.

References egl_decimal_to_string(), egl_enum_to_string(), egl_hexadecimal_to_string(), egl_renderable_type_to_string(), egl_surface_type_to_string(), eglGetConfigAttrib(), name, and value.

Referenced by fl_renderer_wayland_create_surfaces(), setup_egl_display(), setup_egl_surfaces(), and TEST().

126  {
127  struct {
128  EGLint attribute;
129  const gchar* name;
130  gchar* (*to_string)(EGLint value);
131  } config_items[] = {{
132  EGL_CONFIG_ID,
133  "EGL_CONFIG_ID",
135  },
136  {
137  EGL_BUFFER_SIZE,
138  "EGL_BUFFER_SIZE",
140  },
141  {
142  EGL_COLOR_BUFFER_TYPE,
143  "EGL_COLOR_BUFFER_TYPE",
145  },
146  {
147  EGL_TRANSPARENT_TYPE,
148  "EGL_TRANSPARENT_TYPE",
150  },
151  {
152  EGL_LEVEL,
153  "EGL_LEVEL",
155  },
156  {
157  EGL_RED_SIZE,
158  "EGL_RED_SIZE",
160  },
161  {
162  EGL_GREEN_SIZE,
163  "EGL_GREEN_SIZE",
165  },
166  {
167  EGL_BLUE_SIZE,
168  "EGL_BLUE_SIZE",
170  },
171  {
172  EGL_ALPHA_SIZE,
173  "EGL_ALPHA_SIZE",
175  },
176  {
177  EGL_DEPTH_SIZE,
178  "EGL_DEPTH_SIZE",
180  },
181  {
182  EGL_STENCIL_SIZE,
183  "EGL_STENCIL_SIZE",
185  },
186  {
187  EGL_SAMPLES,
188  "EGL_SAMPLES",
190  },
191  {
192  EGL_SAMPLE_BUFFERS,
193  "EGL_SAMPLE_BUFFERS",
195  },
196  {
197  EGL_NATIVE_VISUAL_ID,
198  "EGL_NATIVE_VISUAL_ID",
200  },
201  {
202  EGL_NATIVE_VISUAL_TYPE,
203  "EGL_NATIVE_VISUAL_TYPE",
205  },
206  {
207  EGL_NATIVE_RENDERABLE,
208  "EGL_NATIVE_RENDERABLE",
210  },
211  {
212  EGL_CONFIG_CAVEAT,
213  "EGL_CONFIG_CAVEAT",
215  },
216  {
217  EGL_BIND_TO_TEXTURE_RGB,
218  "EGL_BIND_TO_TEXTURE_RGB",
220  },
221  {
222  EGL_BIND_TO_TEXTURE_RGBA,
223  "EGL_BIND_TO_TEXTURE_RGBA",
225  },
226  {
227  EGL_RENDERABLE_TYPE,
228  "EGL_RENDERABLE_TYPE",
230  },
231  {
232  EGL_CONFORMANT,
233  "EGL_CONFORMANT",
235  },
236  {
237  EGL_SURFACE_TYPE,
238  "EGL_SURFACE_TYPE",
240  },
241  {
242  EGL_MAX_PBUFFER_WIDTH,
243  "EGL_MAX_PBUFFER_WIDTH",
245  },
246  {
247  EGL_MAX_PBUFFER_HEIGHT,
248  "EGL_MAX_PBUFFER_HEIGHT",
250  },
251  {
252  EGL_MAX_PBUFFER_PIXELS,
253  "EGL_MAX_PBUFFER_PIXELS",
255  },
256  {
257  EGL_MIN_SWAP_INTERVAL,
258  "EGL_MIN_SWAP_INTERVAL",
260  },
261  {
262  EGL_MAX_SWAP_INTERVAL,
263  "EGL_MAX_SWAP_INTERVAL",
265  },
266  {EGL_NONE, nullptr, nullptr}};
267 
268  g_autoptr(GPtrArray) strings = g_ptr_array_new_with_free_func(g_free);
269  for (int i = 0; config_items[i].attribute != EGL_NONE; i++) {
270  EGLint value;
271  if (!eglGetConfigAttrib(display, config, config_items[i].attribute, &value))
272  continue;
273  g_autofree gchar* value_string = config_items[i].to_string(value);
274  if (value_string == nullptr)
275  value_string = egl_hexadecimal_to_string(value);
276  g_ptr_array_add(
277  strings, g_strdup_printf("%s=%s", config_items[i].name, value_string));
278  }
279  g_ptr_array_add(strings, nullptr);
280 
281  return g_strjoinv(" ", reinterpret_cast<gchar**>(strings->pdata));
282 }
static gchar * egl_enum_to_string(EGLint value)
Definition: egl_utils.cc:20
EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
Definition: mock_egl.cc:153
static gchar * egl_decimal_to_string(EGLint value)
Definition: egl_utils.cc:10
uint8_t value
static gchar * egl_hexadecimal_to_string(EGLint value)
Definition: egl_utils.cc:15
static gchar * egl_renderable_type_to_string(EGLint value)
Definition: egl_utils.cc:52
const char * name
Definition: fuchsia.cc:50
static gchar * egl_surface_type_to_string(EGLint value)
Definition: egl_utils.cc:73

◆ egl_error_to_string()

G_BEGIN_DECLS const gchar* egl_error_to_string ( EGLint  error)

egl_error_to_string: : an EGL error code.

Converts an egl error code to a human readable string. e.g. "Bad Match".

Returns: an error description.

Definition at line 89 of file egl_utils.cc.

Referenced by fl_renderer_clear_current(), fl_renderer_make_current(), fl_renderer_make_resource_current(), fl_renderer_present(), fl_renderer_wayland_create_surfaces(), setup_egl_display(), setup_egl_surfaces(), and TEST().

89  {
90  switch (error) {
91  case EGL_SUCCESS:
92  return "Success";
93  case EGL_NOT_INITIALIZED:
94  return "Not Initialized";
95  case EGL_BAD_ACCESS:
96  return "Bad Access";
97  case EGL_BAD_ALLOC:
98  return "Bad Allocation";
99  case EGL_BAD_ATTRIBUTE:
100  return "Bad Attribute";
101  case EGL_BAD_CONTEXT:
102  return "Bad Context";
103  case EGL_BAD_CONFIG:
104  return "Bad Configuration";
105  case EGL_BAD_CURRENT_SURFACE:
106  return "Bad Current Surface";
107  case EGL_BAD_DISPLAY:
108  return "Bad Display";
109  case EGL_BAD_SURFACE:
110  return "Bad Surface";
111  case EGL_BAD_MATCH:
112  return "Bad Match";
113  case EGL_BAD_PARAMETER:
114  return "Bad Parameter";
115  case EGL_BAD_NATIVE_PIXMAP:
116  return "Bad Native Pixmap";
117  case EGL_BAD_NATIVE_WINDOW:
118  return "Bad Native Window";
119  case EGL_CONTEXT_LOST:
120  return "Context Lost";
121  default:
122  return "Unknown Error";
123  }
124 }
FlMethodResponse GError ** error