add punch option to tdm-monitor 29/99929/2
authorBoram Park <boram1288.park@samsung.com>
Thu, 24 Nov 2016 03:16:37 +0000 (12:16 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 25 Nov 2016 07:51:51 +0000 (23:51 -0800)
Change-Id: Ib70965942ed775a421a9465ab3e9f2b38ff40a3e

include/tdm_helper.h
src/tdm_helper.c
src/tdm_monitor_server.c

index 3e4459c..3de7da3 100644 (file)
@@ -76,6 +76,23 @@ void
 tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file);
 
 /**
+ * @brief fill a buffer with 0 for given pos.
+ * @details
+ * This function supports only if a buffer has below formats.
+ * - TBM_FORMAT_ARGB8888
+ * - TBM_FORMAT_XRGB8888
+ * - TBM_FORMAT_YVU420
+ * - TBM_FORMAT_YUV420
+ * - TBM_FORMAT_NV12
+ * - TBM_FORMAT_NV21
+ * - TBM_FORMAT_YUYV
+ * - TBM_FORMAT_UYVY
+ * @param[in] buffer A TDM buffer
+ */
+void
+tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos);
+
+/**
  * @brief fill a buffer with 0.
  * @details
  * This function supports only if a buffer has below formats.
index f2fce58..3e4af9d 100644 (file)
@@ -293,8 +293,8 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
        TDM_INFO("dump %s", file);
 }
 
-EXTERN void
-tdm_helper_clear_buffer(tbm_surface_h buffer)
+void
+tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos)
 {
        tbm_surface_info_s info;
        int ret;
@@ -307,7 +307,19 @@ tdm_helper_clear_buffer(tbm_surface_h buffer)
        switch (info.format) {
        case TBM_FORMAT_ARGB8888:
        case TBM_FORMAT_XRGB8888:
-               memset(info.planes[0].ptr, 0, info.planes[0].stride * info.height);
+               if (!pos) {
+                       memset(info.planes[0].ptr, 0, info.planes[0].stride * info.height);
+               } else {
+                       unsigned char *p;
+                       int x, y;
+                       for (y = pos->y; y <= (pos->y + pos->h); y++) {
+                               p = info.planes[0].ptr + info.planes[0].stride * y;
+                               for (x = pos->x; x <= (pos->x + pos->w); x++) {
+                                       int *ibuf = (int*)p;
+                                       ibuf[x] = 0x00000000;
+                               }
+                       }
+               }
                break;
        case TBM_FORMAT_YVU420:
        case TBM_FORMAT_YUV420:
@@ -344,6 +356,14 @@ tdm_helper_clear_buffer(tbm_surface_h buffer)
        tbm_surface_unmap(buffer);
 }
 
+EXTERN void
+tdm_helper_clear_buffer(tbm_surface_h buffer)
+{
+       TDM_RETURN_IF_FAIL(buffer != NULL);
+
+       tdm_helper_clear_buffer_pos(buffer, NULL);
+}
+
 EXTERN int
 tdm_helper_get_fd(const char *env)
 {
index 4ea1184..2a1b318 100644 (file)
@@ -304,6 +304,64 @@ _tdm_monitor_server_dump(unsigned int pid, char *cwd, int argc, char *argv[], ch
        tdm_display_enable_dump(dpy, (const char*)argv[2], reply, len);
 }
 
+static void
+_tdm_monitor_server_punch(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
+{
+       char *arg, *end;
+       unsigned int output_id, layer_id;
+       tdm_output *output;
+       tdm_layer *layer;
+       tbm_surface_h buffer;
+
+       arg = argv[2];
+
+       output_id = strtol(arg, &end, 10);
+       output = tdm_display_get_output(dpy, output_id, NULL);
+       if (!output) {
+               TDM_SNPRINTF(reply, len, "not found output\n");
+               return;
+       }
+       if (*end != ',') {
+               TDM_SNPRINTF(reply, len, "not found ',<layer_idx>'\n");
+               return;
+       }
+
+       arg = end + 1;
+       layer_id = strtol(arg, &end, 10);
+       layer = tdm_output_get_layer(output, layer_id, NULL);
+       if (!layer) {
+               TDM_SNPRINTF(reply, len, "not found layer\n");
+               return;
+       }
+
+       buffer = tdm_layer_get_displaying_buffer(layer, NULL);
+       if (!buffer) {
+               TDM_SNPRINTF(reply, len, "not found buffer\n");
+               return;
+       }
+
+       if (*end == ':') {
+               tdm_pos pos = {0,};
+
+               arg = end + 1;
+               pos.w = strtol(arg, &end, 10);
+               TDM_EXIT_IF_FAIL(*end == 'x');
+               arg = end + 1;
+               pos.h = strtol(arg, &end, 10);
+               if (*end == '+') {
+                       arg = end + 1;
+                       pos.x = strtol(arg, &end, 10);
+                       TDM_EXIT_IF_FAIL(*end == '+');
+                       arg = end + 1;
+                       pos.y = strtol(arg, &end, 10);
+               }
+
+               tdm_helper_clear_buffer_pos(buffer, &pos);
+       }
+       else
+               tdm_helper_clear_buffer(buffer);
+}
+
 static struct {
        const char *opt;
        void (*func)(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy);
@@ -351,6 +409,12 @@ static struct {
                "<object_type1>[,<object_type2>[,...]][@<directory_path>]",
                NULL
        },
+       {
+               "punch", _tdm_monitor_server_punch,
+               "punch a layer",
+               "<output_idx>,<layer_idx>[:<w>x<h>[+<x>+<y>]]",
+               NULL
+       },
 };
 
 static void