[cogl/wip/public-atlas-apis: 6/9] sdl2: Add android support



commit ff0968a38d2f0304f862e158262e44ef17098c8b
Author: Robert Bragg <robert linux intel com>
Date:   Thu Feb 13 12:23:53 2014 +0000

    sdl2: Add android support
    
    This adds Android support to the SDL2 winsys. Unlike some other window
    systems, Android's SDL2 backend only allows you to create one window.
    Since the Cogl SDL2 winsys creates a "dummy" window when setting up the
    display (so we have something to bind a GL context to) it wasn't then
    possible to create a CoglOnscreen framebuffer for rendering. This
    updates the winsys so that the first CoglOnscreen framebuffer created
    will actually refer to the dummy window we created earlier.
    
    Note: it doesn't matter that we request the dummy window to have a 1x1
    size, and request for it to be hidden because these are overridden by
    SDL's Android backend.

 cogl/winsys/cogl-winsys-sdl2.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/cogl/winsys/cogl-winsys-sdl2.c b/cogl/winsys/cogl-winsys-sdl2.c
index 1a65594..5ffd093 100644
--- a/cogl/winsys/cogl-winsys-sdl2.c
+++ b/cogl/winsys/cogl-winsys-sdl2.c
@@ -61,6 +61,7 @@ typedef struct _CoglDisplaySdl2
 {
   SDL_Window *dummy_window;
   SDL_GLContext *context;
+  CoglBool have_onscreen;
 } CoglDisplaySdl2;
 
 typedef struct _CoglOnscreenSdl2
@@ -499,6 +500,32 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
   int width, height;
   SDL_WindowFlags flags;
 
+#ifdef __ANDROID__
+  {
+    CoglDisplay *display = framebuffer->context->display;
+    CoglDisplaySdl2 *sdl_display = display->winsys;
+    int win_width, win_height;
+
+    if (sdl_display->have_onscreen)
+      {
+        _cogl_set_error (error, COGL_WINSYS_ERROR,
+                         COGL_WINSYS_ERROR_CREATE_ONSCREEN,
+                         "Android platform only supports a single "
+                         "onscreen window");
+        return FALSE;
+      }
+
+    window = sdl_display->dummy_window;
+
+    SDL_GetWindowSize (window, &win_width, &win_height);
+
+    _cogl_framebuffer_winsys_update_size (framebuffer, win_width, win_height);
+
+    sdl_display->have_onscreen = TRUE;
+  }
+
+#else /* __ANDROID__ */
+
   width = cogl_framebuffer_get_width (framebuffer);
   height = cogl_framebuffer_get_height (framebuffer);
 
@@ -513,7 +540,6 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
                              0, 0, /* x/y */
                              width, height,
                              flags);
-
   if (window == NULL)
     {
       _cogl_set_error (error, COGL_WINSYS_ERROR,
@@ -523,6 +549,8 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
       return FALSE;
     }
 
+#endif /* __ANDROID__ */
+
   SDL_SetWindowData (window, COGL_SDL_WINDOW_DATA_KEY, onscreen);
 
   onscreen->winsys = u_slice_new (CoglOnscreenSdl2);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]