From 469d9132d97603cadb2ab57190e2990e5bbf9308 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Fri, 21 Aug 2020 15:22:42 +0900 Subject: [PATCH 01/16] Add DSWaylandProtocolTrace in DSCompositor Change-Id: Ifbad214d1bc1e0dbd3cbaaf29a512ad456cdd62a --- src/DSCompositor/DSCompositor.cpp | 10 ++++++++++ src/DSCompositor/DSCompositorPrivate.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/DSCompositor/DSCompositor.cpp b/src/DSCompositor/DSCompositor.cpp index bda6f1d..a4cfa29 100644 --- a/src/DSCompositor/DSCompositor.cpp +++ b/src/DSCompositor/DSCompositor.cpp @@ -30,6 +30,7 @@ #include "DSSeat.h" #include "DSInput.h" #include "DSWaylandCompositor.h" +#include "DSWaylandProtocolTrace.h" #include namespace display_server @@ -88,6 +89,7 @@ DSCompositorPrivate::~DSCompositorPrivate() DSBufferManager::releaseInstance(); DSEventLoop::releaseInstance(); DSTizenAppinfoMgr::releaseInstance(); + DSWaylandProtocolTrace::releaseInstance(); } bool DSCompositorPrivate::run() @@ -99,6 +101,7 @@ bool DSCompositorPrivate::run() __initializeBufferManager(); __initializeTizenAppinfoMgr(); __initializeWindowManager(); + __initializeProtocolTrace(); __canvas = pub->_onInitialized(); if (!__canvas) { DSLOG_ERR("Compositor", "_onInitialized() fails."); @@ -164,4 +167,11 @@ void DSCompositorPrivate::__initializeWindowManager() __dsWindowMgr = DSWindowManager::getInstance(); } +void DSCompositorPrivate::__initializeProtocolTrace() +{ + __protocolTrace = DSWaylandProtocolTrace::getInstance(); + __protocolTrace->init(); + __protocolTrace->enableProtocolTrace(true); +} + } // namespace display_server diff --git a/src/DSCompositor/DSCompositorPrivate.h b/src/DSCompositor/DSCompositorPrivate.h index e926204..5f072d8 100644 --- a/src/DSCompositor/DSCompositorPrivate.h +++ b/src/DSCompositor/DSCompositorPrivate.h @@ -30,6 +30,7 @@ #include "DSBufferManager.h" #include "DSTizenAppinfoMgr.h" #include "DSWindowManager.h" +#include "DSWaylandProtocolTrace.h" namespace display_server { @@ -64,12 +65,14 @@ private: DSBufferManager *__dsBufferManager; DSTizenAppinfoMgr * __dsAppinfoMgr; DSWindowManager *__dsWindowMgr; + DSWaylandProtocolTrace *__protocolTrace; void __initializeWlDisplay(); void __initializeOutputs(); void __initializeBufferManager(); void __initializeTizenAppinfoMgr(); void __initializeWindowManager(); + void __initializeProtocolTrace(); }; } -- 2.7.4 From bca04730f96eb9746eee970c296a487e60a724eb Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Fri, 21 Aug 2020 18:32:45 +0900 Subject: [PATCH 02/16] correct typo error and defect Change-Id: Idb57323778c2cee9850a52681d7e8a676d541c44 --- src/DSCompositor/DSCompositor.cpp | 10 +- src/DSWaylandServer/DSWaylandProtocolTrace.cpp | 123 ++++++++++++++------- .../DSWaylandProtocolTracePrivate.h | 1 + tests/DSWaylandProtocolTrace-test.cpp | 4 +- 4 files changed, 95 insertions(+), 43 deletions(-) diff --git a/src/DSCompositor/DSCompositor.cpp b/src/DSCompositor/DSCompositor.cpp index a4cfa29..30e8d02 100644 --- a/src/DSCompositor/DSCompositor.cpp +++ b/src/DSCompositor/DSCompositor.cpp @@ -74,7 +74,8 @@ DSCompositorPrivate::DSCompositorPrivate(DSCompositor *p_ptr) __canvas(nullptr), __dsBufferManager(nullptr), __dsAppinfoMgr(nullptr), - __dsWindowMgr(nullptr) + __dsWindowMgr(nullptr), + __protocolTrace(nullptr) { __eventLoop = DSEventLoop::getInstance(); @@ -170,8 +171,9 @@ void DSCompositorPrivate::__initializeWindowManager() void DSCompositorPrivate::__initializeProtocolTrace() { __protocolTrace = DSWaylandProtocolTrace::getInstance(); - __protocolTrace->init(); - __protocolTrace->enableProtocolTrace(true); + if(__protocolTrace){ + if(__protocolTrace->init()) + __protocolTrace->enableProtocolTrace(true); + } } - } // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp index 97eaad0..9122a09 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp +++ b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp @@ -93,9 +93,6 @@ const char *get_next_argument(const char *signature, struct argument_details *de DSWaylandProtocolTrace::DSWaylandProtocolTrace(DSObject *parent) : DS_INIT_PRIVATE_PTR(DSWaylandProtocolTrace) { - //init(); - DS_GET_PRIV(DSWaylandProtocolTrace); - priv->__wlCompositor = DSWaylandCompositor::getInstance(); } DSWaylandProtocolTrace::~DSWaylandProtocolTrace() @@ -138,7 +135,6 @@ bool DSWaylandProtocolTrace::init(void) DS_GET_PRIV(DSWaylandProtocolTrace); bool ret = false; char *env_path = nullptr; - char tmp[PATH_MAX] = {0,}; rc = priv->rulechecker_init(); @@ -150,11 +146,10 @@ bool DSWaylandProtocolTrace::init(void) if(env_path) { - //TODO: free env_path - DSLOG_DBG("DSWaylandProtocolTrace", "delete rule file path = %s", env_path); - //free(env_path); + char *tmp = strdup(env_path); + if(!tmp) return false; + free(tmp); env_path = nullptr; - DSLOG_DBG("DSWaylandProtocolTrace", "delete rule file path done."); } if(!ret) return ret; @@ -164,13 +159,13 @@ bool DSWaylandProtocolTrace::init(void) DSLOG_DBG("DSWaylandProtocolTrace", "==================================================== trace file path = %s", env_path); ret = priv->protocol_trace_init(env_path); DSLOG_DBG("DSWaylandProtocolTrace", "result of protocol trace init = %d", ret); + if(env_path) { - //TODO: free env_path - DSLOG_DBG("DSWaylandProtocolTrace", "delete trace file path = %s", env_path); - //free(env_path); + char *tmp = strdup(env_path); + if(!tmp) return false; + free(tmp); env_path = nullptr; - DSLOG_DBG("DSWaylandProtocolTrace", "delete trace file path done."); } return ret; } @@ -219,7 +214,7 @@ bool DSWaylandProtocolTrace::updateProtocolRule(const int argc, const char **arg DSWaylandProtocolTracePrivate::DSWaylandProtocolTracePrivate(DSWaylandProtocolTrace *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) { - + __wlCompositor = DSWaylandCompositor::getInstance(); } DSWaylandProtocolTracePrivate::~DSWaylandProtocolTracePrivate() @@ -229,27 +224,34 @@ DSWaylandProtocolTracePrivate::~DSWaylandProtocolTracePrivate() bool DSWaylandProtocolTracePrivate::protocol_rule_init(char *rule_path) { + bool ret = false; char *argv[2]; int argc = 2; if(!rule_path || strlen(rule_path) <= 0) + { + DSLOG_ERR("DSWaylandProtocolTracePrivate", "rule path is null"); return false; + } argv[0] = "file"; argv[1] = rule_path; DSLOG_DBG("DSWaylandProtocolTracePriv", "rule_path = %s", rule_path); - protocol_rule_set(argc, (const char**)&(argv[0])); + ret = protocol_rule_set(argc, (const char**)&(argv[0])); - return true; + return ret; } bool DSWaylandProtocolTracePrivate::protocol_trace_init(char *trace_path) { DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> protocol_trace_init"); if(!trace_path || strlen(trace_path) <= 0) + { + DSLOG_ERR("DSWaylandProtocolTracePrivate", "trace path is null"); return false; + } trace_env_path = trace_path; DSLOG_DBG("DSWaylandProtocolTracePriv", "saved trace path = %s", trace_env_path); @@ -274,6 +276,38 @@ bool DSWaylandProtocolTracePrivate::protocol_trace_init(char *trace_path) return true; } +int DSWaylandProtocolTracePrivate::chk(const char *str) +{ + char *endptr; + int index = strtol(str, &endptr, 10); + if(errno == ERANGE) + { + DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : overflow"); + return -1; + } + if(errno != 0) + { + DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : other error"); + return -1; + } + if(endptr == 0) + { + DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : non-numeric"); + return -1; + } + if(*endptr != '\0') + { + DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : non-numeric at end"); + return -1; + } + if(isspace(*str)) + { + DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : space at beginning"); + return -1; + } + return index; +} + bool DSWaylandProtocolTracePrivate::protocol_rule_set(const int argc, const char **argv) { DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> protocol_rule_set"); @@ -361,7 +395,7 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_set(const int argc, const char } else if(result == PROTOCOLTRACE_RULE_SET_ERR_PARSE) { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Error: An error occured during parsing the rule [%s]", rule); + DSLOG_ERR("DSWaylandProtocolTracePriv", "Error: An error occurred during parsing the rule [%s]", rule); return false; } DSLOG_INF("DSWaylandProtocolTracePriv", "The rule was successfully added"); @@ -398,13 +432,20 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_set(const int argc, const char } else { - int index = atoi(remove_idx); - DSLOG_DBG("DSWaylandProtocolTracePriv", "REMOVE :: remove idx = %d", index); - - if(isdigit(*remove_idx) && rulechecker_rule_remove(rc, index) == 0) - DSLOG_INF("DSWaylandProtocolTracePriv", "The rule [%d] was successfully removed.", index); + int index = chk(remove_idx); + if(index == -1) + { + DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : overflow"); + } else - DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : No such rule [%s]", remove_idx); + { + DSLOG_DBG("DSWaylandProtocolTracePriv", "REMOVE :: remove idx = %d", index); + + if(isdigit(*remove_idx) && rulechecker_rule_remove(rc, index) == 0) + DSLOG_INF("DSWaylandProtocolTracePriv", "The rule [%d] was successfully removed.", index); + else + DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : No such rule [%s]", remove_idx); + } } } rulechecker_rule_print(rc); @@ -438,7 +479,7 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_set(const int argc, const char return true; } - DSLOG_ERR("DSWaylandProtocolTracePriv", "%s\nUnkown command : [%s] ", rulechecker_usage_print(), command); + DSLOG_ERR("DSWaylandProtocolTracePriv", "%s\nUnknown command : [%s] ", rulechecker_usage_print(), command); DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << protocol_rule_set"); @@ -454,7 +495,7 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_file_set(const char *filename) fd = open(filename, O_RDONLY); if(fd<0) { - DSLOG_DBG("DSWaylandProtocolTracePriv", "failed: open '%s'", filename); + DSLOG_ERR("DSWaylandProtocolTracePriv", "failed: open '%s'", filename); return false; } @@ -577,8 +618,7 @@ void DSWaylandProtocolTracePrivate::wl_protocol_cb_client_destroy(struct wl_list DSLOG_INF("DSWaylandProtocolTracePriv", "%s", strbuf); wl_list_remove(&listener->link); - //free(listener); - delete listener; + free(listener); listener = nullptr; } @@ -593,6 +633,8 @@ void DSWaylandProtocolTracePrivate::protocol_client_destroy_listener_reg(struct destroy_listener = (struct wl_listener *)calloc(1, sizeof(wl_listener)); //EINA_SAFETY_ON_NULL_RETURN(destroy_listener); + if(!destroy_listener) + return; destroy_listener->notify = wl_protocol_cb_client_destroy; wl_client_add_destroy_listener(client, destroy_listener); @@ -693,6 +735,8 @@ ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_create_node(Prot { ProtocolTrace_Tree_Node *node = (ProtocolTrace_Tree_Node*) calloc(1, sizeof(ProtocolTrace_Tree_Node) + tree->size); // enia safety + if(!node) + return nullptr; node->left = nullptr; node->right = nullptr; @@ -704,6 +748,8 @@ ProtocolTrace_Tree *DSWaylandProtocolTracePrivate::bintree_create_tree(int size) { ProtocolTrace_Tree *tree = (ProtocolTrace_Tree *)calloc(1, sizeof(ProtocolTrace_Tree) + size); // eina safety + if(!tree) + return nullptr; tree->size = size; tree->head = nullptr; @@ -714,8 +760,7 @@ void DSWaylandProtocolTracePrivate::bintree_destroy_tree(ProtocolTrace_Tree *tre { if(tree->head) bintree_remove_node_recursive(tree->head); - //free(tree); - delete tree; + free(tree); } ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_get_head(ProtocolTrace_Tree *tree) @@ -779,8 +824,7 @@ int DSWaylandProtocolTracePrivate::bintree_postorder_traverse_recursive(Protocol void DSWaylandProtocolTracePrivate::bintree_remove_node(ProtocolTrace_Tree_Node *node) { - //free(node); - delete node; + free(node); } void DSWaylandProtocolTracePrivate::bintree_remove_node_recursive(ProtocolTrace_Tree_Node *node) @@ -919,7 +963,7 @@ ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::parser_statement_parse(P goto fail; node = bintree_create_node(tree); - //eina safty + //eina safety data = (ProtocolTrace_Rule_Node *) bintree_get_node_data(node); @@ -981,6 +1025,7 @@ ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::parser_statement_parse(P parser_token_process(token); return node; + fail: if(node) bintree_remove_node_recursive(node); @@ -1093,8 +1138,7 @@ void DSWaylandProtocolTracePrivate::rulechecker_destroy(ProtocolTrace_Rule_Check for(i=rc->count-1; i>=0; i--) rulechecker_rule_remove(rc,i); - //free(rc); - delete rc; + free(rc); } ProtocolTrace_Rule_Checker *DSWaylandProtocolTracePrivate::rulechecker_init() @@ -1147,8 +1191,10 @@ ProtocolTrace_Rule_Set_Result DSWaylandProtocolTracePrivate::rulechecker_rule_ad void DSWaylandProtocolTracePrivate::rulechecker_rule_print(ProtocolTrace_Rule_Checker *rc) { - char *reply; - int *len; + char tmpReply[4096]; + int tmpLen = sizeof(tmpReply); + char *reply = tmpReply; + int *len = &tmpLen; ProtocolTrace_Reply_Buffer buffer = {&reply, len}; int i; @@ -1322,11 +1368,12 @@ int DSWaylandProtocolTracePrivate::rule_validate_func(ProtocolTrace_Tree *tree, } else if(data->node_type == PROTOCOLTRACE_NODE_TYPE_DATA) { - char iface[64]; + char iface[64] = {0,}; char *msg = nullptr; + int colon = atoi(":"); if(args->name) - msg = ":";//index(args->name, ":"); + msg = (char *) index(args->name, colon); if(msg) { int min = MIN(sizeof(iface)-1, msg-args->name); @@ -1354,7 +1401,7 @@ int DSWaylandProtocolTracePrivate::rule_validate_func(ProtocolTrace_Tree *tree, } else if(!strcasecmp(data->variable_name, "IFACE")) { - if(msg && rulechecker_string_compare(data->comparer, data->value.string, iface)) + if(msg && !iface[0] && rulechecker_string_compare(data->comparer, data->value.string, iface)) data->result = PROTOCOLTRACE_RESULT_TRUE; else data->result = PROTOCOLTRACE_RESULT_FALSE; diff --git a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h index 8c22087..ffecf2d 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h +++ b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h @@ -283,6 +283,7 @@ private: const char * rulechecker_usage_print(); static int rule_print_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); static int rule_validate_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); + int chk(const char *str); }; } diff --git a/tests/DSWaylandProtocolTrace-test.cpp b/tests/DSWaylandProtocolTrace-test.cpp index 63d0e67..31201ff 100644 --- a/tests/DSWaylandProtocolTrace-test.cpp +++ b/tests/DSWaylandProtocolTrace-test.cpp @@ -30,7 +30,9 @@ class DSWaylandProtocolTraceTest : public ::testing::Test { public: void SetUp(void) override - {} + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } void TearDown(void) override {} -- 2.7.4 From 35fea3086fcc142b010b05966a2299c3be3fdb06 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Thu, 27 Aug 2020 19:40:38 +0900 Subject: [PATCH 03/16] fix not working trace by rule without all case and add log about cmd part Change-Id: Ic6696761b25ee43276a05b0cc09df0e96be6be25 --- src/DSWaylandServer/DSWaylandProtocolTrace.cpp | 47 ++++++++++++++++++++-- .../DSWaylandProtocolTracePrivate.h | 1 + 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp index 9122a09..1d4194f 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp +++ b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp @@ -23,6 +23,7 @@ #include "DSWaylandProtocolTrace.h" #include "DSWaylandProtocolTracePrivate.h" +#include "DSWaylandClient.h" #include #include @@ -552,6 +553,31 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_validate(ProtocolTrace_Protoco return rulechecker_rule_validate(rc, log->type, log->target_id, log->name, log->client_pid, cmd); } +void DSWaylandProtocolTracePrivate::wl_client_proc_name_get(pid_t pid, char *name, int size) + { + if(!name) return; + + FILE *h; + char proc[512], pname[512]; + size_t len; + + snprintf(proc, 512, "/proc/%d/cmdline", pid); + + h = fopen(proc, "r"); + if(!h) return; + + len = fread(pname, sizeof(char), 512, h); + if(len >0) + pname[len-1]='\0'; + else + { + strncpy(pname, "NO NAME", sizeof(pname)); + } + fclose(h); + + strncpy(name, pname, size); +} + void DSWaylandProtocolTracePrivate::protocol_trace_set(void) { DSLOG_DBG("DSWaylandProtocolTracePriv","IN >> protocol trace set"); @@ -575,7 +601,7 @@ void DSWaylandProtocolTracePrivate::protocol_trace_set(void) DSLOG_DBG("DSWaylandProtocolTracePriv","get display "); //check working - ds_wl_protocol_logger = wl_display_add_protocol_logger(display, protocol_trace_func, nullptr); + ds_wl_protocol_logger = wl_display_add_protocol_logger(display, protocol_trace_func, __wlCompositor); DSLOG_DBG("DSWaylandProtocolTracePriv","OUT << protocol trace set"); } @@ -671,6 +697,18 @@ void DSWaylandProtocolTracePrivate::protocol_trace_func(void *user_data, enum wl elog.target_id = wl_resource_get_id(message->resource); snprintf(elog.name, PATH_MAX,"%s:%s", wl_resource_get_class(message->resource), message->message->name); + DSWaylandCompositor * comp = (DSWaylandCompositor * )user_data; + std::list clients = comp->clients(); + for(auto client : clients) + { + char name[512]; + wl_client_proc_name_get(client->pid(), name, sizeof(name)); + if(client->pid() == client_pid) + { + snprintf(elog.cmd, PATH_MAX, "%s", name); + } + } + if(!protocol_rule_validate(&elog)) return; BUF_SNPRINTF("[%10.3f] %s%d%s%s@%u.%s(", @@ -1370,10 +1408,11 @@ int DSWaylandProtocolTracePrivate::rule_validate_func(ProtocolTrace_Tree *tree, { char iface[64] = {0,}; char *msg = nullptr; - int colon = atoi(":"); if(args->name) - msg = (char *) index(args->name, colon); + { + msg = (char *) strchr(args->name, ':'); + } if(msg) { int min = MIN(sizeof(iface)-1, msg-args->name); @@ -1401,7 +1440,7 @@ int DSWaylandProtocolTracePrivate::rule_validate_func(ProtocolTrace_Tree *tree, } else if(!strcasecmp(data->variable_name, "IFACE")) { - if(msg && !iface[0] && rulechecker_string_compare(data->comparer, data->value.string, iface)) + if(msg && iface[0] && rulechecker_string_compare(data->comparer, data->value.string, iface)) data->result = PROTOCOLTRACE_RESULT_TRUE; else data->result = PROTOCOLTRACE_RESULT_FALSE; diff --git a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h index ffecf2d..569b462 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h +++ b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h @@ -284,6 +284,7 @@ private: static int rule_print_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); static int rule_validate_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); int chk(const char *str); + static void wl_client_proc_name_get(pid_t pid, char *name, int size); }; } -- 2.7.4 From 9a000fb324467a028fbf0bc25b3cfea3fee06a97 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Fri, 28 Aug 2020 10:09:44 +0900 Subject: [PATCH 04/16] fix the warning issues Change-Id: I7638271160cc6a31201b0c98a0e66ff0159b29c6 --- src/DSWaylandServer/DSWaylandProtocolTrace.cpp | 31 ++++++++++++---------- .../DSWaylandProtocolTracePrivate.h | 8 +++--- tests/DSWaylandProtocolTrace-test.cpp | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp index 1d4194f..75d8583 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp +++ b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp @@ -226,7 +226,7 @@ DSWaylandProtocolTracePrivate::~DSWaylandProtocolTracePrivate() bool DSWaylandProtocolTracePrivate::protocol_rule_init(char *rule_path) { bool ret = false; - char *argv[2]; + const char *argv[2]; int argc = 2; if(!rule_path || strlen(rule_path) <= 0) @@ -330,7 +330,7 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_set(const int argc, const char ProtocolTrace_Rule_Set_Result result; const char * policy = argv[1]; //allow, deny char merge[8192] = {0,}, rule[8192] = {0,}; - int i, index=0, size_rule, apply = 0; + int i, index=0, size_rule, apply = 0, size_merge; if(argc <3) { @@ -354,8 +354,9 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_set(const int argc, const char protocol_arguments_merge(merge, sizeof(merge), argc -2, &(argv[2])); size_rule = sizeof(rule) -1; + size_merge = strlen(merge); - for(i=0; isize_rule) return false; @@ -506,7 +508,7 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_file_set(const char *filename) while(pfs -fs < rule_len) { int i, new_argc =3; - char *new_argv[3] = {"add", }; + const char *new_argv[3] = {"add", }; char policy[64] = {0,}; char rule[1024] = {0,}; @@ -543,7 +545,7 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_file_set(const char *filename) bool DSWaylandProtocolTracePrivate::protocol_rule_validate(ProtocolTrace_Protocol_Log *log) { - char *cmd = ""; + const char *cmd = ""; if(!rc) return false; @@ -1262,7 +1264,7 @@ ProtocolTrace_Rule_Set_Result DSWaylandProtocolTracePrivate::rulechecker_rule_re return PROTOCOLTRACE_RULE_SET_OK; } -int DSWaylandProtocolTracePrivate::rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, char *cmd) +int DSWaylandProtocolTracePrivate::rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, const char *cmd) { ProtocolTrace_Validate_Args args = {type, target_id, name, pid, cmd}; ProtocolTrace_Tree_Node *node; @@ -1284,7 +1286,7 @@ int DSWaylandProtocolTracePrivate::rulechecker_rule_validate(ProtocolTrace_Rule_ return default_policy == PROTOCOLTRACE_TYPE_ALLOW; } -int DSWaylandProtocolTracePrivate::rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, char *str1) +int DSWaylandProtocolTracePrivate::rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, const char *str1) { int result = strcasecmp(str2, str1); @@ -1344,8 +1346,8 @@ int DSWaylandProtocolTracePrivate::rule_print_func(ProtocolTrace_Tree *tree, Pro { ProtocolTrace_Reply_Buffer *buffer = (ProtocolTrace_Reply_Buffer *)arg; char *reply = *buffer->reply; - int *len = buffer->len; - char *operators[] = {"==", "<", ">", "<=", ">=", "!=" }; + //int *len = buffer->len; + const char *operators[] = {"==", "<", ">", "<=", ">=", "!=" }; ProtocolTrace_Rule_Node *data; data = (ProtocolTrace_Rule_Node *)bintree_get_node_data(node); @@ -1415,14 +1417,15 @@ int DSWaylandProtocolTracePrivate::rule_validate_func(ProtocolTrace_Tree *tree, } if(msg) { - int min = MIN(sizeof(iface)-1, msg-args->name); + int size_iface = sizeof(iface) -1; + int min = MIN(size_iface, msg-args->name); strncpy(iface, args->name, min); iface[min] = '\0'; msg++; } if(!strcasecmp(data->variable_name, "TYPE")) { - char *type_string; + const char *type_string; if(args->type == 0) type_string = "REQUEST"; else if(args->type == 1) @@ -1440,7 +1443,7 @@ int DSWaylandProtocolTracePrivate::rule_validate_func(ProtocolTrace_Tree *tree, } else if(!strcasecmp(data->variable_name, "IFACE")) { - if(msg && iface[0] && rulechecker_string_compare(data->comparer, data->value.string, iface)) + if(msg && iface[0] && rulechecker_string_compare(data->comparer, data->value.string, (const char *)iface)) data->result = PROTOCOLTRACE_RESULT_TRUE; else data->result = PROTOCOLTRACE_RESULT_FALSE; diff --git a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h index 569b462..d387a9f 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h +++ b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h @@ -31,7 +31,7 @@ #include #include -#define PATH_MAX 255 //tmp 255 +#define PATH_MAX 512 #ifndef MAX #define MAX(x, y) (((x) > (y)) ? (x) : (y)) @@ -210,7 +210,7 @@ typedef struct int target_id; const char *name; int pid; - char *cmd; + const char *cmd; } ProtocolTrace_Validate_Args; typedef struct @@ -278,8 +278,8 @@ private: ProtocolTrace_Rule_Set_Result rulechecker_rule_add(_ProtocolTrace_Rule_Checker *rc, ProtocolTrace_Policy_Type policy, const char *rule_string); void rulechecker_rule_print(ProtocolTrace_Rule_Checker *rc); ProtocolTrace_Rule_Set_Result rulechecker_rule_remove(ProtocolTrace_Rule_Checker *rc, int index); - static int rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, char *cmd); - static int rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, char *str1); + static int rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, const char *cmd); + static int rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, const char *str1); const char * rulechecker_usage_print(); static int rule_print_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); static int rule_validate_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); diff --git a/tests/DSWaylandProtocolTrace-test.cpp b/tests/DSWaylandProtocolTrace-test.cpp index 31201ff..3139fd4 100644 --- a/tests/DSWaylandProtocolTrace-test.cpp +++ b/tests/DSWaylandProtocolTrace-test.cpp @@ -67,7 +67,7 @@ TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceUpdateRule) pTrace->init(); int argc = 3; - char *argv[3]; + const char *argv[3]; argv[0] = "add"; argv[1] = "ALLOW"; argv[2] = "all"; -- 2.7.4 From 0ce3b859d7779d626ef434d70ab01b2f06a7e905 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Fri, 28 Aug 2020 13:23:25 +0900 Subject: [PATCH 05/16] separate structures in DSWaylandProtocolTracePrivate.h to DSWaylandProtocolTraceStruct.h Change-Id: I0f49469d9a5daaea37626043c7713fca19a3d91c --- src/DSWaylandServer/DSWaylandProtocolTrace.h | 1 - .../DSWaylandProtocolTracePrivate.h | 187 +----------------- src/DSWaylandServer/DSWaylandProtocolTraceStruct.h | 218 +++++++++++++++++++++ src/meson.build | 3 +- 4 files changed, 221 insertions(+), 188 deletions(-) create mode 100644 src/DSWaylandServer/DSWaylandProtocolTraceStruct.h diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.h b/src/DSWaylandServer/DSWaylandProtocolTrace.h index b53e999..59cbbf0 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTrace.h +++ b/src/DSWaylandServer/DSWaylandProtocolTrace.h @@ -51,7 +51,6 @@ private: static std::mutex __mutex; static DSWaylandProtocolTrace *__protocolTrace; static int __refCount; - }; } diff --git a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h index d387a9f..a64c0db 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h +++ b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h @@ -25,200 +25,15 @@ #define __DS_WAYLAND_PROTOCOL_TRACE_PRIVATE_H__ #include "DSWaylandProtocolTrace.h" -//#include "DSWaylandProtocolTraceStruct.h" +#include "DSWaylandProtocolTraceStruct.h" #include #include #include #include -#define PATH_MAX 512 - -#ifndef MAX -#define MAX(x, y) (((x) > (y)) ? (x) : (y)) -#endif - -#ifndef MIN -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#endif - -#define BUF_SNPRINTF(fmt, ARG...) do { \ - str_l = snprintf(str_buff, str_r, fmt, ##ARG); \ - str_buff += str_l; \ - str_r -= str_l; \ -} while(0) - - -/* -#ifndef REPLY - #define REPLY(fmt, ARG...) \ - do { \ - if (reply && len && *len > 0) \ - { \ - int s = snprintf(reply, *len, fmt, ##ARG); \ - reply += s; \ - *len -= s; \ - } \ - } while (0) -#endif -*/ -#define MAX_RULE 64 -#define STRING_MAX 64 namespace display_server { -typedef struct _ProtocolTrace_Tree_Node ProtocolTrace_Tree_Node; -typedef struct _ProtocolTrace_Tree ProtocolTrace_Tree; -typedef struct _ProtocolTrace_Token_Data ProtocolTrace_Token_Data; -typedef struct _ProtocolTrace_Rule_Node ProtocolTrace_Rule_Node; -typedef struct _ProtocolTrace_Rule ProtocolTrace_Rule; -typedef struct _ProtocolTrace_Rule_Checker ProtocolTrace_Rule_Checker; -typedef struct _ProtocolTrace_Protocol_Log ProtocolTrace_Protocol_Log; - -typedef int (*ProtocolTrace_Tree_Traverse_Cb) (ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); - -struct _ProtocolTrace_Tree_Node -{ - ProtocolTrace_Tree_Node *left; - ProtocolTrace_Tree_Node *right; -}; - -struct _ProtocolTrace_Tree -{ - int size; - ProtocolTrace_Tree_Node *head; -}; - -typedef enum -{ - PROTOCOLTRACE_TOKEN_UNKNOWN = 0, - PROTOCOLTRACE_TOKEN_L_BR =1, - PROTOCOLTRACE_TOKEN_R_BR =2, - PROTOCOLTRACE_TOKEN_NOT_EQ=3, - PROTOCOLTRACE_TOKEN_EQUAL=4, - PROTOCOLTRACE_TOKEN_LSS_THAN=5, - PROTOCOLTRACE_TOKEN_LSS_EQ =6, - PROTOCOLTRACE_TOKEN_GRT_THAN=7, - PROTOCOLTRACE_TOKEN_GRT_EQ =8, - PROTOCOLTRACE_TOKEN_AND=9, - PROTOCOLTRACE_TOKEN_OR=10, - PROTOCOLTRACE_TOKEN_SPACE=11, - PROTOCOLTRACE_TOKEN_SYMBOL=12, - PROTOCOLTRACE_TOKEN_NUMBER=13, - PROTOCOLTRACE_TOKEN_EOS=14, -} ProtocolTrace_Token; - -struct _ProtocolTrace_Token_Data -{ - const char **string; - ProtocolTrace_Token last_token; - const char *last_symbol; - int symbol_len; -}; -typedef enum -{ - PROTOCOLTRACE_NODE_TYPE_NONE, - PROTOCOLTRACE_NODE_TYPE_AND, - PROTOCOLTRACE_NODE_TYPE_OR, - PROTOCOLTRACE_NODE_TYPE_DATA, - PROTOCOLTRACE_NODE_TYPE_ALL -} ProtocolTrace_Node_Type; - -typedef enum -{ - PROTOCOLTRACE_COMPARER_EQUAL, - PROTOCOLTRACE_COMPARER_LESS, - PROTOCOLTRACE_COMPARER_GREATER, - PROTOCOLTRACE_COMPARER_LESS_EQ, - PROTOCOLTRACE_COMPARER_GREATE_EQ, - PROTOCOLTRACE_COMPARER_NOT_EQ -} ProtocolTrace_Comparer; - -typedef enum -{ - PROTOCOLTRACE_DATA_TYPE_INTEGER, - PROTOCOLTRACE_DATA_TYPE_STRING -} ProtocolTrace_Data_Type; - -typedef enum -{ - PROTOCOLTRACE_RESULT_UNKNOWN, - PROTOCOLTRACE_RESULT_TRUE, - PROTOCOLTRACE_RESULT_FALSE -} ProtocolTrace_Result_Type; - -struct _ProtocolTrace_Rule_Node -{ - ProtocolTrace_Node_Type node_type; - char variable_name[STRING_MAX]; - ProtocolTrace_Comparer comparer; - ProtocolTrace_Data_Type value_type; - - union - { - char string[STRING_MAX]; - int integer; - }value; - - ProtocolTrace_Result_Type result; -}; - -typedef enum -{ - PROTOCOLTRACE_POLICY_TYPE_UNDEFINED, - PROTOCOLTRACE_TYPE_ALLOW, - PROTOCOLTRACE_TYPE_DENY -} ProtocolTrace_Policy_Type; - -struct _ProtocolTrace_Rule -{ - ProtocolTrace_Policy_Type policy; - ProtocolTrace_Tree *tree; -}; - -struct _ProtocolTrace_Rule_Checker -{ - ProtocolTrace_Rule rules[MAX_RULE]; - int count; -}; -typedef enum -{ - PROTOCOLTRACE_RULE_SET_OK, - PROTOCOLTRACE_RULE_SET_ERR_TOO_MANY_RULES, - PROTOCOLTRACE_RULE_SET_ERR_PARSE, - PROTOCOLTRACE_RULE_SET_ERR_NO_RULE - } ProtocolTrace_Rule_Set_Result; -typedef enum{ - PROTOCOL_TYPE_REQUEST, - PROTOCOL_TYPE_EVENT -} ProtocolTrace_Protocol_Type; -struct _ProtocolTrace_Protocol_Log -{ - ProtocolTrace_Protocol_Type type; - int client_pid; - int target_id; - char name[PATH_MAX +1]; - char cmd[PATH_MAX +1]; -}; -struct argument_details { - char type; - int nullable; -}; - -typedef struct -{ - int type; - int target_id; - const char *name; - int pid; - const char *cmd; -} ProtocolTrace_Validate_Args; - -typedef struct -{ - char **reply; - int *len; -} ProtocolTrace_Reply_Buffer; - class DSWaylandProtocolTracePrivate : public DSObjectPrivate { DS_PIMPL_USE_PUBLIC(DSWaylandProtocolTrace); diff --git a/src/DSWaylandServer/DSWaylandProtocolTraceStruct.h b/src/DSWaylandServer/DSWaylandProtocolTraceStruct.h new file mode 100644 index 0000000..a1129cd --- /dev/null +++ b/src/DSWaylandServer/DSWaylandProtocolTraceStruct.h @@ -0,0 +1,218 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* 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. +*/ + +#ifndef __DS_WAYLAND_PROTOCOL_TRACE_STRUCT_H__ +#define __DS_WAYLAND_PROTOCOL_TRACE_STRUCT_H__ + +#define PATH_MAX 512 +#define MAX_RULE 64 +#define STRING_MAX 64 + +#ifndef MAX +#define MAX(x, y) (((x) > (y)) ? (x) : (y)) +#endif + +#ifndef MIN +#define MIN(x, y) (((x) < (y)) ? (x) : (y)) +#endif + +#define BUF_SNPRINTF(fmt, ARG...) do { \ + str_l = snprintf(str_buff, str_r, fmt, ##ARG); \ + str_buff += str_l; \ + str_r -= str_l; \ +} while(0) + +/* +#ifndef REPLY + #define REPLY(fmt, ARG...) \ + do { \ + if (reply && len && *len > 0) \ + { \ + int s = snprintf(reply, *len, fmt, ##ARG); \ + reply += s; \ + *len -= s; \ + } \ + } while (0) +#endif +*/ + +namespace display_server +{ + +typedef struct _ProtocolTrace_Tree_Node ProtocolTrace_Tree_Node; +typedef struct _ProtocolTrace_Tree ProtocolTrace_Tree; +typedef struct _ProtocolTrace_Token_Data ProtocolTrace_Token_Data; +typedef struct _ProtocolTrace_Rule_Node ProtocolTrace_Rule_Node; +typedef struct _ProtocolTrace_Rule ProtocolTrace_Rule; +typedef struct _ProtocolTrace_Rule_Checker ProtocolTrace_Rule_Checker; +typedef struct _ProtocolTrace_Protocol_Log ProtocolTrace_Protocol_Log; + +typedef int (*ProtocolTrace_Tree_Traverse_Cb) (ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); + +struct _ProtocolTrace_Tree_Node +{ + ProtocolTrace_Tree_Node *left; + ProtocolTrace_Tree_Node *right; +}; + +struct _ProtocolTrace_Tree +{ + int size; + ProtocolTrace_Tree_Node *head; +}; + +typedef enum +{ + PROTOCOLTRACE_TOKEN_UNKNOWN = 0, + PROTOCOLTRACE_TOKEN_L_BR =1, + PROTOCOLTRACE_TOKEN_R_BR =2, + PROTOCOLTRACE_TOKEN_NOT_EQ=3, + PROTOCOLTRACE_TOKEN_EQUAL=4, + PROTOCOLTRACE_TOKEN_LSS_THAN=5, + PROTOCOLTRACE_TOKEN_LSS_EQ =6, + PROTOCOLTRACE_TOKEN_GRT_THAN=7, + PROTOCOLTRACE_TOKEN_GRT_EQ =8, + PROTOCOLTRACE_TOKEN_AND=9, + PROTOCOLTRACE_TOKEN_OR=10, + PROTOCOLTRACE_TOKEN_SPACE=11, + PROTOCOLTRACE_TOKEN_SYMBOL=12, + PROTOCOLTRACE_TOKEN_NUMBER=13, + PROTOCOLTRACE_TOKEN_EOS=14, +} ProtocolTrace_Token; + +struct _ProtocolTrace_Token_Data +{ + const char **string; + ProtocolTrace_Token last_token; + const char *last_symbol; + int symbol_len; +}; +typedef enum +{ + PROTOCOLTRACE_NODE_TYPE_NONE, + PROTOCOLTRACE_NODE_TYPE_AND, + PROTOCOLTRACE_NODE_TYPE_OR, + PROTOCOLTRACE_NODE_TYPE_DATA, + PROTOCOLTRACE_NODE_TYPE_ALL +} ProtocolTrace_Node_Type; + +typedef enum +{ + PROTOCOLTRACE_COMPARER_EQUAL, + PROTOCOLTRACE_COMPARER_LESS, + PROTOCOLTRACE_COMPARER_GREATER, + PROTOCOLTRACE_COMPARER_LESS_EQ, + PROTOCOLTRACE_COMPARER_GREATE_EQ, + PROTOCOLTRACE_COMPARER_NOT_EQ +} ProtocolTrace_Comparer; + +typedef enum +{ + PROTOCOLTRACE_DATA_TYPE_INTEGER, + PROTOCOLTRACE_DATA_TYPE_STRING +} ProtocolTrace_Data_Type; + +typedef enum +{ + PROTOCOLTRACE_RESULT_UNKNOWN, + PROTOCOLTRACE_RESULT_TRUE, + PROTOCOLTRACE_RESULT_FALSE +} ProtocolTrace_Result_Type; + +struct _ProtocolTrace_Rule_Node +{ + ProtocolTrace_Node_Type node_type; + char variable_name[STRING_MAX]; + ProtocolTrace_Comparer comparer; + ProtocolTrace_Data_Type value_type; + + union + { + char string[STRING_MAX]; + int integer; + }value; + + ProtocolTrace_Result_Type result; +}; + +typedef enum +{ + PROTOCOLTRACE_POLICY_TYPE_UNDEFINED, + PROTOCOLTRACE_TYPE_ALLOW, + PROTOCOLTRACE_TYPE_DENY +} ProtocolTrace_Policy_Type; + +struct _ProtocolTrace_Rule +{ + ProtocolTrace_Policy_Type policy; + ProtocolTrace_Tree *tree; +}; + +struct _ProtocolTrace_Rule_Checker +{ + ProtocolTrace_Rule rules[MAX_RULE]; + int count; +}; +typedef enum +{ + PROTOCOLTRACE_RULE_SET_OK, + PROTOCOLTRACE_RULE_SET_ERR_TOO_MANY_RULES, + PROTOCOLTRACE_RULE_SET_ERR_PARSE, + PROTOCOLTRACE_RULE_SET_ERR_NO_RULE + } ProtocolTrace_Rule_Set_Result; +typedef enum{ + PROTOCOL_TYPE_REQUEST, + PROTOCOL_TYPE_EVENT +} ProtocolTrace_Protocol_Type; +struct _ProtocolTrace_Protocol_Log +{ + ProtocolTrace_Protocol_Type type; + int client_pid; + int target_id; + char name[PATH_MAX +1]; + char cmd[PATH_MAX +1]; +}; +struct argument_details { + char type; + int nullable; +}; + +typedef struct +{ + int type; + int target_id; + const char *name; + int pid; + const char *cmd; +} ProtocolTrace_Validate_Args; + +typedef struct +{ + char **reply; + int *len; +} ProtocolTrace_Reply_Buffer; + +} + + +#endif //__DS_WAYLAND_PROTOCOL_TRACE_STRUCT_H__ \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index ea39c2c..62c7b30 100644 --- a/src/meson.build +++ b/src/meson.build @@ -177,13 +177,14 @@ libds_wayland_srcs = [ 'DSWaylandServer/DSWaylandTizenLaunchSplash.h', 'DSWaylandServer/DSWaylandTizenLaunchSplash.cpp', 'DSWaylandServer/DSWaylandProtocolTracePrivate.h', + 'DSWaylandServer/DSWaylandProtocolTraceStruct.h', 'DSWaylandServer/DSWaylandProtocolTrace.h', 'DSWaylandServer/DSWaylandProtocolTrace.cpp', 'DSWaylandServer/DSWaylandTizenPolicyExt.h', 'DSWaylandServer/DSWaylandTizenPolicyExtPrivate.h', 'DSWaylandServer/DSWaylandTizenPolicyExt.cpp', 'DSWaylandServer/tizen_policy_ext-server-protocol.h', - 'DSWaylandServer/tizen_policy_ext-protocol.c', + 'DSWaylandServer/tizen_policy_ext-protocol.c', ] libds_srcs += libds_wayland_srcs -- 2.7.4 From 942b2a4c077056ca7fd75e131eefcd8dc55f9337 Mon Sep 17 00:00:00 2001 From: Duna Oh Date: Fri, 28 Aug 2020 15:33:51 +0900 Subject: [PATCH 06/16] DSTraceInfo: print out windows' infomation(pid,title,,etc.) Change-Id: Ib786d3b9139b41bbe93eec8faba071c76d749800 --- samples/exampleCompositor.cpp | 5 ++ src/DSTraceInfo/DSTraceInfo.cpp | 118 ++++++++++++++++++++++++++++++++++++++++ src/DSTraceInfo/DSTraceInfo.h | 62 +++++++++++++++++++++ src/meson.build | 3 + 4 files changed, 188 insertions(+) create mode 100644 src/DSTraceInfo/DSTraceInfo.cpp create mode 100644 src/DSTraceInfo/DSTraceInfo.h diff --git a/samples/exampleCompositor.cpp b/samples/exampleCompositor.cpp index 27787f5..a7b23a2 100644 --- a/samples/exampleCompositor.cpp +++ b/samples/exampleCompositor.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "DSDebugLog.h" using namespace display_server; @@ -70,6 +71,9 @@ public: __textInput = std::make_shared(); + __traceInfo = std::make_shared(); + __traceInfo->attachPolicyArea(__policyArea); + return __canvas; } @@ -103,6 +107,7 @@ private: std::shared_ptr __policyArea; std::shared_ptr __displayArea; std::shared_ptr __textInput; + std::shared_ptr __traceInfo; }; int main() { diff --git a/src/DSTraceInfo/DSTraceInfo.cpp b/src/DSTraceInfo/DSTraceInfo.cpp new file mode 100644 index 0000000..608c562 --- /dev/null +++ b/src/DSTraceInfo/DSTraceInfo.cpp @@ -0,0 +1,118 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* 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 "DSTraceInfo.h" +#include "DSPolicyAreaPrivate.h" + +namespace display_server +{ +DSTraceInfo::DSTraceInfo() + : __policyArea(nullptr), + __zone(nullptr), + __eventLoop(nullptr), + __windowUpdated(false) +{ + __eventLoop = DSEventLoop::getInstance(); + if (__eventLoop) + __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSTraceInfo::__onEventIdleEnterer, this, std::placeholders::_1)); +} + +DSTraceInfo::~DSTraceInfo() +{ + if (__eventLoop) + DSEventLoop::releaseInstance(); +} + +bool DSTraceInfo::attachPolicyArea(std::shared_ptr policyArea) +{ + __policyArea = policyArea; + + DSPolicyAreaPrivate *policyAreaPriv = DSPolicyAreaPrivate::getPrivate(__policyArea.get()); + __zone = policyAreaPriv->getZone(); + + if (__zone == nullptr) { + DSLOG_ERR("DSTraceInfo", "No zone attached to this policyArea(%p)", policyArea); + return false; + } + + __zone->registerCallbackWindowCreated(this, std::bind(&DSTraceInfo::__onWindowCreated, this, std::placeholders::_1)); + __zone->registerCallbackWindowStackChanged(this, std::bind(&DSTraceInfo::__onWindowStackChanged, this, std::placeholders::_1)); + __zone->registerCallbackWindowDestroy(this, std::bind(&DSTraceInfo::__onWindowDestroy, this, std::placeholders::_1)); + + __windowList = __zone->getWindowList(); + + return true; +} + +void DSTraceInfo::__onEventIdleEnterer(void *data) +{ + if (__windowUpdated) + { + printWindowsInfo(); + __windowUpdated = false; + } +} + +void DSTraceInfo::printWindowsInfo() +{ + DSLOG_INF("DSTraceInfo", "--------------Top level windows: %d--------------", __windowList.size()); + DSLOG_INF("DSTraceInfo", " No Win_ID PID w h x y (S)kipFoc has(F)ocus (U)serGeom (V)kbdFloating Parent Title"); + + for (std::shared_ptr w : __windowList) + { + stPosition pos = w->getPosition(); + stSize sz = w->getSize(); + DSWaylandSurface *dwlSurface = w->surface(); + DSWaylandClient *dwClient = dwlSurface->getClient(); + pid_t pid = dwClient->pid(); + DSLOG_INF("DSTraceInfo", " %d: %p %d %4d %4d %4d %4d %c %c %c %c %p %s", w->getZOrder(), w.get(), pid, \ + sz.w, sz.h, pos.x, pos.y, w->getSkipFocus()?'S':' ', w->hasFocus()?'F':' ', w->isAllowUserGeometry()?'U':' ', w->getVkbdFloating()?'V':' ', \ + w->getParent(), (w->getTitle().compare("") == 0)?"No Title":w->getTitle().c_str()); + } + + DSLOG_INF("DSTraceInfo", "------------------------------------------------"); +} + +void DSTraceInfo::__onWindowCreated(std::shared_ptr window) +{ + __windowList.remove(window); + __windowList.push_front(window); + + __windowUpdated = true; +} + +void DSTraceInfo::__onWindowStackChanged(std::shared_ptr window) +{ + __windowList = __zone->getWindowList(); + + __windowUpdated = true; +} + +void DSTraceInfo::__onWindowDestroy(std::shared_ptr window) +{ + __windowList.remove(window); + + __windowUpdated = true; +} + +} \ No newline at end of file diff --git a/src/DSTraceInfo/DSTraceInfo.h b/src/DSTraceInfo/DSTraceInfo.h new file mode 100644 index 0000000..35a6516 --- /dev/null +++ b/src/DSTraceInfo/DSTraceInfo.h @@ -0,0 +1,62 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* 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. +*/ + +#ifndef __DS_TRACE_INFO_H__ +#define __DS_TRACE_INFO_H__ + +#include +#include "DSSignal.h" +#include "DSWindow.h" +#include "DSPolicyArea.h" +#include "DSZone.h" +#include "DSEventLoop.h" + +namespace display_server +{ + +class DSTraceInfo : public DSObject +{ +public: + explicit DSTraceInfo(); + virtual ~DSTraceInfo(); + bool attachPolicyArea(std::shared_ptr policyArea); + void printWindowsInfo(); + +private: + void __onWindowCreated(std::shared_ptr window); + void __onWindowStackChanged(std::shared_ptr window); + void __onWindowDestroy(std::shared_ptr window); + + void __onEventIdleEnterer(void *data); + + std::shared_ptr __policyArea; + std::shared_ptr __zone; + std::list> __windowList; + + DSEventLoop *__eventLoop; + bool __windowUpdated; +}; + +} + +#endif \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index 62c7b30..9facc3c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -78,6 +78,8 @@ libds_srcs = [ 'DSTextInput/DSTextInput.cpp', 'DSUtil/DSUtilSocket.h', 'DSUtil/DSUtilSocket.cpp', + 'DSTraceInfo/DSTraceInfo.h', + 'DSTraceInfo/DSTraceInfo.cpp', ] libds_wayland_srcs = [ @@ -255,6 +257,7 @@ libds_include_dirs = include_directories( './DSTextInput', './DSTizenAppinfo', './DSUtil', + './DSTraceInfo', ) libds_lib = shared_library( -- 2.7.4 From 53b4e1a5841269d1ad647689e1d2660c4150cc1b Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 28 Aug 2020 16:50:55 +0900 Subject: [PATCH 07/16] DSTextInput: Add a TextInput API to get current TextInput window Change-Id: If73ce8395a909588e1fbd4df39303fceb21b582a --- src/DSTextInput/DSTextInput.cpp | 5 ++++ src/DSTextInput/DSTextInputPrivate.h | 1 + src/DSWaylandServer/DSWaylandInputPanel.cpp | 29 ++++++++++++++++++++-- src/DSWaylandServer/DSWaylandInputPanel.h | 1 + .../DSWaylandInputPanelSurfacePrivate.h | 1 + src/DSWaylandServer/DSWaylandTextInput.cpp | 15 ++++++++++- src/DSWaylandServer/DSWaylandTextInput.h | 2 ++ src/DSWaylandServer/DSWaylandTextInputManager.h | 2 ++ src/DSWaylandServer/DSWaylandTextInputPrivate.h | 2 +- tests/DSWaylandInputPanel-test.cpp | 12 +++++++++ tests/DSWaylandTextInput-test.cpp | 14 +++++++++++ tests/DSWaylandTextInputManager-test.cpp | 12 +++++++++ 12 files changed, 92 insertions(+), 4 deletions(-) diff --git a/src/DSTextInput/DSTextInput.cpp b/src/DSTextInput/DSTextInput.cpp index 83e4eb7..9f61c9a 100644 --- a/src/DSTextInput/DSTextInput.cpp +++ b/src/DSTextInput/DSTextInput.cpp @@ -174,6 +174,11 @@ void DSTextInputPrivate::setGeometryUpdated(bool updated) __wlTextInputManager->setGeometryUpdated(updated); } +DSWaylandSurface *DSTextInputPrivate::getTextInputSurface() +{ + return __wlTextInputManager->getTextInputSurface(); +} + void DSTextInputPrivate::contextCommitString(unsigned int serial, std::string text) { diff --git a/src/DSTextInput/DSTextInputPrivate.h b/src/DSTextInput/DSTextInputPrivate.h index ae1199a..d99726a 100644 --- a/src/DSTextInput/DSTextInputPrivate.h +++ b/src/DSTextInput/DSTextInputPrivate.h @@ -83,6 +83,7 @@ public: void predictionHintData(std::string key, std::string value); void updateTextInputPanelState(bool state); void setGeometryUpdated(bool updated); + DSWaylandSurface *getTextInputSurface(); /* DSWaylandInputMethodContext request */ void contextCommitString(unsigned int serial, std::string text); diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index 51ef817..77c65a0 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -256,6 +256,13 @@ void DSWaylandInputPanel::updateTextInputPanelState(bool state) __dsTextInputPrivate->updateTextInputPanelState(state); } +DSWaylandSurface *DSWaylandInputPanel::getTextInputSurface() +{ + if (!__dsTextInputPrivate) return nullptr; + + return __dsTextInputPrivate->getTextInputSurface(); +} + void DSWaylandInputPanel::__onEventIdleEnterer(void *data) { } @@ -274,8 +281,7 @@ DSWaylandInputPanelSurfacePrivate::~DSWaylandInputPanelSurfacePrivate() void DSWaylandInputPanelSurfacePrivate::createGlobal(void *client, void *inputPanelResource, unsigned int id, void *surface) { Resource *resource = add((struct ::wl_client *)client, id, 1); - DSWaylandInputPanelSurfaceData *data = new DSWaylandInputPanelSurfaceData(resource, inputPanelResource, surface); - __dataMap.insert(std::pair(resource, data)); + __appendSurface(resource, inputPanelResource, surface); } void DSWaylandInputPanelSurfacePrivate::clearGlobals(void *inputPanelResource) @@ -571,6 +577,25 @@ void DSWaylandInputPanelSurfacePrivate::__updateSurfaceVisibility(DSWaylandInput } } +void DSWaylandInputPanelSurfacePrivate::__appendSurface(Resource *resource, void *inputPanelResource, void *surface) +{ + DS_GET_PUB(DSWaylandInputPanelSurface); + DSWaylandInputPanelSurfaceData *data = new DSWaylandInputPanelSurfaceData(resource, inputPanelResource, surface); + __dataMap.insert(std::pair(resource, data)); + + DSWaylandSurface *textInputSurface = pub->__inputPanel->getTextInputSurface(); + + if (textInputSurface) + { + //TODO: transparent set + } + + if (pub->__inputPanel->getRerunPanelShow()) + { + pub->__inputPanel->changeVisibility(true); + } +} + DSWaylandInputPanelSurface::DSWaylandInputPanelSurface(DSWaylandCompositor *compositor, DSWaylandInputPanel *inputPanel) : DSObject(), _d_ptr(std::make_unique(this, compositor)), diff --git a/src/DSWaylandServer/DSWaylandInputPanel.h b/src/DSWaylandServer/DSWaylandInputPanel.h index 4217502..f456580 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.h +++ b/src/DSWaylandServer/DSWaylandInputPanel.h @@ -63,6 +63,7 @@ public: DSWaylandInputPanelFloating *getFloatingData(); stGeometry getSurfaceGeometry(DSWaylandSurface *wlSurface); void updateTextInputPanelState(bool state); + DSWaylandSurface *getTextInputSurface(); private: DSWaylandCompositor *__compositor; diff --git a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h b/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h index 6644229..4896e3c 100644 --- a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h +++ b/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h @@ -68,6 +68,7 @@ private: std::multimap __dataMap; void __updateSurfaceVisibility(DSWaylandInputPanelSurfaceData *surfaceData); + void __appendSurface(Resource *resource, void *inputPanelResource, void *surface); }; } diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index e062cb0..743d57c 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -25,6 +25,7 @@ #include "DSWaylandTextInputManagerPrivate.h" #include "DSWaylandTextInput.h" #include "DSWaylandTextInputPrivate.h" +#include "DSWaylandSurface.h" namespace display_server { @@ -203,6 +204,11 @@ void DSWaylandTextInputManager::setGeometryUpdated(bool updated) __textInput->setGeometryUpdated(updated); } +DSWaylandSurface* DSWaylandTextInputManager::getTextInputSurface() +{ + return __textInput->getClientSurface(); +} + DSWaylandTextInputPrivate::DSWaylandTextInputPrivate(DSWaylandTextInput *p_ptr, DSWaylandCompositor *compositor) : DSObjectPrivate(p_ptr), @@ -297,7 +303,7 @@ void DSWaylandTextInputPrivate::text_input_activate(Resource *resource, struct : pub->__dsTextInputPrivate->activateTextInput(pub, id); __activatedResource = resource; - __clientSurface = surface; + __clientSurface = DSWaylandSurface::fromWlResource(surface); } void DSWaylandTextInputPrivate::text_input_deactivate(Resource *resource, struct ::wl_resource *seat) @@ -1107,4 +1113,11 @@ void DSWaylandTextInput::setGeometryUpdated(bool updated) __geometryUpdated = updated; } +DSWaylandSurface* DSWaylandTextInput::getClientSurface() +{ + DS_GET_PRIV(DSWaylandTextInput); + + return priv->__clientSurface; +} + } diff --git a/src/DSWaylandServer/DSWaylandTextInput.h b/src/DSWaylandServer/DSWaylandTextInput.h index 7f56414..c6b738b 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.h +++ b/src/DSWaylandServer/DSWaylandTextInput.h @@ -33,6 +33,7 @@ namespace display_server class DSWaylandTextInputPrivate; class DSTextInputPrivate; +class DSWaylandSurface; class DS_DECL_EXPORT DSWaylandTextInput : public DSObject { @@ -69,6 +70,7 @@ public: void updatePanelState(bool state); void setGeometryUpdated(bool updated); + DSWaylandSurface* getClientSurface(); protected: diff --git a/src/DSWaylandServer/DSWaylandTextInputManager.h b/src/DSWaylandServer/DSWaylandTextInputManager.h index 8523e10..c19519f 100644 --- a/src/DSWaylandServer/DSWaylandTextInputManager.h +++ b/src/DSWaylandServer/DSWaylandTextInputManager.h @@ -34,6 +34,7 @@ namespace display_server class DSWaylandTextInputManagerPrivate; class DSWaylandTextInput; +class DSWaylansSurface; class DS_DECL_EXPORT DSWaylandTextInputManager : public DSObject { @@ -71,6 +72,7 @@ public: void updateTextInputPanelState(bool state); void setGeometryUpdated(bool updated); + DSWaylandSurface* getTextInputSurface(); protected: diff --git a/src/DSWaylandServer/DSWaylandTextInputPrivate.h b/src/DSWaylandServer/DSWaylandTextInputPrivate.h index bf9ef9d..55fb499 100644 --- a/src/DSWaylandServer/DSWaylandTextInputPrivate.h +++ b/src/DSWaylandServer/DSWaylandTextInputPrivate.h @@ -103,7 +103,7 @@ private: std::multimap __resourceIdMap; struct ::wl_client *__showClient; Resource *__activatedResource; - struct ::wl_resource *__clientSurface; + DSWaylandSurface *__clientSurface; }; } diff --git a/tests/DSWaylandInputPanel-test.cpp b/tests/DSWaylandInputPanel-test.cpp index 7e9b421..04d72a2 100644 --- a/tests/DSWaylandInputPanel-test.cpp +++ b/tests/DSWaylandInputPanel-test.cpp @@ -204,3 +204,15 @@ TEST_F(DSWaylandInputPanelTest, UpdateTextInputPanelState) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandInputPanelTest, GetTextInputSurface) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + EXPECT_TRUE(inputPanel != nullptr); + + (void)inputPanel->getTextInputSurface(); + + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + diff --git a/tests/DSWaylandTextInput-test.cpp b/tests/DSWaylandTextInput-test.cpp index 0befd84..5a3e18e 100644 --- a/tests/DSWaylandTextInput-test.cpp +++ b/tests/DSWaylandTextInput-test.cpp @@ -389,3 +389,17 @@ TEST_F(DSWaylandTextInputTest, SetGeometryUpdated) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandTextInputTest, GetClientSurface) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + (void)textInput->getClientSurface(); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + diff --git a/tests/DSWaylandTextInputManager-test.cpp b/tests/DSWaylandTextInputManager-test.cpp index 4f74e7f..abca02b 100644 --- a/tests/DSWaylandTextInputManager-test.cpp +++ b/tests/DSWaylandTextInputManager-test.cpp @@ -338,3 +338,15 @@ TEST_F(DSWaylandTextInputManagerTest, SetGeometryUpdated) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandTextInputManagerTest, GetTextInputSurface) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + (void)textInputManager->getTextInputSurface(); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + -- 2.7.4 From 825c66e075bbcf2029ee396c1191a1d10ce03ac0 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 Aug 2020 16:43:33 +0900 Subject: [PATCH 08/16] DsRenderView: add raiseToTop, lowerToBottom and setPosition methods Change-Id: I6b2c11f9c1b3f31de6d531cac2389a1f0e7aa3c5 --- src/DSRender/DSRenderView.h | 3 +++ src/DSRender/DSRenderViewDaliImpl.cpp | 30 ++++++++++++++++++++++++++++++ src/DSRender/DSRenderViewDaliImpl.h | 3 +++ src/DSRender/DSRenderViewEcoreEvasImpl.cpp | 15 +++++++++++++++ src/DSRender/DSRenderViewEcoreEvasImpl.h | 3 +++ 5 files changed, 54 insertions(+) diff --git a/src/DSRender/DSRenderView.h b/src/DSRender/DSRenderView.h index e5c85b4..e67a05a 100644 --- a/src/DSRender/DSRenderView.h +++ b/src/DSRender/DSRenderView.h @@ -40,6 +40,9 @@ public: virtual bool setBuffer(std::shared_ptr buffer) = 0; virtual std::shared_ptr getWindow() = 0; + virtual void raiseToTop() = 0; + virtual void lowerToBottom() = 0; + virtual void setPosition(int x, int y) = 0; virtual void registerCallbackUpdated(DSObject *slot, std::function func) = 0; private: diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index a72214f..18ec7e7 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -162,6 +162,36 @@ void DSRenderViewDaliImpl::registerCallbackUpdated(DSObject *slot, std::function __updatedSignal.connect(slot, func); } +void DSRenderViewDaliImpl::raiseToTop() +{ + DSLOG_INF("DSRenderViewDaliImpl", ""); + + __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); + __textureViewActor.RaiseToTop(); + + __updatedSignal.emit(nullptr); +} + +void DSRenderViewDaliImpl::lowerToBottom() +{ + DSLOG_INF("DSRenderViewDaliImpl", ""); + + __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); + __textureViewActor.LowerToBottom(); + + __updatedSignal.emit(nullptr); +} + +void DSRenderViewDaliImpl::setPosition(int x, int y) +{ + DSLOG_INF("DSRenderViewDaliImpl", ""); + + __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); + __textureViewActor.SetProperty(Actor::Property::POSITION, Vector3(x, y, 0.0f)); + + __updatedSignal.emit(nullptr); +} + void DSRenderViewDaliImpl::__onWindowBufferChanged(std::shared_ptr buffer) { if (buffer) { diff --git a/src/DSRender/DSRenderViewDaliImpl.h b/src/DSRender/DSRenderViewDaliImpl.h index 8ffd858..6a0c252 100644 --- a/src/DSRender/DSRenderViewDaliImpl.h +++ b/src/DSRender/DSRenderViewDaliImpl.h @@ -42,6 +42,9 @@ public: bool setBuffer(std::shared_ptr buffer) override; std::shared_ptr getWindow() override; + void raiseToTop() override; + void lowerToBottom() override; + void setPosition(int x, int y) override; void registerCallbackUpdated(DSObject *slot, std::function func) override; diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp index 9fe237d..d97e3e7 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp @@ -78,6 +78,21 @@ std::shared_ptr DSRenderViewEcoreEvasImpl::getWindow() return __window; } +void DSRenderViewEcoreEvasImpl::raiseToTop() +{ + //TODO: +} + +void DSRenderViewEcoreEvasImpl::lowerToBottom() +{ + //TODO: +} + +void DSRenderViewEcoreEvasImpl::setPosition(int x, int y) +{ + //TODO: +} + void DSRenderViewEcoreEvasImpl::registerCallbackUpdated(DSObject *slot, std::function func) { // No updated signal at ecore evas implementation yet. diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.h b/src/DSRender/DSRenderViewEcoreEvasImpl.h index 0572a19..18d1eff 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.h +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.h @@ -39,6 +39,9 @@ public: bool setBuffer(std::shared_ptr buffer) override; std::shared_ptr getWindow() override; + void raiseToTop() override; + void lowerToBottom() override; + void setPosition(int x, int y) override; void registerCallbackUpdated(DSObject *slot, std::function func) override; -- 2.7.4 From adc598383bba9e6dda8245ee45f7398a6e64532d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 Aug 2020 16:59:13 +0900 Subject: [PATCH 09/16] DSDisplayDeviceHWC: make hwc window without DSWindow parameter Change-Id: I090b3ef69362d875c4bb84c1476da8e04fb2b381 --- src/DSDisplayArea/DSDisplayArea.cpp | 2 +- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp | 4 ++-- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h | 2 +- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp | 6 +++--- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h | 2 +- src/DSDisplayDevice/IDSDisplayDeviceHWC.h | 2 +- tests/DSDisplayDeviceTDMImpl-test.cpp | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 0fee756..0630043 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -139,7 +139,7 @@ void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) { // TODO: think about using unordered_map __renderViewList.push_back(__renderEngine->makeRenderView(window)); - __displayDeviceHWCWindowList.push_back(__displayDeviceHWC->makeHWCWindow(window)); + __displayDeviceHWCWindowList.push_back(__displayDeviceHWC->makeHWCWindow()); } void DSDisplayAreaPrivate::__onWindowDestroy(std::shared_ptr window) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp index 9a3b3a0..b6be04f 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp @@ -77,7 +77,7 @@ bool DSDisplayDeviceHWCTDMImpl::setTargetBuffer(std::shared_ptr buffe return true; } -std::shared_ptr DSDisplayDeviceHWCTDMImpl::makeHWCWindow(std::shared_ptr window) +std::shared_ptr DSDisplayDeviceHWCTDMImpl::makeHWCWindow() { std::shared_ptr deviceHWCWindow; tdm_error terror; @@ -89,7 +89,7 @@ std::shared_ptr DSDisplayDeviceHWCTDMImpl::makeHWCWin return nullptr; } - deviceHWCWindow = std::make_shared(window, twindow); + deviceHWCWindow = std::make_shared(twindow); if (!deviceHWCWindow) { DSLOG_ERR("HWCTDM", "new DSDisplayDeviceHWCWindowTDMImpl fails."); return nullptr; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h index abdfc70..d33efaa 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h @@ -39,7 +39,7 @@ public: std::shared_ptr getTargetBufferQueue() override; bool setTargetBuffer(std::shared_ptr buffer) override; - std::shared_ptr makeHWCWindow(std::shared_ptr window) override; + std::shared_ptr makeHWCWindow() override; bool addVisibleHWCWindow(std::shared_ptr deviceHWCWindow) override; bool removeVisibleHWCWindow(std::shared_ptr deviceHWCWindow) override; void clearVisibleHWCWindows() override; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp index 051cbd1..2b19be8 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp @@ -26,10 +26,10 @@ namespace display_server { -DSDisplayDeviceHWCWindowTDMImpl::DSDisplayDeviceHWCWindowTDMImpl(std::shared_ptr window, tdm_hwc_window *twindow) - : __window(window), - __twindow(twindow) +DSDisplayDeviceHWCWindowTDMImpl::DSDisplayDeviceHWCWindowTDMImpl(tdm_hwc_window *twindow) + : __twindow(twindow) {} + DSDisplayDeviceHWCWindowTDMImpl::~DSDisplayDeviceHWCWindowTDMImpl() { tdm_hwc_window_destroy(__twindow); diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h index 1a6fc6a..5550190 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h @@ -34,7 +34,7 @@ namespace display_server class DSDisplayDeviceHWCWindowTDMImpl : public IDSDisplayDeviceHWCWindow { public: - DSDisplayDeviceHWCWindowTDMImpl(std::shared_ptr window, tdm_hwc_window *twindow); + DSDisplayDeviceHWCWindowTDMImpl(tdm_hwc_window *twindow); ~DSDisplayDeviceHWCWindowTDMImpl(); tdm_hwc_window *getNativeHWCWindow(); diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWC.h b/src/DSDisplayDevice/IDSDisplayDeviceHWC.h index ca02b5f..050316b 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWC.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceHWC.h @@ -39,7 +39,7 @@ public: virtual std::shared_ptr getTargetBufferQueue() = 0; virtual bool setTargetBuffer(std::shared_ptr buffer) = 0; - virtual std::shared_ptr makeHWCWindow(std::shared_ptr window) = 0; + virtual std::shared_ptr makeHWCWindow() = 0; virtual bool addVisibleHWCWindow(std::shared_ptr deviceHWCWindow) = 0; virtual bool removeVisibleHWCWindow(std::shared_ptr deviceHWCWindow) = 0; virtual void clearVisibleHWCWindows() = 0; diff --git a/tests/DSDisplayDeviceTDMImpl-test.cpp b/tests/DSDisplayDeviceTDMImpl-test.cpp index 7f9f47c..b23e6bd 100644 --- a/tests/DSDisplayDeviceTDMImpl-test.cpp +++ b/tests/DSDisplayDeviceTDMImpl-test.cpp @@ -255,7 +255,7 @@ TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_makeHWCWindow) deviceHWC = output->getHWC(); EXPECT_TRUE(deviceHWC != nullptr); - deviceHWCWindow = deviceHWC->makeHWCWindow(std::make_shared()); + deviceHWCWindow = deviceHWC->makeHWCWindow(); EXPECT_TRUE(deviceHWC != nullptr); } } @@ -289,7 +289,7 @@ TEST_F(DSDisplayDeviceTDMImplTest, DeviceHWC_commit) auto bufferQueue = deviceHWC->getTargetBufferQueue(); EXPECT_TRUE(deviceHWC != nullptr); - deviceHWCWindow = deviceHWC->makeHWCWindow(std::make_shared()); + deviceHWCWindow = deviceHWC->makeHWCWindow(); EXPECT_TRUE(deviceHWC != nullptr); EXPECT_TRUE(deviceHWC->addVisibleHWCWindow(deviceHWCWindow)); -- 2.7.4 From ab83f261f7a88d6658136c6fcb648528e2292095 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 Aug 2020 17:05:06 +0900 Subject: [PATCH 10/16] DSDisplayDeviceHWCWindow: remove getWindow method Change-Id: Ia0428733ab9d6fc6c9af21c47415ae322b697019 --- src/DSDisplayArea/DSDisplayArea.cpp | 9 --------- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp | 5 ----- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h | 2 -- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 5 ----- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h | 2 -- src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h | 3 --- 6 files changed, 26 deletions(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 0630043..2862419 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -153,15 +153,6 @@ void DSDisplayAreaPrivate::__onWindowDestroy(std::shared_ptr window) break; } } - - for (auto displayDeviceHWCWindow : __displayDeviceHWCWindowList) { - auto tmpHWCWindow = displayDeviceHWCWindow->getWindow(); - if (tmpHWCWindow.get() == window.get()) { - __displayDeviceHWCWindowList.remove(displayDeviceHWCWindow); - displayDeviceHWCWindow.reset(); - break; - } - } } void DSDisplayAreaPrivate::__onEventIdleEnterer(void *data) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp index 2b19be8..121ca63 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp @@ -55,9 +55,4 @@ void DSDisplayDeviceHWCWindowTDMImpl::onPresentFrameDone() /* TODO:: */ } -std::shared_ptr DSDisplayDeviceHWCWindowTDMImpl::getWindow() -{ - return __window; -} - } diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h index 5550190..2cc68c3 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h @@ -41,10 +41,8 @@ public: bool updateFrame() override; void presentFrame() override; void onPresentFrameDone() override; - std::shared_ptr getWindow() override; private: - std::shared_ptr __window; tdm_hwc_window *__twindow; }; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index abc3893..37269ec 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -91,11 +91,6 @@ void DSDisplayDeviceHWCWindowTDMTargetImpl::onPresentFrameDone() __presentedBuffer = std::move(__presentBuffer); } -std::shared_ptr DSDisplayDeviceHWCWindowTDMTargetImpl::getWindow() -{ - return nullptr; -} - Eina_Bool DSDisplayDeviceHWCWindowTDMTargetImpl::__onFdHandler(void *data, Ecore_Fd_Handler *hdlr) { int len; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h index 756b920..4f644f6 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h @@ -27,7 +27,6 @@ #include "IDSDisplayDeviceHWCWindow.h" #include "IDSDisplayDeviceHWC.h" #include "IDSBufferQueue.h" -#include "DSWindow.h" #include "IDSBuffer.h" #include #include @@ -43,7 +42,6 @@ public: bool updateFrame() override; void presentFrame() override; void onPresentFrameDone() override; - std::shared_ptr getWindow() override; private: static Eina_Bool __onFdHandler(void *data, Ecore_Fd_Handler *hdlr); diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h index e8eb85f..b3d5e21 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h @@ -24,8 +24,6 @@ #ifndef _I_DS_DISPLAY_DEVICE_HWC_WINDOW_H_ #define _I_DS_DISPLAY_DEVICE_HWC_WINDOW_H_ -#include "DSWindow.h" - namespace display_server { class IDSDisplayDeviceHWCWindow @@ -35,7 +33,6 @@ public: virtual bool updateFrame() = 0; virtual void presentFrame() = 0; virtual void onPresentFrameDone() = 0; - virtual std::shared_ptr getWindow() = 0; }; } -- 2.7.4 From 8422ea82e36bb60cd0fb9be7092d4e2e33099b52 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 Aug 2020 17:06:23 +0900 Subject: [PATCH 11/16] DSDisplayArea: remove registerCallbackWindowDestroyed. Change-Id: Ie51ac8c28ff87dbbf77e782bf483bc82cfc9e583 --- src/DSDisplayArea/DSDisplayArea.cpp | 14 -------------- src/DSDisplayArea/DSDisplayAreaPrivate.h | 1 - 2 files changed, 15 deletions(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 2862419..7ad9f92 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -130,7 +130,6 @@ bool DSDisplayAreaPrivate::addZone(std::shared_ptr zone) { __zone = zone; __zone->registerCallbackWindowCreated(this, std::bind(&DSDisplayAreaPrivate::__onWindowCreated, this, std::placeholders::_1)); - __zone->registerCallbackWindowDestroy(this, std::bind(&DSDisplayAreaPrivate::__onWindowDestroy, this, std::placeholders::_1)); return true; } @@ -142,19 +141,6 @@ void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) __displayDeviceHWCWindowList.push_back(__displayDeviceHWC->makeHWCWindow()); } -void DSDisplayAreaPrivate::__onWindowDestroy(std::shared_ptr window) -{ - // TODO: think about using unordered_map - for (auto renderView : __renderViewList) { - auto tmpWindow = renderView->getWindow(); - if (tmpWindow.get() == window.get()) { - __renderViewList.remove(renderView); - renderView.reset(); - break; - } - } -} - void DSDisplayAreaPrivate::__onEventIdleEnterer(void *data) { //DSLOG_INF("DSDisplayAreaPrivate", "__onEventIdleEnterer"); diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index cb16595..1b92f99 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -54,7 +54,6 @@ public: private: void __onWindowCreated(std::shared_ptr window); - void __onWindowDestroy(std::shared_ptr window); void __onEventIdleEnterer(void *data); std::shared_ptr __output; -- 2.7.4 From 204ae289b70d72cb75a4234f3369c13f5618f2de Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 Aug 2020 17:07:50 +0900 Subject: [PATCH 12/16] DSDisplayArea: remove renderView list and HWC Window list Change-Id: I5743572884bd8eed6c2f303863af3aa0d67219e5 --- src/DSDisplayArea/DSDisplayArea.cpp | 8 +++++--- src/DSDisplayArea/DSDisplayAreaPrivate.h | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 7ad9f92..9bef0d3 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -136,9 +136,11 @@ bool DSDisplayAreaPrivate::addZone(std::shared_ptr zone) void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) { - // TODO: think about using unordered_map - __renderViewList.push_back(__renderEngine->makeRenderView(window)); - __displayDeviceHWCWindowList.push_back(__displayDeviceHWC->makeHWCWindow()); + // make a render view and set to the window. + auto renderView = __renderEngine->makeRenderView(window); + + // make a hwc window and set to the window. + auto displayDeviceHWCWindow = __displayDeviceHWC->makeHWCWindow(); } void DSDisplayAreaPrivate::__onEventIdleEnterer(void *data) diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index 1b92f99..693458b 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -64,8 +64,6 @@ private: DSEventLoop *__eventLoop; int __x, __y; int __width, __height; - std::list> __renderViewList; - std::list> __displayDeviceHWCWindowList; }; } -- 2.7.4 From fbd5b30b17440ad510b7436a5d8b956c62b77e3e Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 Aug 2020 17:18:02 +0900 Subject: [PATCH 13/16] DSRenderView: remove a dependency on DSWindow. Change-Id: I1ceb08d3bb46d10db5bedaf0c5bcdaa3e2fc8f11 --- src/DSDisplayArea/DSDisplayArea.cpp | 2 +- src/DSRender/DSRenderEngineDaliImpl.cpp | 4 +- src/DSRender/DSRenderEngineDaliImpl.h | 2 +- src/DSRender/DSRenderEngineEcoreEvasImpl.cpp | 4 +- src/DSRender/DSRenderEngineEcoreEvasImpl.h | 2 +- src/DSRender/DSRenderView.h | 2 - src/DSRender/DSRenderViewDaliImpl.cpp | 71 +++------------------------- src/DSRender/DSRenderViewDaliImpl.h | 4 +- src/DSRender/DSRenderViewEcoreEvasImpl.cpp | 26 ++-------- src/DSRender/DSRenderViewEcoreEvasImpl.h | 6 +-- src/DSRender/IDSRenderEngine.h | 3 +- tests/DSRenderEngineDaliImpl-test.cpp | 36 +++++--------- tests/DSRenderEngineEcoreEvasImpl-test.cpp | 12 ++--- 13 files changed, 35 insertions(+), 139 deletions(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 9bef0d3..33e6fe5 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -137,7 +137,7 @@ bool DSDisplayAreaPrivate::addZone(std::shared_ptr zone) void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) { // make a render view and set to the window. - auto renderView = __renderEngine->makeRenderView(window); + auto renderView = __renderEngine->makeRenderView(); // make a hwc window and set to the window. auto displayDeviceHWCWindow = __displayDeviceHWC->makeHWCWindow(); diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index 5314d7f..bf2ab39 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -56,9 +56,9 @@ void DSRenderEngineDaliImpl::onInitialize() window.SetBackgroundColor(Color::TRANSPARENT); } -std::shared_ptr DSRenderEngineDaliImpl::makeRenderView(std::shared_ptr window) +std::shared_ptr DSRenderEngineDaliImpl::makeRenderView() { - std::shared_ptr renderView = std::make_shared(window, __offscreenApplication.GetWindow()); + std::shared_ptr renderView = std::make_shared(__offscreenApplication.GetWindow()); // callbacks renderView->registerCallbackUpdated(this, std::bind(&DSRenderEngineDaliImpl::__onRenderViewUpdated, this, std::placeholders::_1)); diff --git a/src/DSRender/DSRenderEngineDaliImpl.h b/src/DSRender/DSRenderEngineDaliImpl.h index 977c580..d35b209 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.h +++ b/src/DSRender/DSRenderEngineDaliImpl.h @@ -41,7 +41,7 @@ public: DSRenderEngineDaliImpl(std::shared_ptr bufferQueue); ~DSRenderEngineDaliImpl(); - std::shared_ptr makeRenderView(std::shared_ptr window) override; + std::shared_ptr makeRenderView() override; bool renderFrame() override; void onInitialize(); diff --git a/src/DSRender/DSRenderEngineEcoreEvasImpl.cpp b/src/DSRender/DSRenderEngineEcoreEvasImpl.cpp index d2854fd..ae03499 100644 --- a/src/DSRender/DSRenderEngineEcoreEvasImpl.cpp +++ b/src/DSRender/DSRenderEngineEcoreEvasImpl.cpp @@ -67,9 +67,9 @@ DSRenderEngineEcoreEvasImpl::~DSRenderEngineEcoreEvasImpl() evas_shutdown(); } -std::shared_ptr DSRenderEngineEcoreEvasImpl::makeRenderView(std::shared_ptr window) +std::shared_ptr DSRenderEngineEcoreEvasImpl::makeRenderView() { - std::shared_ptr renderView = std::make_shared(__ee, window); + std::shared_ptr renderView = std::make_shared(__ee); return renderView; } diff --git a/src/DSRender/DSRenderEngineEcoreEvasImpl.h b/src/DSRender/DSRenderEngineEcoreEvasImpl.h index cf23fba..23b2837 100644 --- a/src/DSRender/DSRenderEngineEcoreEvasImpl.h +++ b/src/DSRender/DSRenderEngineEcoreEvasImpl.h @@ -37,7 +37,7 @@ public: DSRenderEngineEcoreEvasImpl(std::shared_ptr bufferQueue); ~DSRenderEngineEcoreEvasImpl(); - std::shared_ptr makeRenderView(std::shared_ptr window) override; + std::shared_ptr makeRenderView() override; bool renderFrame() override; private: diff --git a/src/DSRender/DSRenderView.h b/src/DSRender/DSRenderView.h index e67a05a..0696c16 100644 --- a/src/DSRender/DSRenderView.h +++ b/src/DSRender/DSRenderView.h @@ -25,7 +25,6 @@ #define __DS_RENDER_VIEW_H__ #include "IDSBuffer.h" -#include "DSWindow.h" #include "DSObject.h" #include "DSSignal.h" @@ -39,7 +38,6 @@ public: virtual ~DSRenderView(); virtual bool setBuffer(std::shared_ptr buffer) = 0; - virtual std::shared_ptr getWindow() = 0; virtual void raiseToTop() = 0; virtual void lowerToBottom() = 0; virtual void setPosition(int x, int y) = 0; diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index 18ec7e7..f39a017 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -82,9 +82,8 @@ Geometry DSRenderViewDaliImpl::CreateTexturedQuad() return geometry; } -DSRenderViewDaliImpl::DSRenderViewDaliImpl(std::shared_ptr window, Dali::OffscreenWindow offscreenWindow) - : __window(window), - __offscreenWindow(offscreenWindow) +DSRenderViewDaliImpl::DSRenderViewDaliImpl(Dali::OffscreenWindow offscreenWindow) + : __offscreenWindow(offscreenWindow) { std::string fragmentShader = "#extension GL_OES_EGL_image_external:require\n"; fragmentShader += FRAGMENT_SHADER; @@ -103,18 +102,12 @@ DSRenderViewDaliImpl::DSRenderViewDaliImpl(std::shared_ptr window, Dal offscreenWindow.Add(__textureViewActor); - // callbacks - window->registerCallbackBufferChanged(this, std::bind(&DSRenderViewDaliImpl::__onWindowBufferChanged, this, std::placeholders::_1)); - window->registerCallbackWindowRaiseToTop(this, std::bind(&DSRenderViewDaliImpl::__onWindowRaiseToTopChanged, this, std::placeholders::_1)); - window->registerCallbackWindowLowerToBottom(this, std::bind(&DSRenderViewDaliImpl::__onWindowLowerToBottomChanged, this, std::placeholders::_1)); - window->registerCallbackWindowPositionChanged(this, std::bind(&DSRenderViewDaliImpl::__onWindowPositionChanged, this, std::placeholders::_1)); - - DSLOG_INF("DSRenderViewDaliImpl", "RenderView created. window(%p)", __window.get()); + DSLOG_INF("DSRenderViewDaliImpl", "RenderView(%p) created.", this); } DSRenderViewDaliImpl::~DSRenderViewDaliImpl() { - DSLOG_INF("DSRenderViewDaliImpl", "RenderView destroyed. window(%p)", __window.get()); + DSLOG_INF("DSRenderViewDaliImpl", "RenderView(%p) destroyed", this); __textureViewActor.RemoveRenderer(__renderer); __offscreenWindow.Remove(__textureViewActor); @@ -152,16 +145,6 @@ bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) return true; } -std::shared_ptr DSRenderViewDaliImpl::getWindow() -{ - return __window; -} - -void DSRenderViewDaliImpl::registerCallbackUpdated(DSObject *slot, std::function func) -{ - __updatedSignal.connect(slot, func); -} - void DSRenderViewDaliImpl::raiseToTop() { DSLOG_INF("DSRenderViewDaliImpl", ""); @@ -192,51 +175,9 @@ void DSRenderViewDaliImpl::setPosition(int x, int y) __updatedSignal.emit(nullptr); } -void DSRenderViewDaliImpl::__onWindowBufferChanged(std::shared_ptr buffer) -{ - if (buffer) { - std::shared_ptr bufferSize = buffer->getSize(); - DSLOG_INF("DSRenderViewDaliImpl", "Window Buffer changed. buffer(%p) size(%d, %d)", buffer.get(), bufferSize->w, bufferSize->h); - } else { - DSLOG_INF("DSRenderViewDaliImpl", "Window Buffer changed. buffer(nullptr)"); - } - - if (!setBuffer(buffer)) { - DSLOG_ERR("DSRenderViewDaliImpl", "setBuffer fails."); - return; - } -} - -void DSRenderViewDaliImpl::__onWindowRaiseToTopChanged(void *data) -{ - DSLOG_INF("DSRenderViewDaliImpl", "__onWindowRaiseToTopChanged."); - - __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); - __textureViewActor.RaiseToTop(); - - __updatedSignal.emit(nullptr); -} - -void DSRenderViewDaliImpl::__onWindowLowerToBottomChanged(void *data) -{ - DSLOG_INF("DSRenderViewDaliImpl", "__onWindowLowerToBottomChanged."); - - __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); - __textureViewActor.LowerToBottom(); - - __updatedSignal.emit(nullptr); -} - -void DSRenderViewDaliImpl::__onWindowPositionChanged(void *data) +void DSRenderViewDaliImpl::registerCallbackUpdated(DSObject *slot, std::function func) { - DSLOG_INF("DSRenderViewDaliImpl", "__onWindowPositionChanged."); - - stPosition pos = __window->getPosition(); - - __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); - __textureViewActor.SetProperty(Actor::Property::POSITION, Vector3( pos.x, pos.y, 0.0f )); - - __updatedSignal.emit(nullptr); + __updatedSignal.connect(slot, func); } } // namespace display_server diff --git a/src/DSRender/DSRenderViewDaliImpl.h b/src/DSRender/DSRenderViewDaliImpl.h index 6a0c252..53ea9bf 100644 --- a/src/DSRender/DSRenderViewDaliImpl.h +++ b/src/DSRender/DSRenderViewDaliImpl.h @@ -37,11 +37,10 @@ namespace display_server class DSRenderViewDaliImpl : public DSRenderView, public DSObject { public: - DSRenderViewDaliImpl(std::shared_ptr window, Dali::OffscreenWindow offscreenWindow); + DSRenderViewDaliImpl(Dali::OffscreenWindow offscreenWindow); ~DSRenderViewDaliImpl(); bool setBuffer(std::shared_ptr buffer) override; - std::shared_ptr getWindow() override; void raiseToTop() override; void lowerToBottom() override; void setPosition(int x, int y) override; @@ -56,7 +55,6 @@ private: void __onWindowLowerToBottomChanged(void *data); void __onWindowPositionChanged(void *data); - std::shared_ptr __window; Dali::OffscreenWindow __offscreenWindow; Dali::Renderer __renderer; Dali::Actor __textureViewActor; diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp index d97e3e7..d829ee4 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp @@ -27,15 +27,11 @@ namespace display_server { -DSRenderViewEcoreEvasImpl::DSRenderViewEcoreEvasImpl(Ecore_Evas *ee, std::shared_ptr window) - : __window(window) +DSRenderViewEcoreEvasImpl::DSRenderViewEcoreEvasImpl(Ecore_Evas *ee) { __evasView = evas_object_image_filled_add(ecore_evas_get(ee)); evas_object_image_border_center_fill_set(__evasView, EVAS_BORDER_FILL_SOLID); evas_object_image_colorspace_set(__evasView, EVAS_COLORSPACE_ARGB8888); - - // callbacks - window->registerCallbackBufferChanged(this, std::bind(&DSRenderViewEcoreEvasImpl::__onWindowBufferChanged, this, std::placeholders::_1)); } DSRenderViewEcoreEvasImpl::~DSRenderViewEcoreEvasImpl() @@ -50,32 +46,18 @@ bool DSRenderViewEcoreEvasImpl::setBuffer(std::shared_ptr buffer) ns.type = EVAS_NATIVE_SURFACE_TBM; ns.version = EVAS_NATIVE_SURFACE_VERSION; ns.data.tbm.buffer = buffer->getNativeBuffer(); - evas_object_image_native_surface_set(__evasView, &ns); - return true; -} - -void DSRenderViewEcoreEvasImpl::__onWindowBufferChanged(std::shared_ptr buffer) -{ std::shared_ptr bufferSize = buffer->getSize(); - DSLOG_INF("DSRenderViewEcoreEvasImpl", "Window Buffer changed. buffer(%p) size(%d, %d)", buffer.get(), bufferSize->w, bufferSize->h); - - if (!setBuffer(buffer)) { - DSLOG_ERR("DSRenderViewEcoreEvasImpl", "setBuffer fails."); - return; - } - evas_object_image_size_set(__evasView, bufferSize->w, bufferSize->h); evas_object_image_pixels_dirty_set(__evasView, 1); evas_object_resize(__evasView, bufferSize->w, bufferSize->h); evas_object_show(__evasView); -} -std::shared_ptr DSRenderViewEcoreEvasImpl::getWindow() -{ - return __window; + DSLOG_INF("DSRenderViewEcoreEvasImpl", "Window Buffer changed. buffer(%p) size(%d, %d)", buffer.get(), bufferSize->w, bufferSize->h); + + return true; } void DSRenderViewEcoreEvasImpl::raiseToTop() diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.h b/src/DSRender/DSRenderViewEcoreEvasImpl.h index 18d1eff..717c23a 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.h +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.h @@ -34,11 +34,10 @@ namespace display_server class DSRenderViewEcoreEvasImpl : public DSRenderView, public DSObject { public: - DSRenderViewEcoreEvasImpl(Ecore_Evas *ee, std::shared_ptr window); + DSRenderViewEcoreEvasImpl(Ecore_Evas *ee); ~DSRenderViewEcoreEvasImpl(); bool setBuffer(std::shared_ptr buffer) override; - std::shared_ptr getWindow() override; void raiseToTop() override; void lowerToBottom() override; void setPosition(int x, int y) override; @@ -46,10 +45,7 @@ public: void registerCallbackUpdated(DSObject *slot, std::function func) override; private: - void __onWindowBufferChanged(std::shared_ptr buffer); - Evas_Object *__evasView; - std::shared_ptr __window; DSSignal __updatedSignal; }; diff --git a/src/DSRender/IDSRenderEngine.h b/src/DSRender/IDSRenderEngine.h index 65a5a07..b616da9 100644 --- a/src/DSRender/IDSRenderEngine.h +++ b/src/DSRender/IDSRenderEngine.h @@ -25,7 +25,6 @@ #define __I_DS_RENDER_ENGINE_H_ #include "DSRenderView.h" -#include "DSWindow.h" namespace display_server { @@ -35,7 +34,7 @@ class IDSRenderEngine public: virtual ~IDSRenderEngine() = default; - virtual std::shared_ptr makeRenderView(std::shared_ptr window) = 0; + virtual std::shared_ptr makeRenderView() = 0; virtual bool renderFrame() = 0; }; diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index 227026d..f3e6143 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -119,9 +119,7 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_CreateRenderView) EXPECT_TRUE(bufferQueue != nullptr); auto renderEngine = std::make_unique(bufferQueue); EXPECT_TRUE(renderEngine != nullptr); - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - auto renderView = renderEngine->makeRenderView(window); + auto renderView = renderEngine->makeRenderView(); EXPECT_TRUE(renderView != nullptr); } @@ -131,9 +129,7 @@ TEST_F(DSRenderEngineDaliTest, RenderView_SetBuffer) EXPECT_TRUE(bufferQueue != nullptr); auto renderEngine = std::make_unique(bufferQueue); EXPECT_TRUE(renderEngine != nullptr); - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - auto renderView = renderEngine->makeRenderView(window); + auto renderView = renderEngine->makeRenderView(); EXPECT_TRUE(renderView != nullptr); auto buffer = std::make_shared(100, 100, IDSBuffer::FORMAT_ARGB8888); EXPECT_TRUE(renderView->setBuffer(buffer)); @@ -145,9 +141,7 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderFrame) EXPECT_TRUE(bufferQueue != nullptr); auto renderEngine = std::make_unique(bufferQueue); EXPECT_TRUE(renderEngine != nullptr); - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - auto renderView = renderEngine->makeRenderView(window); + auto renderView = renderEngine->makeRenderView(); EXPECT_TRUE(renderView != nullptr); auto buffer = std::make_shared (100, 100, IDSBuffer::FORMAT_ARGB8888); EXPECT_TRUE(renderView->setBuffer(buffer)); @@ -184,9 +178,7 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) auto renderEngine = std::make_unique(bufferQueue); EXPECT_TRUE(renderEngine != nullptr); - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - auto renderView = renderEngine->makeRenderView(window); + auto renderView = renderEngine->makeRenderView(); EXPECT_TRUE(renderView != nullptr); int imgWidth = 500; @@ -211,7 +203,7 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) } } -TEST_F(DSRenderEngineDaliTest, RenderEngine_ComposeTwoWindow) +TEST_F(DSRenderEngineDaliTest, RenderEngine_ComposeTwoRenderView) { std::unique_ptr displayDevice = std::make_unique(); std::list> outputList = displayDevice->getOutputList(); @@ -245,10 +237,8 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_ComposeTwoWindow) int imgWidth = 500; int imgHeight = 500; - // for 1st window -- begin -- - auto windowA = std::make_shared(); - EXPECT_TRUE(windowA != nullptr); - auto renderViewA = renderEngine->makeRenderView(windowA); + // for 1st renderView -- begin -- + auto renderViewA = renderEngine->makeRenderView(); EXPECT_TRUE(renderViewA != nullptr); // create RED image buffer @@ -260,13 +250,11 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_ComposeTwoWindow) EXPECT_TRUE(renderViewA->setBuffer(imageSourceBufferA)); // -- end -- - // for 2nd window -- begin -- - auto windowB = std::make_shared(); - EXPECT_TRUE(windowB != nullptr); - auto renderViewB = renderEngine->makeRenderView(windowB); + // for 2nd renderView -- begin -- + auto renderViewB = renderEngine->makeRenderView(); EXPECT_TRUE(renderViewB != nullptr); - // The buffer size of the second window is half of the first. + // The buffer size of the second renderView is half of the first. // create BLUE image buffer tbm_surface_h tbmTextureB = DSRenderEngineDaliTest::createTbmTexture( imgWidth/2, imgHeight/2, 0, 0, 255, 255); @@ -279,8 +267,8 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_ComposeTwoWindow) EXPECT_TRUE(renderEngine->renderFrame()); /* - * Since windowA was created and added before windowB, - * windowB should be drawn above and windowA below. + * Since renderViewA was created and added before renderViewB, + * renderViewB should be drawn above and renderViewA below. * * ┌──────┬──────┐ * │ B │ │ diff --git a/tests/DSRenderEngineEcoreEvasImpl-test.cpp b/tests/DSRenderEngineEcoreEvasImpl-test.cpp index 66567a3..ff917fd 100644 --- a/tests/DSRenderEngineEcoreEvasImpl-test.cpp +++ b/tests/DSRenderEngineEcoreEvasImpl-test.cpp @@ -51,9 +51,7 @@ TEST_F(DSRenderEngineEcoreEvasTest, RenderEngine_MakeRenderView) EXPECT_TRUE(bufferQueue != nullptr); auto renderEngine = std::make_unique(bufferQueue); EXPECT_TRUE(renderEngine != nullptr); - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - auto renderView = renderEngine->makeRenderView(window); + auto renderView = renderEngine->makeRenderView(); EXPECT_TRUE(renderView != nullptr); } @@ -63,9 +61,7 @@ TEST_F(DSRenderEngineEcoreEvasTest, RenderView_SetBuffer) EXPECT_TRUE(bufferQueue != nullptr); auto renderEngine = std::make_unique(bufferQueue); EXPECT_TRUE(renderEngine != nullptr); - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - auto renderView = renderEngine->makeRenderView(window); + auto renderView = renderEngine->makeRenderView(); EXPECT_TRUE(renderView != nullptr); auto buffer = std::make_shared (100, 100, IDSBuffer::FORMAT_ARGB8888); EXPECT_TRUE(renderView->setBuffer(buffer)); @@ -77,9 +73,7 @@ TEST_F(DSRenderEngineEcoreEvasTest, RenderEngine_RenderFrame) EXPECT_TRUE(bufferQueue != nullptr); auto renderEngine = std::make_unique(bufferQueue); EXPECT_TRUE(renderEngine != nullptr); - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - auto renderView = renderEngine->makeRenderView(window); + auto renderView = renderEngine->makeRenderView(); EXPECT_TRUE(renderView != nullptr); auto buffer = std::make_shared (100, 100, IDSBuffer::FORMAT_ARGB8888); EXPECT_TRUE(renderView->setBuffer(buffer)); -- 2.7.4 From 0d176ca0586dd4ce03aca38ebbce4e3ca2f9bfb8 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 Aug 2020 17:19:06 +0900 Subject: [PATCH 14/16] DSRenderViewDaliImpl: code clean and put the log Change-Id: I3656ec6a1778d3a35c5d1391c7eb1e74ea0da177 --- src/DSRender/DSRenderViewDaliImpl.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index f39a017..6595726 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -118,14 +118,12 @@ DSRenderViewDaliImpl::~DSRenderViewDaliImpl() bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) { if (buffer) { - DSLOG_INF("DSRenderViewDaliImpl", "buffer set."); + std::shared_ptr bufferSize = buffer->getSize(); __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); + __textureViewActor.SetProperty(Actor::Property::SIZE, Vector2(bufferSize->w, bufferSize->h)); tbm_surface_h nativeBuffer = (tbm_surface_h)buffer->getNativeBuffer(); - std::shared_ptr bufferSize = buffer->getSize(); - - __textureViewActor.SetProperty(Actor::Property::SIZE, Vector2(bufferSize->w, bufferSize->h)); NativeImageSourcePtr nativeImageSource = NativeImageSource::New(Any(nativeBuffer)); @@ -135,9 +133,12 @@ bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) textureSet.SetTexture(0u, nativeTexture); __renderer.SetTextures(textureSet); + + DSLOG_INF("DSRenderViewDaliImpl", "Buffer set. buffer(%p) size(%d, %d)", buffer.get(), bufferSize->w, bufferSize->h); } else { - DSLOG_INF("DSRenderViewDaliImpl", "buffer NULL."); __textureViewActor.SetProperty(Actor::Property::VISIBLE, false); + + DSLOG_INF("DSRenderViewDaliImpl", "buffer set NULL."); } __updatedSignal.emit(nullptr); -- 2.7.4 From 2ec83ab2b7592c3a6adcaba44c99a44b353aa700 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 Aug 2020 17:23:45 +0900 Subject: [PATCH 15/16] DSWindow: remove unused register callback functions Change-Id: Ic5b003d0f937ea8339ce5b47c51764142f47e48f --- src/DSWindow/DSWindow.cpp | 24 ------------------------ src/DSWindow/DSWindow.h | 8 -------- 2 files changed, 32 deletions(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index d9e0599..64bc43c 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -316,14 +316,12 @@ bool DSWindow::lower(void) bool DSWindow::raiseToTop() { - __windowRaiseToTopSignal.emit(nullptr); return true; } bool DSWindow::lowerToBottom() { - __windowLowerToBottomSignal.emit(nullptr); return true; } @@ -355,8 +353,6 @@ void DSWindow::setPosition(int x, int y) priv->__x = x; priv->__y = y; - - __windowPositionChangedSignal.emit(nullptr); } stPosition DSWindow::getPosition(void) @@ -432,29 +428,9 @@ DSWaylandSurface *DSWindow::surface() return priv->__waylandSurface.get(); } -void DSWindow::registerCallbackSizeChanged(DSObject *slot, std::function)> func) -{ - __sizeChangedSignal.connect(slot, func); -} - void DSWindow::registerCallbackBufferChanged(DSObject *slot, std::function)> func) { __bufferChangedSignal.connect(slot, func); } -void DSWindow::registerCallbackWindowRaiseToTop(DSObject *slot, std::function func) -{ - __windowRaiseToTopSignal.connect(slot, func); -} - -void DSWindow::registerCallbackWindowLowerToBottom(DSObject *slot, std::function func) -{ - __windowLowerToBottomSignal.connect(slot, func); -} - -void DSWindow::registerCallbackWindowPositionChanged(DSObject *slot, std::function func) -{ - __windowPositionChangedSignal.connect(slot, func); -} - } // namespace display_server diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index fc4d810..7350e52 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -90,11 +90,7 @@ public: DSWaylandSurface *surface(); - void registerCallbackSizeChanged(DSObject *slot, std::function)> func); void registerCallbackBufferChanged(DSObject *slot, std::function)> func); - void registerCallbackWindowRaiseToTop(DSObject *slot, std::function func); - void registerCallbackWindowLowerToBottom(DSObject *slot, std::function func); - void registerCallbackWindowPositionChanged(DSObject *slot, std::function func); protected: //virtual bool _onFocus(void); @@ -102,11 +98,7 @@ protected: private: // signals - DSSignal> __sizeChangedSignal; DSSignal> __bufferChangedSignal; - DSSignal __windowRaiseToTopSignal; - DSSignal __windowLowerToBottomSignal; - DSSignal __windowPositionChangedSignal; }; } -- 2.7.4 From 283dfa9d99be519f0384dc647df456dacdc00638 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 Aug 2020 17:31:26 +0900 Subject: [PATCH 16/16] DSWindow: add setRenderView method Change-Id: Ia8592a62ff035a20d48abea9e073c0649762c494 --- src/DSWindow/DSWindow.cpp | 15 ++++++++++++++- src/DSWindow/DSWindow.h | 4 +++- src/DSWindow/DSWindowPrivate.h | 6 +++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 64bc43c..7ac5334 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -46,7 +46,8 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __acceptsFocus(true), __allowUserGeometry(false), __title(""), - __vkbd_floating(false) + __vkbd_floating(false), + __renderView(nullptr) { } @@ -171,6 +172,11 @@ bool DSWindowPrivate::getVkbdFloating() return __vkbd_floating; } +void DSWindowPrivate::setRenderView(std::shared_ptr &renderView) +{ + __renderView = renderView; +} + void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo) { DS_GET_PUB(DSWindow); @@ -428,6 +434,13 @@ DSWaylandSurface *DSWindow::surface() return priv->__waylandSurface.get(); } +void DSWindow::setRenderView(std::shared_ptr &renderView) +{ + DS_GET_PRIV(DSWindow); + + priv->setRenderView(renderView); +} + void DSWindow::registerCallbackBufferChanged(DSObject *slot, std::function)> func) { __bufferChangedSignal.connect(slot, func); diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 7350e52..3e807c3 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -29,7 +29,7 @@ #include "DSObject.h" #include "DSSignal.h" #include "IDSBuffer.h" -#include "DSWindowShell.h" +#include "DSRenderView.h" namespace display_server { @@ -90,6 +90,8 @@ public: DSWaylandSurface *surface(); + void setRenderView(std::shared_ptr &renderView); + void registerCallbackBufferChanged(DSObject *slot, std::function)> func); protected: diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index 3e87830..4b03957 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -27,7 +27,7 @@ #include "DSCore.h" #include "DSObjectPrivate.h" #include "DSWaylandSurface.h" -#include "DSWindowShell.h" +#include "DSRenderView.h" namespace display_server { @@ -73,6 +73,8 @@ public: bool setVkbdFloating(bool set); bool getVkbdFloating(); + void setRenderView(std::shared_ptr &renderView); + private: void __onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo); @@ -91,6 +93,8 @@ private: std::string __title; bool __vkbd_floating; + + std::shared_ptr __renderView; }; } -- 2.7.4