Load Scene along with scene updates 32/102932/1
authorVarun <tallytalwar@gmail.com>
Thu, 1 Dec 2016 15:13:28 +0000 (10:13 -0500)
committerVarun <tallytalwar@gmail.com>
Wed, 7 Dec 2016 00:06:17 +0000 (19:06 -0500)
- Updated core tangram with some optimizations and sceneUpdate API changes
Change-Id: I76bc1f40329f01dc5775e6a1f6dcf71287d2eb23

lib/aarch64/libtangram.so
lib/arm/libtangram.so
lib/i586/libtangram.so
lib/x86_64/libtangram.so
src/mapzen/tangram/tangram.h
src/mapzen/tangram_view.cpp

index e2fa14d..24d28d8 100755 (executable)
Binary files a/lib/aarch64/libtangram.so and b/lib/aarch64/libtangram.so differ
index 8fbc932..6b8dd62 100755 (executable)
Binary files a/lib/arm/libtangram.so and b/lib/arm/libtangram.so differ
index d6f70c6..c350909 100755 (executable)
Binary files a/lib/i586/libtangram.so and b/lib/i586/libtangram.so differ
index 98ce6ff..e2bfc42 100755 (executable)
Binary files a/lib/x86_64/libtangram.so and b/lib/x86_64/libtangram.so differ
index abb1e56..d539f02 100644 (file)
@@ -38,15 +38,18 @@ public:
 
     // Load the scene at the given absolute file path asynchronously
     void loadSceneAsync(const char* _scenePath, bool _useScenePosition = false,
-            std::function<void(void*)> _platformCallback = {}, void *_cbData = nullptr);
+                        std::function<void(void*)> _platformCallback = {}, void *_cbData = nullptr,
+                        const std::vector<SceneUpdate>& sceneUpdates = {});
 
     // Load the scene at the given absolute file path synchronously
-    void loadScene(const char* _scenePath, bool _useScenePosition = false);
+    void loadScene(const char* _scenePath, bool _useScenePosition = false,
+                   const std::vector<SceneUpdate>& sceneUpdates = {});
 
     // Request an update to the scene configuration; the path is a series of yaml keys
     // separated by a '.' and the value is a string of yaml to replace the current value
     // at the given path in the scene
     void queueSceneUpdate(const char* _path, const char* _value);
+    void queueSceneUpdate(std::vector<SceneUpdate> sceneUpdates);
 
     // Apply all previously requested scene updates
     void applySceneUpdates();
index 51bd130..5aa690d 100644 (file)
@@ -857,31 +857,18 @@ void TangramView::setMapType(maps_view_h view)
                return;
        }
 
+       std::vector<Tangram::SceneUpdate> sceneUpdates;
        maps_view_type_e map_type;
        maps_view_get_type(view, &map_type);
 
        tangram_view_type newViewType = (tangram_view_type)convert_maps_view_type_to_tangram_view_type(map_type);
 
-       // Loading a new tangram scene resets the map states/caches.
+       // If Scene is being reloaded then reset all the scene preferences to their defaults (building/transit/language/providerKey)
        if (newViewType != m_viewType) {
-               const char* newSceneFile = NORMAL_SCENE_FILE_PATH;
-               switch(newViewType) {
-                       case TANGRAM_VIEW_TERRAIN:
-                               newSceneFile = TERRAIN_SCENE_FILE_PATH;
-                               break;
-                       case TANGRAM_VIEW_NORMAL:
-                               newSceneFile = NORMAL_SCENE_FILE_PATH;
-                               break;
-                       default:
-                               return;
-               }
-               m_viewType = newViewType;
-               m_map->loadSceneAsync(newSceneFile, false, sceneLoadedCb, (void*)view);
+               m_buildingsEnabled = true;
+               m_publicTransitEnabled = false;
+               m_language = "eng";
                m_isProviderKeySet = false;
-
-               // When the scene is changed, update the 'sdk-point-overlay' style to remove it's texture;
-               // this allows us to use this style for markers with custom bitmaps.
-               m_map->queueSceneUpdate("styles.sdk-point-overlay.texture", "null");
        }
 
        bool buildings_enabled = false;
@@ -889,9 +876,9 @@ void TangramView::setMapType(maps_view_h view)
        if (buildings_enabled != m_buildingsEnabled) {
                m_buildingsEnabled = buildings_enabled;
                if (m_buildingsEnabled) {
-                       m_map->queueSceneUpdate("global.building_extrude", "true");
+                       sceneUpdates.push_back( {"global.building_extrude", "true"} );
                } else {
-                       m_map->queueSceneUpdate("global.building_extrude", "false");
+                       sceneUpdates.push_back( {"global.building_extrude", "false"} );
                }
        }
 
@@ -900,30 +887,53 @@ void TangramView::setMapType(maps_view_h view)
        if (public_transit_enabled != m_publicTransitEnabled) {
                m_publicTransitEnabled = public_transit_enabled;
                if (m_publicTransitEnabled) {
-                       m_map->queueSceneUpdate("global.sdk_transit_overlay", "true");
+                       sceneUpdates.push_back( {"global.sdk_transit_overlay", "true"} );
                } else {
-                       m_map->queueSceneUpdate("global.sdk_transit_overlay", "false");
+                       sceneUpdates.push_back( {"global.sdk_transit_overlay", "false"} );
                }
        }
 
        char* language = nullptr;
        maps_view_get_language(view, &language);
-       if (std::string(language) != m_language) {
+       if (m_language != language) {
                m_language = language;
-               m_map->queueSceneUpdate("global.ux_language", m_language.c_str());
+               sceneUpdates.push_back( {"global.ux_language", m_language.c_str()} );
        }
        free(language);
 
        // set provider key for vector tiles
        if (m_providerKey.size() > 0 && !m_isProviderKeySet) {
                MAPS_LOGD("Queueing API key update: %s", m_providerKey.c_str());
-               m_map->queueSceneUpdate("sources.mapzen.url_params.api_key", m_providerKey.c_str());
+               sceneUpdates.push_back( {"sources.mapzen.url_params.api_key", m_providerKey.c_str()} );
                m_isProviderKeySet = true;
        }
 
-       // bool traffic_enabled = false;
-       // maps_view_get_traffic_enabled(view, &traffic_enabled);
-       m_map->applySceneUpdates();
+       // Loading a new tangram scene resets the map states/caches.
+       if (newViewType != m_viewType) {
+               // When the scene is changed, update the 'sdk-point-overlay' style to remove it's texture;
+               // this allows us to use this style for markers with custom bitmaps.
+               sceneUpdates.push_back( {"styles.sdk-point-overlay.texture", "null"} );
+
+               const char* newSceneFile = NORMAL_SCENE_FILE_PATH;
+               switch(newViewType) {
+                       case TANGRAM_VIEW_TERRAIN:
+                               newSceneFile = TERRAIN_SCENE_FILE_PATH;
+                               break;
+                       case TANGRAM_VIEW_NORMAL:
+                               newSceneFile = NORMAL_SCENE_FILE_PATH;
+                               break;
+                       default:
+                               return;
+               }
+               m_viewType = newViewType;
+               m_map->loadSceneAsync(newSceneFile, false, sceneLoadedCb, (void*)view, sceneUpdates);
+       } else {
+               // bool traffic_enabled = false;
+               // maps_view_get_traffic_enabled(view, &traffic_enabled);
+               if (sceneUpdates.empty()) { return; }
+               m_map->queueSceneUpdate(sceneUpdates);
+               m_map->applySceneUpdates();
+       }
 }
 
 void TangramView::sceneLoadedCb(void *data) {