From 9cf6df09be87349d5a20c3a8ac67e86d50b6f943 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Fri, 11 Apr 2014 16:01:58 +0900 Subject: [PATCH] display: Add dirty flag for display At idle screen moment, there is no need to copy framebuffers to the display. Change-Id: I4006e5732de947ce1617161182ca901b179c9423 Signed-off-by: Stanislav Vorobiov Signed-off-by: GiWoong Kim --- hw/vigs/vigs_backend.h | 3 +- hw/vigs/vigs_device.c | 28 ++++++++++++++----- hw/vigs/vigs_gl_backend.c | 2 +- hw/vigs/vigs_server.c | 24 ++++++++++++---- hw/vigs/vigs_server.h | 3 +- hw/vigs/vigs_sw_backend.c | 2 +- tizen/src/hw/maru_brightness.c | 11 ++------ tizen/src/maru_display.c | 18 ++++++++++++ tizen/src/maru_display.h | 2 ++ tizen/src/maru_sdl.c | 25 +++++++++++++++++ tizen/src/maru_sdl.h | 2 ++ .../tizen/emulator/skin/EmulatorShmSkin.java | 13 +++++++++ .../org/tizen/emulator/skin/EmulatorSkin.java | 15 ++++++++++ .../emulator/skin/comm/ICommunicator.java | 1 + tizen/src/skin/maruskin_operation.c | 28 +++++++++---------- tizen/src/skin/maruskin_operation.h | 1 + tizen/src/skin/maruskin_server.c | 22 +++++++++++++++ 17 files changed, 159 insertions(+), 41 deletions(-) diff --git a/hw/vigs/vigs_backend.h b/hw/vigs/vigs_backend.h index 126cc5d2b3..cffcd2bb55 100644 --- a/hw/vigs/vigs_backend.h +++ b/hw/vigs/vigs_backend.h @@ -43,7 +43,8 @@ typedef uint8_t *(*vigs_composite_start_cb)(void */*user_data*/, vigsp_surface_format /*format*/); typedef void (*vigs_composite_end_cb)(void */*user_data*/, - bool /*was_started*/); + bool /*was_started*/, + bool /*dirty*/); struct vigs_backend { diff --git a/hw/vigs/vigs_device.c b/hw/vigs/vigs_device.c index f9e2da884a..3f66f1b40b 100644 --- a/hw/vigs/vigs_device.c +++ b/hw/vigs/vigs_device.c @@ -42,6 +42,12 @@ #define VIGS_IO_SIZE 0x1000 +#ifndef CONFIG_USE_SHM +#define VIGS_EXTRA_INVALIDATION (9) +#else +#define VIGS_EXTRA_INVALIDATION (0) +#endif + struct work_queue; typedef struct VIGSState @@ -70,6 +76,7 @@ typedef struct VIGSState * Our console. */ QemuConsole *con; + int invalidate_cnt; uint32_t reg_con; uint32_t reg_int; @@ -119,15 +126,19 @@ static void vigs_hw_update(void *opaque) return; } - vigs_server_update_display(s->server); + if (vigs_server_update_display(s->server, s->invalidate_cnt)) { + /* + * 'vigs_server_update_display' could have updated the surface, + * so fetch it again. + */ + ds = qemu_console_surface(s->con); - /* - * 'vigs_server_update_display' could have updated the surface, - * so fetch it again. - */ - ds = qemu_console_surface(s->con); + dpy_gfx_update(s->con, 0, 0, surface_width(ds), surface_height(ds)); + } - dpy_gfx_update(s->con, 0, 0, surface_width(ds), surface_height(ds)); + if (s->invalidate_cnt > 0) { + s->invalidate_cnt--; + } if (s->reg_con & VIGS_REG_CON_VBLANK_ENABLE) { s->reg_int |= VIGS_REG_INT_VBLANK_PENDING; @@ -137,6 +148,9 @@ static void vigs_hw_update(void *opaque) static void vigs_hw_invalidate(void *opaque) { + VIGSState *s = opaque; + + s->invalidate_cnt = 1 + VIGS_EXTRA_INVALIDATION; } static void vigs_dpy_resize(void *user_data, diff --git a/hw/vigs/vigs_gl_backend.c b/hw/vigs/vigs_gl_backend.c index 1e26d99882..db077dbbf3 100644 --- a/hw/vigs/vigs_gl_backend.c +++ b/hw/vigs/vigs_gl_backend.c @@ -1132,7 +1132,7 @@ static void vigs_gl_backend_read_pixels_work(struct work_queue_item *wq_item) backend->read_pixels_make_current(backend, false); } - item->end_cb(item->user_data, (dst != NULL)); + item->end_cb(item->user_data, (dst != NULL), true); g_free(item); } diff --git a/hw/vigs/vigs_server.c b/hw/vigs/vigs_server.c index a710a6ce66..6be06b75bd 100644 --- a/hw/vigs/vigs_server.c +++ b/hw/vigs/vigs_server.c @@ -455,7 +455,8 @@ static uint8_t *vigs_server_update_display_start_cb(void *user_data, } static void vigs_server_update_display_end_cb(void *user_data, - bool was_started) + bool was_started, + bool dirty) { struct vigs_server *server = user_data; uint32_t capture_fence_seq; @@ -464,6 +465,10 @@ static void vigs_server_update_display_end_cb(void *user_data, qemu_mutex_lock(&server->capture_mutex); } + if (dirty) { + server->captured.dirty = true; + } + server->is_capturing = false; capture_fence_seq = server->capture_fence_seq; server->capture_fence_seq = 0; @@ -490,7 +495,7 @@ static void vigs_server_update_display_work(struct work_queue_item *wq_item) * If no root surface then this is a no-op. * TODO: Can planes be enabled without a root surface ? */ - vigs_server_update_display_end_cb(server, false); + vigs_server_update_display_end_cb(server, false, false); goto out; } @@ -530,7 +535,7 @@ static void vigs_server_update_display_work(struct work_queue_item *wq_item) root_sfc->ptr, root_sfc->stride * root_sfc->ws_sfc->height); - vigs_server_update_display_end_cb(server, true); + vigs_server_update_display_end_cb(server, true, true); } else if (root_sfc->ptr || root_sfc->is_dirty || planes_dirty) { /* * Composite root surface and planes. @@ -559,7 +564,7 @@ static void vigs_server_update_display_work(struct work_queue_item *wq_item) /* * No changes, no-op. */ - vigs_server_update_display_end_cb(server, false); + vigs_server_update_display_end_cb(server, false, false); } out: @@ -768,18 +773,23 @@ void vigs_server_dispatch(struct vigs_server *server, server); } -void vigs_server_update_display(struct vigs_server *server) +bool vigs_server_update_display(struct vigs_server *server, int invalidate_cnt) { + bool updated = false; uint32_t sfc_bpp; uint32_t display_stride, display_bpp; uint8_t *display_data; qemu_mutex_lock(&server->capture_mutex); - if (!server->captured.data) { + if (!server->captured.data || + (!server->captured.dirty && invalidate_cnt <= 0)) { goto out; } + server->captured.dirty = false; + updated = true; + sfc_bpp = vigs_format_bpp(server->captured.format); server->display_ops->resize(server->display_user_data, @@ -846,4 +856,6 @@ out: work_queue_add_item(server->render_queue, &item->base); } + + return updated; } diff --git a/hw/vigs/vigs_server.h b/hw/vigs/vigs_server.h index 9ced88d124..7bb902bd87 100644 --- a/hw/vigs/vigs_server.h +++ b/hw/vigs/vigs_server.h @@ -109,6 +109,7 @@ struct vigs_server uint32_t height; uint32_t stride; vigsp_surface_format format; + bool dirty; } captured; /* @@ -130,6 +131,6 @@ void vigs_server_reset(struct vigs_server *server); void vigs_server_dispatch(struct vigs_server *server, uint32_t ram_offset); -void vigs_server_update_display(struct vigs_server *server); +bool vigs_server_update_display(struct vigs_server *server, int invalidate_cnt); #endif diff --git a/hw/vigs/vigs_sw_backend.c b/hw/vigs/vigs_sw_backend.c index 52e524ba08..5991089237 100644 --- a/hw/vigs/vigs_sw_backend.c +++ b/hw/vigs/vigs_sw_backend.c @@ -390,7 +390,7 @@ static void vigs_sw_backend_composite(struct vigs_surface *surface, surface->stride * surface->ws_sfc->height); } - end_cb(user_data, true); + end_cb(user_data, true, true); } static void vigs_sw_backend_batch_end(struct vigs_backend *backend) diff --git a/tizen/src/hw/maru_brightness.c b/tizen/src/hw/maru_brightness.c index 5442e2e937..b65e15d59e 100644 --- a/tizen/src/hw/maru_brightness.c +++ b/tizen/src/hw/maru_brightness.c @@ -32,9 +32,7 @@ #include "hw/i386/pc.h" -#ifdef TARGET_ARM #include "ui/console.h" -#endif #include "hw/pci/pci.h" #include "maru_device_ids.h" #include "maru_brightness.h" @@ -104,6 +102,8 @@ static void maru_pixman_image_set_alpha(uint8_t value) } level_color.alpha = value << 8; brightness_image = pixman_image_create_solid_fill(&level_color); + + graphic_hw_invalidate(NULL); } static void brightness_reg_write(void *opaque, @@ -126,9 +126,6 @@ static void brightness_reg_write(void *opaque, } else { brightness_level = val; maru_pixman_image_set_alpha(brightness_tbl[brightness_level]); -#ifdef TARGET_ARM - graphic_hw_invalidate(NULL); -#endif } return; case BRIGHTNESS_OFF: @@ -143,10 +140,6 @@ static void brightness_reg_write(void *opaque, maru_pixman_image_set_alpha(brightness_tbl[brightness_level]); } -#ifdef TARGET_ARM - graphic_hw_invalidate(NULL); -#endif - /* notify to skin process */ qemu_bh_schedule(bh); diff --git a/tizen/src/maru_display.c b/tizen/src/maru_display.c index f3873884b9..e5286734ca 100644 --- a/tizen/src/maru_display.c +++ b/tizen/src/maru_display.c @@ -74,6 +74,24 @@ void maru_display_fini(void) #endif } +void maru_display_update(void) +{ +#ifndef CONFIG_USE_SHM + maruskin_sdl_update(); +#else + /* do nothing */ +#endif +} + +void maru_display_invalidate(bool on) +{ +#ifndef CONFIG_USE_SHM + maruskin_sdl_invalidate(on); +#else + /* do nothing */ +#endif +} + void maru_display_interpolation(bool on) { #ifndef CONFIG_USE_SHM diff --git a/tizen/src/maru_display.h b/tizen/src/maru_display.h index 326c6764e3..e85cc3ebc9 100644 --- a/tizen/src/maru_display.h +++ b/tizen/src/maru_display.h @@ -41,6 +41,8 @@ typedef struct MaruScreenshot { void maru_display_init(DisplayState *ds); void maru_display_fini(void); +void maru_display_update(void); +void maru_display_invalidate(bool on); void maru_display_interpolation(bool on); void maruskin_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index 366ee828fd..ab4d121b38 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -48,6 +48,7 @@ MULTI_DEBUG_CHANNEL(tizen, maru_sdl); static QEMUBH *sdl_init_bh; static QEMUBH *sdl_resize_bh; +static QEMUBH *sdl_update_bh; static DisplaySurface *dpy_surface; static SDL_Surface *surface_screen; @@ -60,6 +61,7 @@ static double current_scale_factor = 1.0; static double current_screen_degree; static pixman_filter_t sdl_pixman_filter; +static bool sdl_invalidate; static int sdl_alteration; static unsigned int sdl_skip_update; @@ -546,6 +548,9 @@ static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl) } } + if (sdl_invalidate) { + graphic_hw_invalidate(NULL); + } graphic_hw_update(NULL); /* Usually, continuously updated. @@ -684,6 +689,11 @@ static void *run_qemu_update(void *arg) } #endif +static void maru_sdl_update_bh(void *opaque) +{ + qemu_ds_sdl_update(NULL, 0, 0, 0, 0); +} + static void maru_sdl_resize_bh(void *opaque) { int surface_width = 0, surface_height = 0; @@ -743,6 +753,8 @@ static void maru_sdl_resize_bh(void *opaque) return; } + SDL_UpdateRect(surface_screen, 0, 0, 0, 0); + /* create buffer for image processing */ SDL_FreeSurface(scaled_screen); scaled_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, @@ -772,6 +784,8 @@ static void maru_sdl_resize_bh(void *opaque) #ifdef SDL_THREAD pthread_mutex_unlock(&sdl_mutex); #endif + + graphic_hw_invalidate(NULL); } static void maru_sdl_init_bh(void *opaque) @@ -820,6 +834,7 @@ void maruskin_sdl_init(uint64 swt_handle, sdl_init_bh = qemu_bh_new(maru_sdl_init_bh, NULL); sdl_resize_bh = qemu_bh_new(maru_sdl_resize_bh, NULL); + sdl_update_bh = qemu_bh_new(maru_sdl_update_bh, NULL); sprintf(SDL_windowhack, "%ld", window_id); g_setenv("SDL_WINDOWID", SDL_windowhack, 1); @@ -880,3 +895,13 @@ void maruskin_sdl_resize(void) qemu_bh_schedule(sdl_resize_bh); } + +void maruskin_sdl_update(void) +{ + qemu_bh_schedule(sdl_update_bh); +} + +void maruskin_sdl_invalidate(bool on) +{ + sdl_invalidate = on; +} diff --git a/tizen/src/maru_sdl.h b/tizen/src/maru_sdl.h index a5ac72b262..eba4305a70 100644 --- a/tizen/src/maru_sdl.h +++ b/tizen/src/maru_sdl.h @@ -43,6 +43,8 @@ void maruskin_sdl_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide); void maruskin_sdl_resize(void); +void maruskin_sdl_update(void); +void maruskin_sdl_invalidate(bool on); void maruskin_sdl_interpolation(bool on); void maruskin_sdl_quit(void); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java index 882b6ff173..800f2004e7 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java @@ -473,10 +473,14 @@ public class EmulatorShmSkin extends EmulatorSkin { if (finger.getMultiTouchEnable() == 1) { finger.maruFingerProcessing1(eventType, e.x, e.y, geometry[0], geometry[1]); + + lcdCanvas.redraw(); return; } else if (finger.getMultiTouchEnable() == 2) { finger.maruFingerProcessing2(eventType, e.x, e.y, geometry[0], geometry[1]); + + lcdCanvas.redraw(); return; } @@ -505,11 +509,15 @@ public class EmulatorShmSkin extends EmulatorSkin { logger.info("maruFingerProcessing 1"); finger.maruFingerProcessing1(MouseEventType.RELEASE.value(), e.x, e.y, geometry[0], geometry[1]); + + lcdCanvas.redraw(); return; } else if (finger.getMultiTouchEnable() == 2) { logger.info("maruFingerProcessing 2"); finger.maruFingerProcessing2(MouseEventType.RELEASE.value(), e.x, e.y, geometry[0], geometry[1]); + + lcdCanvas.redraw(); return; } @@ -540,11 +548,15 @@ public class EmulatorShmSkin extends EmulatorSkin { logger.info("maruFingerProcessing 1"); finger.maruFingerProcessing1(MouseEventType.PRESS.value(), e.x, e.y, geometry[0], geometry[1]); + + lcdCanvas.redraw(); return; } else if (finger.getMultiTouchEnable() == 2) { logger.info("maruFingerProcessing 2"); finger.maruFingerProcessing2(MouseEventType.PRESS.value(), e.x, e.y, geometry[0], geometry[1]); + + lcdCanvas.redraw(); return; } @@ -570,6 +582,7 @@ public class EmulatorShmSkin extends EmulatorSkin { logger.info("enable multi-touch = mode 1"); } else { finger.clearFingerSlot(false); + updateDisplay(); logger.info("disable multi-touch"); } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 43c546302f..92031adfd8 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -370,11 +370,23 @@ public class EmulatorSkin { public void grabShell(int x, int y) { shellGrabPosition.x = x; shellGrabPosition.y = y; + + if (SwtUtil.isWindowsPlatform() == true) { + final BooleanData dataGrabbing = new BooleanData( + true, SendCommand.SEND_SKIN_GRABBED.toString()); + communicator.sendToQEMU(SendCommand.SEND_SKIN_GRABBED, dataGrabbing, false); + } } public void ungrabShell() { shellGrabPosition.x = -1; shellGrabPosition.y = -1; + + if (SwtUtil.isWindowsPlatform() == true) { + final BooleanData dataGrabbing = new BooleanData( + false, SendCommand.SEND_SKIN_GRABBED.toString()); + communicator.sendToQEMU(SendCommand.SEND_SKIN_GRABBED, dataGrabbing, false); + } } public boolean isShellGrabbing() { @@ -1513,6 +1525,8 @@ public class EmulatorSkin { currentState.getCurrentScale(), rotationId); communicator.sendToQEMU(SendCommand.SEND_DISPLAY_STATE, stateData, false); + + updateDisplay(); } }; @@ -1558,6 +1572,7 @@ public class EmulatorSkin { communicator.sendToQEMU(SendCommand.SEND_DISPLAY_STATE, stateData, false); + updateDisplay(); } }; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java index 587277144d..523bf88a4b 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java @@ -168,6 +168,7 @@ public interface ICommunicator extends Runnable { /* This values must match the QEMU definitions */ SEND_SKIN_OPENED((short) 1), + SEND_SKIN_GRABBED((short) 2), SEND_MOUSE_EVENT((short) 10), SEND_KEYBOARD_KEY_EVENT((short) 11), diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 94f9cfd79d..6c6b150ee1 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -93,6 +93,13 @@ void start_display(uint64 handle_id, display_width, display_height, blank_guide); } +void do_grabbing_enable(bool on) +{ + INFO("skin grabbing enable : %d\n", on); + + maru_display_invalidate(on); +} + void do_mouse_event(int button_type, int event_type, int origin_x, int origin_y, int x, int y, int z) { @@ -118,9 +125,13 @@ void do_mouse_event(int button_type, int event_type, /* multi-touch */ if (get_emul_multi_touch_state()->multitouch_enable == 1) { maru_finger_processing_1(event_type, origin_x, origin_y, x, y); + + maru_display_update(); return; } else if (get_emul_multi_touch_state()->multitouch_enable == 2) { maru_finger_processing_2(event_type, origin_x, origin_y, x, y); + + maru_display_update(); return; } #endif @@ -172,14 +183,6 @@ void do_mouse_event(int button_type, int event_type, ERR("undefined mouse event type passed : %d\n", event_type); break; } - -#if 0 -#ifdef CONFIG_WIN32 - Sleep(1); -#else - usleep(1000); -#endif -#endif } void do_keyboard_key_event(int event_type, @@ -244,6 +247,8 @@ void do_keyboard_key_event(int event_type, clear_finger_slot(false); INFO("disable multi-touch\n"); } + + maru_display_update(); } } @@ -310,13 +315,6 @@ void do_scale_event(double scale_factor) INFO("do_scale_event scale_factor : %lf\n", scale_factor); set_emul_win_scale(scale_factor); - -#if 0 - //TODO: thread safe - //qemu refresh - vga_hw_invalidate(); - vga_hw_update(); -#endif } void do_rotation_event(int rotation_type) diff --git a/tizen/src/skin/maruskin_operation.h b/tizen/src/skin/maruskin_operation.h index e7234c0906..b7703500ee 100644 --- a/tizen/src/skin/maruskin_operation.h +++ b/tizen/src/skin/maruskin_operation.h @@ -51,6 +51,7 @@ void start_display(uint64 handle_id, unsigned int display_width, unsigned int display_height, double scale_factor, short rotation_type, bool blank_guide); +void do_grabbing_enable(bool on); void do_mouse_event(int button_type, int event_type, int origin_x, int origin_y, int x, int y, int z); void do_keyboard_key_event(int event_type, diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index f3168f7613..ce2273d6ca 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -100,6 +100,7 @@ enum { in Skin process */ RECV_SKIN_OPENED = 1, + RECV_SKIN_GRABBED = 2, RECV_MOUSE_EVENT = 10, RECV_KEYBOARD_KEY_EVENT = 11, @@ -870,6 +871,27 @@ static void* run_skin_server(void* args) break; } + case RECV_SKIN_GRABBED: { + char on = 0; + + log_cnt += sprintf(log_buf + log_cnt, "RECV_SKIN_GRABBED ==\n"); + TRACE(log_buf); + + if (length <= 0) { + INFO("there is no data looking at 0 length.\n"); + continue; + } + + memcpy(&on, recvbuf, sizeof(on)); + + if (on == 0) { + do_grabbing_enable(false); + } else { + do_grabbing_enable(true); + } + + break; + } case RECV_MOUSE_EVENT: { log_cnt += sprintf( log_buf + log_cnt, "RECV_MOUSE_EVENT ==\n" ); TRACE( log_buf ); -- 2.34.1