#include "hw/maru_brightness.h"
#include "debug_ch.h"
+#include "tethering/touch.h"
+
+#include <SDL.h>
+#ifndef CONFIG_WIN32
+#include <SDL_syswm.h>
+#endif
+
MULTI_DEBUG_CHANNEL(tizen, maru_sdl);
static QEMUBH *sdl_init_bh;
static void qemu_update(void);
-
static void qemu_ds_sdl_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
{
#else
qemu_update();
#endif
+
+ set_display_dirty(true);
}
static void qemu_ds_sdl_switch(DisplayChangeListener *dcl,
{
sdl_invalidate = on;
}
+
+bool maru_extract_framebuffer(void *buffer)
+{
+ uint32_t buffer_size = 0;
+
+ if (!buffer) {
+ ERR("given buffer is null\n");
+ return false;
+ }
+
+ if (!surface_qemu) {
+ ERR("surface_qemu is null\n");
+ return false;
+ }
+
+ maru_do_pixman_dpy_surface(dpy_surface->image);
+
+ buffer_size = surface_stride(dpy_surface) * surface_height(dpy_surface);
+ INFO("extract framebuffer %d\n", buffer_size);
+
+ memcpy(buffer, surface_data(dpy_surface), buffer_size);
+ return true;
+}
#ifndef MARU_SDL_H_
#define MARU_SDL_H_
-#include <SDL.h>
-#include <SDL_syswm.h>
#include "ui/console.h"
extern DisplayChangeListenerOps maru_dcl_ops;
void maru_sdl_interpolation(bool on);
void maru_sdl_quit(void);
+bool maru_extract_framebuffer(void *buffer);
+
#endif /* MARU_SDL_H_ */
#include "emul_state.h"
#include "hw/maru_brightness.h"
#include "skin/maruskin_server.h"
-#include "debug_ch.h"
#include "maru_err_table.h"
+#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(tizen, maru_shm);
{
shm_skip_update = 0;
}
+
+bool maru_extract_framebuffer(void* buffer)
+{
+ INFO("not support on Mac OS X\n");
+ return false;
+}
bool blank_guide);
void maru_shm_resize(void);
void maru_shm_quit(void);
+bool maru_extract_framebuffer(void *buffer);
#endif /* MARU_SHM_H_ */
*
* Contact:
* Kitae Kim <kt920.kim@samsung.com>
+ * SangHo Park <sangho1206.park@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
*
* This program is free software; you can redistribute it and/or
#include <png.h>
#include "emul_state.h"
+
+#ifdef CONFIG_SDL
+#include "maru_sdl.h"
+#endif
+#ifdef CONFIG_USE_SHM
+#include "maru_shm.h"
+#endif
+
#include "skin/maruskin_operation.h"
#include "encode_fb.h"
+
+#if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG)
+#include <time.h>
+#endif
+
#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(tizen, app_tethering);
#if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG)
clock_gettime(CLOCK_MONOTONIC, &end);
- INFO("encoding time: %.5f seconds\n",
+ 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
*/
int bit_depth = 8;
struct encode_mem *container = NULL;
+ uint8_t *surface = NULL;
+ uint32_t surface_size = 0;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
png_bytepp row_pointers = NULL;
- Framebuffer *surface = NULL;
-
- surface = request_screenshot();
- if (!surface) {
- ERR("failed to get framebuffer\n");
- return NULL;
- }
-
width = get_emul_resolution_width();
height = get_emul_resolution_height();
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) {
+ ERR("failed to allocate framebuffer\n");
+ return NULL;
+ }
+
+ if (!maru_extract_framebuffer(surface)) {
+ ERR("failed to extract framebuffer\n");
+ g_free(surface);
+ return NULL;
+ }
+
TRACE("png_create_write_struct\n");
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
ERR("png_create_write_struct failure\n");
- g_free(surface->data);
g_free(surface);
return NULL;
}
info_ptr = png_create_info_struct(png_ptr);
if (!png_ptr) {
ERR("png_create_info_struct failure\n");
- g_free(surface->data);
g_free(surface);
png_destroy_write_struct(&png_ptr, &info_ptr);
return NULL;
TRACE("try png_jmpbuf\n");
if (setjmp(png_jmpbuf(png_ptr))) {
ERR("png_jmpbuf failure\n");
- g_free(surface->data);
g_free(surface);
png_destroy_write_struct(&png_ptr, &info_ptr);
png_destroy_info_struct(png_ptr, &info_ptr);
container = g_malloc(sizeof(struct encode_mem));
if (!container) {
ERR("failed to allocate encode_mem\n");
- g_free(surface->data);
g_free(surface);
png_destroy_write_struct(&png_ptr, &info_ptr);
png_destroy_info_struct(png_ptr, &info_ptr);
row_pointers = png_malloc(png_ptr, sizeof(png_bytep) * height);
if (row_pointers == NULL) {
ERR("failed to allocate png memory\n");
- g_free(surface->data);
g_free(surface);
png_destroy_write_struct(&png_ptr, &info_ptr);
png_destroy_info_struct(png_ptr, &info_ptr);
}
for (row_index = 0; row_index < height; row_index++) {
- row_pointers[row_index] = surface->data + (row_index * image_stride);
+ row_pointers[row_index] = surface + (row_index * image_stride);
}
TRACE("png_write_image\n");
TRACE("png_write_end\n");
png_write_end(png_ptr, info_ptr);
- g_free(surface->data);
g_free(surface);
TRACE("png image size %d\n", container->length);
*
*/
-#include <time.h>
-
struct encode_mem {
uint8_t *buffer;
uint32_t length;
bool is_touch_supported;
// int touch_max_point;
-
// display_state *display;
} touch_event;
// static void set_touch_event_status(bool status);
static bool send_display_image_data(void);
-
#if 0
touch_state *init_touch_state(void)
{
}
#endif
+static bool is_display_dirty = false;
+
+void set_display_dirty(bool dirty)
+{
+ TRACE("qemu display update: %d\n", is_display_dirty);
+ is_display_dirty = dirty;
+}
+
// bool msgproc_tethering_touch_msg(Tethering__TouchMsg *msg)
bool msgproc_tethering_touch_msg(void *message)
{
break;
case TETHERING__TOUCH_MSG__TYPE__DISPLAY_MSG:
- send_display_image_data();
+ if (is_display_dirty) {
+ send_display_image_data();
+ is_display_dirty = false;
+ }
break;
#if 0
send_tethering_touch_status_ecp();
}
+static void dump_display_image_data(struct encode_mem *image)
+{
+#ifdef IMAGE_DUMP
+ FILE *fp = NULL;
+
+ fp = fopen("display_image_dump.png", "wb");
+ if (fp != NULL) {
+ fwrite(image->buffer, 1, image->length, fp);
+ fclose(fp);
+ }
+#endif
+}
+
static bool send_display_image_data(void)
{
bool ret = false;
TRACE("enter: %s\n", __func__);
+#ifdef CONFIG_PNG
image = (struct encode_mem *)encode_framebuffer();
if (!image) {
ERR("failed to encode framebuffer\n");
return false;
}
+#else
+ INFO("not support display feature\n");
+ return false;
+#endif
+ dump_display_image_data(image);
TRACE("image data size %d\n", image->length);
display.has_imagedata = true;
display.imagedata.len = image->length;
display.imagedata.data = image->buffer;
-#ifdef IMAGE_DUMP
- {
- FILE *fp = NULL;
-
- fp = fopen("test2.png", "wb");
- if (fp != NULL) {
- fwrite(image->buffer, 1, image->length, fp);
- fclose(fp);
- }
- }
-#endif
-
touch.type = TETHERING__TOUCH_MSG__TYPE__DISPLAY_MSG;
touch.display = &display;
- // ret = build_display_msg(&display);
ret = build_touch_msg(&touch);
- INFO("send display message: %d\n", ret);
+ TRACE("send display message: %d\n", ret);
g_free(image->buffer);
g_free(image);
*
*/
-// #include "genmsg/tethering.pb-c.h"
+enum {
+ ENCODE_WEBP = 0,
+ ENCODE_PNG,
+};
-// bool msgproc_tethering_touch_msg(Tethering__TouchMsg *msg);
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);