Advertisement
Guest User

egl-platform-mir.patch

a guest
Mar 20th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 19.39 KB | None | 0 0
  1. commit 84246bcebf415b524c28ded3027b23b6a6706221
  2. Author: Christopher James Halse Rogers <raof@ubuntu.com>
  3. Date:   Thu Feb 7 16:34:17 2013 +0800
  4.  
  5.     Squash all the bzr commits for Mir into one ungovernable mess, because we no longer invest in our tooling
  6.  
  7. diff --git a/configure.ac b/configure.ac
  8. index ef6da49..1718548 100644
  9. --- a/configure.ac
  10. +++ b/configure.ac
  11. @@ -1542,7 +1542,9 @@ for plat in $egl_platforms; do
  12.  
  13.     android|gdi)
  14.         ;;
  15. -
  16. +        mir)
  17. +                PKG_CHECK_MODULES([MIR], [mirclient])
  18. +                ;;
  19.     *)
  20.         AC_MSG_ERROR([EGL platform '$plat' does not exist])
  21.         ;;
  22. @@ -1570,6 +1572,7 @@ AM_CONDITIONAL(HAVE_EGL_PLATFORM_WAYLAND, echo "$egl_platforms" | grep 'wayland'
  23.  AM_CONDITIONAL(HAVE_EGL_PLATFORM_DRM, echo "$egl_platforms" | grep 'drm' >/dev/null 2>&1)
  24.  AM_CONDITIONAL(HAVE_EGL_PLATFORM_FBDEV, echo "$egl_platforms" | grep 'fbdev' >/dev/null 2>&1)
  25.  AM_CONDITIONAL(HAVE_EGL_PLATFORM_NULL, echo "$egl_platforms" | grep 'null' >/dev/null 2>&1)
  26. +AM_CONDITIONAL(HAVE_EGL_PLATFORM_MIR, echo "$egl_platforms" | grep 'mir' >/dev/null 2>&1)
  27.  
  28.  AM_CONDITIONAL(HAVE_EGL_DRIVER_DRI2, test "x$HAVE_EGL_DRIVER_DRI2" != "x")
  29.  AM_CONDITIONAL(HAVE_EGL_DRIVER_GLX, test "x$HAVE_EGL_DRIVER_GLX" != "x")
  30. diff --git a/src/egl/drivers/dri2/Makefile.am b/src/egl/drivers/dri2/Makefile.am
  31. index 45f7dfa..dfb0c05 100644
  32. --- a/src/egl/drivers/dri2/Makefile.am
  33. +++ b/src/egl/drivers/dri2/Makefile.am
  34. @@ -62,3 +62,9 @@ if HAVE_EGL_PLATFORM_DRM
  35.  libegl_dri2_la_SOURCES += platform_drm.c
  36.  AM_CFLAGS += -DHAVE_DRM_PLATFORM
  37.  endif
  38. +
  39. +if HAVE_EGL_PLATFORM_MIR
  40. +libegl_dri2_la_SOURCES += platform_mir.c
  41. +AM_CFLAGS += -DHAVE_MIR_PLATFORM
  42. +AM_CFLAGS += $(MIR_CFLAGS)
  43. +endif
  44. diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
  45. index 351fbf4..99d8508 100644
  46. --- a/src/egl/drivers/dri2/egl_dri2.c
  47. +++ b/src/egl/drivers/dri2/egl_dri2.c
  48. @@ -587,6 +587,12 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
  49.           return EGL_TRUE;
  50.        return dri2_initialize_wayland(drv, disp);
  51.  #endif
  52. +#ifdef HAVE_MIR_PLATFORM
  53. +   case _EGL_PLATFORM_MIR:
  54. +      if (disp->Options.TestOnly)
  55. +         return EGL_TRUE;
  56. +      return dri2_initialize_mir(drv, disp);
  57. +#endif
  58.  #endif
  59.  #ifdef HAVE_ANDROID_PLATFORM
  60.     case _EGL_PLATFORM_ANDROID:
  61. diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
  62. index 84ea2a6..d82b9f8 100644
  63. --- a/src/egl/drivers/dri2/egl_dri2.h
  64. +++ b/src/egl/drivers/dri2/egl_dri2.h
  65. @@ -65,6 +65,10 @@
  66.  
  67.  #endif /* HAVE_ANDROID_PLATFORM */
  68.  
  69. +#ifdef HAVE_MIR_PLATFORM
  70. +#include <mir_client_library.h>
  71. +#endif
  72. +
  73.  #include "eglconfig.h"
  74.  #include "eglcontext.h"
  75.  #include "egldisplay.h"
  76. @@ -134,6 +138,10 @@ struct dri2_egl_display
  77.     int              formats;
  78.  #endif
  79.  
  80. +#ifdef HAVE_MIR_PLATFORM
  81. +   MirConnection            *mir_conn;
  82. +#endif
  83. +
  84.     int (*authenticate) (_EGLDisplay *disp, uint32_t id);
  85.  };
  86.  
  87. @@ -182,7 +190,9 @@ struct dri2_egl_surface
  88.     struct gbm_dri_surface *gbm_surf;
  89.  #endif
  90.  
  91. -#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
  92. +#if defined(HAVE_WAYLAND_PLATFORM) \
  93. +   || defined(HAVE_DRM_PLATFORM) \
  94. +   || defined(HAVE_MIR_PLATFORM)
  95.     __DRIbuffer           *dri_buffers[__DRI_BUFFER_COUNT];
  96.     struct {
  97.  #ifdef HAVE_WAYLAND_PLATFORM
  98. @@ -204,6 +214,10 @@ struct dri2_egl_surface
  99.     /* EGL-owned buffers */
  100.     __DRIbuffer           *local_buffers[__DRI_BUFFER_COUNT];
  101.  #endif
  102. +
  103. +#ifdef HAVE_MIR_PLATFORM
  104. +   MirSurface            *mir_surf;
  105. +#endif
  106.  };
  107.  
  108.  
  109. @@ -265,6 +279,9 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp);
  110.  EGLBoolean
  111.  dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp);
  112.  
  113. +EGLBoolean
  114. +dri2_initialize_mir(_EGLDriver *drv, _EGLDisplay *disp);
  115. +
  116.  char *
  117.  dri2_get_driver_for_fd(int fd);
  118.  char *
  119. diff --git a/src/egl/drivers/dri2/platform_mir.c b/src/egl/drivers/dri2/platform_mir.c
  120. new file mode 100644
  121. index 0000000..5782875
  122. --- /dev/null
  123. +++ b/src/egl/drivers/dri2/platform_mir.c
  124. @@ -0,0 +1,376 @@
  125. +/*
  126. + * Copyright © 2012 Canonical, Inc
  127. + *
  128. + * Permission is hereby granted, free of charge, to any person obtaining a
  129. + * copy of this software and associated documentation files (the "Software"),
  130. + * to deal in the Software without restriction, including without limitation
  131. + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  132. + * and/or sell copies of the Software, and to permit persons to whom the
  133. + * Software is furnished to do so, subject to the following conditions:
  134. + *
  135. + * The above copyright notice and this permission notice (including the next
  136. + * paragraph) shall be included in all copies or substantial portions of the
  137. + * Software.
  138. + *
  139. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  140. + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  141. + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  142. + * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  143. + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  144. + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  145. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  146. + * DEALINGS IN THE SOFTWARE.
  147. + *
  148. + * Authors:
  149. + *    Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
  150. + */
  151. +
  152. +#include <mir_client_library.h>
  153. +
  154. +#include "egl_dri2.h"
  155. +
  156. +#include <stdlib.h>
  157. +#include <string.h>
  158. +
  159. +static __DRIbuffer *
  160. +dri2_get_buffers_with_format(__DRIdrawable * driDrawable,
  161. +                int *width, int *height,
  162. +                unsigned int *attachments, int count,
  163. +                int *out_count, void *loaderPrivate)
  164. +{
  165. +   struct dri2_egl_surface *dri2_surf = loaderPrivate;
  166. +   struct dri2_egl_display *dri2_dpy =
  167. +      dri2_egl_display(dri2_surf->base.Resource.Display);
  168. +   int i;
  169. +
  170. +   dri2_surf->buffer_count = 0;
  171. +   for (i = 0; i < 2*count; i+=2) {
  172. +      assert(attachments[i] < __DRI_BUFFER_COUNT);
  173. +      assert(dri2_surf->buffer_count < 5);
  174. +
  175. +      if (dri2_surf->dri_buffers[attachments[i]] == NULL) {
  176. +         /* Our frame callback must keep these buffers valid */
  177. +         assert(attachments[i] != __DRI_BUFFER_FRONT_LEFT);
  178. +         assert(attachments[i] != __DRI_BUFFER_BACK_LEFT);
  179. +
  180. +         dri2_surf->dri_buffers[attachments[i]] =
  181. +            dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen,
  182. +                  attachments[i], attachments[i+1],
  183. +                  dri2_surf->base.Width, dri2_surf->base.Height);
  184. +
  185. +         if (!dri2_surf->dri_buffers[attachments[i]])
  186. +            continue;
  187. +      }
  188. +
  189. +      memcpy(&dri2_surf->buffers[dri2_surf->buffer_count],
  190. +             dri2_surf->dri_buffers[attachments[i]],
  191. +             sizeof(__DRIbuffer));
  192. +
  193. +      dri2_surf->buffer_count++;
  194. +   }
  195. +
  196. +   assert(dri2_surf->base.Type == EGL_PIXMAP_BIT ||
  197. +          dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]);
  198. +
  199. +   *out_count = dri2_surf->buffer_count;
  200. +   if (dri2_surf->buffer_count == 0)
  201. +      return NULL;
  202. +
  203. +   *width = dri2_surf->base.Width;
  204. +   *height = dri2_surf->base.Height;
  205. +
  206. +   return dri2_surf->buffers;
  207. +}
  208. +
  209. +static __DRIbuffer *
  210. +dri2_get_buffers(__DRIdrawable * driDrawable,
  211. +        int *width, int *height,
  212. +        unsigned int *attachments, int count,
  213. +        int *out_count, void *loaderPrivate)
  214. +{
  215. +   unsigned int *attachments_with_format;
  216. +   __DRIbuffer *buffer;
  217. +   const unsigned int format = 32;
  218. +   int i;
  219. +
  220. +   attachments_with_format = calloc(count * 2, sizeof(unsigned int));
  221. +   if (!attachments_with_format) {
  222. +      *out_count = 0;
  223. +      return NULL;
  224. +   }
  225. +
  226. +   for (i = 0; i < count; ++i) {
  227. +      attachments_with_format[2*i] = attachments[i];
  228. +      attachments_with_format[2*i + 1] = format;
  229. +   }
  230. +
  231. +   buffer =
  232. +      dri2_get_buffers_with_format(driDrawable,
  233. +                  width, height,
  234. +                  attachments_with_format, count,
  235. +                  out_count, loaderPrivate);
  236. +
  237. +   free(attachments_with_format);
  238. +
  239. +   return buffer;
  240. +}
  241. +
  242. +
  243. +static void
  244. +dri2_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
  245. +{
  246. +   (void) driDrawable;
  247. +
  248. +   /* FIXME: Does EGL support front buffer rendering at all? */
  249. +
  250. +#if 0
  251. +   struct dri2_egl_surface *dri2_surf = loaderPrivate;
  252. +
  253. +   dri2WaitGL(dri2_surf);
  254. +#else
  255. +   (void) loaderPrivate;
  256. +#endif
  257. +}
  258. +
  259. +static void
  260. +mir_copy_back_to_front(struct dri2_egl_surface *surf)
  261. +{
  262. +   memcpy(surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT],
  263. +          surf->dri_buffers[__DRI_BUFFER_BACK_LEFT],
  264. +          sizeof(*surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]));
  265. +
  266. +   surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT]->attachment =
  267. +      __DRI_BUFFER_FRONT_LEFT;
  268. +}
  269. +
  270. +static void
  271. +mir_populate_colour_buffers(struct dri2_egl_surface *surf)
  272. +{
  273. +   MirBufferPackage buffer_package;
  274. +  
  275. +   mir_surface_get_current_buffer(surf->mir_surf, &buffer_package);
  276. +   /* We expect [name, pitch] in our buffer */
  277. +   assert(buffer_package.data_items == 1);
  278. +
  279. +   /* Frontbuffer hack; Mir doesn't give us access to the front buffer */
  280. +   mir_copy_back_to_front(surf);
  281. +
  282. +   surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]->name = buffer_package.data[0];
  283. +   /* Man, I hope that Intel's just being funky when they multiply pitch by
  284. +      cpp */
  285. +   surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]->pitch = buffer_package.stride;
  286. +}
  287. +
  288. +/**
  289. + * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
  290. + */
  291. +static _EGLSurface *
  292. +dri2_create_mir_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
  293. +                               _EGLConfig *conf, EGLNativeWindowType window,
  294. +                               const EGLint *attrib_list)
  295. +{
  296. +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
  297. +   struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
  298. +   struct dri2_egl_surface *dri2_surf;
  299. +   MirSurfaceParameters surf_params;
  300. +
  301. +   (void) drv;
  302. +
  303. +   dri2_surf = calloc(1, sizeof *dri2_surf);
  304. +   if (!dri2_surf) {
  305. +      _eglError(EGL_BAD_ALLOC, "dri2_create_surface");
  306. +      return NULL;
  307. +   }
  308. +  
  309. +   if (!_eglInitSurface(&dri2_surf->base, disp, EGL_WINDOW_BIT, conf, attrib_list))
  310. +      goto cleanup_surf;
  311. +
  312. +   dri2_surf->mir_surf = (MirSurface *)window;
  313. +   mir_surface_get_parameters(dri2_surf->mir_surf, &surf_params);
  314. +   dri2_surf->base.Width = surf_params.width;
  315. +   dri2_surf->base.Height = surf_params.height;
  316. +
  317. +   dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT] =
  318. +      calloc(sizeof(*dri2_surf->dri_buffers[0]), 1);
  319. +   dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT] =
  320. +      calloc(sizeof(*dri2_surf->dri_buffers[0]), 1);
  321. +  
  322. +   dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]->attachment =
  323. +      __DRI_BUFFER_BACK_LEFT;
  324. +   /* We only do ARGB 8888 for the moment */
  325. +   dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]->cpp = 4;
  326. +
  327. +   mir_populate_colour_buffers(dri2_surf);
  328. +   /* Hack: this is not actually the front buffer, but we can't get it */
  329. +   mir_copy_back_to_front(dri2_surf);
  330. +
  331. +   dri2_surf->dri_drawable =
  332. +      (*dri2_dpy->dri2->createNewDrawable) (dri2_dpy->dri_screen,
  333. +                                            dri2_conf->dri_double_config,
  334. +                                            dri2_surf);
  335. +
  336. +   if (dri2_surf->dri_drawable == NULL) {
  337. +      _eglError(EGL_BAD_ALLOC, "dri2->createNewDrawable");
  338. +   }
  339. +  
  340. +   return &dri2_surf->base;
  341. +
  342. +cleanup_surf:
  343. +   free(dri2_surf);
  344. +   return NULL;
  345. +}
  346. +
  347. +static EGLBoolean
  348. +dri2_destroy_mir_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
  349. +{
  350. +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
  351. +   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
  352. +   int i;
  353. +
  354. +   (void) drv;
  355. +
  356. +   if (!_eglPutSurface(surf))
  357. +      return EGL_TRUE;
  358. +
  359. +   (*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable);
  360. +
  361. +   for (i = 0; i < __DRI_BUFFER_COUNT; ++i) {
  362. +      if (dri2_surf->dri_buffers[i] && !((i == __DRI_BUFFER_FRONT_LEFT) ||
  363. +                                         (i == __DRI_BUFFER_BACK_LEFT))) {
  364. +         dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
  365. +                                       dri2_surf->dri_buffers[i]);
  366. +      }
  367. +   }
  368. +
  369. +   free(surf);
  370. +
  371. +   return EGL_TRUE;
  372. +}
  373. +
  374. +static void
  375. +surface_callback(MirSurface *surface, void *ctx)
  376. +{
  377. +   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(ctx);
  378. +
  379. +}
  380. +
  381. +/**
  382. + * Called via eglSwapBuffers(), drv->API.SwapBuffers().
  383. + */
  384. +static EGLBoolean
  385. +dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
  386. +{
  387. +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
  388. +   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
  389. +   struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
  390. +
  391. +   mir_wait_for(mir_surface_next_buffer(dri2_surf->mir_surf, surface_callback, dri2_surf));
  392. +
  393. +   mir_populate_colour_buffers(dri2_surf);
  394. +
  395. +   (*dri2_dpy->flush->flush)(dri2_surf->dri_drawable);
  396. +   (*dri2_dpy->flush->invalidate)(dri2_surf->dri_drawable);
  397. +
  398. +   return EGL_TRUE;
  399. +}
  400. +
  401. +static void connection_callback(MirConnection *conn, void *context)
  402. +{
  403. +   struct dri2_egl_display *dri2_dpy = context;
  404. +
  405. +   dri2_dpy->mir_conn = conn;
  406. +}
  407. +
  408. +static int
  409. +dri2_mir_authenticate(_EGLDisplay *disp, uint32_t id)
  410. +{
  411. +   return 0;
  412. +}
  413. +
  414. +EGLBoolean
  415. +dri2_initialize_mir(_EGLDriver *drv, _EGLDisplay *disp)
  416. +{
  417. +   struct dri2_egl_display *dri2_dpy;
  418. +   MirPlatformPackage platform;
  419. +   const __DRIconfig *config;
  420. +   static const unsigned int argb_masks[4] =
  421. +      { 0xff0000, 0xff00, 0xff, 0xff000000 };
  422. +   uint32_t types;
  423. +   int i;
  424. +
  425. +   drv->API.CreateWindowSurface = dri2_create_mir_window_surface;
  426. +   drv->API.DestroySurface = dri2_destroy_mir_surface;
  427. +   drv->API.SwapBuffers = dri2_swap_buffers;
  428. +/*   drv->API.CreatePixmapSurface = dri2_create_pixmap_surface;
  429. +   drv->API.CreatePbufferSurface = dri2_create_pbuffer_surface;
  430. +   drv->API.CopyBuffers = dri2_copy_buffers;
  431. +   drv->API.CreateImageKHR = dri2_x11_create_image_khr;
  432. +   drv->API.SwapInterval = dri2_swap_interval;
  433. +*/
  434. +
  435. +   dri2_dpy = calloc(1, sizeof *dri2_dpy);
  436. +   if (!dri2_dpy)
  437. +      return _eglError(EGL_BAD_ALLOC, "eglInitialize");
  438. +
  439. +   disp->DriverData = (void *) dri2_dpy;
  440. +   if (disp->PlatformDisplay == NULL) {
  441. +      mir_wait_for(mir_connect("some_socket_file", "EGL Client",
  442. +                               connection_callback, dri2_dpy));
  443. +   } else {
  444. +      dri2_dpy->mir_conn = (MirConnection *)disp->PlatformDisplay;
  445. +   }
  446. +
  447. +   if (!mir_connection_is_valid(dri2_dpy->mir_conn)) {
  448. +      _eglLog(_EGL_WARNING, "DRI2: mir_connect failed: %s",
  449. +              mir_connection_get_error_message(dri2_dpy->mir_conn));
  450. +      goto cleanup_dpy;
  451. +   }
  452. +
  453. +   mir_connection_get_platform(dri2_dpy->mir_conn, &platform);
  454. +   dri2_dpy->fd = platform.fd[0];
  455. +   dri2_dpy->driver_name = dri2_get_driver_for_fd(dri2_dpy->fd);
  456. +   dri2_dpy->device_name = dri2_get_device_name_for_fd(dri2_dpy->fd);
  457. +
  458. +   if (dri2_dpy->driver_name == NULL ||
  459. +       dri2_dpy->device_name == NULL)
  460. +      goto cleanup_conn;
  461. +
  462. +   if (!dri2_load_driver(disp))
  463. +      goto cleanup_conn;
  464. +
  465. +   dri2_dpy->dri2_loader_extension.base.name = __DRI_DRI2_LOADER;
  466. +   dri2_dpy->dri2_loader_extension.base.version = 3;
  467. +   dri2_dpy->dri2_loader_extension.getBuffers = dri2_get_buffers;
  468. +   dri2_dpy->dri2_loader_extension.flushFrontBuffer = dri2_flush_front_buffer;
  469. +   dri2_dpy->dri2_loader_extension.getBuffersWithFormat =
  470. +      dri2_get_buffers_with_format;
  471. +      
  472. +   dri2_dpy->extensions[0] = &dri2_dpy->dri2_loader_extension.base;
  473. +   dri2_dpy->extensions[1] = &image_lookup_extension.base;
  474. +   dri2_dpy->extensions[2] = &use_invalidate.base;
  475. +   dri2_dpy->extensions[3] = NULL;
  476. +
  477. +   if (!dri2_create_screen(disp))
  478. +      goto cleanup_conn;
  479. +
  480. +   types = EGL_WINDOW_BIT;
  481. +   for (i = 0; dri2_dpy->driver_configs[i]; i++) {
  482. +      config = dri2_dpy->driver_configs[i];
  483. +      dri2_add_config(disp, config, i + 1, 0, types, NULL, argb_masks);
  484. +   }
  485. +
  486. +   dri2_dpy->authenticate = dri2_mir_authenticate;
  487. +
  488. +   disp->VersionMajor = 1;
  489. +   disp->VersionMinor = 4;
  490. +
  491. +   return EGL_TRUE;
  492. +
  493. + cleanup_conn:
  494. +   if (disp->PlatformDisplay == NULL)
  495. +      mir_connection_release(dri2_dpy->mir_conn);
  496. + cleanup_dpy:
  497. +   free(dri2_dpy);
  498. +
  499. +   return EGL_FALSE;
  500. +}
  501. diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am
  502. index ca5257a..64af1fd 100644
  503. --- a/src/egl/main/Makefile.am
  504. +++ b/src/egl/main/Makefile.am
  505. @@ -103,6 +103,12 @@ if HAVE_EGL_PLATFORM_NULL
  506.  AM_CFLAGS += -DHAVE_NULL_PLATFORM
  507.  endif
  508.  
  509. +if HAVE_EGL_PLATFORM_MIR
  510. +AM_CFLAGS += -DHAVE_MIR_PLATFORM
  511. +AM_CFLAGS += $(MIR_CFLAGS)
  512. +libEGL_la_LIBADD += $(MIR_LIBS)
  513. +endif
  514. +
  515.  if HAVE_EGL_DRIVER_GLX
  516.  AM_CFLAGS += -D_EGL_BUILT_IN_DRIVER_GLX
  517.  libEGL_la_LIBADD += ../drivers/glx/libegl_glx.la
  518. diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
  519. index 985e781..da8136c 100644
  520. --- a/src/egl/main/egldisplay.c
  521. +++ b/src/egl/main/egldisplay.c
  522. @@ -59,7 +59,9 @@
  523.  #include <sys/types.h>
  524.  #include <sys/stat.h>
  525.  #endif
  526. -
  527. +#ifdef HAVE_MIR_PLATFORM
  528. +#include <mir_client_library.h>
  529. +#endif
  530.  
  531.  /**
  532.   * Map --with-egl-platforms names to platform types.
  533. @@ -74,7 +76,8 @@ static const struct {
  534.     { _EGL_PLATFORM_DRM, "drm" },
  535.     { _EGL_PLATFORM_FBDEV, "fbdev" },
  536.     { _EGL_PLATFORM_NULL, "null" },
  537. -   { _EGL_PLATFORM_ANDROID, "android" }
  538. +   { _EGL_PLATFORM_ANDROID, "android" },
  539. +   { _EGL_PLATFORM_MIR, "mir" },
  540.  };
  541.  
  542.  
  543. @@ -154,6 +157,11 @@ _eglNativePlatformDetectNativeDisplay(EGLNativeDisplayType nativeDisplay)
  544.        return _EGL_PLATFORM_FBDEV;
  545.  #endif
  546.  
  547. +#ifdef HAVE_MIR_PLATFORM
  548. +   if (mir_connection_is_valid(nativeDisplay))
  549. +      return _EGL_PLATFORM_MIR;
  550. +#endif
  551. +
  552.     if (_eglPointerIsDereferencable(nativeDisplay)) {
  553.        void *first_pointer = *(void **) nativeDisplay;
  554.  
  555. diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
  556. index 4b33470..3999d22 100644
  557. --- a/src/egl/main/egldisplay.h
  558. +++ b/src/egl/main/egldisplay.h
  559. @@ -46,6 +46,7 @@ enum _egl_platform_type {
  560.     _EGL_PLATFORM_FBDEV,
  561.     _EGL_PLATFORM_NULL,
  562.     _EGL_PLATFORM_ANDROID,
  563. +   _EGL_PLATFORM_MIR,
  564.  
  565.     _EGL_NUM_PLATFORMS,
  566.     _EGL_INVALID_PLATFORM = -1
  567. diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
  568. index 519929e..a157bae 100644
  569. --- a/src/gbm/backends/dri/gbm_dri.c
  570. +++ b/src/gbm/backends/dri/gbm_dri.c
  571. @@ -44,6 +44,8 @@
  572.  #include "gbm_driint.h"
  573.  
  574.  #include "gbmint.h"
  575. +#include <xf86drm.h>
  576. +
  577.  
  578.  /* For importing wl_buffer */
  579.  #if HAVE_WAYLAND_PLATFORM
  580. @@ -281,9 +283,11 @@ gbm_dri_is_format_supported(struct gbm_device *gbm,
  581.     switch (format) {
  582.     case GBM_BO_FORMAT_XRGB8888:
  583.     case GBM_FORMAT_XRGB8888:
  584. +   case GBM_FORMAT_XBGR8888:
  585.        break;
  586.     case GBM_BO_FORMAT_ARGB8888:
  587.     case GBM_FORMAT_ARGB8888:
  588. +   case GBM_FORMAT_ABGR8888:
  589.        if (usage & GBM_BO_USE_SCANOUT)
  590.           return 0;
  591.        break;
  592. @@ -348,6 +352,9 @@ gbm_dri_to_gbm_format(uint32_t dri_format)
  593.     case __DRI_IMAGE_FORMAT_ABGR8888:
  594.        ret = GBM_FORMAT_ABGR8888;
  595.        break;
  596. +   case __DRI_IMAGE_FORMAT_XBGR8888:
  597. +      ret = GBM_FORMAT_XBGR8888;
  598. +      break;
  599.     default:
  600.        ret = 0;
  601.        break;
  602. @@ -545,10 +552,15 @@ gbm_dri_bo_create(struct gbm_device *gbm,
  603.     case GBM_FORMAT_ABGR8888:
  604.        dri_format = __DRI_IMAGE_FORMAT_ABGR8888;
  605.        break;
  606. +   case GBM_FORMAT_XBGR8888:
  607. +      dri_format = __DRI_IMAGE_FORMAT_XBGR8888;
  608. +      break;
  609.     default:
  610.        return NULL;
  611.     }
  612.  
  613. +   bo->base.base.format = gbm_dri_to_gbm_format(dri_format);
  614. +
  615.     if (usage & GBM_BO_USE_SCANOUT)
  616.        dri_use |= __DRI_IMAGE_USE_SCANOUT;
  617.     if (usage & GBM_BO_USE_CURSOR_64X64)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement