tethering: provide a function to get framebuffer on Mac OS X. 66/25566/1
authorKitae Kim <kt920.kim@samsung.com>
Thu, 31 Jul 2014 02:30:39 +0000 (11:30 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 7 Aug 2014 05:45:10 +0000 (14:45 +0900)
maru_shm module is used to draw display instead of maru_sdl on Mac OS X.
so, add a function for extracting framebuffer from display.

Change-Id: Ied85db82eef38d2856c60b521ac0490959e3f507
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
tizen/src/display/maru_display.c
tizen/src/display/maru_shm.c

index 23dff8f..7616657 100644 (file)
@@ -75,7 +75,7 @@ void maru_display_init(DisplayState *ds)
     maru_sdl_pre_init();
 #endif
 #else
-    /* do nothing */
+    maru_shm_pre_init();
 #endif
 
     /*  graphics context information */
@@ -114,7 +114,7 @@ void maru_display_update(void)
     maru_sdl_update();
 #endif
 #else
-    /* do nothing */
+    maru_shm_update();
 #endif
 }
 
index cb0f6dc..9d14fcc 100644 (file)
 #include <sys/ipc.h>
 #include <sys/shm.h>
 
-#include "maru_shm.h"
+#include "qemu/main-loop.h"
 #include "emul_state.h"
+#include "maru_display.h"
+#include "maru_shm.h"
 #include "hw/pci/maru_brightness.h"
 #include "skin/maruskin_server.h"
 #include "util/maru_err_table.h"
 #include "debug_ch.h"
 
+#include "tethering/touch.h"
+
 MULTI_DEBUG_CHANNEL(tizen, maru_shm);
 
+static QEMUBH *shm_update_bh;
+
 static DisplaySurface *dpy_surface;
 static void *shared_memory = (void *) 0;
 static int skin_shmid;
@@ -89,6 +95,8 @@ static void qemu_ds_shm_update(DisplayChangeListener *dcl,
             if (is_fit_console_size == true) {
                 maru_do_pixman_dpy_surface(dpy_surface->image);
 
+                save_screenshot(dpy_surface);
+
                 memcpy(shared_memory,
                     surface_data(dpy_surface),
                     surface_stride(dpy_surface) *
@@ -115,6 +123,8 @@ static void qemu_ds_shm_update(DisplayChangeListener *dcl,
              drop_frame, draw_frame + drop_frame);
 #endif
     }
+
+    set_display_dirty(true);
 }
 
 static void qemu_ds_shm_switch(DisplayChangeListener *dcl,
@@ -191,6 +201,11 @@ static void qemu_ds_shm_refresh(DisplayChangeListener *dcl)
     }
 }
 
+static void maru_shm_update_bh(void *opaque)
+{
+    graphic_hw_invalidate(NULL);
+}
+
 DisplayChangeListenerOps maru_dcl_ops = {
     .dpy_name          = "maru_shm",
     .dpy_refresh       = qemu_ds_shm_refresh,
@@ -198,6 +213,11 @@ DisplayChangeListenerOps maru_dcl_ops = {
     .dpy_gfx_switch    = qemu_ds_shm_switch,
 };
 
+void maru_shm_pre_init(void)
+{
+    shm_update_bh = qemu_bh_new(maru_shm_update_bh, NULL);
+}
+
 void maru_shm_init(uint64 swt_handle,
     unsigned int display_width, unsigned int display_height,
     bool blank_guide)
@@ -288,8 +308,27 @@ void maru_shm_resize(void)
     shm_skip_update = 0;
 }
 
-bool maru_extract_framebuffer(void* buffer)
+void maru_shm_update(void)
+{
+    if (shm_update_bh != NULL) {
+        qemu_bh_schedule(shm_update_bh);
+    }
+}
+
+bool maru_extract_framebuffer(void *buffer)
 {
-    INFO("not support on Mac OS X\n");
-    return false;
+    uint32_t buffer_size = 0;
+
+    if (!buffer) {
+        ERR("given buffer is null\n");
+        return false;
+    }
+
+    maru_do_pixman_dpy_surface(dpy_surface->image);
+
+    buffer_size = surface_stride(dpy_surface) * surface_height(dpy_surface);
+    TRACE("extract framebuffer %d\n", buffer_size);
+
+    memcpy(buffer, surface_data(dpy_surface), buffer_size);
+    return true;
 }