display: Add dirty flag for display 84/19484/2
authorGiWoong Kim <giwoong.kim@samsung.com>
Fri, 11 Apr 2014 07:01:58 +0000 (16:01 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Mon, 14 Apr 2014 09:05:45 +0000 (18:05 +0900)
At idle screen moment, there is no need to copy framebuffers
to the display.

Change-Id: I4006e5732de947ce1617161182ca901b179c9423
Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
17 files changed:
hw/vigs/vigs_backend.h
hw/vigs/vigs_device.c
hw/vigs/vigs_gl_backend.c
hw/vigs/vigs_server.c
hw/vigs/vigs_server.h
hw/vigs/vigs_sw_backend.c
tizen/src/hw/maru_brightness.c
tizen/src/maru_display.c
tizen/src/maru_display.h
tizen/src/maru_sdl.c
tizen/src/maru_sdl.h
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java
tizen/src/skin/maruskin_operation.c
tizen/src/skin/maruskin_operation.h
tizen/src/skin/maruskin_server.c

index 126cc5d2b36797f8e008ed549cc00b9c4744a916..cffcd2bb553fe963c0f3cb6f1a4d97268ddffda9 100644 (file)
@@ -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
 {
index f9e2da884a19feaa34b1f05169a0955483127487..3f66f1b40bbf00fb9bae8ce160d04c49c593b3b2 100644 (file)
 
 #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,
index 1e26d99882039af2a2caceaa9fe5a52e39f89d7d..db077dbbf3fcf94881dbe66251e502f98a795501 100644 (file)
@@ -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);
 }
index a710a6ce66a2795bfc30b83271ff9b2e92b3115e..6be06b75bd1d9822f1e6efb5975a3e537da264f6 100644 (file)
@@ -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;
 }
index 9ced88d1249b4c9f96d62fdc40b434ca6c867dbb..7bb902bd8717789f79c2875d78befc7c1149f3e7 100644 (file)
@@ -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
index 52e524ba088d652c0d23fad86f601603fbb72cd0..5991089237fc766718251cef2ec89ba3f426512d 100644 (file)
@@ -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)
index 5442e2e937758af9d4fd0cf9694850c0c0cdad9f..b65e15d59e07370143325171fbfec9ca98699806 100644 (file)
@@ -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);
 
index f3873884b935624137d7b730c3719d2bde8c3e04..e5286734caf34aa583c60daa70cc4086c489c34e 100644 (file)
@@ -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
index 326c6764e3d75d03fbeeeefac97e60775e539762..e85cc3ebc92a1513e9b9699b1b6436f81dd8967d 100644 (file)
@@ -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,
index 366ee828fd110d4897ef10df89e45dd1c7576f79..ab4d121b3855550bfbcaaecd1ca45ca934fc420b 100644 (file)
@@ -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;
+}
index a5ac72b262477145e8a267691f8d60487d63e556..eba4305a70462f675009a332a269084ebe1bdac9 100644 (file)
@@ -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);
 
index 882b6ff1734b012ce4478cb1093312f5fd6021c8..800f2004e7478c5d904fdf6411673cbe5543453f 100644 (file)
@@ -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");
                        }
index 43c546302f041edb7240840530c72727aacf4785..92031adfd8732d51b0c2ccb4eef082c1e9dbe7c0 100755 (executable)
@@ -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();
                        }
                };
 
index 587277144d14b0ea26f8a33ddd210901fbbced08..523bf88a4b9a84a9d0cab00accbdccef8db435c8 100644 (file)
@@ -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),
index 94f9cfd79db8d008d734f483bcf7175d3a0eef83..6c6b150ee1e495f6042ca6c933bffdf8b71e87ea 100644 (file)
@@ -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)
index e7234c0906d3044997868d9543a35e7b9ef5acc8..b7703500eeb61dcc1f19876ad91a4261f8ebf3c5 100644 (file)
@@ -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,
index f3168f761387876826f0241925c5fe7d784b7790..ce2273d6ca245b856ee9c640d99781d89187cbf2 100644 (file)
@@ -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 );