Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tangrams/tangram-es
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fe6ddd230ed5958719ece4f5735ed4cb2a6f130f
Choose a base ref
..
head repository: tangrams/tangram-es
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3b348114a83383e442950cc1f548842761dfd34d
Choose a head ref
Showing with 4,061 additions and 2,800 deletions.
  1. +8 −19 bench/src/benchStyleContext.cpp
  2. +8 −20 bench/src/benchTileBuilder.cpp
  3. +2 −2 core/CMakeLists.txt
  4. +49 −0 core/include/tangram/log.h
  5. +61 −49 core/include/tangram/map.h
  6. +66 −0 core/include/tangram/sceneOptions.h
  7. +1 −1 core/shaders/rasters.glsl
  8. +4 −2 core/src/data/networkDataSource.cpp
  9. +8 −3 core/src/data/rasterSource.cpp
  10. +1 −1 core/src/debug/frameInfo.cpp
  11. +1 −1 core/src/debug/frameInfo.h
  12. +6 −0 core/src/gl/texture.cpp
  13. +2 −2 core/src/gl/texture.h
  14. +20 −22 core/src/labels/{labels.cpp → labelManager.cpp}
  15. +5 −7 core/src/labels/{labels.h → labelManager.h}
  16. +238 −450 core/src/map.cpp
  17. +8 −7 core/src/marker/marker.cpp
  18. +1 −1 core/src/marker/marker.h
  19. +52 −79 core/src/marker/markerManager.cpp
  20. +7 −5 core/src/marker/markerManager.h
  21. +5 −0 core/src/platform.cpp
  22. +82 −30 core/src/scene/importer.cpp
  23. +39 −10 core/src/scene/importer.h
  24. +509 −92 core/src/scene/scene.cpp
  25. +172 −119 core/src/scene/scene.h
  26. +1,183 −1,210 core/src/scene/sceneLoader.cpp
  27. +66 −53 core/src/scene/sceneLoader.h
  28. +2 −2 core/src/selection/selectionQuery.cpp
  29. +3 −2 core/src/selection/selectionQuery.h
  30. +1 −1 core/src/style/debugTextStyle.h
  31. +2 −3 core/src/style/pointStyle.cpp
  32. +6 −2 core/src/style/pointStyle.h
  33. +2 −5 core/src/style/textStyle.cpp
  34. +7 −3 core/src/style/textStyle.h
  35. +2 −0 core/src/style/textStyleBuilder.cpp
  36. +15 −23 core/src/tile/tileBuilder.cpp
  37. +7 −7 core/src/tile/tileBuilder.h
  38. +42 −24 core/src/tile/tileManager.cpp
  39. +10 −3 core/src/tile/tileManager.h
  40. +36 −18 core/src/tile/tileWorker.cpp
  41. +9 −2 core/src/tile/tileWorker.h
  42. +28 −2 core/src/view/view.cpp
  43. +16 −2 core/src/view/view.h
  44. +11 −1 platforms/android/demo/src/main/java/com/mapzen/tangram/android/MainActivity.java
  45. +14 −13 platforms/android/tangram/src/main/cpp/androidPlatform.cpp
  46. +4 −11 platforms/android/tangram/src/main/cpp/jniExports.cpp
  47. +0 −23 platforms/android/tangram/src/main/java/com/mapzen/tangram/MapController.java
  48. +27 −8 platforms/android/tangram/src/main/java/com/mapzen/tangram/MapRenderer.java
  49. +1 −1 platforms/android/tangram/src/main/java/com/mapzen/tangram/viewholder/GLViewHolder.java
  50. +0 −2 platforms/android/tangram/src/main/java/com/mapzen/tangram/viewholder/GLViewHolderFactory.java
  51. +581 −0 platforms/android/tangram/src/main/java/com/mapzen/tangram/viewholder/TextureViewHolder.java
  52. +43 −0 platforms/android/tangram/src/main/java/com/mapzen/tangram/viewholder/TextureViewHolderFactory.java
  53. +48 −19 platforms/common/glfwApp.cpp
  54. +1 −1 platforms/common/glfwApp.h
  55. +305 −124 platforms/common/urlClient.cpp
  56. +29 −19 platforms/common/urlClient.h
  57. +3 −7 platforms/ios/demo/src/MapViewController.m
  58. +0 −12 platforms/ios/framework/src/TGMapView.h
  59. +24 −23 platforms/ios/framework/src/TGMapView.mm
  60. +5 −19 platforms/linux/src/linuxPlatform.cpp
  61. +1 −3 platforms/linux/src/linuxPlatform.h
  62. +2 −15 platforms/windows/src/windowsPlatform.cpp
  63. +0 −2 platforms/windows/src/windowsPlatform.h
  64. +5 −0 scenes/raster-terrain-offset.yaml
  65. +19 −25 tests/unit/dukTests.cpp
  66. +1 −1 tests/unit/labelTests.cpp
  67. +3 −3 tests/unit/labelsTests.cpp
  68. +24 −34 tests/unit/sceneImportTests.cpp
  69. +7 −12 tests/unit/sceneLoaderTests.cpp
  70. +95 −113 tests/unit/sceneUpdateTests.cpp
  71. +13 −20 tests/unit/styleUniformsTests.cpp
  72. +3 −5 tests/unit/yamlFilterTests.cpp
27 changes: 8 additions & 19 deletions bench/src/benchStyleContext.cpp
Original file line number Diff line number Diff line change
@@ -32,30 +32,19 @@ const char tile_file[] = "res/tile.mvt";
std::shared_ptr<Scene> scene;
std::shared_ptr<TileSource> source;
std::shared_ptr<TileData> tileData;

std::unique_ptr<MockPlatform> platform = std::make_unique<MockPlatform>();
MockPlatform platform;

void globalSetup() {
static std::atomic<bool> initialized{false};
if (initialized.exchange(true)) { return; }

Url sceneUrl(scene_file);
platform->putMockUrlContents(sceneUrl, MockPlatform::getBytesFromFile(scene_file));
scene = std::make_shared<Scene>(*platform, sceneUrl);
Importer importer(scene);
try {
scene->config() = importer.applySceneImports(*platform);
}
catch (const YAML::ParserException& e) {
LOGE("Parsing scene config '%s'", e.what());
exit(-1);
}
if (!scene->config()) {
LOGE("Invalid scene file '%s'", scene_file);
exit(-1);
}
SceneLoader::applyConfig(*platform, scene);
scene->fontContext()->loadFonts();
SceneOptions sceneOptions{platform.resolveUrl(Url(scene_file))};
sceneOptions.numTileWorkers = 0;
sceneOptions.prefetchTiles = false;

scene = std::make_shared<Scene>(platform, std::move(sceneOptions));
if (!scene->load()) { exit(-1); }

for (auto& s : scene->tileSources()) {
source = s;
if (source->generateGeometry()) { break; }
28 changes: 8 additions & 20 deletions bench/src/benchTileBuilder.cpp
Original file line number Diff line number Diff line change
@@ -32,31 +32,18 @@ const char tile_file[] = "res/tile.mvt";
std::shared_ptr<Scene> scene;
std::shared_ptr<TileSource> source;
std::shared_ptr<TileData> tileData;

std::unique_ptr<MockPlatform> platform = std::make_unique<MockPlatform>();
MockPlatform platform;

void globalSetup() {
static std::atomic<bool> initialized{false};
if (initialized.exchange(true)) { return; }

Url sceneUrl(scene_file);
platform->putMockUrlContents(sceneUrl, MockPlatform::getBytesFromFile(scene_file));
SceneOptions sceneOptions{platform.resolveUrl(Url(scene_file))};
sceneOptions.numTileWorkers = 0;
sceneOptions.prefetchTiles = false;

scene = std::make_shared<Scene>(*platform, sceneUrl);
Importer importer(scene);
try {
scene->config() = importer.applySceneImports(*platform);
}
catch (const YAML::ParserException& e) {
LOGE("Parsing scene config '%s'", e.what());
exit(-1);
}
if (!scene->config()) {
LOGE("Invalid scene file '%s'", scene_file);
exit(-1);
}
SceneLoader::applyConfig(*platform, scene);
scene->fontContext()->loadFonts();
scene = std::make_shared<Scene>(platform, std::move(sceneOptions));
if (!scene->load()) { exit(-1); }

for (auto& s : scene->tileSources()) {
source = s;
@@ -82,7 +69,8 @@ class TileBuilderFixture : public benchmark::Fixture {
std::shared_ptr<Tile> result;
void SetUp(const ::benchmark::State& state) override {
globalSetup();
tileBuilder = std::make_unique<TileBuilder>(scene, new StyleContext());
tileBuilder = std::make_unique<TileBuilder>(*scene, new StyleContext());
tileBuilder->init();
}
void TearDown(const ::benchmark::State& state) override {
result.reset();
4 changes: 2 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -74,8 +74,8 @@ add_library(tangram-core
src/labels/labelProperty.cpp
src/labels/labelSet.h
src/labels/labelSet.cpp
src/labels/labels.h
src/labels/labels.cpp
src/labels/labelManager.h
src/labels/labelManager.cpp
src/labels/spriteLabel.h
src/labels/spriteLabel.cpp
src/labels/textLabel.h
49 changes: 49 additions & 0 deletions core/include/tangram/log.h
Original file line number Diff line number Diff line change
@@ -66,3 +66,52 @@ do { Tangram::logMsg("ERROR %s:%d: " fmt "\n", __FILENAME__, __LINE__, ## __VA_A
#define LOG(fmt, ...)
#define LOGN(fmt, ...)
#endif

#if 0
#include <mutex>
#include <chrono>

extern std::chrono::time_point<std::chrono::system_clock> tangram_log_time_start, tangram_log_time_last;
extern std::mutex tangram_log_time_mutex;

#define LOGTIME(fmt, ...) do { \
int l = strlen( __FILENAME__); \
Tangram::logMsg("TIME %-18.*s " fmt "\n", \
l > 4 ? l-4 : l, __FILENAME__, ##__VA_ARGS__); } while (0)

// Overall timing init/reset
#define LOGTOInit() do { \
std::lock_guard<std::mutex> lock(tangram_log_time_mutex); \
tangram_log_time_last = tangram_log_time_start = std::chrono::system_clock::now(); } while(0)

// Overall timing
#define LOGTO(fmt, ...) do { \
std::lock_guard<std::mutex> lock(tangram_log_time_mutex); \
std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now(); \
std::chrono::duration<double> t1 = now - tangram_log_time_start; \
std::chrono::duration<double> t2 = now - tangram_log_time_last; \
tangram_log_time_last = now; \
LOGTIME("%7.2f %7.2f " fmt, t1.count()*1000.f, t2.count()*1000.f, ## __VA_ARGS__); } while(0)

// Local timing init
#define LOGTInit(fmt, ...) \
std::chrono::time_point<std::chrono::system_clock> _time_last, _time_start; \
std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now(); \
std::chrono::duration<double> t0 = now - tangram_log_time_start; \
_time_start = _time_last = now; \
LOGTIME("%7.2f " fmt, t0.count()*1000.f, ## __VA_ARGS__)

// Local timing
#define LOGT(fmt, ...) do { \
std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now(); \
std::chrono::duration<double> t0 = now - tangram_log_time_start; \
std::chrono::duration<double> t1 = now - _time_start; \
std::chrono::duration<double> t2 = now - _time_last; \
_time_last = now; \
LOGTIME("%7.2f %7.2f %7.2f " fmt, t0.count()*1000.f, t1.count()*1000.f, t2.count()*1000.f, ## __VA_ARGS__); } while(0)
#else
#define LOGT(...)
#define LOGTInit(...)
#define LOGTOInit()
#define LOGTO(...)
#endif
110 changes: 61 additions & 49 deletions core/include/tangram/map.h
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

#include "data/properties.h"
#include "util/types.h"
#include "sceneOptions.h"

#include <array>
#include <functional>
@@ -14,6 +15,7 @@ namespace Tangram {
class Platform;
class TileSource;
class Scene;
class SceneOptions;

enum LabelType {
icon,
@@ -58,13 +60,6 @@ struct MarkerPickResult {
// Returns a pointer to the selected marker pick result or null, only valid on the callback scope
using MarkerPickCallback = std::function<void(const MarkerPickResult*)>;

struct SceneUpdate {
std::string path;
std::string value;
SceneUpdate(std::string p, std::string v) : path(p), value(v) {}
SceneUpdate() {}
};

enum Error {
none,
scene_update_path_not_found,
@@ -114,15 +109,15 @@ struct EdgePadding {

struct CameraUpdate {
enum Flags {
SET_LNGLAT = 1 << 0,
SET_ZOOM = 1 << 1,
SET_ZOOM_BY = 1 << 2,
SET_ROTATION = 1 << 3,
SET_ROTATION_BY = 1 << 4,
SET_TILT = 1 << 5,
SET_TILT_BY = 1 << 6,
SET_BOUNDS = 1 << 7,
SET_CAMERA = 1 << 8,
set_lnglat = 1 << 0,
set_zoom = 1 << 1,
set_zoom_by = 1 << 2,
set_rotation = 1 << 3,
set_rotation_by = 1 << 4,
set_tilt = 1 << 5,
set_tilt_by = 1 << 6,
set_bounds = 1 << 7,
set_camera = 1 << 8,
};
int set = 0;

@@ -137,6 +132,26 @@ struct CameraUpdate {
EdgePadding padding;
};

struct MapState {
enum Flags {
// NB: View is complete when no other flags are set.
view_complete = 0,
view_changing = 1 << 0,
labels_changing = 1 << 1,
tiles_loading = 1 << 3,
scene_loading = 1 << 4,
is_animating = 1 << 5,
};
uint32_t flags = 0;

bool viewComplete() { return flags == 0; }
bool viewChanging() { return flags & view_changing; }
bool labelsChanging() { return flags & labels_changing; }
bool tilesLoading() { return flags & tiles_loading; }
bool sceneLoading() { return flags & scene_loading; }
bool isAnimating() { return flags & is_animating; }
};

class Map {

public:
@@ -145,31 +160,37 @@ class Map {
explicit Map(std::unique_ptr<Platform> _platform);
~Map();


// Load the scene with the given SceneOptions
SceneID loadScene(SceneOptions&& _sceneOptions, bool _async = true);


// Load the scene at the given absolute file path synchronously
SceneID loadScene(const std::string& _scenePath, bool _useScenePosition = false,
const std::vector<SceneUpdate>& _sceneUpdates = {}) {
return loadScene(SceneOptions{Url(_scenePath), _useScenePosition, _sceneUpdates}, false);

}

// Load the scene at the given absolute file path asynchronously.
SceneID loadSceneAsync(const std::string& _scenePath,
bool _useScenePosition = false,
const std::vector<SceneUpdate>& _sceneUpdates = {});
SceneID loadSceneAsync(const std::string& _scenePath, bool _useScenePosition = false,
const std::vector<SceneUpdate>& _sceneUpdates = {}) {
return loadScene(SceneOptions{Url(_scenePath), _useScenePosition, _sceneUpdates}, true);
}

// Load the scene provided an explicit yaml scene string
SceneID loadSceneYaml(const std::string& _yaml, const std::string& _resourceRoot,
bool _useScenePosition = false,
const std::vector<SceneUpdate>& _sceneUpdates = {});
const std::vector<SceneUpdate>& _sceneUpdates = {}) {
return loadScene(SceneOptions{_yaml, Url(_resourceRoot), _useScenePosition, _sceneUpdates}, false);
}

// Load the scene provided an explicit yaml scene string
SceneID loadSceneYamlAsync(const std::string& _yaml, const std::string& _resourceRoot,
bool _useScenePosition = false,
const std::vector<SceneUpdate>& _sceneUpdates = {});

// Load the scene at the given absolute file path synchronously
SceneID loadScene(const std::string& _scenePath,
bool _useScenePosition = false,
const std::vector<SceneUpdate>& sceneUpdates = {});

// Request updates to the current scene configuration. This reloads the
// scene with the updated configuration.
// The SceneUpdate 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.
SceneID updateSceneAsync(const std::vector<SceneUpdate>& sceneUpdates);
bool _useScenePosition = false,
const std::vector<SceneUpdate>& _sceneUpdates = {}) {
return loadScene(SceneOptions{_yaml, Url(_resourceRoot), _useScenePosition, _sceneUpdates}, true);
}

// Set listener for scene load events. The callback receives the SceneID
// of the loaded scene and SceneError in case loading was not successful.
@@ -178,22 +199,18 @@ class Map {

void setCameraAnimationListener(CameraAnimationCallback _cb);

// Set an MBTiles SQLite database file for a DataSource in the scene.
void setMBTiles(const char* _dataSourceName, const char* _mbtilesFilePath);

// Initialize graphics resources; OpenGL context must be created prior to calling this
void setupGL();

// Resize the map view to a new width and height (in pixels)
void resize(int _newWidth, int _newHeight);

// Update the map state with the time interval since the last update, returns
// true when the current view is completely loaded (all tiles are available and
// no animation in progress)
bool update(float _dt);
// Update the map state with the time interval since the last update.
// Return MapState with flags set to determine whether the view is complete or changing.
MapState update(float _dt);

// Render a new frame of the map view (if needed)
bool render();
void render();

// Gets the viewport height in physical pixels (framebuffer size)
int getViewportHeight();
@@ -301,7 +318,8 @@ class Map {
// and removed, otherwise returns false.
bool removeTileSource(TileSource& _source);

void clearTileSource(TileSource& _source, bool _data, bool _tiles);
// Returns true if the source was found and cleared, otherwise returns false.
bool clearTileSource(TileSource& _source, bool _data, bool _tiles);

// Add a marker object to the map and return an ID for it; an ID of 0 indicates an invalid marker;
// the marker will not be drawn until both styling and geometry are set using the functions below.
@@ -424,12 +442,6 @@ class Map {

std::unique_ptr<Platform> platform;

SceneID loadSceneAsync(std::shared_ptr<Scene> _scene,
const std::vector<SceneUpdate>& _sceneUpdates = {});

SceneID loadScene(std::shared_ptr<Scene> _scene,
const std::vector<SceneUpdate>& _sceneUpdates = {});

private:

class Impl;
Loading