From: Kitae Kim Date: Tue, 5 Aug 2014 04:27:37 +0000 (+0900) Subject: tethering: provide a function to get framebuffer on Mac OS X. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~263^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=798f94328e10b920629ff2e827d5ce8f9ee8a052;p=sdk%2Femulator%2Fqemu.git tethering: provide a function to get framebuffer on Mac OS X. 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: I1e20995cc21dc358365204631e83597eb5fad296 Signed-off-by: Kitae Kim --- diff --git a/tizen/src/maru_display.c b/tizen/src/maru_display.c index 328330e195..3fd8327784 100644 --- a/tizen/src/maru_display.c +++ b/tizen/src/maru_display.c @@ -50,7 +50,7 @@ void maru_display_init(DisplayState *ds) #ifndef CONFIG_USE_SHM maru_sdl_pre_init(); #else - /* do nothing */ + maru_shm_pre_init(); #endif /* graphics context information */ @@ -93,7 +93,7 @@ void maru_display_update(void) #ifndef CONFIG_USE_SHM maru_sdl_update(); #else - /* do nothing */ + maru_shm_update(); #endif } diff --git a/tizen/src/maru_shm.c b/tizen/src/maru_shm.c index dacf35fa73..9408f7af70 100644 --- a/tizen/src/maru_shm.c +++ b/tizen/src/maru_shm.c @@ -32,15 +32,21 @@ #include #include -#include "maru_shm.h" +#include "qemu/main-loop.h" #include "emul_state.h" +#include "maru_display.h" +#include "maru_shm.h" #include "hw/maru_brightness.h" #include "skin/maruskin_server.h" #include "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; } diff --git a/tizen/src/maru_shm.h b/tizen/src/maru_shm.h index 7beebee399..efa50e2fe9 100644 --- a/tizen/src/maru_shm.h +++ b/tizen/src/maru_shm.h @@ -35,11 +35,13 @@ extern DisplayChangeListenerOps maru_dcl_ops; +void maru_shm_pre_init(void); void maru_shm_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide); void maru_shm_resize(void); void maru_shm_quit(void); +void maru_shm_update(void); bool maru_extract_framebuffer(void *buffer); #endif /* MARU_SHM_H_ */