Guest User

Untitled

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