From cde7f5a554815a93f1b2503e271d266f13e0305a Mon Sep 17 00:00:00 2001 From: Boram Park Date: Thu, 24 Nov 2016 12:16:37 +0900 Subject: [PATCH] add punch option to tdm-monitor Change-Id: Ib70965942ed775a421a9465ab3e9f2b38ff40a3e --- include/tdm_helper.h | 17 +++++++++++++ src/tdm_helper.c | 26 +++++++++++++++++--- src/tdm_monitor_server.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 3 deletions(-) diff --git a/include/tdm_helper.h b/include/tdm_helper.h index 3e4459c..3de7da3 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -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. diff --git a/src/tdm_helper.c b/src/tdm_helper.c index f2fce58..3e4af9d 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -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) { diff --git a/src/tdm_monitor_server.c b/src/tdm_monitor_server.c index 4ea1184..2a1b318 100644 --- a/src/tdm_monitor_server.c +++ b/src/tdm_monitor_server.c @@ -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 ','\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 { "[,[,...]][@]", NULL }, + { + "punch", _tdm_monitor_server_punch, + "punch a layer", + ",[:x[++]]", + NULL + }, }; static void -- 2.7.4