add punch option to tdm-monitor
[platform/core/uifw/libtdm.git] / src / tdm_helper.c
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)
 {