qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 5/7] g364fb: port to test_and_clear instead of test/


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 5/7] g364fb: port to test_and_clear instead of test/reset
Date: Fri, 11 Oct 2013 16:20:48 +0200

From: Juan Quintela <address@hidden>

Now page_min/max are not needed anymore.  In this case, we need to
know if something has changed to refresh the display. Introduce
"dirty" bool for that.

Signed-off-by: Juan Quintela <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
 hw/display/g364fb.c | 38 ++++++++++++--------------------------
 1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 7082171..8306294 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -60,19 +60,11 @@ typedef struct G364State {

 #define G364_PAGE_SIZE 4096

-static inline int check_dirty(G364State *s, ram_addr_t page)
+static inline bool test_and_clear_dirty(G364State *s, ram_addr_t page)
 {
-    return memory_region_get_dirty(&s->mem_vram, page, G364_PAGE_SIZE,
-                                   DIRTY_MEMORY_VGA);
-}
-
-static inline void reset_dirty(G364State *s,
-                               ram_addr_t page_min, ram_addr_t page_max)
-{
-    memory_region_reset_dirty(&s->mem_vram,
-                              page_min,
-                              page_max + G364_PAGE_SIZE - page_min - 1,
-                              DIRTY_MEMORY_VGA);
+    return memory_region_test_and_clear_dirty(&s->mem_vram, page,
+                                              G364_PAGE_SIZE,
+                                              DIRTY_MEMORY_VGA);
 }

 static void g364fb_draw_graphic8(G364State *s)
@@ -81,12 +73,13 @@ static void g364fb_draw_graphic8(G364State *s)
     int i, w;
     uint8_t *vram;
     uint8_t *data_display, *dd;
-    ram_addr_t page, page_min, page_max;
+    ram_addr_t page;
     int x, y;
     int xmin, xmax;
     int ymin, ymax;
     int xcursor, ycursor;
     unsigned int (*rgb_to_pixel)(unsigned int r, unsigned int g, unsigned int 
b);
+    bool dirty;

     switch (surface_bits_per_pixel(surface)) {
         case 8:
@@ -112,9 +105,7 @@ static void g364fb_draw_graphic8(G364State *s)
     }

     page = 0;
-    page_min = (ram_addr_t)-1;
-    page_max = 0;
-
+    dirty = false;
     x = y = 0;
     xmin = s->width;
     xmax = 0;
@@ -132,12 +123,10 @@ static void g364fb_draw_graphic8(G364State *s)
     /* XXX: out of range in vram? */
     data_display = dd = surface_data(surface);
     while (y < s->height) {
-        if (check_dirty(s, page)) {
+        if (test_and_clear_dirty(s, page)) {
+            dirty = true;
             if (y < ymin)
                 ymin = ymax = y;
-            if (page_min == (ram_addr_t)-1)
-                page_min = page;
-            page_max = page;
             if (x < xmin)
                 xmin = x;
             for (i = 0; i < G364_PAGE_SIZE; i++) {
@@ -194,10 +183,8 @@ static void g364fb_draw_graphic8(G364State *s)
                 ymax = y;
         } else {
             int dy;
-            if (page_min != (ram_addr_t)-1) {
-                reset_dirty(s, page_min, page_max);
-                page_min = (ram_addr_t)-1;
-                page_max = 0;
+            if (dirty) {
+                dirty = false;
                 dpy_gfx_update(s->con, xmin, ymin,
                                xmax - xmin + 1, ymax - ymin + 1);
                 xmin = s->width;
@@ -217,9 +204,8 @@ static void g364fb_draw_graphic8(G364State *s)
     }

 done:
-    if (page_min != (ram_addr_t)-1) {
+    if (dirty) {
         dpy_gfx_update(s->con, xmin, ymin, xmax - xmin + 1, ymax - ymin + 1);
-        reset_dirty(s, page_min, page_max);
     }
 }

-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]