From: Kitae Kim Date: Wed, 17 Sep 2014 05:03:10 +0000 (+0900) Subject: tethering: remove build depedency. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~228^2^2~13^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3607dcc0523f77069b19138afe4bf161a70407d5;p=sdk%2Femulator%2Fqemu.git tethering: remove build depedency. when --disable-sdl or --disable-shm on Mac OS X, encode_fb module get compilation errors because of depedencies. Change-Id: I0a312acb9ba4b0ec77de5df960de852b8c55a890 Signed-off-by: Kitae Kim --- diff --git a/tizen/src/display/maru_sdl.c b/tizen/src/display/maru_sdl.c index 04bf1a7fbe..e0c177e0da 100644 --- a/tizen/src/display/maru_sdl.c +++ b/tizen/src/display/maru_sdl.c @@ -39,7 +39,7 @@ #include "hw/pci/maru_brightness.h" #include "debug_ch.h" -#include "tethering/touch.h" +#include "tethering/encode_fb.h" #include #ifndef CONFIG_WIN32 diff --git a/tizen/src/display/maru_sdl.h b/tizen/src/display/maru_sdl.h index 5345c78476..87e4ec877d 100644 --- a/tizen/src/display/maru_sdl.h +++ b/tizen/src/display/maru_sdl.h @@ -46,6 +46,4 @@ void maru_sdl_invalidate(bool on); void maru_sdl_interpolation(bool on); void maru_sdl_quit(void); -bool maru_extract_framebuffer(void *buffer); - #endif /* MARU_SDL_H_ */ diff --git a/tizen/src/display/maru_shm.c b/tizen/src/display/maru_shm.c index 9d14fcc2ea..e2c00bae60 100644 --- a/tizen/src/display/maru_shm.c +++ b/tizen/src/display/maru_shm.c @@ -41,7 +41,7 @@ #include "util/maru_err_table.h" #include "debug_ch.h" -#include "tethering/touch.h" +#include "tethering/encode_fb.h" MULTI_DEBUG_CHANNEL(tizen, maru_shm); diff --git a/tizen/src/display/maru_shm.h b/tizen/src/display/maru_shm.h index efa50e2fe9..e52d389847 100644 --- a/tizen/src/display/maru_shm.h +++ b/tizen/src/display/maru_shm.h @@ -42,6 +42,5 @@ void maru_shm_init(uint64 swt_handle, 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_ */ diff --git a/tizen/src/tethering/encode_fb.c b/tizen/src/tethering/encode_fb.c index 139fcb1959..022fba13f5 100644 --- a/tizen/src/tethering/encode_fb.c +++ b/tizen/src/tethering/encode_fb.c @@ -32,14 +32,6 @@ #include "emulator_common.h" #include "emul_state.h" - -#ifdef CONFIG_SDL -#include "display/maru_sdl.h" -#endif -#ifdef CONFIG_USE_SHM -#include "display/maru_shm.h" -#endif - #include "skin/maruskin_operation.h" #include "encode_fb.h" @@ -56,41 +48,74 @@ DECLARE_DEBUG_CHANNEL(app_tethering); #ifdef CONFIG_WEBP -static void *encode_webp(void); -#endif -static void *encode_png(void); - -void *encode_framebuffer(int encoder) +/* + * webp functions + */ +static void *encode_webp(void) { - void *output = NULL; + int width = 0, height = 0, image_stride = 0; + size_t ret = 0; -#if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG) - struct timespec start, end; + struct encode_mem *container = NULL; + uint8_t *surface = NULL; + uint32_t surface_size = 0; - clock_gettime(CLOCK_MONOTONIC, &start); -#endif + container = g_malloc(sizeof(struct encode_mem)); + if (!container) { + LOG_SEVERE("failed to allocate encode_mem\n"); + return NULL; + } -#ifdef CONFIG_WEBP - if (encoder == 0) { - output = encode_webp(); - } else if (encoder == 1) { - output = encode_png(); + container->buffer = NULL; + container->length = 0; + + width = get_emul_resolution_width(); + height = get_emul_resolution_height(); + + image_stride = width * 4; + LOG_TRACE("width %d, height %d, stride %d, raw image %d\n", + width, height, image_stride, (image_stride * height)); + + surface_size = width * height * 4; + + surface = g_malloc0(surface_size); + if (!surface) { + LOG_SEVERE("failed to allocate framebuffer\n"); + return NULL; } -#else - output = encode_png(); -#endif -#if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG) - clock_gettime(CLOCK_MONOTONIC, &end); + if (!maru_extract_framebuffer(surface)) { + LOG_SEVERE("failed to extract framebuffer\n"); + g_free(surface); + return NULL; + } - LOG_TRACE("encoding time: %.5f seconds\n", - ((double)end.tv_sec + (1.0e-9 * end.tv_nsec)) - - ((double)start.tv_sec + (1.0e-9 * start.tv_nsec))); -#endif + container = g_malloc(sizeof(struct encode_mem)); + if (!container) { + LOG_SEVERE("failed to allocate encode_mem\n"); + g_free(surface); + return NULL; + } - return output; + container->buffer = NULL; + container->length = 0; + + ret = WebPEncodeLosslessBGRA((const uint8_t *)surface, width, + height, image_stride, &container->buffer); + LOG_TRACE("lossless encode framebuffer via webp. result %zu\n", ret); + + container->length = (int)ret; + + g_free(surface); + + return container; } +#endif +#ifdef CONFIG_PNG +/* + * png functions + */ static void user_write_data(png_structp png_ptr, png_bytep data, png_size_t len) { struct encode_mem *p = (struct encode_mem *)png_get_io_ptr(png_ptr); @@ -232,65 +257,42 @@ static void *encode_png(void) return container; } +#endif -#ifdef CONFIG_WEBP -static void *encode_webp(void) +void *encode_framebuffer(int encoder) { - int width = 0, height = 0, image_stride = 0; - size_t ret = 0; - - struct encode_mem *container = NULL; - uint8_t *surface = NULL; - uint32_t surface_size = 0; - - container = g_malloc(sizeof(struct encode_mem)); - if (!container) { - LOG_SEVERE("failed to allocate encode_mem\n"); - return NULL; - } - - container->buffer = NULL; - container->length = 0; - - width = get_emul_resolution_width(); - height = get_emul_resolution_height(); - - image_stride = width * 4; - LOG_TRACE("width %d, height %d, stride %d, raw image %d\n", - width, height, image_stride, (image_stride * height)); + void *output = NULL; - surface_size = width * height * 4; +#ifdef CONFIG_PNG +#if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG) + struct timespec start, end; - surface = g_malloc0(surface_size); - if (!surface) { - LOG_SEVERE("failed to allocate framebuffer\n"); - return NULL; - } + clock_gettime(CLOCK_MONOTONIC, &start); +#endif - if (!maru_extract_framebuffer(surface)) { - LOG_SEVERE("failed to extract framebuffer\n"); - g_free(surface); - return NULL; - } + output = encode_png(); - container = g_malloc(sizeof(struct encode_mem)); - if (!container) { - LOG_SEVERE("failed to allocate encode_mem\n"); - g_free(surface); - return NULL; - } +#if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG) + clock_gettime(CLOCK_MONOTONIC, &end); - container->buffer = NULL; - container->length = 0; + LOG_TRACE("encoding time: %.5f seconds\n", + ((double)end.tv_sec + (1.0e-9 * end.tv_nsec)) - + ((double)start.tv_sec + (1.0e-9 * start.tv_nsec))); +#endif +#endif - ret = WebPEncodeLosslessBGRA((const uint8_t *)surface, width, - height, image_stride, &container->buffer); - LOG_TRACE("lossless encode framebuffer via webp. result %zu\n", ret); + return output; +} - container->length = (int)ret; +static bool display_dirty = false; - g_free(surface); +void set_display_dirty(bool dirty) +{ + LOG_TRACE("qemu display update: %d\n", display_dirty); + display_dirty = dirty; +} - return container; +bool is_display_dirty(void) +{ + return display_dirty; } -#endif diff --git a/tizen/src/tethering/encode_fb.h b/tizen/src/tethering/encode_fb.h index 330fc3abd6..32a777f22f 100644 --- a/tizen/src/tethering/encode_fb.h +++ b/tizen/src/tethering/encode_fb.h @@ -34,3 +34,9 @@ struct encode_mem { }; void *encode_framebuffer(int encoder); + +bool maru_extract_framebuffer(void *buffer); + +void set_display_dirty(bool dirty); + +bool is_display_dirty(void); diff --git a/tizen/src/tethering/touch.c b/tizen/src/tethering/touch.c index 85f067cd9d..30a0b3a09d 100644 --- a/tizen/src/tethering/touch.c +++ b/tizen/src/tethering/touch.c @@ -197,14 +197,6 @@ static void set_hwkey_data(Tethering__HWKeyMsg *msg) send_tethering_hwkey_data(keycode); } -static bool is_display_dirty = false; - -void set_display_dirty(bool dirty) -{ - LOG_TRACE("qemu display update: %d\n", is_display_dirty); - is_display_dirty = dirty; -} - bool msgproc_tethering_touch_msg(void *message) { bool ret = true; @@ -229,11 +221,11 @@ bool msgproc_tethering_touch_msg(void *message) case TETHERING__TOUCH_MSG__TYPE__DISPLAY_MSG: LOG_TRACE("TOUCH_MSG_TYPE_DISPLAY_MSG\n"); - if (is_display_dirty) { + if (is_display_dirty()) { LOG_TRACE("display dirty status!! send the image\n"); send_display_image_data(); - is_display_dirty = false; + set_display_dirty(false); } break; diff --git a/tizen/src/tethering/touch.h b/tizen/src/tethering/touch.h index 251a68b9fe..cb29c9b804 100644 --- a/tizen/src/tethering/touch.h +++ b/tizen/src/tethering/touch.h @@ -38,5 +38,3 @@ bool msgproc_tethering_touch_msg(void *message); int get_tethering_touch_status(void); void set_tethering_touch_status(int status); - -void set_display_dirty(bool dirty);