add the api functions (dump_all and queue_dump) for the debugging 92/80892/5
authorRoman Marchenko <r.marchenko@samsung.com>
Wed, 20 Jul 2016 11:26:06 +0000 (14:26 +0300)
committerRoman Marchenko <r.marchenko@samsung.com>
Thu, 1 Sep 2016 15:11:08 +0000 (18:11 +0300)
Change-Id: If65bf485517fa0f9e5b0aa5d9546ce3ec2b18513
Signed-off-by: Roman Marchenko <r.marchenko@samsung.com>
src/tbm_bufmgr.c
src/tbm_bufmgr.h
src/tbm_bufmgr_int.h
src/tbm_surface_internal.c
src/tbm_surface_internal.h
src/tbm_surface_queue.c

index 4e78ce2..65c3ba6 100644 (file)
@@ -48,6 +48,8 @@ int bTrace;
 int bDlog;
 #endif
 
+int b_dump_queue;
+
 #define PREFIX_LIB    "libtbm_"
 #define SUFFIX_LIB    ".so"
 #define DEFAULT_LIB   PREFIX_LIB"default"SUFFIX_LIB
@@ -112,6 +114,32 @@ _tbm_util_check_bo_cnt(tbm_bufmgr bufmgr)
        }
 }
 
+static int
+_tbm_util_get_max_surface_size(int * w, int * h)
+{
+       int count = 0;
+       tbm_surface_h surface = NULL, tmp = NULL;
+       tbm_surface_info_s info;
+
+       *w = 0;
+       *h = 0;
+
+       if (gBufMgr == NULL)
+               return count;
+
+       if (!LIST_IS_EMPTY(&gBufMgr->surf_list)) {
+               LIST_FOR_EACH_ENTRY_SAFE(surface, tmp, &gBufMgr->surf_list, item_link) {
+                       if (tbm_surface_get_info(surface, &info) == TBM_SURFACE_ERROR_NONE) {
+                               count++;
+                               if (*w < info.width) *w = info.width;
+                               if (*h < info.height) *h = info.height;
+                       }
+               }
+       }
+
+       return count;
+}
+
 static void
 _tbm_util_get_appname_brief(char *brief)
 {
@@ -1410,6 +1438,63 @@ tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff)
 #endif
 }
 
+int
+tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff)
+{
+       TBM_LOG_D("path=%s count=%d onoff=%d\n", path, count, onoff);
+
+       if (onoff == 1) {
+
+               TBM_RETURN_VAL_IF_FAIL(path != NULL, 0);
+
+               int w = 0, h = 0;
+               if (_tbm_util_get_max_surface_size(&w, &h) == 0) {
+                       TBM_LOG_I("No tbm_surface.\n");
+                       return 0;
+               }
+
+               tbm_surface_internal_dump_start(path, w, h, count);
+               b_dump_queue = 1;
+
+       } else if (onoff == 0) {
+
+               tbm_surface_internal_dump_end();
+               b_dump_queue = 0;
+
+       } else {
+               return 0;
+       }
+
+       return 1;
+}
+
+int
+tbm_bufmgr_debug_dump_all(char *path)
+{
+       TBM_RETURN_VAL_IF_FAIL(path != NULL, 0);
+
+       TBM_LOG_D("path=%s\n", path);
+       int w = 0, h = 0, count = 0;
+       tbm_surface_h surface = NULL, tmp = NULL;
+
+       count = _tbm_util_get_max_surface_size(&w, &h);
+       if (count == 0) {
+               TBM_LOG_I("No tbm_surface.\n");
+               return 1;
+       }
+
+       tbm_surface_internal_dump_start(path, w, h, count);
+
+       LIST_FOR_EACH_ENTRY_SAFE(surface, tmp, &gBufMgr->surf_list, item_link) {
+               tbm_surface_internal_dump_buffer(surface, "dump_all");
+       }
+
+       tbm_surface_internal_dump_end();
+
+       return 1;
+
+}
+
 /* internal function */
 tbm_bufmgr
 _tbm_bufmgr_get_bufmgr(void)
index ff65efb..366341d 100644 (file)
@@ -1036,6 +1036,23 @@ void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr);
  */
 void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff);
 
+/**
+ * @brief Dump all tbm surfaces
+ * @param[in] path : the given dump path
+ * @return 1 if this function succeeds, otherwise 0.
+ */
+int tbm_bufmgr_debug_dump_all(char *path);
+
+/**
+ * @brief Start the dump debugging for queue.
+ * @since_tizen 3.0
+ * @param[in] path : the given dump path
+ * @param[in] count : the dump count number
+ * @param[in] onoff : 1 is on, and 0 is off, if onoff==0 path and count are ignored
+ * @return 1 if this function succeeds, otherwise 0.
+ */
+int tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff);
+
 int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay);
 
 #ifdef __cplusplus
index c3e8040..2cb7d1c 100644 (file)
@@ -67,6 +67,8 @@ extern int bDebug;
 extern int bTrace;
 #endif /* TRACE */
 
+extern int b_dump_queue;
+
 #ifdef HAVE_DLOG
 #include <dlog.h>
 
index 7b99c2c..57c491f 100644 (file)
@@ -327,32 +327,6 @@ _tbm_surface_internal_destroy(tbm_surface_h surface)
        }
 }
 
-static int
-_tbm_surface_get_max_size(int * w, int * h)
-{
-       int count = 0;
-       tbm_surface_h surface = NULL, tmp = NULL;
-       tbm_surface_info_s info;
-
-       *w = 0;
-       *h = 0;
-
-       if (g_surface_bufmgr == NULL)
-               return count;
-
-       if (!LIST_IS_EMPTY(&g_surface_bufmgr->surf_list)) {
-               LIST_FOR_EACH_ENTRY_SAFE(surface, tmp, &g_surface_bufmgr->surf_list, item_link) {
-                       if (tbm_surface_get_info(surface, &info) == TBM_SURFACE_ERROR_NONE) {
-                               count++;
-                               if (*w < info.width) *w = info.width;
-                               if (*h < info.height) *h = info.height;
-                       }
-               }
-       }
-
-       return count;
-}
-
 int
 tbm_surface_internal_is_valid(tbm_surface_h surface)
 {
@@ -1840,25 +1814,4 @@ void tbm_surface_internal_dump_shm_buffer(void *ptr, int w, int h, int  stride,
 
        TBM_LOG_I("Dump %s \n", buf_info->name);
 }
-
-void tbm_surface_internal_dump_all(char *path)
-{
-       TBM_RETURN_IF_FAIL(path != NULL);
-       int w = 0, h = 0, count = 0;
-       tbm_surface_h surface = NULL, tmp = NULL;
-
-       count = _tbm_surface_get_max_size(&w, &h);
-       if (count == 0) {
-               TBM_LOG_I("No tbm_surface.\n");
-               return;
-       }
-
-       tbm_surface_internal_dump_start(path, w, h, count);
-
-       LIST_FOR_EACH_ENTRY_SAFE(surface, tmp, &g_surface_bufmgr->surf_list, item_link) {
-               tbm_surface_internal_dump_buffer(surface, "dump_all");
-       }
-
-       tbm_surface_internal_dump_end();
-}
 /*LCOV_EXCL_STOP*/
index be88d50..d836774 100644 (file)
@@ -457,12 +457,6 @@ void tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type);
 void tbm_surface_internal_dump_shm_buffer(void *ptr, int w, int h, int stride, const char *type);
 
 /**
- * @brief Dump all tbm surfaces
- * @param[in] path : the given dump path
- */
-void tbm_surface_internal_dump_all(char *path);
-
-/**
  * @brief check valid tbm surface.
  * @since_tizen 3.0
  * @param[in] surface : the tbm surface.
index 9648a9a..23377a7 100644 (file)
@@ -674,6 +674,9 @@ tbm_surface_queue_enqueue(tbm_surface_queue_h
        TBM_RETURN_VAL_IF_FAIL(surface != NULL,
                               TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE);
 
+       if (b_dump_queue)
+               tbm_surface_internal_dump_buffer(surface, "enqueue");
+
        pthread_mutex_lock(&surface_queue->lock);
 
        TBM_QUEUE_TRACE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, surface);
@@ -860,6 +863,9 @@ tbm_surface_queue_acquire(tbm_surface_queue_h
 
        pthread_mutex_unlock(&surface_queue->lock);
 
+       if (b_dump_queue)
+               tbm_surface_internal_dump_buffer(*surface, "acquire");
+
        return TBM_SURFACE_QUEUE_ERROR_NONE;
 }