display : Modified to use the pixman library.
authorjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 3 Jul 2013 06:47:56 +0000 (15:47 +0900)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 3 Jul 2013 06:59:17 +0000 (15:59 +0900)
Now, the brightness & overlay devices using the pixman APIs.
There is a bit of a performance enhancements.

Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
tizen/src/hw/maru_brightness.c
tizen/src/hw/maru_brightness.h
tizen/src/hw/maru_overlay.c
tizen/src/hw/maru_overlay.h
tizen/src/hw/maru_vga.c

index a170dbac44ad66120c068192506f26be1ff772fb..17e10ab6f269a9c54a75e54a663fb944a1c0f188 100644 (file)
@@ -61,20 +61,22 @@ enum {
 
 uint32_t brightness_level = BRIGHTNESS_MAX;
 uint32_t brightness_off;
+pixman_color_t level_color;
+pixman_image_t *brightness_image;
 
 /* level : 1 ~ 100, interval : 1 or 2 */
 /* skip 100 level, set to default alpha */
-uint8_t brightness_tbl[] = {100, /* level 0 : for dimming */
-/* level 01 ~ 10 */         106, 108, 109, 111, 112, 114, 115, 117, 118, 120,
-/* level 11 ~ 20 */         121, 123, 124, 126, 127, 129, 130, 132, 133, 135,
-/* level 21 ~ 30 */         136, 138, 139, 141, 142, 144, 145, 147, 148, 150,
-/* level 31 ~ 40 */         151, 153, 154, 156, 157, 159, 160, 162, 163, 165,
-/* level 41 ~ 50 */         166, 168, 169, 171, 172, 174, 175, 177, 178, 180,
-/* level 51 ~ 60 */         181, 183, 184, 186, 187, 189, 190, 192, 193, 195,
-/* level 61 ~ 70 */         196, 198, 199, 201, 202, 204, 205, 207, 208, 210,
-/* level 71 ~ 80 */         211, 213, 214, 216, 217, 219, 220, 222, 223, 225,
-/* level 81 ~ 90 */         226, 228, 229, 231, 232, 234, 235, 237, 238, 240,
-/* level 91 ~ 99 */         241, 243, 244, 246, 247, 249, 250, 252, 253};
+uint8_t brightness_tbl[] = {155, /* level 0 : for dimming */
+/* level 01 ~ 10 */         149, 147, 146, 144, 143, 141, 140, 138, 137, 135,
+/* level 11 ~ 20 */         134, 132, 131, 129, 128, 126, 125, 123, 122, 120,
+/* level 21 ~ 30 */         119, 117, 116, 114, 113, 111, 110, 108, 107, 105,
+/* level 31 ~ 40 */         104, 102, 101,  99,  98,  96,  95,  93,  92,  90,
+/* level 41 ~ 50 */          89,  87,  86,  84,  83,  81,  80,  78,  77,  75,
+/* level 51 ~ 60 */          74,  72,  71,  69,  68,  66,  65,  63,  62,  60,
+/* level 61 ~ 70 */          59,  57,  56,  54,  53,  51,  50,  48,  47,  45,
+/* level 71 ~ 80 */          44,  42,  41,  39,  38,  36,  35,  33,  32,  30,
+/* level 81 ~ 90 */          29,  27,  26,  24,  23,  21,  20,  18,  17,  15,
+/* level 91 ~ 99 */          14,  12,  11,   9,   8,   6,   5,   3,   2};
 
 QEMUBH *bh;
 
@@ -112,6 +114,11 @@ static void brightness_reg_write(void *opaque,
             ERR("brightness_reg_write: Invalide brightness level.\n");
         } else {
             brightness_level = val;
+            if (brightness_image) {
+                pixman_image_unref(brightness_image);
+            }
+            level_color.alpha = brightness_tbl[brightness_level] << 8;
+            brightness_image = pixman_image_create_solid_fill(&level_color);
             INFO("brightness_level : %lld\n", val);
 #ifdef TARGET_ARM
             vga_hw_invalidate();
@@ -151,6 +158,9 @@ static void brightness_exitfn(PCIDevice *dev)
     if (bh) {
         qemu_bh_delete(bh);
     }
+    if (brightness_image) {
+        pixman_image_unref(brightness_image);
+    }
 }
 
 static void maru_brightness_bh(void *opaque)
index 98787c3ffeae5f1f55a544a260a016dbe177feee..f545c2a1cfd4f47d46893d9d4c4d396ed415c3ba 100644 (file)
@@ -33,6 +33,7 @@
 #define MARU_BRIGHTNESS_H_
 
 #include "qemu-common.h"
+#include <pixman.h>
 
 #define BRIGHTNESS_MIN          (0)
 #define BRIGHTNESS_MAX          (100)
@@ -40,6 +41,7 @@
 extern uint32_t brightness_level;
 extern uint32_t brightness_off;
 extern uint8_t brightness_tbl[];
+extern pixman_image_t *brightness_image;
 
 DeviceState *pci_maru_brightness_init(PCIBus *bus);
 
index 7072f586c3012813cacf6c1703b5f1efdce51dca..90aa7f524b3e8e362ce3a125f6b1a068047f3815 100644 (file)
@@ -53,6 +53,9 @@ enum {
 
 uint8_t *overlay_ptr;
 
+pixman_image_t *overlay0_image;
+pixman_image_t *overlay1_image;
+
 uint8_t overlay0_power;
 uint16_t overlay0_left;
 uint16_t overlay0_top;
@@ -127,7 +130,17 @@ static void overlay_reg_write(void *opaque,
             /* clear the last overlay area. */
             memset(overlay_ptr, 0x00, (OVERLAY_MEM_SIZE / 2));
             overlay0_left = overlay0_top = overlay0_width = overlay0_height = 0;
+            if (overlay0_image) {
+                pixman_image_unref(overlay0_image);
+                overlay0_image = NULL;
+            }
             TRACE("clear the last overlay0 area\n");
+        } else {
+            overlay0_image = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+                                overlay0_width, overlay0_height,
+                                (uint32_t *)overlay_ptr,
+                                overlay0_width * 4);
+            TRACE("create the overlay0 pixman image\n");
         }
         break;
     case OVERLAY_POSITION:
@@ -150,7 +163,17 @@ static void overlay_reg_write(void *opaque,
             memset(overlay_ptr + OVERLAY1_REG_OFFSET,
                    0x00, (OVERLAY_MEM_SIZE / 2));
             overlay1_left = overlay1_top = overlay1_width = overlay1_height = 0;
+            if (overlay1_image) {
+                pixman_image_unref(overlay1_image);
+                overlay1_image = NULL;
+            }
             TRACE("clear the last overlay1 area\n");
+        } else {
+            overlay1_image = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+                                overlay1_width, overlay1_height,
+                                (uint32_t *)(overlay_ptr + OVERLAY1_REG_OFFSET),
+                                overlay1_width * 4);
+            TRACE("create the overlay1 pixman image\n");
         }
         break;
     case OVERLAY1_REG_OFFSET + OVERLAY_POSITION:
index 24a4529560cb6b2b9bdde91068466038571954ac..f2da6c55667bbeb5376d7099152c44c057136f43 100644 (file)
 #define MARU_OVERLAY_H_
 
 #include "qemu-common.h"
+#include <pixman.h>
+
+extern pixman_image_t *overlay0_image;
+extern pixman_image_t *overlay1_image;
 
 extern uint8_t *overlay_ptr;
 extern uint8_t overlay0_power;
index c1991a46a90789dc903e96ef62c4411d118e95b7..84b659ac9bf5c0942dd935b47b7aaaf8d7773499 100644 (file)
@@ -1171,6 +1171,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
     uint8_t *d;
     uint32_t v, addr1, addr;
     maru_vga_draw_line_func *maru_vga_draw_line;
+    static pixman_image_t *surface = NULL;
 
     full_update |= update_basic_params(s);
 
@@ -1227,6 +1228,10 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
                     disp_width * 4, (uint8_t*)shared_memory); */
             s->ds->surface = qemu_create_displaysurface(s->ds, disp_width, height);
 
+            surface = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+                                           disp_width, height,
+                                           (uint32_t *)ds_get_data(s->ds),
+                                           disp_width * 4);
 
 #else //MARU_VGA
             s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth,
@@ -1360,76 +1365,6 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
                 if (s->cursor_draw_line)
                     s->cursor_draw_line(s, d, y);
             }
-
-#ifdef MARU_VGA
-
-            int i;
-            uint8_t *fb_sub;
-            uint8_t *over_sub;
-            uint8_t *dst_sub;
-            uint8_t alpha, c_alpha;
-            uint32_t *dst;
-            uint16_t overlay_bottom;
-
-            if ( overlay0_power ) {
-
-                overlay_bottom = overlay0_top + overlay0_height;
-
-                if ( overlay0_top <= y && y < overlay_bottom ) {
-
-                    fb_sub = s->vram_ptr + addr + overlay0_left * 4;
-                    over_sub = overlay_ptr + ( y - overlay0_top ) * overlay0_width * 4;
-                    dst = (uint32_t*) ( s->ds->surface->data + addr + overlay0_left * 4 );
-
-                    for ( i = 0; i < overlay0_width; i++, fb_sub += 4, over_sub += 4, dst++ ) {
-
-                        alpha = fb_sub[3];
-                        c_alpha = 0xff - alpha;
-
-                        *dst = ( ( c_alpha * over_sub[0] + alpha * fb_sub[0] ) >> 8 )
-                            | ( ( c_alpha * over_sub[1] + alpha * fb_sub[1] ) & 0xFF00 )
-                            | ( ( ( c_alpha * over_sub[2] + alpha * fb_sub[2] ) & 0xFF00 ) << 8 );
-                    }
-
-                }
-
-            }
-
-            if ( overlay1_power ) {
-
-                overlay_bottom = overlay1_top + overlay1_height;
-
-                if ( overlay1_top <= y && y < overlay_bottom ) {
-
-                    fb_sub = s->vram_ptr + addr + overlay1_left * 4;
-                    over_sub = overlay_ptr + ( y - overlay1_top ) * overlay1_width * 4 + 0x00400000;
-                    dst = (uint32_t*) ( s->ds->surface->data + addr + overlay1_left * 4 );
-
-                    for ( i = 0; i < overlay1_width; i++, fb_sub += 4, over_sub += 4, dst++ ) {
-
-                        alpha = fb_sub[3];
-                        c_alpha = 0xff - alpha;
-
-                        *dst = ( ( c_alpha * over_sub[0] + alpha * fb_sub[0] ) >> 8 )
-                            | ( ( c_alpha * over_sub[1] + alpha * fb_sub[1] ) & 0xFF00 )
-                            | ( ( ( c_alpha * over_sub[2] + alpha * fb_sub[2] ) & 0xFF00 ) << 8 );
-                    }
-
-                }
-
-            }
-            if (brightness_level < BRIGHTNESS_MAX) {
-                alpha = brightness_tbl[brightness_level];
-                    dst_sub = ds_get_data(s->ds) + addr;
-                    dst = (uint32_t *)(ds_get_data(s->ds) + addr);
-                    for (i = 0; i < disp_width; i++, dst_sub += 4, dst++) {
-                        *dst = ((alpha * dst_sub[0])>> 8)
-                                | ((alpha * dst_sub[1]) & 0xFF00)
-                                | (((alpha * dst_sub[2]) & 0xFF00) << 8);
-                }
-            }
-#endif /* MARU_VGA */
-
         } else {
             if (y_start >= 0) {
                 /* flush to display */
@@ -1453,6 +1388,29 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
         d += linesize;
     }
 
+#ifdef MARU_VGA
+    /* overlay0 */
+    if (overlay0_power) {
+        pixman_image_composite(PIXMAN_OP_OVER,
+                               overlay0_image, NULL, surface,
+                               0, 0, 0, 0, overlay0_left, overlay0_top,
+                               overlay0_width, overlay0_height);
+    }
+    /* overlay1 */
+    if (overlay1_power) {
+        pixman_image_composite(PIXMAN_OP_OVER,
+                               overlay1_image, NULL, surface,
+                               0, 0, 0, 0, overlay1_left, overlay1_top,
+                               overlay1_width, overlay1_height);
+    }
+    /* apply the brightness level */
+    if (brightness_level < BRIGHTNESS_MAX) {
+        pixman_image_composite(PIXMAN_OP_OVER,
+                               brightness_image, NULL, surface,
+                               0, 0, 0, 0, 0, 0,
+                               disp_width, height);
+    }
+#endif
     if (y_start >= 0) {
         /* flush to display */
         dpy_update(s->ds, 0, y_start,