surface: added tbm_surface_internal_set/get_damage func 43/178543/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Thu, 10 May 2018 06:48:35 +0000 (15:48 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Thu, 10 May 2018 09:46:55 +0000 (18:46 +0900)
Change-Id: I25e77606b987e7761c0ad16ad6d6d5f70a09351d

include/tbm_surface_internal.h
src/tbm_bufmgr_int.h
src/tbm_surface_internal.c

index 0ada9c0..9454a36 100644 (file)
@@ -522,6 +522,28 @@ int tbm_surface_internal_capture_buffer(tbm_surface_h surface, const char *path,
 int tbm_surface_internal_capture_shm_buffer(void *ptr, int w, int h, int stride,
                                       const char *path, const char *name, const char *type);
 
+/**
+ * @brief Set damage to surface
+ * @param[in] surface : a tbm surface
+ * @param[in] x : a x coordinate of damage
+ * @param[in] y : a y coordinate of damage
+ * @param[in] with : a width of damage rectangle
+ * @param[in] height : a height of damage rectangle
+ * @return 1 if success, otherwise 0.
+ */
+int tbm_surface_internal_set_damage(tbm_surface_h surface, int x, int y, int width, int height);
+
+/**
+ * @brief Get damage of surface
+ * @param[in] surface : a tbm surface
+ * @param[out] x : a x coordinate of damage
+ * @param[out] y : a y coordinate of damage
+ * @param[out] with : a width of damage rectangle
+ * @param[out] height : a height of damage rectangle
+ * @return 1 if success, otherwise 0.
+ */
+int tbm_surface_internal_get_damage(tbm_surface_h surface, int *x, int *y, int *width, int *height);
+
 #ifdef __cplusplus
 }
 #endif
index a75c696..f4cc290 100644 (file)
@@ -234,6 +234,13 @@ struct _tbm_surface {
        struct list_head user_data_list;        /* list of the user_date in surface */
 
        struct list_head debug_data_list;       /* list of debug data */
+
+       struct {
+               int x;
+               int y;
+               int width;
+               int height;
+       } damage;
 };
 
 typedef struct {
index c32b881..6fc9b55 100644 (file)
@@ -2563,4 +2563,58 @@ tbm_surface_internal_capture_shm_buffer(void *ptr, int w, int h, int stride,
 
        return 1;
 }
+
+int
+tbm_surface_internal_set_damage(tbm_surface_h surface, int x, int y, int width, int height)
+{
+       struct _tbm_surface *surf;
+
+       _tbm_surface_mutex_lock();
+       _tbm_set_last_result(TBM_ERROR_NONE);
+
+       TBM_SURFACE_RETURN_VAL_IF_FAIL(width > 0, 0);
+       TBM_SURFACE_RETURN_VAL_IF_FAIL(height > 0, 0);
+       TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
+
+       surf = (struct _tbm_surface *)surface;
+
+       surf->damage.x = x;
+       surf->damage.y = y;
+       surf->damage.width = width;
+       surf->damage.height = height;
+
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) x(%d) y(%d) width(%d) height(%d)\n",
+                                                       surface, x, y, width, height);
+
+       _tbm_surface_mutex_unlock();
+
+       return 1;
+}
+
+int
+tbm_surface_internal_get_damage(tbm_surface_h surface, int *x, int *y, int *width, int *height)
+{
+       struct _tbm_surface *surf;
+
+       _tbm_surface_mutex_lock();
+       _tbm_set_last_result(TBM_ERROR_NONE);
+
+       TBM_SURFACE_RETURN_VAL_IF_FAIL(width > 0, 0);
+       TBM_SURFACE_RETURN_VAL_IF_FAIL(height > 0, 0);
+       TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
+
+       surf = (struct _tbm_surface *)surface;
+
+       *x = surf->damage.x;
+       *y = surf->damage.y;
+       *width = surf->damage.width;
+       *height = surf->damage.height;
+
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) x(%d) y(%d) width(%d) height(%d)\n",
+                                                       surface, *x, *y, *width, *height);
+
+       _tbm_surface_mutex_unlock();
+
+       return 1;
+}
 /*LCOV_EXCL_STOP*/