Workarround hw specific screenshot issue 73/121973/2 accepted/tizen/3.0/common/20170330.125433 accepted/tizen/3.0/ivi/20170329.223137 accepted/tizen/3.0/mobile/20170329.223047 accepted/tizen/3.0/tv/20170329.223103 accepted/tizen/3.0/wearable/20170329.223120 submit/tizen_3.0/20170329.161118 submit/tizen_3.0/20170329.161715
authorDmitry Kovalenko <d.kovalenko@samsung.com>
Wed, 29 Mar 2017 15:45:56 +0000 (18:45 +0300)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Wed, 29 Mar 2017 16:08:28 +0000 (19:08 +0300)
Qualcom devices has 16 pixel padding on right side
So display driver has screen_width+16 width

This workarround detects padding (as black pixels on the right)

Change-Id: I4aa5eea216cee561b19086ee8aa03ce6d8d5a8aa

probe_screenshot/dacapture_wayland.c

index c1e4bc7..b379ef5 100755 (executable)
@@ -478,6 +478,39 @@ fail_display:
        free(data);
        return NULL;
 }
+
+#define QUALCOMPADDING 16
+static int check_padding(uint32_t *img, int width, int height)
+{
+       int padding;
+       int x, y, tmp;
+
+       /* check that potential padding is all black */
+       padding = 1;
+       for (y = 0; y < height; y += height / 16) {
+               tmp = y * (width + QUALCOMPADDING) + width;
+               if (img[tmp] &&
+                   img[tmp + 4] &&
+                   img[tmp + 8]) {
+                       padding = 0;
+                       break;
+               }
+       }
+
+       if (!padding) {
+               return 0;
+       }
+       /* check for black screen*/
+       for (y = 0; y < height; y++) {
+               for (x = 0; x < width; x++) {
+                       if (img[y * width + x] != 0) {
+                               return -EAGAIN;
+                       }
+               }
+       }
+       return -ECANCELED;
+}
+
 static int __capture_screnshot_wayland(const char *path)
 {
        struct screenshooter_output *output;
@@ -489,6 +522,9 @@ static int __capture_screnshot_wayland(const char *path)
        int plane_idx = 0;
        int ret = -1;
        int err;
+       static int checked4padding;
+       static int padding;
+       int width, height;
 
        data =  __wayland_init();
        if (!data) {
@@ -509,7 +545,10 @@ static int __capture_screnshot_wayland(const char *path)
                return -1;
        }
 
-       t_surface = tbm_surface_create(data->width, data->height, TBM_FORMAT_XRGB8888);
+       width = data->width + padding;
+       height = data->height;
+
+       t_surface = tbm_surface_create(width, data->height, TBM_FORMAT_XRGB8888);
        if (!t_surface) {
                PRINTERR("failed to create tbm_surface\n");
                goto fail_tbm_client;
@@ -540,9 +579,25 @@ static int __capture_screnshot_wayland(const char *path)
                goto fail_map_surface;
        }
 
+       if (!checked4padding) {
+               ret = check_padding((uint32_t *)tsuri.planes[plane_idx].ptr,
+                                   data->width, data->height);
+               if (ret == -EAGAIN) {
+                       padding = QUALCOMPADDING; /* HW specific 16 pixels
+                                                    padding on right side */
+                       checked4padding = true;
+                       goto wrong_padding;
+               } else if (ret == -ECANCELED) {
+                       PRINTERR("Checking for padding failed because of screen is black. Let's check next time.\n");
+               } else {
+                       checked4padding = true;
+               }
+       }
+
        ret = __save_to_png(path, tsuri.planes[plane_idx].ptr,
-                           data->width, data->height);
+                           width, height);
 
+wrong_padding:
        tbm_surface_unmap(t_surface);
 
 fail_map_surface:
@@ -582,6 +637,8 @@ int captureScreen()
                 getCurrentEventIndex());
 
        ret = __capture_screnshot_wayland(dstpath);
+       if (ret == -EAGAIN)
+               ret = __capture_screnshot_wayland(dstpath);
        if (!ret) {
                if (chmod(dstpath, 0777) == -1)
                        PRINTWRN("cannot chmod -R777 <%s>", dstpath);