Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2017
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.09 KB | None | 0 0
  1. diff -r d716dff4b13e configure.in
  2. --- a/configure.in Thu Dec 02 11:56:23 2010 -0800
  3. +++ b/configure.in Sun Dec 05 09:18:37 2010 -0800
  4. @@ -1002,6 +1002,19 @@
  5. }
  6.  
  7.  
  8. +dnl Find wayland stuff
  9. +CheckWayland()
  10. +{
  11. + AC_ARG_ENABLE(video-wayland,
  12. +AC_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]),
  13. + , enable_video_wayland=yes)
  14. + if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
  15. + AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND)
  16. + SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
  17. + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L/home/joel/install/lib -lwayland-client -ldrm -lEGL -lcairo"
  18. + fi
  19. +}
  20. +
  21. dnl Find the X11 include and library directories
  22. CheckX11()
  23. {
  24. @@ -2270,6 +2283,7 @@
  25. CheckESD
  26. CheckNAS
  27. CheckX11
  28. + CheckWayland
  29. CheckFBCON
  30. CheckDirectFB
  31. CheckFusionSound
  32. diff -r d716dff4b13e include/SDL_config.h.in
  33. --- a/include/SDL_config.h.in Thu Dec 02 11:56:23 2010 -0800
  34. +++ b/include/SDL_config.h.in Sun Dec 05 09:18:37 2010 -0800
  35. @@ -267,6 +267,7 @@
  36. #undef SDL_VIDEO_DRIVER_RISCOS
  37. #undef SDL_VIDEO_DRIVER_SVGALIB
  38. #undef SDL_VIDEO_DRIVER_WIN32
  39. +#undef SDL_VIDEO_DRIVER_WAYLAND
  40. #undef SDL_VIDEO_DRIVER_X11
  41. #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
  42. #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
  43. diff -r d716dff4b13e src/video/SDL_sysvideo.h
  44. --- a/src/video/SDL_sysvideo.h Thu Dec 02 11:56:23 2010 -0800
  45. +++ b/src/video/SDL_sysvideo.h Sun Dec 05 09:18:37 2010 -0800
  46. @@ -453,6 +453,9 @@
  47. #if SDL_VIDEO_DRIVER_ANDROID
  48. extern VideoBootStrap Android_bootstrap;
  49. #endif
  50. +#if SDL_VIDEO_DRIVER_WAYLAND
  51. +extern VideoBootStrap Wayland_bootstrap;
  52. +#endif
  53.  
  54. #define SDL_CurrentDisplay (&_this->displays[_this->current_display])
  55. #define SDL_CurrentRenderer (SDL_CurrentDisplay->current_renderer)
  56. diff -r d716dff4b13e src/video/SDL_video.c
  57. --- a/src/video/SDL_video.c Thu Dec 02 11:56:23 2010 -0800
  58. +++ b/src/video/SDL_video.c Sun Dec 05 09:18:37 2010 -0800
  59. @@ -107,6 +107,9 @@
  60. #if SDL_VIDEO_DRIVER_ANDROID
  61. &Android_bootstrap,
  62. #endif
  63. +#if SDL_VIDEO_DRIVER_WAYLAND
  64. + &Wayland_bootstrap,
  65. +#endif
  66. NULL
  67. };
  68.  
  69. diff -r d716dff4b13e src/video/wayland/SDL_waylandevents.c
  70. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  71. +++ b/src/video/wayland/SDL_waylandevents.c Sun Dec 05 09:18:37 2010 -0800
  72. @@ -0,0 +1,39 @@
  73. +/*
  74. + SDL - Simple DirectMedia Layer
  75. + Copyright (C) 1997-2010 Sam Lantinga
  76. +
  77. + This library is free software; you can redistribute it and/or
  78. + modify it under the terms of the GNU Lesser General Public
  79. + License as published by the Free Software Foundation; either
  80. + version 2.1 of the License, or (at your option) any later version.
  81. +
  82. + This library is distributed in the hope that it will be useful,
  83. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  84. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  85. + Lesser General Public License for more details.
  86. +
  87. + You should have received a copy of the GNU Lesser General Public
  88. + License along with this library; if not, write to the Free Software
  89. + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  90. +
  91. + Sam Lantinga
  92. + slouken@libsdl.org
  93. +*/
  94. +#include "SDL_config.h"
  95. +
  96. +/* Being a null driver, there's no event stream. We just define stubs for
  97. + most of the API. */
  98. +
  99. +#include "../../events/SDL_sysevents.h"
  100. +#include "../../events/SDL_events_c.h"
  101. +
  102. +#include "SDL_waylandvideo.h"
  103. +#include "SDL_waylandevents_c.h"
  104. +
  105. +void
  106. +Wayland_PumpEvents(_THIS)
  107. +{
  108. + /* do nothing. */
  109. +}
  110. +
  111. +/* vi: set ts=4 sw=4 expandtab: */
  112. diff -r d716dff4b13e src/video/wayland/SDL_waylandevents_c.h
  113. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  114. +++ b/src/video/wayland/SDL_waylandevents_c.h Sun Dec 05 09:18:37 2010 -0800
  115. @@ -0,0 +1,28 @@
  116. +/*
  117. + SDL - Simple DirectMedia Layer
  118. + Copyright (C) 1997-2010 Sam Lantinga
  119. +
  120. + This library is free software; you can redistribute it and/or
  121. + modify it under the terms of the GNU Lesser General Public
  122. + License as published by the Free Software Foundation; either
  123. + version 2.1 of the License, or (at your option) any later version.
  124. +
  125. + This library is distributed in the hope that it will be useful,
  126. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  127. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  128. + Lesser General Public License for more details.
  129. +
  130. + You should have received a copy of the GNU Lesser General Public
  131. + License along with this library; if not, write to the Free Software
  132. + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  133. +
  134. + Sam Lantinga
  135. + slouken@libsdl.org
  136. +*/
  137. +#include "SDL_config.h"
  138. +
  139. +#include "SDL_waylandvideo.h"
  140. +
  141. +extern void Wayland_PumpEvents(_THIS);
  142. +
  143. +/* vi: set ts=4 sw=4 expandtab: */
  144. diff -r d716dff4b13e src/video/wayland/SDL_waylandgl.c
  145. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  146. +++ b/src/video/wayland/SDL_waylandgl.c Sun Dec 05 09:18:37 2010 -0800
  147. @@ -0,0 +1,191 @@
  148. +#include "SDL_config.h"
  149. +
  150. +#include "SDL_waylandgl.h"
  151. +#include "SDL_waylandwindow.h"
  152. +
  153. +
  154. +void Wayland_GL_SwapWindow(_THIS, SDL_Window * window)
  155. +{
  156. + printf("Wayland_GL_SwapWindow\n");
  157. + SDL_WaylandWindow *data = window->driverdata;
  158. + data->current ^= 1;
  159. +
  160. + glFramebufferRenderbuffer(GL_FRAMEBUFFER,
  161. + GL_COLOR_ATTACHMENT0,
  162. + GL_RENDERBUFFER,
  163. + data->rbo[data->current]);
  164. +
  165. + wl_surface_attach(data->surface,
  166. + data->buffer[data->current ^ 1]);
  167. + wl_surface_damage(data->surface, 0, 0,
  168. + window->w, window->h);
  169. +}
  170. +
  171. +int
  172. +Wayland_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
  173. +{
  174. + printf("Wayland_GL_MakeCurrent\n");
  175. + SDL_WaylandData *data = _this->driverdata;
  176. + SDL_WaylandWindow *wind = (SDL_WaylandWindow *) window->driverdata;
  177. + if (!eglMakeCurrent(data->edpy,EGL_NO_SURFACE,
  178. + EGL_NO_SURFACE,wind->context)) {
  179. + SDL_SetError("Unable to make EGL context current");
  180. + return -1;
  181. + }
  182. +
  183. + return 1;
  184. +}
  185. +
  186. +int
  187. +Wayland_GL_LoadLibrary(_THIS, const char *path)
  188. +{
  189. +/* void *handle;
  190. + int dlopen_flags;
  191. +
  192. + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
  193. +
  194. + if (_this->gles_data->egl_active) {
  195. + SDL_SetError("OpenGL ES context already created");
  196. + return -1;
  197. + }
  198. +#ifdef RTLD_GLOBAL
  199. + dlopen_flags = RTLD_LAZY | RTLD_GLOBAL;
  200. +#else
  201. + dlopen_flags = RTLD_LAZY;
  202. +#endif
  203. + handle = dlopen(path, dlopen_flags);
  204. + /* Catch the case where the application isn't linked with EGL *//*
  205. + if ((dlsym(handle, "eglChooseConfig") == NULL) && (path == NULL)) {
  206. +
  207. + dlclose(handle);
  208. + path = getenv("SDL_VIDEO_GL_DRIVER");
  209. + if (path == NULL) {
  210. + path = DEFAULT_OPENGL;
  211. + }
  212. + handle = dlopen(path, dlopen_flags);
  213. + }
  214. +
  215. + if (handle == NULL) {
  216. + SDL_SetError("Could not load OpenGL ES/EGL library");
  217. + return -1;
  218. + }
  219. +
  220. + /* Unload the old driver and reset the pointers *//*
  221. + Wayland_GL_UnloadLibrary(_this);
  222. +
  223. +
  224. +
  225. + _this->gles_data->egl_display =
  226. + _this->gles_data->eglGetDisplay((NativeDisplayType) data->display);
  227. +
  228. + if (!_this->gles_data->egl_display) {
  229. + SDL_SetError("Could not get EGL display");
  230. + return -1;
  231. + }
  232. +
  233. + if (eglInitialize(_this->gles_data->egl_display, NULL,
  234. + NULL) != EGL_TRUE) {
  235. + SDL_SetError("Could not initialize EGL");
  236. + return -1;
  237. + }
  238. +
  239. + _this->gl_config.dll_handle = handle;
  240. + _this->gl_config.driver_loaded = 1;
  241. +
  242. + if (path) {
  243. + strncpy(_this->gl_config.driver_path, path,
  244. + sizeof(_this->gl_config.driver_path) - 1);
  245. + } else {
  246. + strcpy(_this->gl_config.driver_path, "");
  247. + }*/
  248. + SDL_WaylandData *data = _this->driverdata;
  249. +
  250. + data->edpy = eglGetDRMDisplayMESA(data->drm_fd);
  251. +
  252. + int major, minor;
  253. + if (!eglInitialize(data->edpy, &major, &minor)) {
  254. + fprintf(stderr, "failed to initialize display\n");
  255. + return -1;
  256. + }
  257. +
  258. +/* if (!eglBindAPI(EGL_OPENGL_ES_API)) {
  259. + fprintf(stderr, "failed to bind EGL_OPENGL_ES_API\n");
  260. + return -1;
  261. + }
  262. +
  263. + data->context = eglCreateContext(data->edpy, NULL,
  264. + EGL_NO_CONTEXT, context_attribs);
  265. + if (data->context == NULL) {
  266. + fprintf(stderr, "failed to create context\n");
  267. + return -1;
  268. + }
  269. +
  270. + if (!eglMakeCurrent(data->edpy, EGL_NO_SURFACE,
  271. + EGL_NO_SURFACE, data->context)) {
  272. + fprintf(stderr, "failed to make context current\n");
  273. + return -1;
  274. + }*/
  275. + return 0;
  276. +}
  277. +
  278. +void
  279. +Wayland_GL_UnloadLibrary(_THIS)
  280. +{
  281. + /*if (_this->gl_config.driver_loaded) {
  282. + _this->gles_data->eglTerminate(_this->gles_data->egl_display);
  283. +
  284. + dlclose(_this->gl_config.dll_handle);
  285. +
  286. + _this->gles_data->eglGetProcAddress = NULL;
  287. + _this->gles_data->eglChooseConfig = NULL;
  288. + _this->gles_data->eglCreateContext = NULL;
  289. + _this->gles_data->eglCreateWindowSurface = NULL;
  290. + _this->gles_data->eglDestroyContext = NULL;
  291. + _this->gles_data->eglDestroySurface = NULL;
  292. + _this->gles_data->eglMakeCurrent = NULL;
  293. + _this->gles_data->eglSwapBuffers = NULL;
  294. + _this->gles_data->eglGetDisplay = NULL;
  295. + _this->gles_data->eglTerminate = NULL;
  296. +
  297. + _this->gl_config.dll_handle = NULL;
  298. + _this->gl_config.driver_loaded = 0;
  299. + }*/
  300. +}
  301. +
  302. +SDL_GLContext
  303. +Wayland_GL_CreateContext(_THIS, SDL_Window * window)
  304. +{
  305. + SDL_WaylandData *data = _this->driverdata;
  306. + SDL_WaylandWindow *wind = (SDL_WaylandWindow *) window->driverdata;
  307. + //Display *display = data->videodata->display;
  308. +
  309. +
  310. + static const EGLint context_attribs[] = {
  311. + EGL_CONTEXT_CLIENT_VERSION, 2,
  312. + EGL_NONE
  313. + };
  314. + wind->context = eglCreateContext(data->edpy, NULL, EGL_NO_CONTEXT, context_attribs);
  315. +
  316. +
  317. + if (wind->context == EGL_NO_CONTEXT) {
  318. + SDL_SetError("Could not create EGL context");
  319. + return NULL;
  320. + }
  321. +
  322. + //data->egl_active = 1;
  323. +
  324. +
  325. + return 1;
  326. +}
  327. +
  328. +int
  329. +Wayland_GL_SetSwapInterval(_THIS, int interval)
  330. +{
  331. + return 0;
  332. +}
  333. +
  334. +int
  335. +Wayland_GL_GetSwapInterval(_THIS)
  336. +{
  337. + return 0;
  338. +}
  339. diff -r d716dff4b13e src/video/wayland/SDL_waylandgl.h
  340. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  341. +++ b/src/video/wayland/SDL_waylandgl.h Sun Dec 05 09:18:37 2010 -0800
  342. @@ -0,0 +1,15 @@
  343. +#include "SDL_config.h"
  344. +
  345. +#ifndef _SDL_waylandgl_h
  346. +#define _SDL_waylandgl_h
  347. +#include "SDL_waylandwindow.h"
  348. +#include </home/joel/install/include/wayland-client-protocol.h>
  349. +
  350. +void Wayland_GL_SwapWindow(_THIS, SDL_Window * window);
  351. +int Wayland_GL_GetSwapInterval(_THIS);
  352. +int Wayland_GL_SetSwapInterval(_THIS, int interval);
  353. +int Wayland_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
  354. +SDL_GLContext Wayland_GL_CreateContext(_THIS, SDL_Window * window);
  355. +int Wayland_GL_LoadLibrary(_THIS, const char *path);
  356. +void Wayland_GL_UnloadLibrary(_THIS);
  357. +#endif
  358. diff -r d716dff4b13e src/video/wayland/SDL_waylandrender.c
  359. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  360. +++ b/src/video/wayland/SDL_waylandrender.c Sun Dec 05 09:18:37 2010 -0800
  361. @@ -0,0 +1,349 @@
  362. +/*
  363. + SDL - Simple DirectMedia Layer
  364. + Copyright (C) 1997-2010 Sam Lantinga
  365. +
  366. + This library is free software; you can redistribute it and/or
  367. + modify it under the terms of the GNU Lesser General Public
  368. + License as published by the Free Software Foundation; either
  369. + version 2.1 of the License, or (at your option) any later version.
  370. +
  371. + This library is distributed in the hope that it will be useful,
  372. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  373. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  374. + Lesser General Public License for more details.
  375. +
  376. + You should have received a copy of the GNU Lesser General Public
  377. + License along with this library; if not, write to the Free Software
  378. + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  379. +
  380. + Sam Lantinga
  381. + slouken@libsdl.org
  382. +*/
  383. +#include "SDL_config.h"
  384. +
  385. +#include "SDL_video.h"
  386. +#include "../SDL_sysvideo.h"
  387. +#include "../SDL_yuv_sw_c.h"
  388. +#include "../SDL_renderer_sw.h"
  389. +
  390. +
  391. +/* SDL surface based renderer implementation */
  392. +
  393. +static SDL_Renderer *SDL_Wayland_CreateRenderer(SDL_Window * window,
  394. + Uint32 flags);
  395. +static int SDL_Wayland_RenderDrawPoints(SDL_Renderer * renderer,
  396. + const SDL_Point * points, int count);
  397. +static int SDL_Wayland_RenderDrawLines(SDL_Renderer * renderer,
  398. + const SDL_Point * points, int count);
  399. +static int SDL_Wayland_RenderDrawRects(SDL_Renderer * renderer,
  400. + const SDL_Rect ** rects, int count);
  401. +static int SDL_Wayland_RenderFillRects(SDL_Renderer * renderer,
  402. + const SDL_Rect ** rects, int count);
  403. +static int SDL_Wayland_RenderCopy(SDL_Renderer * renderer,
  404. + SDL_Texture * texture,
  405. + const SDL_Rect * srcrect,
  406. + const SDL_Rect * dstrect);
  407. +static int SDL_Wayland_RenderReadPixels(SDL_Renderer * renderer,
  408. + const SDL_Rect * rect,
  409. + Uint32 format,
  410. + void * pixels, int pitch);
  411. +static int SDL_Wayland_RenderWritePixels(SDL_Renderer * renderer,
  412. + const SDL_Rect * rect,
  413. + Uint32 format,
  414. + const void * pixels, int pitch);
  415. +static void SDL_Wayland_RenderPresent(SDL_Renderer * renderer);
  416. +static void SDL_Wayland_DestroyRenderer(SDL_Renderer * renderer);
  417. +static int *SDL_Wayland_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
  418. +
  419. +SDL_RenderDriver SDL_Wayland_RenderDriver = {
  420. + SDL_Wayland_CreateRenderer,
  421. + {
  422. + "Wayland",
  423. + (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
  424. + SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
  425. + SDL_RENDERER_PRESENTDISCARD),
  426. + }
  427. +};
  428. +
  429. +typedef struct
  430. +{
  431. + int current_screen;
  432. + SDL_Surface *screens[3];
  433. +} SDL_Wayland_RenderData;
  434. +
  435. +SDL_Renderer *
  436. +SDL_Wayland_CreateRenderer(SDL_Window * window, Uint32 flags)
  437. +{
  438. + SDL_VideoDisplay *display = window->display;
  439. + SDL_DisplayMode *displayMode = &display->current_mode;
  440. + SDL_Renderer *renderer;
  441. + SDL_Wayland_RenderData *data;
  442. + int i, n;
  443. + int bpp;
  444. + Uint32 Rmask, Gmask, Bmask, Amask;
  445. +
  446. + if (!SDL_PixelFormatEnumToMasks
  447. + (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
  448. + SDL_SetError("Unknown display format");
  449. + return NULL;
  450. + }
  451. +
  452. + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
  453. + if (!renderer) {
  454. + SDL_OutOfMemory();
  455. + return NULL;
  456. + }
  457. +
  458. + data = (SDL_Wayland_RenderData *) SDL_malloc(sizeof(*data));
  459. + if (!data) {
  460. + SDL_Wayland_DestroyRenderer(renderer);
  461. + SDL_OutOfMemory();
  462. + return NULL;
  463. + }
  464. + SDL_zerop(data);
  465. +
  466. + renderer->RenderDrawPoints = SDL_Wayland_RenderDrawPoints;
  467. + renderer->RenderDrawLines = SDL_Wayland_RenderDrawLines;
  468. + renderer->RenderDrawRects = SDL_Wayland_RenderDrawRects;
  469. + renderer->RenderFillRects = SDL_Wayland_RenderFillRects;
  470. + renderer->RenderCopy = SDL_Wayland_RenderCopy;
  471. + renderer->RenderReadPixels = SDL_Wayland_RenderReadPixels;
  472. + renderer->RenderWritePixels = SDL_Wayland_RenderWritePixels;
  473. + renderer->RenderPresent = SDL_Wayland_RenderPresent;
  474. + renderer->DestroyRenderer = SDL_Wayland_DestroyRenderer;
  475. + //renderer->CreateTexture = SDL_Wayland_CreateTexture;
  476. + renderer->info.name = SDL_Wayland_RenderDriver.info.name;
  477. + renderer->info.flags = 0;
  478. + renderer->window = window;
  479. + renderer->driverdata = data;
  480. + Setup_SoftwareRenderer(renderer);
  481. +
  482. + if (flags & SDL_RENDERER_PRESENTFLIP2) {
  483. + renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
  484. + n = 2;
  485. + } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
  486. + renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
  487. + n = 3;
  488. + } else {
  489. + renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
  490. + n = 1;
  491. + }
  492. + for (i = 0; i < n; ++i) {
  493. + data->screens[i] =
  494. + SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
  495. + Bmask, Amask);
  496. + if (!data->screens[i]) {
  497. + SDL_Wayland_DestroyRenderer(renderer);
  498. + return NULL;
  499. + }
  500. + SDL_SetSurfacePalette(data->screens[i], display->palette);
  501. + }
  502. + data->current_screen = 0;
  503. +
  504. + return renderer;
  505. +}
  506. +
  507. +static int
  508. +SDL_Wayland_RenderDrawPoints(SDL_Renderer * renderer,
  509. + const SDL_Point * points, int count)
  510. +{
  511. + SDL_Wayland_RenderData *data =
  512. + (SDL_Wayland_RenderData *) renderer->driverdata;
  513. + SDL_Surface *target = data->screens[data->current_screen];
  514. +
  515. + if (renderer->blendMode == SDL_BLENDMODE_NONE ||
  516. + renderer->blendMode == SDL_BLENDMODE_MASK) {
  517. + Uint32 color = SDL_MapRGBA(target->format,
  518. + renderer->r, renderer->g, renderer->b,
  519. + renderer->a);
  520. +
  521. + return SDL_DrawPoints(target, points, count, color);
  522. + } else {
  523. + return SDL_BlendPoints(target, points, count, renderer->blendMode,
  524. + renderer->r, renderer->g, renderer->b,
  525. + renderer->a);
  526. + }
  527. +}
  528. +
  529. +static int
  530. +SDL_Wayland_RenderDrawLines(SDL_Renderer * renderer,
  531. + const SDL_Point * points, int count)
  532. +{
  533. + SDL_Wayland_RenderData *data =
  534. + (SDL_Wayland_RenderData *) renderer->driverdata;
  535. + SDL_Surface *target = data->screens[data->current_screen];
  536. +
  537. + if (renderer->blendMode == SDL_BLENDMODE_NONE ||
  538. + renderer->blendMode == SDL_BLENDMODE_MASK) {
  539. + Uint32 color = SDL_MapRGBA(target->format,
  540. + renderer->r, renderer->g, renderer->b,
  541. + renderer->a);
  542. +
  543. + return SDL_DrawLines(target, points, count, color);
  544. + } else {
  545. + return SDL_BlendLines(target, points, count, renderer->blendMode,
  546. + renderer->r, renderer->g, renderer->b,
  547. + renderer->a);
  548. + }
  549. +}
  550. +
  551. +static int
  552. +SDL_Wayland_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
  553. + int count)
  554. +{
  555. + SDL_Wayland_RenderData *data =
  556. + (SDL_Wayland_RenderData *) renderer->driverdata;
  557. + SDL_Surface *target = data->screens[data->current_screen];
  558. +
  559. + if (renderer->blendMode == SDL_BLENDMODE_NONE ||
  560. + renderer->blendMode == SDL_BLENDMODE_MASK) {
  561. + Uint32 color = SDL_MapRGBA(target->format,
  562. + renderer->r, renderer->g, renderer->b,
  563. + renderer->a);
  564. +
  565. + return SDL_DrawRects(target, rects, count, color);
  566. + } else {
  567. + return SDL_BlendRects(target, rects, count,
  568. + renderer->blendMode,
  569. + renderer->r, renderer->g, renderer->b,
  570. + renderer->a);
  571. + }
  572. +}
  573. +
  574. +static int
  575. +SDL_Wayland_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
  576. + int count)
  577. +{
  578. + SDL_Wayland_RenderData *data =
  579. + (SDL_Wayland_RenderData *) renderer->driverdata;
  580. + SDL_Surface *target = data->screens[data->current_screen];
  581. +
  582. + if (renderer->blendMode == SDL_BLENDMODE_NONE ||
  583. + renderer->blendMode == SDL_BLENDMODE_MASK) {
  584. + Uint32 color = SDL_MapRGBA(target->format,
  585. + renderer->r, renderer->g, renderer->b,
  586. + renderer->a);
  587. +
  588. + return SDL_FillRects(target, rects, count, color);
  589. + } else {
  590. + return SDL_BlendFillRects(target, rects, count,
  591. + renderer->blendMode,
  592. + renderer->r, renderer->g, renderer->b,
  593. + renderer->a);
  594. + }
  595. +}
  596. +
  597. +static int
  598. +SDL_Wayland_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
  599. + const SDL_Rect * srcrect, const SDL_Rect * dstrect)
  600. +{
  601. + SDL_Wayland_RenderData *data =
  602. + (SDL_Wayland_RenderData *) renderer->driverdata;
  603. + SDL_Window *window = renderer->window;
  604. + SDL_VideoDisplay *display = window->display;
  605. +
  606. + if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
  607. + SDL_Surface *target = data->screens[data->current_screen];
  608. + void *pixels =
  609. + (Uint8 *) target->pixels + dstrect->y * target->pitch +
  610. + dstrect->x * target->format->BytesPerPixel;
  611. + return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
  612. + srcrect, display->current_mode.format,
  613. + dstrect->w, dstrect->h, pixels,
  614. + target->pitch);
  615. + } else {
  616. + SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
  617. + SDL_Surface *target = data->screens[data->current_screen];
  618. + SDL_Rect real_srcrect = *srcrect;
  619. + SDL_Rect real_dstrect = *dstrect;
  620. +
  621. + return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
  622. + }
  623. +}
  624. +
  625. +static int
  626. +SDL_Wayland_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
  627. + Uint32 format, void * pixels, int pitch)
  628. +{
  629. + SDL_Wayland_RenderData *data =
  630. + (SDL_Wayland_RenderData *) renderer->driverdata;
  631. + SDL_Window *window = renderer->window;
  632. + SDL_VideoDisplay *display = window->display;
  633. + SDL_Surface *screen = data->screens[data->current_screen];
  634. + Uint32 screen_format = display->current_mode.format;
  635. + Uint8 *screen_pixels = (Uint8 *) screen->pixels +
  636. + rect->y * screen->pitch +
  637. + rect->x * screen->format->BytesPerPixel;
  638. + int screen_pitch = screen->pitch;
  639. +
  640. + return SDL_ConvertPixels(rect->w, rect->h,
  641. + screen_format, screen_pixels, screen_pitch,
  642. + format, pixels, pitch);
  643. +}
  644. +
  645. +static int
  646. +SDL_Wayland_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
  647. + Uint32 format, const void * pixels, int pitch)
  648. +{
  649. + SDL_Wayland_RenderData *data =
  650. + (SDL_Wayland_RenderData *) renderer->driverdata;
  651. + SDL_Window *window = renderer->window;
  652. + SDL_VideoDisplay *display = window->display;
  653. + SDL_Surface *screen = data->screens[data->current_screen];
  654. + Uint32 screen_format = display->current_mode.format;
  655. + Uint8 *screen_pixels = (Uint8 *) screen->pixels +
  656. + rect->y * screen->pitch +
  657. + rect->x * screen->format->BytesPerPixel;
  658. + int screen_pitch = screen->pitch;
  659. +
  660. + return SDL_ConvertPixels(rect->w, rect->h,
  661. + format, pixels, pitch,
  662. + screen_format, screen_pixels, screen_pitch);
  663. +}
  664. +
  665. +static void
  666. +SDL_Wayland_RenderPresent(SDL_Renderer * renderer)
  667. +{
  668. + static int frame_number;
  669. + SDL_Wayland_RenderData *data =
  670. + (SDL_Wayland_RenderData *) renderer->driverdata;
  671. +
  672. + /* Send the data to the display */
  673. + if (SDL_getenv("SDL_VIDEO_Wayland_SAVE_FRAMES")) {
  674. + char file[128];
  675. + SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
  676. + renderer->window->id, ++frame_number);
  677. + SDL_SaveBMP(data->screens[data->current_screen], file);
  678. + }
  679. +
  680. + /* Update the flipping chain, if any */
  681. + if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
  682. + data->current_screen = (data->current_screen + 1) % 2;
  683. + } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
  684. + data->current_screen = (data->current_screen + 1) % 3;
  685. + }
  686. +}
  687. +
  688. +static int *SDL_Wayland_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
  689. +{
  690. +}
  691. +
  692. +static void
  693. +SDL_Wayland_DestroyRenderer(SDL_Renderer * renderer)
  694. +{
  695. + SDL_Wayland_RenderData *data =
  696. + (SDL_Wayland_RenderData *) renderer->driverdata;
  697. + int i;
  698. +
  699. + if (data) {
  700. + for (i = 0; i < SDL_arraysize(data->screens); ++i) {
  701. + if (data->screens[i]) {
  702. + SDL_FreeSurface(data->screens[i]);
  703. + }
  704. + }
  705. + SDL_free(data);
  706. + }
  707. + SDL_free(renderer);
  708. +}
  709. +
  710. +/* vi: set ts=4 sw=4 expandtab: */
  711. diff -r d716dff4b13e src/video/wayland/SDL_waylandrender_c.h
  712. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  713. +++ b/src/video/wayland/SDL_waylandrender_c.h Sun Dec 05 09:18:37 2010 -0800
  714. @@ -0,0 +1,28 @@
  715. +/*
  716. + SDL - Simple DirectMedia Layer
  717. + Copyright (C) 1997-2010 Sam Lantinga
  718. +
  719. + This library is free software; you can redistribute it and/or
  720. + modify it under the terms of the GNU Lesser General Public
  721. + License as published by the Free Software Foundation; either
  722. + version 2.1 of the License, or (at your option) any later version.
  723. +
  724. + This library is distributed in the hope that it will be useful,
  725. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  726. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  727. + Lesser General Public License for more details.
  728. +
  729. + You should have received a copy of the GNU Lesser General Public
  730. + License along with this library; if not, write to the Free Software
  731. + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  732. +
  733. + Sam Lantinga
  734. + slouken@libsdl.org
  735. +*/
  736. +#include "SDL_config.h"
  737. +
  738. +/* SDL surface based renderer implementation */
  739. +
  740. +extern SDL_RenderDriver SDL_Wayland_RenderDriver;
  741. +
  742. +/* vi: set ts=4 sw=4 expandtab: */
  743. diff -r d716dff4b13e src/video/wayland/SDL_waylandvideo.c
  744. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  745. +++ b/src/video/wayland/SDL_waylandvideo.c Sun Dec 05 09:18:37 2010 -0800
  746. @@ -0,0 +1,265 @@
  747. +/*
  748. + SDL - Simple DirectMedia Layer
  749. + Copyright (C) 1997-2010 Sam Lantinga
  750. +
  751. + This library is free software; you can redistribute it and/or
  752. + modify it under the terms of the GNU Lesser General Public
  753. + License as published by the Free Software Foundation; either
  754. + version 2.1 of the License, or (at your option) any later version.
  755. +
  756. + This library is distributed in the hope that it will be useful,
  757. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  758. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  759. + Lesser General Public License for more details.
  760. +
  761. + You should have received a copy of the GNU Lesser General Public
  762. + License along with this library; if not, write to the Free Software
  763. + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  764. +
  765. + Sam Lantinga
  766. + slouken@libsdl.org
  767. +*/
  768. +#include "SDL_config.h"
  769. +
  770. +
  771. +#include <fcntl.h>
  772. +#include "SDL_video.h"
  773. +#include "SDL_mouse.h"
  774. +#include "../SDL_sysvideo.h"
  775. +#include "../SDL_pixels_c.h"
  776. +#include "../../events/SDL_events_c.h"
  777. +
  778. +#include "SDL_waylandvideo.h"
  779. +#include "SDL_waylandevents_c.h"
  780. +#include "SDL_waylandrender_c.h"
  781. +#include "SDL_waylandwindow.h"
  782. +#include "SDL_waylandgl.h"
  783. +
  784. +
  785. +#define WAYLANDVID_DRIVER_NAME "wayland"
  786. +
  787. +/* Initialization/Query functions */
  788. +static int Wayland_VideoInit(_THIS);
  789. +static int Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
  790. +static void Wayland_VideoQuit(_THIS);
  791. +
  792. +
  793. +/* Wayland driver bootstrap functions */
  794. +
  795. +static int
  796. +Wayland_Available(void)
  797. +{
  798. + const char *envr = SDL_getenv("SDL_VIDEODRIVER");
  799. + if ((envr) && (SDL_strcmp(envr, WAYLANDVID_DRIVER_NAME) == 0)) {
  800. + return (1);
  801. + }
  802. +
  803. + return (0);
  804. +}
  805. +
  806. +static void
  807. +Wayland_DeleteDevice(SDL_VideoDevice * device)
  808. +{
  809. + SDL_free(device);
  810. +}
  811. +
  812. +static SDL_VideoDevice *
  813. +Wayland_CreateDevice(int devindex)
  814. +{
  815. + SDL_VideoDevice *device;
  816. +
  817. + /* Initialize all variables that we clean on shutdown */
  818. + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
  819. + if (!device) {
  820. + SDL_OutOfMemory();
  821. + if (device) {
  822. + SDL_free(device);
  823. + }
  824. + return (0);
  825. + }
  826. +
  827. + /* Set the function pointers */
  828. + device->VideoInit = Wayland_VideoInit;
  829. + device->VideoQuit = Wayland_VideoQuit;
  830. + device->SetDisplayMode = Wayland_SetDisplayMode;
  831. + device->PumpEvents = Wayland_PumpEvents;
  832. +
  833. + device->GL_SwapWindow = Wayland_GL_SwapWindow;
  834. + device->GL_GetSwapInterval = Wayland_GL_GetSwapInterval;
  835. + device->GL_SetSwapInterval = Wayland_GL_SetSwapInterval;
  836. + device->GL_MakeCurrent = Wayland_GL_MakeCurrent;
  837. + device->GL_CreateContext = Wayland_GL_CreateContext;
  838. + device->GL_LoadLibrary = Wayland_GL_LoadLibrary;
  839. + device->GL_UnloadLibrary = Wayland_GL_UnloadLibrary;
  840. +
  841. +
  842. +
  843. + device->CreateWindow = Wayland_CreateWindow;
  844. +
  845. +
  846. + device->free = Wayland_DeleteDevice;
  847. +
  848. + return device;
  849. +}
  850. +
  851. +VideoBootStrap Wayland_bootstrap = {
  852. + WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
  853. + Wayland_Available, Wayland_CreateDevice
  854. +};
  855. +
  856. +static void
  857. +display_handle_geometry(void *data,
  858. + struct wl_output *output,
  859. + int32_t width, int32_t height)
  860. +{
  861. + SDL_WaylandData *d = data;
  862. +
  863. + d->screen_allocation.x = 0;
  864. + d->screen_allocation.y = 0;
  865. + d->screen_allocation.width = width;
  866. + d->screen_allocation.height = height;
  867. +}
  868. +
  869. +
  870. +static const struct wl_output_listener output_listener = {
  871. + display_handle_geometry,
  872. +};
  873. +
  874. +static void
  875. +handle_configure(void *data, struct wl_shell *shell,
  876. + uint32_t time, uint32_t edges,
  877. + struct wl_surface *surface,
  878. + int32_t x, int32_t y, int32_t width, int32_t height)
  879. +{
  880. +
  881. +}
  882. +
  883. +static const struct wl_shell_listener shell_listener = {
  884. + handle_configure,
  885. +};
  886. +
  887. +
  888. +static void
  889. +drm_handle_device(void *data, struct wl_drm *drm, const char *device)
  890. +{
  891. + SDL_WaylandData *c = data;
  892. +
  893. + c->device_name = strdup(device);
  894. +}
  895. +
  896. +static void drm_handle_authenticated(void *data, struct wl_drm *drm)
  897. +{
  898. + SDL_WaylandData *c = data;
  899. +
  900. + c->authenticated = 1;
  901. +}
  902. +
  903. +static const struct wl_drm_listener drm_listener = {
  904. + drm_handle_device,
  905. + drm_handle_authenticated
  906. +};
  907. +
  908. +
  909. +static void
  910. +display_handle_global(struct wl_display *display, uint32_t id,
  911. + const char *interface, uint32_t version, void *data)
  912. +{
  913. + SDL_WaylandData *d = data;
  914. +
  915. + if (strcmp(interface, "compositor") == 0) {
  916. + d->compositor = wl_compositor_create(display, id);
  917. + } else if (strcmp(interface, "output") == 0) {
  918. + d->output = wl_output_create(display, id);
  919. + wl_output_add_listener(d->output, &output_listener, d);
  920. + } else if (strcmp(interface, "input_device") == 0) {
  921. + //display_add_input(d, id);
  922. + } else if (strcmp(interface, "shell") == 0) {
  923. + d->shell = wl_shell_create(display, id);
  924. + wl_shell_add_listener(d->shell, &shell_listener, d);
  925. + } else if (strcmp(interface, "drm") == 0) {
  926. + d->drm = wl_drm_create(display, id);
  927. + wl_drm_add_listener(d->drm, &drm_listener, d);
  928. + }
  929. +}
  930. +
  931. +
  932. +
  933. +int
  934. +Wayland_VideoInit(_THIS)
  935. +{
  936. + SDL_WaylandData *data;// = (SDL_WaylandData *) _this->driverdata;
  937. + data = malloc(sizeof *data);
  938. + if (data == NULL)
  939. + return 0;
  940. +
  941. + _this->driverdata = data;
  942. +
  943. + data->display = wl_display_connect(NULL);
  944. + if (data->display == NULL) {
  945. + fprintf(stderr, "failed to create display: %m\n");
  946. + return 0;
  947. + }
  948. +
  949. + wl_display_add_global_listener(data->display,
  950. + display_handle_global, data);
  951. +
  952. + wl_display_iterate(data->display, WL_DISPLAY_READABLE);
  953. +
  954. + /*if (wayland_compositor_init_egl(c) < 0)
  955. + return NULL;*/
  956. +
  957. + data->drm_fd = open (data->device_name, O_RDWR);
  958. + if (data->drm_fd < 0)
  959. + {
  960. + fprintf(stderr, "Failed to open drm device\n");
  961. +
  962. + return 0;
  963. + }
  964. +
  965. + int magic;
  966. + if (drmGetMagic (data->drm_fd, &magic))
  967. + {
  968. + fprintf(stderr, "Failed to get drm magic\n");
  969. +
  970. + return 0;
  971. + }
  972. + wl_drm_authenticate (data->drm, magic);
  973. +
  974. + wl_display_iterate (data->display, WL_DISPLAY_WRITABLE);
  975. + while (!data->authenticated)
  976. + wl_display_iterate (data->display, WL_DISPLAY_READABLE);
  977. +
  978. +
  979. +
  980. +
  981. +
  982. + SDL_VideoDisplay display;
  983. + SDL_DisplayMode mode;
  984. +
  985. + /* Use a fake 32-bpp desktop mode */
  986. + mode.format = SDL_PIXELFORMAT_RGB888;
  987. + mode.w = 1024;
  988. + mode.h = 768;
  989. + mode.refresh_rate = 0;
  990. + mode.driverdata = NULL;
  991. + SDL_zero(display);
  992. + display.desktop_mode = mode;
  993. + display.current_mode = mode;
  994. + display.driverdata = NULL;
  995. + SDL_AddVideoDisplay(&display);
  996. +
  997. + return 0;
  998. +}
  999. +
  1000. +static int
  1001. +Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
  1002. +{
  1003. + return 0;
  1004. +}
  1005. +
  1006. +void
  1007. +Wayland_VideoQuit(_THIS)
  1008. +{
  1009. +}
  1010. +
  1011. +/* vi: set ts=4 sw=4 expandtab: */
  1012. diff -r d716dff4b13e src/video/wayland/SDL_waylandvideo.h
  1013. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  1014. +++ b/src/video/wayland/SDL_waylandvideo.h Sun Dec 05 09:18:37 2010 -0800
  1015. @@ -0,0 +1,60 @@
  1016. +/*
  1017. + SDL - Simple DirectMedia Layer
  1018. + Copyright (C) 1997-2010 Sam Lantinga
  1019. +
  1020. + This library is free software; you can redistribute it and/or
  1021. + modify it under the terms of the GNU Lesser General Public
  1022. + License as published by the Free Software Foundation; either
  1023. + version 2.1 of the License, or (at your option) any later version.
  1024. +
  1025. + This library is distributed in the hope that it will be useful,
  1026. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  1027. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1028. + Lesser General Public License for more details.
  1029. +
  1030. + You should have received a copy of the GNU Lesser General Public
  1031. + License along with this library; if not, write to the Free Software
  1032. + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  1033. +
  1034. + Sam Lantinga
  1035. + slouken@libsdl.org
  1036. +*/
  1037. +#include "SDL_config.h"
  1038. +
  1039. +#ifndef _SDL_waylandvideo_h
  1040. +#define _SDL_waylandvideo_h
  1041. +
  1042. +#include "../SDL_sysvideo.h"
  1043. +#include </home/joel/install/include/wayland-client.h>
  1044. +#include </home/joel/install/include/wayland-client-protocol.h>
  1045. +#define GL_GLEXT_PROTOTYPES
  1046. +#define EGL_EGLEXT_PROTOTYPES
  1047. +#include <EGL/egl.h>
  1048. +#include <EGL/eglext.h>
  1049. +#include <GL/gl.h>
  1050. +
  1051. +
  1052. +typedef struct
  1053. +{
  1054. + struct wl_display *display;
  1055. + struct wl_compositor *compositor;
  1056. + struct wl_drm *drm;
  1057. + struct wl_output *output;
  1058. + struct wl_shell *shell;
  1059. +
  1060. + struct {
  1061. + int32_t x, y, width, height;
  1062. + } screen_allocation;
  1063. +
  1064. + char *device_name;
  1065. + int authenticated;
  1066. +
  1067. + int drm_fd;
  1068. +
  1069. + EGLDisplay edpy;
  1070. +
  1071. +} SDL_WaylandData;
  1072. +
  1073. +#endif /* _SDL_nullvideo_h */
  1074. +
  1075. +/* vi: set ts=4 sw=4 expandtab: */
  1076. diff -r d716dff4b13e src/video/wayland/SDL_waylandwindow.c
  1077. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  1078. +++ b/src/video/wayland/SDL_waylandwindow.c Sun Dec 05 09:18:37 2010 -0800
  1079. @@ -0,0 +1,70 @@
  1080. +#include "SDL_config.h"
  1081. +
  1082. +#include "../SDL_sysvideo.h"
  1083. +#include "SDL_waylandwindow.h"
  1084. +#include "SDL_waylandvideo.h"
  1085. +
  1086. +
  1087. +
  1088. +int Wayland_CreateWindow(_THIS, SDL_Window * window)
  1089. +{
  1090. + printf("window create\n");
  1091. + SDL_WaylandWindow *data;
  1092. + data = malloc(sizeof *data);
  1093. + if (data == NULL)
  1094. + return 0;
  1095. + SDL_WaylandData *c;
  1096. + c = _this->driverdata;
  1097. + window->driverdata = data;
  1098. + struct wl_visual *visual;
  1099. + int i;
  1100. + EGLint name, stride, attribs[] = {
  1101. + EGL_WIDTH, 0,
  1102. + EGL_HEIGHT, 0,
  1103. + EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
  1104. + EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SCANOUT_MESA,
  1105. + EGL_NONE
  1106. + };
  1107. +
  1108. +
  1109. + data->surface =
  1110. + wl_compositor_create_surface(c->compositor);
  1111. + wl_surface_set_user_data(data->surface, data);
  1112. +
  1113. + glGenRenderbuffers(2, data->rbo);
  1114. + visual = wl_display_get_premultiplied_argb_visual(c->display);
  1115. + for (i = 0; i < 2; i++) {
  1116. + glBindRenderbuffer(GL_RENDERBUFFER, data->rbo[i]);
  1117. +
  1118. + attribs[1] = window->w;
  1119. + attribs[3] = window->h;
  1120. + data->image[i] =
  1121. + eglCreateDRMImageMESA(c->display, attribs);
  1122. + glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER,
  1123. + data->image[i]);
  1124. + eglExportDRMImageMESA(c->display, data->image[i],
  1125. + &name, NULL, &stride);
  1126. + data->buffer[i] =
  1127. + wl_drm_create_buffer(c->drm, name,
  1128. + window->w, window->h,
  1129. + stride, visual);
  1130. + }
  1131. +
  1132. + data->current = 0;
  1133. + glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, data->image[0]);
  1134. + glFramebufferRenderbuffer(GL_FRAMEBUFFER,
  1135. + GL_COLOR_ATTACHMENT0,
  1136. + GL_RENDERBUFFER,
  1137. + data->rbo[data->current]);
  1138. +
  1139. + wl_surface_attach(data->surface,
  1140. + data->buffer[data->current]);
  1141. + wl_surface_map(data->surface,
  1142. + 0, 0,
  1143. + window->w, window->h);
  1144. + printf("window %d %d\n", window->w, window->h);
  1145. +
  1146. + glClearColor(0, 0, 0, 0.5);
  1147. +
  1148. + return 0;
  1149. +}
  1150. diff -r d716dff4b13e src/video/wayland/SDL_waylandwindow.h
  1151. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  1152. +++ b/src/video/wayland/SDL_waylandwindow.h Sun Dec 05 09:18:37 2010 -0800
  1153. @@ -0,0 +1,28 @@
  1154. +#include "SDL_config.h"
  1155. +
  1156. +#ifndef _SDL_waylandwindow_h
  1157. +#define _SDL_waylandwindow_h
  1158. +
  1159. +#include "../SDL_sysvideo.h"
  1160. +
  1161. +#include "SDL_waylandvideo.h"
  1162. +
  1163. +typedef struct
  1164. +{
  1165. + struct wl_surface *surface;
  1166. + struct wl_buffer *buffer[2];
  1167. +
  1168. + EGLImageKHR image[2];
  1169. + GLuint rbo[2];
  1170. + uint32_t fb_id[2];
  1171. + uint32_t current;
  1172. +
  1173. + EGLContext context;
  1174. +
  1175. +} SDL_WaylandWindow;
  1176. +
  1177. +extern int Wayland_CreateWindow(_THIS, SDL_Window * window);
  1178. +
  1179. +#endif /* _SDL_waylandwindow_h */
  1180. +
  1181. +/* vi: set ts=4 sw=4 expandtab: */
  1182. diff -r d716dff4b13e src/video/x11/SDL_x11video.h
  1183. --- a/src/video/x11/SDL_x11video.h Thu Dec 02 11:56:23 2010 -0800
  1184. +++ b/src/video/x11/SDL_x11video.h Sun Dec 05 09:18:37 2010 -0800
  1185. @@ -68,6 +68,7 @@
  1186. #include "SDL_x11mouse.h"
  1187. #include "SDL_x11opengl.h"
  1188. #include "SDL_x11window.h"
  1189. +#include "SDL_x11touch.h"
  1190.  
  1191. /* Private display data */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement