case E_COMP_WL_BUFFER_TYPE_VIDEO:
/* capture_data->buffer_ref.buffer can indicate NULL pointer
* if wl_buffer is destroyed later. */
- capture_data->tbm_surface = buffer->tbm_surface;
- if (!capture_data->tbm_surface) goto err;
+ if (!buffer->tbm_surface) goto err;
- /* Referencing tbm_surface_h to prevent it from being freed. */
- tbm_surface_internal_ref(capture_data->tbm_surface);
+ /* already capturable tbm_surface is referenced */
+ capture_data->tbm_surface = e_comp_wl_tbm_capturable_buffer_get(buffer->tbm_surface);
+ if (!capture_data->tbm_surface) goto err;
break;
default:
ERR("Unsupported buffer type(%d) win(0x%08zx) name(%s)",
tbm_surface = wayland_tbm_server_get_surface(e_comp_wl->tbm.server, buffer->resource);
if (!tbm_surface) goto end;
- tbm_surface_internal_ref(tbm_surface);
- capture_data->tbm_surface = tbm_surface;
+ capture_data->tbm_surface = e_comp_wl_tbm_capturable_buffer_get(tbm_surface);
+ if (!capture_data->tbm_surface) goto end;
break;
case E_COMP_WL_BUFFER_TYPE_TBM:
tbm_surface = buffer->tbm_surface;
if (!tbm_surface) goto end;
- tbm_surface_internal_ref(tbm_surface);
- capture_data->tbm_surface = tbm_surface;
+ capture_data->tbm_surface = e_comp_wl_tbm_capturable_buffer_get(tbm_surface);
+ if (!capture_data->tbm_surface) goto end;
break;
default:
tbm_surface = wayland_tbm_server_get_surface(e_comp_wl->tbm.server, buffer->resource);
if (!tbm_surface) goto end;
- tbm_surface_internal_ref(tbm_surface);
- td->tbm_surface = tbm_surface;
+ td->tbm_surface = e_comp_wl_tbm_capturable_buffer_get(tbm_surface);
+ if (!td->tbm_surface) goto end;
break;
case E_COMP_WL_BUFFER_TYPE_TBM:
tbm_surface = buffer->tbm_surface;
if (!tbm_surface) goto end;
- tbm_surface_internal_ref(tbm_surface);
- td->tbm_surface = tbm_surface;
+ td->tbm_surface = e_comp_wl_tbm_capturable_buffer_get(tbm_surface);
+ if (!td->tbm_surface) goto end;
break;
default:
goto end;
EINTERN void
e_hwc_window_commit_data_buffer_dump(E_Hwc_Window *hwc_window, E_Hwc_Window_Commit_Data *commit_data)
{
+ tbm_surface_h capturable_tsurface;
char fname[64];
EINA_SAFETY_ON_FALSE_RETURN(hwc_window);
EINA_SAFETY_ON_FALSE_RETURN(commit_data);
+ if (!commit_data->buffer.tsurface) return;
+
if (hwc_window->is_target)
snprintf(fname, sizeof(fname), "hwc_commit_composite_%p",
hwc_window);
snprintf(fname, sizeof(fname), "hwc_commit_0x%08zx_%p",
e_client_util_win_get(hwc_window->ec), hwc_window);
- tbm_surface_internal_dump_buffer(commit_data->buffer.tsurface,
+ capturable_tsurface = e_comp_wl_tbm_capturable_buffer_get(commit_data->buffer.tsurface);
+ EINA_SAFETY_ON_NULL_RETURN(capturable_tsurface);
+
+ tbm_surface_internal_dump_buffer(capturable_tsurface,
fname);
+ tbm_surface_internal_unref(capturable_tsurface);
}
EINTERN Eina_Bool
E_Client *ec;
Evas_Native_Surface *ns = NULL;
Evas_Object *co = NULL; // native surface set
- tbm_surface_h tbm_surface = NULL;
+ tbm_surface_h tbm_surface = NULL, capturable_tbm_surface = NULL;
char fname[PATH_MAX];
const char *bltin_t = NULL;
{
case EVAS_NATIVE_SURFACE_WL:
snprintf(fname, sizeof(fname), "%s/0x%08zx_wl_%p.png", dir, win, co);
- if (ns->data.wl.legacy_buffer)
- tbm_surface = wayland_tbm_server_get_surface(NULL, ns->data.wl.legacy_buffer);
- if (tbm_surface)
- tdm_helper_dump_buffer(tbm_surface, fname);
+ if (!ns->data.wl.legacy_buffer) continue;
+
+ tbm_surface = wayland_tbm_server_get_surface(NULL, ns->data.wl.legacy_buffer);
+ if (!tbm_surface) continue;
+
+ capturable_tbm_surface = e_comp_wl_tbm_capturable_buffer_get(tbm_surface);
+ if (!capturable_tbm_surface) continue;
+
+ tdm_helper_dump_buffer(capturable_tbm_surface, fname);
+ tbm_surface_internal_unref(capturable_tbm_surface);
break;
case EVAS_NATIVE_SURFACE_TBM:
snprintf(fname, sizeof(fname), "%s/0x%08zx_tbm_%p.png", dir, win, co);
- if (ns->data.tbm.buffer)
- tdm_helper_dump_buffer(ns->data.tbm.buffer, fname);
+ if (!ns->data.tbm.buffer) continue;
+
+ capturable_tbm_surface = e_comp_wl_tbm_capturable_buffer_get(ns->data.tbm.buffer);
+ if (!capturable_tbm_surface) continue;
+
+ tdm_helper_dump_buffer(capturable_tbm_surface, fname);
+ tbm_surface_internal_unref(capturable_tbm_surface);
break;
default:
break;
{
char fname[PATH_MAX];
tbm_format fmt;
+ tbm_surface_h capturable_tbm_surface;
if (!hwc_window) continue;
if (!hwc_window->display.buffer.tsurface) continue;
snprintf(fname, sizeof(fname), "0x%08zx_hwin_%p_tbm_%p", e_client_util_win_get(hwc_window->ec),
hwc_window, hwc_window->display.buffer.tsurface);
- tbm_surface_internal_capture_buffer(hwc_window->display.buffer.tsurface, dir, fname, "png");
+ capturable_tbm_surface = e_comp_wl_tbm_capturable_buffer_get(hwc_window->display.buffer.tsurface);
+ if (!capturable_tbm_surface) continue;
+
+ tbm_surface_internal_capture_buffer(capturable_tbm_surface, dir, fname, "png");
+ tbm_surface_internal_unref(capturable_tbm_surface);
break;
case TBM_FORMAT_YUV420:
case TBM_FORMAT_YVU420:
snprintf(fname, sizeof(fname), "0x%08zx_hwin_%p_tbm_%p", e_client_util_win_get(hwc_window->ec),
hwc_window, hwc_window->display.buffer.tsurface);
- tbm_surface_internal_capture_buffer(hwc_window->display.buffer.tsurface, dir, fname, "yuv");
+ capturable_tbm_surface = e_comp_wl_tbm_capturable_buffer_get(hwc_window->display.buffer.tsurface);
+ if (!capturable_tbm_surface) continue;
+
+ tbm_surface_internal_capture_buffer(capturable_tbm_surface, dir, fname, "png");
+ tbm_surface_internal_unref(capturable_tbm_surface);
break;
default:
break;
Ecore_Window event_win;
char fname[PATH_MAX];
E_Comp_Wl_Buffer *buffer;
- tbm_surface_h tbm_surface;
+ tbm_surface_h tbm_surface, capturable_tbm_surface;
struct wl_shm_buffer *shmbuffer = NULL;
void *ptr;
int stride, w, h, rotation, row, col;
tbm_surface = wayland_tbm_server_get_surface(NULL, buffer->resource);
EINA_SAFETY_ON_NULL_RETURN_VAL(tbm_surface, ECORE_CALLBACK_PASS_ON);
+ capturable_tbm_surface = e_comp_wl_tbm_capturable_buffer_get(tbm_surface);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(capturable_tbm_surface, ECORE_CALLBACK_PASS_ON);
+
if (e_info_dump_mark)
{
unsigned int colors[5] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFF00FFFF, 0xFFFF00FF};
int box_size = 20;
int box = e_info_dump_mark_count * box_size;
- w = tbm_surface_get_width(tbm_surface);
- h = tbm_surface_get_height(tbm_surface);
+ w = tbm_surface_get_width(capturable_tbm_surface);
+ h = tbm_surface_get_height(capturable_tbm_surface);
EINA_SAFETY_ON_FALSE_RETURN_VAL((w != 0), ECORE_CALLBACK_PASS_ON);
EINA_SAFETY_ON_FALSE_RETURN_VAL((h != 0), ECORE_CALLBACK_PASS_ON);
pos.w = box_size;
pos.h = box_size;
- tdm_helper_clear_buffer_color(tbm_surface, &pos, colors[e_info_dump_mark_count % 5]);
+ tdm_helper_clear_buffer_color(capturable_tbm_surface, &pos, colors[e_info_dump_mark_count % 5]);
e_info_dump_mark_count++;
}
- tbm_surface_internal_dump_buffer(tbm_surface, fname);
+ tbm_surface_internal_dump_buffer(capturable_tbm_surface, fname);
+ tbm_surface_internal_unref(capturable_tbm_surface);
break;
default:
DBG("Unknown type resource:%u", wl_resource_get_id(buffer->resource));
{
int w = 0, h = 0;
E_Comp_Wl_Video_Buf *tmp = NULL;
- tbm_surface_h surface = NULL;
+ tbm_surface_h tsurface = NULL, capturable_tsurface = NULL;
Eina_Rectangle showing_pos = {0, };
Eina_Rectangle dst_pos = {0, };
Eina_Rectangle src_crop = {0, };
e_output_size_get(output, &w, &h);
- surface = e_hwc_window_displaying_surface_get(hwc_window);
- if (!surface) return EINA_FALSE;
+ tsurface = e_hwc_window_displaying_surface_get(hwc_window);
+ if (!tsurface) return EINA_FALSE;
- tmp = e_comp_wl_video_buffer_create_tbm(surface);
+ capturable_tsurface = e_comp_wl_tbm_capturable_buffer_get(tsurface);
+ if (!capturable_tsurface) return EINA_FALSE;
+
+ tmp = e_comp_wl_video_buffer_create_tbm(capturable_tsurface);
if (tmp == NULL)
return EINA_FALSE;
ret = EINA_TRUE;
done:
+ tbm_surface_internal_unref(capturable_tsurface);
e_comp_wl_video_buffer_unref(tmp);
return ret;
E_Comp_Wl_Video_Buf *tmp = NULL;
tdm_layer *layer;
tdm_layer_capability capability;
- tbm_surface_h surface = NULL;
+ tbm_surface_h tsurface = NULL, capturable_tsurface = NULL;
Eina_Rectangle showing_pos = {0, };
Eina_Rectangle dst_pos = {0, };
Eina_Rectangle src_crop = {0, };
if (capability & TDM_LAYER_CAPABILITY_VIDEO)
continue;
- surface = tdm_layer_get_displaying_buffer(layer, &error);
- if (surface == NULL)
+ tsurface = tdm_layer_get_displaying_buffer(layer, &error);
+ if (tsurface == NULL)
continue;
- tmp = e_comp_wl_video_buffer_create_tbm(surface);
+ capturable_tsurface = e_comp_wl_tbm_capturable_buffer_get(tsurface);
+ if (!capturable_tsurface) continue;
+
+ tmp = e_comp_wl_video_buffer_create_tbm(tsurface);
if (tmp == NULL)
- continue;
+ {
+ tbm_surface_internal_unref(capturable_tsurface);
+ continue;
+ }
ret = _e_output_capture_src_crop_get(output, layer, &src_crop, &showing_pos);
if (ret == EINA_FALSE)
{
+ tbm_surface_internal_unref(capturable_tsurface);
e_comp_wl_video_buffer_unref(tmp);
continue;
}
ret = _e_output_capture_position_get(output, vbuf->width, vbuf->height, &dst_pos, rotate_check);
if (ret == EINA_FALSE)
{
+ tbm_surface_internal_unref(capturable_tsurface);
e_comp_wl_video_buffer_unref(tmp);
continue;
}
dst_crop.x, dst_crop.y, dst_crop.w, dst_crop.h,
EINA_TRUE, rotate, 0, 0);
+ tbm_surface_internal_unref(capturable_tsurface);
e_comp_wl_video_buffer_unref(tmp);
}