pthread_mutex_t lock;
};
-static struct wl_tbm_monitor *tbm_monitor;
-
#define DEBUG_TRACE
#ifdef DEBUG_TRACE
#define WL_TBM_TRACE(fmt, ...) if (bTrace) WL_TBM_C_LOG(fmt, ##__VA_ARGS__)
handle_buffer_destroy,
};
-void _waylend_tbm_monitor_client_print_show_to_file(char* show_str)
-{
- FILE * f = NULL;
- static int c = 0;
- char tmp_file[256];
-
- snprintf(tmp_file, sizeof(tmp_file), "/tmp/tbm_debug_show_%d%d", getpid(), c++);
- if ((f = fopen(tmp_file, "a+")) != NULL) {
- WL_TBM_LOG_E("fail to open tmp_file.");
- fprintf(f, "%s", show_str);
- fclose(f);
- }
-}
-
-void _waylend_tbm_monitor_client_show(int argc, char *argv[],
- char *reply, int *len, struct wayland_tbm_client *tbm_client)
-{
- struct wayland_tbm_monitor_path path = {0};
- char *show_str;
-
- _wayland_tbm_util_show_path_parse(argv[2], 0, &path);
-
- if (path.dlog)
- tbm_bufmgr_debug_show(tbm_client->bufmgr);
-
- /* we have to save result to some file as reply can be very long */
- show_str = tbm_bufmgr_debug_tbm_info_get(tbm_client->bufmgr);
- if (show_str) {
- _waylend_tbm_monitor_client_print_show_to_file(show_str);
- free(show_str);
- }
-
-
- /* send empty string to close the session */
- WL_TBM_MONITOR_SNPRINTF(reply, *len, "\n");
-}
-
-void _waylend_tbm_monitor_client_dump_snapshot(int argc, char *argv[],
- char *reply, int *len, struct wayland_tbm_client *tbm_client)
-{
- double scale = 0;
- int i;
- char *path = NULL;
-
- for (i = 1; i < argc; i++) {
- if (_waylend_tbm_util_scale_parse(argv[i], &scale))
- break;
- }
-
- path = _wayland_tbm_dump_directory_make();
- _waylend_tbm_util_dump_snapshot(tbm_client->bufmgr, scale, path);
- WL_TBM_MONITOR_SNPRINTF(reply, *len, "client(%d): snapshot dump is done. path=%s\n", getpid(), path);
- free(path);
-}
-
-void _waylend_tbm_monitor_client_dump_queue(int argc, char *argv[],
- char *reply, int *len, struct wayland_tbm_client *tbm_client)
-{
- int st;
- double scale = 0;
- int i;
-
- st = _waylend_tbm_util_proc_state_parse(argv[1]);
-
- for (i = 2; i < argc; i++) {
- if (_waylend_tbm_util_scale_parse(argv[i], &scale))
- break;
- }
-
- st = _waylend_tbm_util_dump_queue(st, tbm_client->bufmgr, scale);
- WL_TBM_MONITOR_SNPRINTF(reply, *len, "client(%d): queue dump state: %s\n", getpid(),
- st ? "on" : "off");
-}
-
-void _waylend_tbm_monitor_client_trace(int argc, char *argv[],
- char *reply, int *len, struct wayland_tbm_client *tbm_client)
-{
- int st;
-
- st = _waylend_tbm_util_trace(_waylend_tbm_util_proc_state_parse(argv[1]),
- _waylend_tbm_util_resource_parse(argv[2]),
- tbm_client->bufmgr);
- WL_TBM_MONITOR_SNPRINTF(reply, *len, "client(%d): trace state: %s\n", getpid() ,
- st ? "on" : "off");
-}
-
-void _waylend_tbm_monitor_client_debug_level(int argc, char *argv[],
- char *reply, int *len, struct wayland_tbm_client *tbm_client)
-{
- int debug_level = TBM_LOG_LEVEL_NONE;
- int i;
-
- for (i = 1; i < argc; i++) {
- if (_waylend_tbm_util_debug_level_parse(argv[i], &debug_level))
- break;
- }
-
- _waylend_tbm_util_set_log_level(debug_level);
- WL_TBM_MONITOR_SNPRINTF(reply, *len, "client(%d): set tbm_log debug_level(%d)\n", getpid(), debug_level);
-}
-
-static struct {
- const char *opt;
- void (*func)(int argc, char *argv[], char *reply, int *len, struct wayland_tbm_client *tbm_client);
-} option_proc[] = {
- {
- "show",
- _waylend_tbm_monitor_client_show,
- },
- {
- "dump_snapshot",
- _waylend_tbm_monitor_client_dump_snapshot,
- },
- {
- "dump_queue",
- _waylend_tbm_monitor_client_dump_queue,
- },
- {
- "trace",
- _waylend_tbm_monitor_client_trace,
- },
- {
- "debug_level",
- _waylend_tbm_monitor_client_debug_level,
- },
-};
-
-static void
-handle_tbm_monitor_client_done(void *data, struct wl_tbm_monitor *wl_tbm_monitor, const char *message)
-{
-}
-
-static void
-handle_tbm_monitor_client_request_to_client(void *data, struct wl_tbm_monitor *wl_tbm_monitor,
- const char * options, const char * request_id)
-{
- struct wayland_tbm_client *tbm_client = (struct wayland_tbm_client *)data;
- char temp[1024];
- char *argv[WL_TBM_MONITOR_ARGS_MAX] = {0};
- int argc = 0;
-
- char message[WL_TBM_MONITOR_REPLY_MSG_LEN] = {0,};
- int len = sizeof(message);
- char *reply = message;
-
- char *end = NULL;
- int i;
-
- snprintf(temp, sizeof(temp), "%s", options);
-
- argv[argc] = strtok_r(temp, " ", &end);
- while (argv[argc]) {
- argc++;
- if (argc == WL_TBM_MONITOR_ARGS_MAX)
- break;
- argv[argc] = strtok_r(NULL, " ", &end);
- }
-
-#ifdef DEBUG_TRACE
- WL_TBM_TRACE("receive request_id:%s argc:%d [%s %s] options:'%s'", request_id, argc, argv[0], argv[1], temp);
-#endif
-
- if (argc > 0) {
- for (i = 0; i < sizeof(option_proc) / sizeof(option_proc[0]); i++) {
- if (argv[0][0] == '-' && !strncmp(argv[0] + 1, option_proc[i].opt, 32)) {
- if (option_proc[i].func) {
- option_proc[i].func(argc, argv, reply, &len, tbm_client);
- break;
- }
- }
- }
- }
-
- wl_tbm_monitor_responce_to_server(tbm_monitor, message, request_id);
-}
-
-static const struct wl_tbm_monitor_listener wl_tbm_monitor_listener = {
- handle_tbm_monitor_client_done,
- handle_tbm_monitor_client_request_to_client,
-};
-
static void
_wayland_tbm_client_registry_handle_global(void *data,
struct wl_registry *registry, uint32_t name,
}
}
} else if (!strcmp(interface, "wl_tbm_monitor")) {
- /*Create wl_monotor proxy by sington*/
- if (tbm_monitor)
- return;
-
- tbm_monitor = wl_registry_bind(registry, name, &wl_tbm_monitor_interface, version);
- WL_TBM_RETURN_IF_FAIL(tbm_monitor != NULL);
-
- wl_proxy_set_queue((struct wl_proxy *)tbm_monitor, NULL);
-
- wl_tbm_monitor_add_listener(tbm_monitor, &wl_tbm_monitor_listener, tbm_client);
+ if (!wayland_tbm_monitor_client_init(tbm_client, registry, name, version))
+ WL_TBM_LOG_E("fail to wayland_tbm_monitor_client_init");
}
}
wl_tbm_destroy(tbm_client->wl_tbm);
}
- if (tbm_monitor
- && (tbm_client == wl_tbm_monitor_get_user_data(tbm_monitor))) {
- wl_tbm_monitor_destroy(tbm_monitor);
- tbm_monitor = NULL;
- }
+ wayland_tbm_monitor_client_deinit(tbm_client);
wl_list_remove(&tbm_client->queue_info_list);
return NULL;
}
-
static void
_handle_tbm_surface_queue_destroy_notify(tbm_surface_queue_h surface_queue,
void *data)
--- /dev/null
+/*
+Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+ SooChan Lim <sc1.lim@samsung.com>,
+ Sangjin Lee <lsj119@samsung.com>,
+ Boram Park <boram1288.park@samsung.com>,
+ Changyeon Lee <cyeon.lee@samsung.com>
+ Roman Marchenko <r.marchenko@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, sublicense,
+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 NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "wayland-tbm-client.h"
+#include "wayland-tbm-client-protocol.h"
+#include "wayland-tbm-int.h"
+
+static struct wl_tbm_monitor *tbm_monitor;
+
+void _waylend_tbm_monitor_client_print_show_to_file(char* show_str)
+{
+ FILE * f = NULL;
+ static int c = 0;
+ char tmp_file[256];
+
+ snprintf(tmp_file, sizeof(tmp_file), "/tmp/tbm_debug_show_%d%d", getpid(), c++);
+ if ((f = fopen(tmp_file, "a+")) != NULL) {
+ WL_TBM_LOG_E("fail to open tmp_file.");
+ fprintf(f, "%s", show_str);
+ fclose(f);
+ }
+}
+
+void _waylend_tbm_monitor_client_show(int argc, char *argv[],
+ char *reply, int *len, struct wayland_tbm_client *tbm_client)
+{
+ struct wayland_tbm_monitor_path path = {0};
+ char *show_str;
+
+ _wayland_tbm_util_show_path_parse(argv[2], 0, &path);
+
+ if (path.dlog)
+ tbm_bufmgr_debug_show((tbm_bufmgr)wayland_tbm_client_get_bufmgr(tbm_client));
+
+ /* we have to save result to some file as reply can be very long */
+ show_str = tbm_bufmgr_debug_tbm_info_get((tbm_bufmgr)wayland_tbm_client_get_bufmgr(tbm_client));
+ if (show_str) {
+ _waylend_tbm_monitor_client_print_show_to_file(show_str);
+ free(show_str);
+ }
+
+ /* send empty string to close the session */
+ WL_TBM_MONITOR_SNPRINTF(reply, *len, "\n");
+}
+
+void _waylend_tbm_monitor_client_dump_snapshot(int argc, char *argv[],
+ char *reply, int *len, struct wayland_tbm_client *tbm_client)
+{
+ double scale = 0;
+ int i;
+ char *path = NULL;
+
+ for (i = 1; i < argc; i++) {
+ if (_waylend_tbm_util_scale_parse(argv[i], &scale))
+ break;
+ }
+
+ path = _wayland_tbm_dump_directory_make();
+ _waylend_tbm_util_dump_snapshot((tbm_bufmgr)wayland_tbm_client_get_bufmgr(tbm_client), scale, path);
+ WL_TBM_MONITOR_SNPRINTF(reply, *len, "client(%d): snapshot dump is done. path=%s\n", getpid(), path);
+ free(path);
+}
+
+void _waylend_tbm_monitor_client_dump_queue(int argc, char *argv[],
+ char *reply, int *len, struct wayland_tbm_client *tbm_client)
+{
+ int st;
+ double scale = 0;
+ int i;
+
+ st = _waylend_tbm_util_proc_state_parse(argv[1]);
+
+ for (i = 2; i < argc; i++) {
+ if (_waylend_tbm_util_scale_parse(argv[i], &scale))
+ break;
+ }
+
+ st = _waylend_tbm_util_dump_queue(st, (tbm_bufmgr)wayland_tbm_client_get_bufmgr(tbm_client), scale);
+ WL_TBM_MONITOR_SNPRINTF(reply, *len, "client(%d): queue dump state: %s\n", getpid(),
+ st ? "on" : "off");
+}
+
+void _waylend_tbm_monitor_client_trace(int argc, char *argv[],
+ char *reply, int *len, struct wayland_tbm_client *tbm_client)
+{
+ int st;
+
+ st = _waylend_tbm_util_trace(_waylend_tbm_util_proc_state_parse(argv[1]),
+ _waylend_tbm_util_resource_parse(argv[2]),
+ (tbm_bufmgr)wayland_tbm_client_get_bufmgr(tbm_client));
+ WL_TBM_MONITOR_SNPRINTF(reply, *len, "client(%d): trace state: %s\n", getpid() ,
+ st ? "on" : "off");
+}
+
+void _waylend_tbm_monitor_client_debug_level(int argc, char *argv[],
+ char *reply, int *len, struct wayland_tbm_client *tbm_client)
+{
+ int debug_level = TBM_LOG_LEVEL_NONE;
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (_waylend_tbm_util_debug_level_parse(argv[i], &debug_level))
+ break;
+ }
+
+ _waylend_tbm_util_set_log_level(debug_level);
+ WL_TBM_MONITOR_SNPRINTF(reply, *len, "client(%d): set tbm_log debug_level(%d)\n", getpid(), debug_level);
+}
+
+static struct {
+ const char *opt;
+ void (*func)(int argc, char *argv[], char *reply, int *len, struct wayland_tbm_client *tbm_client);
+} option_proc[] = {
+ {
+ "show",
+ _waylend_tbm_monitor_client_show,
+ },
+ {
+ "dump_snapshot",
+ _waylend_tbm_monitor_client_dump_snapshot,
+ },
+ {
+ "dump_queue",
+ _waylend_tbm_monitor_client_dump_queue,
+ },
+ {
+ "trace",
+ _waylend_tbm_monitor_client_trace,
+ },
+ {
+ "debug_level",
+ _waylend_tbm_monitor_client_debug_level,
+ },
+};
+
+static void
+handle_tbm_monitor_client_done(void *data, struct wl_tbm_monitor *wl_tbm_monitor, const char *message)
+{
+}
+
+static void
+handle_tbm_monitor_client_request_to_client(void *data, struct wl_tbm_monitor *wl_tbm_monitor,
+ const char * options, const char * request_id)
+{
+ struct wayland_tbm_client *tbm_client = (struct wayland_tbm_client *)data;
+ char temp[1024];
+ char *argv[WL_TBM_MONITOR_ARGS_MAX] = {0};
+ int argc = 0;
+
+ char message[WL_TBM_MONITOR_REPLY_MSG_LEN] = {0,};
+ int len = sizeof(message);
+ char *reply = message;
+
+ char *end = NULL;
+ int i;
+
+ snprintf(temp, sizeof(temp), "%s", options);
+
+ argv[argc] = strtok_r(temp, " ", &end);
+ while (argv[argc]) {
+ argc++;
+ if (argc == WL_TBM_MONITOR_ARGS_MAX)
+ break;
+ argv[argc] = strtok_r(NULL, " ", &end);
+ }
+
+#ifdef DEBUG_TRACE
+ WL_TBM_TRACE("receive request_id:%s argc:%d [%s %s] options:'%s'", request_id, argc, argv[0], argv[1], temp);
+#endif
+
+ if (argc > 0) {
+ for (i = 0; i < sizeof(option_proc) / sizeof(option_proc[0]); i++) {
+ if (argv[0][0] == '-' && !strncmp(argv[0] + 1, option_proc[i].opt, 32)) {
+ if (option_proc[i].func) {
+ option_proc[i].func(argc, argv, reply, &len, tbm_client);
+ break;
+ }
+ }
+ }
+ }
+
+ wl_tbm_monitor_responce_to_server(tbm_monitor, message, request_id);
+}
+
+static const struct wl_tbm_monitor_listener wl_tbm_monitor_listener = {
+ handle_tbm_monitor_client_done,
+ handle_tbm_monitor_client_request_to_client,
+};
+
+int
+wayland_tbm_monitor_client_init(struct wayland_tbm_client *tbm_client,
+ struct wl_registry *registry, uint32_t name, uint32_t version)
+{
+ /*Create wl_monotor proxy by sington*/
+ if (tbm_monitor)
+ return 1;
+
+ tbm_monitor = wl_registry_bind(registry, name, &wl_tbm_monitor_interface, version);
+ WL_TBM_RETURN_VAL_IF_FAIL(tbm_monitor != NULL, 0);
+
+ wl_proxy_set_queue((struct wl_proxy *)tbm_monitor, NULL);
+
+ wl_tbm_monitor_add_listener(tbm_monitor, &wl_tbm_monitor_listener, tbm_client);
+
+ return 1;
+}
+
+void
+wayland_tbm_monitor_client_deinit(struct wayland_tbm_client *tbm_client)
+{
+ WL_TBM_RETURN_IF_FAIL(tbm_client);
+
+ if (tbm_monitor
+ && (tbm_client == wl_tbm_monitor_get_user_data(tbm_monitor))) {
+ wl_tbm_monitor_destroy(tbm_monitor);
+ tbm_monitor = NULL;
+ }
+}