Postpone layout information parsing until the layout needs to be loaded 61/173861/4
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 26 Mar 2018 11:21:35 +0000 (20:21 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 30 Mar 2018 07:41:43 +0000 (07:41 +0000)
Change-Id: If30db0c89eb43c3a00d0d29b72023ecc8fa18894

scl/sclresourcecache.cpp
xmlresource/include/xmlresource.h
xmlresource/layout_parser.cpp

index e94a810..4e178c1 100644 (file)
@@ -113,9 +113,10 @@ CSCLResourceCache::resize_layout_by_resolution(sclbyte layout_index, sclboolean
 {
     sclint innerLoop;
     CSCLUtils *utils = CSCLUtils::get_instance();
+    CSCLContext *context = CSCLContext::get_instance();
 
     SclResParserManager *sclres_manager = SclResParserManager::get_instance();
-    if (utils && sclres_manager) {
+    if (utils && sclres_manager && context) {
         const PSclDefaultConfigure sclres_default_configure = sclres_manager->get_default_configure();
         const PSclLayout sclres_layout = sclres_manager->get_layout_table();
         const PSclLayoutKeyCoordinatePointerTable sclres_layout_key_coordinate_pointer_frame =
@@ -131,7 +132,7 @@ CSCLResourceCache::resize_layout_by_resolution(sclbyte layout_index, sclboolean
             sclint width, height;
             utils->get_screen_resolution(&width, &height);
             /* If the width of screen is bigger than the height, switch portrait mode and landscape mode */
-            if (width > height) {
+            if (width > height && context->get_display_mode() == DISPLAYMODE_PORTRAIT) {
                 invert_display = TRUE;
             }
         }
@@ -944,7 +945,14 @@ CSCLResourceCache::recompute_layout(sclwindow window)
             }
             if (!(sclres_manager->loaded(layout))) {
                 sclres_manager->load(layout);
-                resize_layout_by_resolution(layout, TRUE);
+                resize_layout_by_resolution(layout);
+            }
+            SCLDisplayMode pair_mode = ((display_mode == DISPLAYMODE_PORTRAIT) ? DISPLAYMODE_LANDSCAPE : DISPLAYMODE_PORTRAIT);
+            sclshort pair_layout = sclres_manager->get_layout_id(
+                sclres_input_mode_configure[inputmode].layouts[pair_mode]);
+            if (!(sclres_manager->loaded(pair_layout))) {
+                sclres_manager->load(pair_layout);
+                resize_layout_by_resolution(pair_layout);
             }
             context->set_base_layout(layout);
 
@@ -960,7 +968,7 @@ CSCLResourceCache::recompute_layout(sclwindow window)
 
             if (!(sclres_manager->loaded(layout))) {
                 sclres_manager->load(layout);
-                resize_layout_by_resolution(layout, TRUE);
+                resize_layout_by_resolution(layout);
             }
             context->set_popup_layout(window, layout);
 
index beb5e71..7552999 100644 (file)
@@ -43,7 +43,6 @@ class XMLResource: public sclres::SclRes{
     bool loaded(int layout_id);
 
     public:
-    XMLFiles& get_xml_files();
     PSclInputModeConfigure get_input_mode_configure_table();
     PSclLayout get_layout_table();
     PSclLayoutKeyCoordinatePointerTable get_key_coordinate_pointer_frame();
index 9cb16e3..836e433 100644 (file)
@@ -206,8 +206,6 @@ class LayoutParserImpl {
         void set_default_row_value(Row*, const PSclLayout cur_rec_layout, const int row_y);
         void set_default_key_coordinate_value(const PSclLayoutKeyCoordinate cur_rec_coordinate, const Row*);
 
-        void free_key_coordinate_table(const PSclLayoutKeyCoordinateTable curTable);
-
         void parsing_layout_row_node(const xmlNodePtr cur_node, const PSclLayout cur_rec_layout,
             int *row_y, int *sub_layout_height, SclLayoutKeyCoordinatePointer **cur_key, int layout_no);
         void parsing_key_coordinate_record_node(const xmlNodePtr cur_node, Row* row,
@@ -307,6 +305,10 @@ LayoutParserImpl::load(int layout_id) {
         }
 
         PSclLayout cur_rec_layout = m_layout_table + layout_id;
+
+        cur_rec_layout->name = (sclchar*)m_file_names[layout_id].c_str();
+
+        parsing_layout_node(cur_node, cur_rec_layout, layout_id);
         loading_coordinate_resources(cur_node, cur_rec_layout, layout_id);
 
         xmlFreeDoc(doc);
@@ -323,6 +325,7 @@ void LayoutParserImpl::unload() {
         }
     }
 
+    release_layout_strings();
     release_key_strings();
     release_upper_strings();
 }
@@ -435,39 +438,7 @@ int
 LayoutParserImpl::parsing_layout_table(const vector<string> &vec_file) {
     m_file_names = vec_file;
     m_layout_size = vec_file.size();
-    vector<string>::const_iterator it;
-    for (it = vec_file.begin(); it != vec_file.end(); it++) {
-        xmlDocPtr doc;
-        xmlNodePtr cur_node;
-
-        string input_file = m_dir + "/" + *it;
-        doc = xmlReadFile(input_file.c_str(), NULL, 0);
-        if (doc == NULL) {
-            SCLLOG(SclLog::DEBUG, "Could not load file: %s.", input_file.c_str());
-            return -1;
-        }
-
-        cur_node = xmlDocGetRootElement(doc);
-        if (cur_node == NULL) {
-            SCLLOG(SclLog::DEBUG, "LayoutParserImpl: empty document.\n");
-            xmlFreeDoc(doc);
-            return -1;
-        }
-        if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)LAYOUT_TAG))
-        {
-            SCLLOG(SclLog::DEBUG, "LayoutParserImpl: root name error: %s\n!", (char *)cur_node->name);
-            xmlFreeDoc(doc);
-            return -1;
-        }
-
-        int layout_id = it - vec_file.begin();
-        PSclLayout cur_rec_layout = &(m_layout_table[layout_id]);
-        parsing_layout_node(cur_node, cur_rec_layout, layout_id);
-        cur_rec_layout->name = (sclchar*)strdup(it->c_str());
-        add_layout_string((xmlChar*)cur_rec_layout->name);
 
-        xmlFreeDoc(doc);
-    }
     return 0;
 }