Merge branch 'tizen' into sandbox/cyeon/devel
[platform/core/uifw/libtdm.git] / src / tdm_helper.c
index 0c8b336..469f9b0 100644 (file)
@@ -136,6 +136,13 @@ _tdm_helper_dump_png(const char *file, const void *data, int width,
                return;
        }
 
+       if (setjmp(png_jmpbuf(pPngStruct))) {
+               /* if png has problem of writing the file, we get here */
+               png_destroy_write_struct(&pPngStruct, &pPngInfo);
+               fclose(fp);
+               return;
+       }
+
        png_init_io(pPngStruct, fp);
        png_set_IHDR(pPngStruct,
                                 pPngInfo,
@@ -288,7 +295,7 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
                strncat(p, file, len);
                p += len;
                *(p++) = '.';
-               strncat(p, ext, 3);
+               strncat(p, ext, 4);
                p += 3;
                *p = '\0';
        } else {
@@ -710,7 +717,7 @@ tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
        TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER);
        TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER);
        TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
-
+/* LCOV_EXCL_START */
        err = tdm_output_get_layer_count(output, &count);
        if (err != TDM_ERROR_NONE) {
                TDM_ERR("tdm_output_get_layer_count fail(%d)\n", err);
@@ -738,6 +745,7 @@ tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
        func(dst_buffer, data);
 
        return TDM_ERROR_NONE;
+/* LCOV_EXCL_STOP */
 }
 
 static char *
@@ -846,6 +854,8 @@ _tdm_helper_get_backend_information(tdm_private_module *private_module, char *re
                        }
                }
        }
+       if (LIST_IS_EMPTY(&private_module->output_list))
+               TDM_SNPRINTF(reply, len, "(no output)\n");
        TDM_SNPRINTF(reply, len, "\n");
 
        /* layer information */
@@ -854,12 +864,17 @@ _tdm_helper_get_backend_information(tdm_private_module *private_module, char *re
        TDM_SNPRINTF(reply, len, "idx   output   zpos   buf   format   size   crop   geometry   transform\n");
        TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
        LIST_FOR_EACH_ENTRY(private_output, &private_module->output_list, link) {
+               if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) {
+                       TDM_SNPRINTF(reply, len, "(no layer), hwc mode on\n");
+                       continue;
+               }
+
+/* LCOV_EXCL_START */
                LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
                        if (!private_layer->usable) {
                                tdm_info_layer info;
                                unsigned int format;
                                tdm_size size;
-                               tbm_surface_info_s buf_info;
 
                                TDM_DBG_RETURN_VAL_IF_FAIL(func_layer->layer_get_info, reply);
                                memset(&info, 0, sizeof info);
@@ -869,17 +884,13 @@ _tdm_helper_get_backend_information(tdm_private_module *private_module, char *re
                                if (!private_layer->showing_buffer)
                                        continue;
 
-                               format = tbm_surface_get_format(private_layer->showing_buffer->buffer);
-                               tbm_surface_get_info(private_layer->showing_buffer->buffer, &buf_info);
-
-                               if (IS_RGB(format))
-                                       size.h = buf_info.planes[0].stride >> 2;
-                               else
-                                       size.h = buf_info.planes[0].stride;
+                               size.h = tbm_surface_get_width(private_layer->showing_buffer->buffer);
                                size.v = tbm_surface_get_height(private_layer->showing_buffer->buffer);
 
                                if (info.src_config.format)
-                                       format = (info.src_config.format) ? : format;
+                                       format = info.src_config.format;
+                               else
+                                       format = tbm_surface_get_format(private_layer->showing_buffer->buffer);
 
                                TDM_SNPRINTF(reply, len, "%d   %d   %d   %p   %c%c%c%c   %ux%u   %ux%u+%u+%u   %ux%u+%u+%u   %s\n",
                                                         private_layer->index,
@@ -946,8 +957,11 @@ _tdm_helper_get_backend_information(tdm_private_module *private_module, char *re
                                }
                                }
                        }
+/* LCOV_EXCL_STOP */
                }
        }
+       if (LIST_IS_EMPTY(&private_module->output_list))
+               TDM_SNPRINTF(reply, len, "(no layer)\n");
        TDM_SNPRINTF(reply, len, "\n");
 
        if (private_module->capabilities & TDM_DISPLAY_CAPABILITY_PP) {