--- /dev/null
+/**************************************************************************
+
+libtbm
+
+Copyright 2018 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>,
+ Changyeon Lee <cyeon.lee@samsung.com>,
+ Sangjin Lee <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _TBM_DUMMY_DISPLAY_H_
+#define _TBM_DUMMY_DISPLAY_H_
+
+/**
+ * \file tbm_dummy_display.h
+ * \brief TBM dummy display
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Definition for dummy display
+ */
+typedef void tbm_dummy_display;
+
+/**
+ * @brief Create the dummy display.
+ * @details The dummy display usually is used by the native_display for the parameger of the eglGetDisplay()\n
+ * The user uses the dummy display as the native_display for calling eglGetDisplay() when the user want to \n
+ * get EGLDisplay for the offscreen rendering in Tizen.
+ * \n
+ * @return a tbm dummy display
+ * @retval #tbm_dummy_display
+ */
+tbm_dummy_display *tbm_dummy_display_create(void);
+
+/**
+ * @brief Destroy the dummy display.
+ * @param[in] dpy : the tbm dummy display
+ */
+void tbm_dummy_display_destroy(tbm_dummy_display *dpy);
+
+/**
+ * @brief Validate the dummy display.
+ * @param[in] dpy : the tbm dummy display
+ * @return 1 if this dpy is valid, otherwise 0.
+ */
+int tbm_dummy_display_is_valid(tbm_dummy_display *dpy);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _TBM_DUMMY_DISPLAY_H_ */
--- /dev/null
+/**************************************************************************
+
+libtbm
+
+Copyright 2018 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>,
+ Changyeon Lee <cyeon.lee@samsung.com>,
+ Sangjin Lee <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+#include "config.h"
+#include "tbm_dummy_display.h"
+#include "tbm_bufmgr_int.h"
+#include "list.h"
+
+/* LCOV_EXCL_START */
+
+static int init_list = 0;
+static struct list_head g_dummy_display_list;
+static pthread_mutex_t tbm_dummy_display_lock;
+void _tbm_dummy_display_mutex_unlock(void);
+
+struct _tbm_dummy_display {
+ struct list_head link;
+};
+
+static bool
+_tbm_dummy_display_mutex_init(void)
+{
+ static bool tbm_dummy_display_mutex_init = false;
+
+ if (tbm_dummy_display_mutex_init)
+ return true;
+
+ if (pthread_mutex_init(&tbm_dummy_display_lock, NULL)) {
+ TBM_ERR("fail: pthread_mutex_init for tbm_dummy_display_lock.\n");
+ return false;
+ }
+
+ tbm_dummy_display_mutex_init = true;
+
+ return true;
+}
+
+void
+_tbm_dummy_display_mutex_lock(void)
+{
+ if (!_tbm_dummy_display_mutex_init()) {
+ TBM_ERR("fail: _tbm_dummy_display_mutex_init.\n");
+ return;
+ }
+
+ pthread_mutex_lock(&tbm_dummy_display_lock);
+}
+
+void
+_tbm_dummy_display_mutex_unlock(void)
+{
+ pthread_mutex_unlock(&tbm_dummy_display_lock);
+}
+
+static int
+_tbm_dummy_display_is_valid(struct _tbm_dummy_display *dummy_dpy)
+{
+ struct _tbm_dummy_display *tmp_dpy = NULL;
+
+ if (!init_list) {
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ if (!LIST_IS_EMPTY(&g_dummy_display_list)) {
+ LIST_FOR_EACH_ENTRY(tmp_dpy, &g_dummy_display_list, link) {
+ if (tmp_dpy == dummy_dpy) {
+ TBM_INFO("tbm_dummy_display(%p)\n", dummy_dpy);
+ return 1;
+ }
+ }
+ }
+
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
+
+ return 0;
+}
+
+tbm_dummy_display *
+tbm_dummy_display_create(void)
+{
+ struct _tbm_dummy_display *dpy = NULL;
+
+ _tbm_dummy_display_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
+
+ /* init list */
+ if (!init_list) {
+ LIST_INITHEAD(&g_dummy_display_list);
+ init_list = 1;
+ }
+
+ dpy = calloc(1, sizeof(struct _tbm_dummy_display));
+ if (!dpy) {
+ /* LCOV_EXCL_START */
+ TBM_ERR("fail to allocate struct _tbm_dummy_display.\n");
+ _tbm_set_last_result(TBM_ERROR_OUT_OF_MEMORY);
+ _tbm_dummy_display_mutex_unlock();
+ return NULL;
+ /* LCOV_EXCL_STOP */
+ }
+
+ LIST_ADD(&dpy->link, &g_dummy_display_list);
+
+ _tbm_dummy_display_mutex_unlock();
+
+ return (tbm_dummy_display *)dpy;
+}
+
+void
+tbm_dummy_display_destroy(tbm_dummy_display *dpy)
+{
+ struct _tbm_dummy_display *dummy_dpy = NULL;
+
+ _tbm_dummy_display_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
+
+ dummy_dpy = (struct _tbm_dummy_display *)dpy;
+
+ if (!_tbm_dummy_display_is_valid(dummy_dpy)) {
+ _tbm_dummy_display_mutex_unlock();
+ return;
+ }
+
+ LIST_DEL(&dummy_dpy->link);
+
+ free(dummy_dpy);
+
+ _tbm_dummy_display_mutex_unlock();
+}
+
+int
+tbm_dummy_display_is_valid(tbm_dummy_display *dpy)
+{
+ int ret = 0;
+ struct _tbm_dummy_display *dummy_dpy = NULL;
+
+ _tbm_dummy_display_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
+
+ dummy_dpy = (struct _tbm_dummy_display *)dpy;
+
+ /* Return silently if dummy_display is null. */
+ if (!dummy_dpy) {
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
+ _tbm_dummy_display_mutex_unlock();
+ return 0;
+ }
+
+ ret = _tbm_dummy_display_is_valid(dummy_dpy);
+
+ _tbm_dummy_display_mutex_unlock();
+
+ return ret;
+}
+
+/* LCOV_EXCL_STOP */