+/* In EGL specs 1.4 and 1.5, at the end of sections 3.5.1 and 3.5.4, it says
+ * that if native_surface was already used to create a window or pixmap, we
+ * can't create a new one. This is what this function checks for.
+ */
+static bool
+_eglNativeSurfaceAlreadyUsed(_EGLDisplay *disp, void *native_surface)
+{
+ _EGLResource *list;
+
+ list = disp->ResourceLists[_EGL_RESOURCE_SURFACE];
+ while (list) {
+ _EGLSurface *surf = (_EGLSurface *) list;
+
+ list = list->Next;
+
+ if (surf->Type == EGL_PBUFFER_BIT)
+ continue;
+
+ if (surf->NativeSurface == native_surface)
+ return true;
+ }
+
+ return false;
+}
+
+