tpl_surface_type_t type, tbm_format format);
/**
+ * Get TPL surface object for the given native surface.
+ *
+ * If there's already existing TPL surface for the given native surface,
+ * then return the existed TPL surface.
+ *
+ * This API is not incremented the reference count of found TPL surface object.
+ * To ensure that the obtained TPL surface is safe to use, it must be increased
+ * the ref count by using tpl_object_reference().
+ * When it becomes unnecessary, it should be decreased by using tpl_object_unreference().
+ *
+ * @param display TPL display used to create TPL surface with given handle.
+ * @param handle Handle to the native surface.
+ * @return pointer to TPL surface if it has already been created, NULL otherwise.
+ *
+ * @see tpl_surface_create()
+ * @see tpl_object_reference()
+ * @see tpl_object_unreference()
+ */
+tpl_surface_t *
+tpl_surface_get(tpl_display_t *display, tpl_handle_t handle);
+
+/**
* Get the TPL display where the given TPL surface was created from.
*
* @param surface surface to get display.
return NULL;
}
- surface = __tpl_runtime_find_surface(display->backend.type, handle);
- if (surface) {
- TPL_LOG_F("[REUSE] tpl_display_t(%p) tpl_surface_t(%p) native_handle(%p) format(%d)",
- display, surface, handle, format);
- return surface;
- }
-
surface = (tpl_surface_t *) calloc(1, sizeof(tpl_surface_t));
if (!surface) {
TPL_ERR("Failed to allocate memory for surface!");
return surface;
}
+tpl_surface_t *
+tpl_surface_get(tpl_display_t *display, tpl_handle_t handle)
+{
+ tpl_surface_t *surface = NULL;
+
+ if (!display) {
+ TPL_ERR("Display is NULL!");
+ return NULL;
+ }
+
+ if (!handle) {
+ TPL_ERR("Handle is NULL!");
+ return NULL;
+ }
+
+ surface = __tpl_runtime_find_surface(display->backend.type, handle);
+ if (surface) {
+ TPL_LOG_F("[REUSE] tpl_display_t(%p) tpl_surface_t(%p) native_handle(%p)",
+ display, surface, handle);
+ }
+
+ return surface;
+}
+
tpl_display_t *
tpl_surface_get_display(tpl_surface_t *surface)
{