프로그램 사용/wayland2022. 8. 17. 16:49

weston_screenshooter_shoot()을 따라오는데 영 어딜 파야 나올지 감이 안온다.

아무튼.. libweston의 screenshooter.c가 실제적으로 수행되는 부분 같은데

//git\include\libweston\libweston.h
int
weston_screenshooter_shoot(struct weston_output *output, struct weston_buffer *buffer,
   weston_screenshooter_done_func_t done, void *data);

//git\libweston\screenshooter.c
WL_EXPORT int
weston_screenshooter_shoot(struct weston_output *output,
   struct weston_buffer *buffer,
   weston_screenshooter_done_func_t done, void *data)
{
struct screenshooter_frame_listener *l;

if (!wl_shm_buffer_get(buffer->resource)) {
done(data, WESTON_SCREENSHOOTER_BAD_BUFFER);
return -1;
}

buffer->shm_buffer = wl_shm_buffer_get(buffer->resource);
buffer->width = wl_shm_buffer_get_width(buffer->shm_buffer);
buffer->height = wl_shm_buffer_get_height(buffer->shm_buffer);

if (buffer->width < output->current_mode->width ||
    buffer->height < output->current_mode->height) {
done(data, WESTON_SCREENSHOOTER_BAD_BUFFER);
return -1;
}

l = malloc(sizeof *l);
if (l == NULL) {
done(data, WESTON_SCREENSHOOTER_NO_MEMORY);
return -1;
}

l->buffer = buffer;
l->output = output;
l->done = done;
l->data = data;
l->listener.notify = screenshooter_frame_notify;
wl_signal_add(&output->frame_signal, &l->listener);
weston_output_disable_planes_incr(output);
weston_output_damage(output);

return 0;
}

 

아무튼 추적을 계속해보면 아래와 같이 event_loop에 wl_event_loop_add_idle() 실행해서 추가해주고 끝.

//git\libweston\compositor.c
static void
weston_schedule_surface_protection_update(struct weston_compositor *compositor)
{
struct content_protection *cp = compositor->content_protection;
struct wl_event_loop *loop;

if (!cp || cp->surface_protection_update)
return;
loop = wl_display_get_event_loop(compositor->wl_display);
cp->surface_protection_update = wl_event_loop_add_idle(loop,
       notify_surface_protection_change,
       compositor);
}

WL_EXPORT void
weston_output_disable_planes_incr(struct weston_output *output)
{
output->disable_planes++;
/*
 * If disable_planes changes from 0 to non-zero, it means some type of
 * recording of content has started, and therefore protection level of
 * the protected surfaces must be updated to avoid the recording of
 * the protected content.
 */
if (output->disable_planes == 1)
weston_schedule_surface_protection_update(output->compositor);
}

 

struct content_protection은 누가 만드나 하면서 따라가보니

weston_compositor_enable_content_protection() 함수에서 만들어 주고 해당 함수는

//git\libweston\content-protection.c
WL_EXPORT int
weston_compositor_enable_content_protection(struct weston_compositor *compositor)
{
struct content_protection *cp;

cp = zalloc(sizeof(*cp));
if (cp == NULL)
return -1;
cp->compositor = compositor;

compositor->content_protection = cp;
wl_list_init(&cp->protected_list);
if (wl_global_create(compositor->wl_display,
     &weston_content_protection_interface, 1, cp,
     bind_weston_content_protection) == NULL)
return -1;

cp->destroy_listener.notify = cp_destroy_listener;
wl_signal_add(&compositor->destroy_signal, &cp->destroy_listener);
cp->debug = weston_compositor_add_log_scope(compositor, "content-protection-debug",
    "debug-logs for content-protection",
    NULL, NULL, NULL);
return 0;
}

 

drm_backend_create() 시에 b->atomic_modeset 조건에 의해서 생성된다.

//git\libweston\backend-drm\drm.c
static struct drm_backend *
drm_backend_create(struct weston_compositor *compositor,
   struct weston_drm_backend_config *config)
{
if (b->atomic_modeset)
if (weston_compositor_enable_content_protection(compositor) < 0)
weston_log("Error: initializing content-protection "
   "support failed.\n");
}

 

 

이름이 비슷한건지 걸려나오는 다른 녀석.

//protocol\weston-screenshooter-client-protocol.h
#define WESTON_SCREENSHOOTER_SHOOT 0

static inline void
weston_screenshooter_shoot(struct weston_screenshooter *weston_screenshooter, struct wl_output *output, struct wl_buffer *buffer)
{
wl_proxy_marshal((struct wl_proxy *) weston_screenshooter,
 WESTON_SCREENSHOOTER_SHOOT, output, buffer);
}

 

 wl_proxy_marshall()은 또 멀까해서 따라가 보지만.. 답이 안나온다 -_ㅠ

//wayland-main\src\wayland-client.c
WL_EXPORT struct wl_proxy *
wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *proxy,
     uint32_t opcode,
     union wl_argument *args,
     const struct wl_interface *interface,
     uint32_t version)
{
return wl_proxy_marshal_array_flags(proxy, opcode, interface, version, 0, args);
}

WL_EXPORT struct wl_proxy *
wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
   uint32_t opcode, union wl_argument *args,
   const struct wl_interface *interface)
{
return wl_proxy_marshal_array_constructor_versioned(proxy, opcode,
    args, interface,
    proxy->version);
}


WL_EXPORT void
wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
{
union wl_argument args[WL_CLOSURE_MAX_ARGS];
va_list ap;

va_start(ap, opcode);
wl_argument_from_va_list(proxy->object.interface->methods[opcode].signature,
 args, WL_CLOSURE_MAX_ARGS, ap);
va_end(ap);

wl_proxy_marshal_array_constructor(proxy, opcode, args, NULL);
}

 

'프로그램 사용 > wayland' 카테고리의 다른 글

wayland hdmi - touch 연결  (0) 2023.09.08
wayland atomic commit 패치?  (0) 2022.08.22
wayland glreadpixels 실패  (0) 2022.08.16
sway + wayvnc  (0) 2022.08.10
wayvnc 0.5 릴리즈  (0) 2022.08.09
Posted by 구차니